Fixed IPC issues; cleaned up arg passthrough flow

Fixing rapid refresh when a lot of file activity happens
WIP memory reaper for Gtk Objects
This commit is contained in:
2025-12-10 19:27:06 -06:00
parent 28fefafa6f
commit 0942af249b
5 changed files with 117 additions and 4 deletions

View File

@@ -47,13 +47,26 @@ class FileActionSignalsMixin:
if tab_widget_id in self.soft_update_lock:
timeout_id = self.soft_update_lock[tab_widget_id]["timeout_id"]
GLib.source_remove(timeout_id)
self.soft_update_lock[tab_widget_id]["call_count"] += 1
else:
self.soft_update_lock[tab_widget_id] = {}
self.soft_update_lock[tab_widget_id]["call_count"] = 0
timeout_id = GLib.timeout_add(0, self.update_on_soft_lock_end, 600, *(tab_widget_id,))
timeout_id = GLib.timeout_add(
500 if self.soft_update_lock[tab_widget_id]["call_count"] <= 5 else 1000,
self.update_on_soft_lock_end,
tab_widget_id
)
self.soft_update_lock[tab_widget_id]["timeout_id"] = timeout_id
def update_on_soft_lock_end(self, timout_ms, tab_widget_id):
def update_on_soft_lock_end(self, tab_widget_id):
GLib.idle_add(self._update_interface, tab_widget_id)
self.soft_update_lock.pop(tab_widget_id, None)
return False
def _update_interface(self, tab_widget_id):
wid, tid = tab_widget_id.split("|")
notebook = self.builder.get_object(f"window_{wid}")
tab = self.get_fm_window(wid).get_tab_by_id(tid)
@@ -70,8 +83,6 @@ class FileActionSignalsMixin:
if [wid, tid] in [state.wid, state.tid]:
self.set_bottom_labels(tab)
return False
def do_file_search(self, widget, eve = None):
if not self.ctrl_down and not self.shift_down and not self.alt_down:
target = widget.get_name()

View File

View File

@@ -0,0 +1,15 @@
#!/bin/bash
# . CONFIG.sh
# set -o xtrace ## To debug scripts
# set -o errexit ## To exit on error
# set -o errunset ## To exit if a variable is referenced but not set
function main() {
cd "$(dirname "")"
echo "Working Dir: " $(pwd)
python3 setup.py build && python3 setup.py install --user
}
main "$@";

View File

@@ -0,0 +1,59 @@
#include <Python.h>
#include <gtk.h>
#include <cairo.h>
#include <gdk-pixbuf/gdk-pixbuf.h>
#include <stdlib.h>
// static PyObject* free_pixbuf(PyObject* self, PyObject* args) {
static void free_pixbuf(PyObject* self, PyObject* args) {
PyObject *py_pixbuf;
if (!PyArg_ParseTuple(args, "O", &py_pixbuf)) {
return NULL;
}
GdkPixbuf *pixbuf = (GdkPixbuf *) PyLong_AsVoidPtr(py_pixbuf);
if (!GDK_IS_PIXBUF(pixbuf)) {
PyErr_SetString(PyExc_TypeError, "Invalid GdkPixbuf pointer.");
return NULL;
}
g_free(pixbuf);
// return PyBytes_FromStringAndSize((const char *) cairo_data, buffer_size);
}
static void free_list_store(PyObject* self, PyObject* args) {
PyObject *py_list_store;
if (!PyArg_ParseTuple(args, "O", &py_list_store)) {
return NULL;
}
GtkListStore *list_store = (GtkListStore *) PyLong_AsVoidPtr(py_list_store);
if (!GTK_IS_LIST_STORE(list_store)) {
PyErr_SetString(PyExc_TypeError, "Invalid Gtk.ListStore pointer.");
return NULL;
}
g_object_unref(list_store);
}
static PyMethodDef Methods[] = {
{"free_pixbuf", free_pixbuf, METH_VARARGS, "Clear GdkPixbuf* ."},
{"free_list_store", free_list_store, METH_VARARGS, "Clear GtkListStore* ."},
{NULL, NULL, 0, NULL}
};
static struct PyModuleDef moduledef = {
PyModuleDef_HEAD_INIT,
"gtkmemreaper",
NULL,
-1,
Methods
};
PyMODINIT_FUNC PyInit_gtkmemreaper(void) {
return PyModule_Create(&moduledef);
}

View File

@@ -0,0 +1,28 @@
# Python imports
from setuptools import setup, Extension
from subprocess import check_output
# Lib imports
# Application imports
pkg_config_args = ["gdk-pixbuf-2.0", "cairo", "gtk"]
def get_pkgconfig_flags(flag_type):
return check_output(["pkg-config", flag_type] + pkg_config_args).decode().split()
ext = Extension(
"gtkmemreaper",
sources = ["gtkmemreaper.c"],
include_dirs = [],
extra_compile_args = get_pkgconfig_flags("--cflags"),
extra_link_args = get_pkgconfig_flags("--libs")
)
setup(
name = "gtkmemreaper",
version = "0.1",
ext_modules = [ext]
)