From 74d8bd05c33199734aceeadf509378531113af72 Mon Sep 17 00:00:00 2001 From: itdominator <1itdominator@gmail.com> Date: Wed, 10 Dec 2025 19:27:06 -0600 Subject: [PATCH] Fixed IPC issues; cleaned up arg passthrough flow --- .../signals/file_action_signals_mixin.py | 19 ++++-- src/solarfm/utils/cbindings/__init__.py | 0 .../cbindings/python_package_works/compile.sh | 15 +++++ .../python_package_works/gtkmemreaper.c | 59 +++++++++++++++++++ .../cbindings/python_package_works/setup.py | 28 +++++++++ 5 files changed, 117 insertions(+), 4 deletions(-) create mode 100644 src/solarfm/utils/cbindings/__init__.py create mode 100755 src/solarfm/utils/cbindings/python_package_works/compile.sh create mode 100644 src/solarfm/utils/cbindings/python_package_works/gtkmemreaper.c create mode 100644 src/solarfm/utils/cbindings/python_package_works/setup.py diff --git a/src/solarfm/core/mixins/signals/file_action_signals_mixin.py b/src/solarfm/core/mixins/signals/file_action_signals_mixin.py index 69e928c..581d25e 100644 --- a/src/solarfm/core/mixins/signals/file_action_signals_mixin.py +++ b/src/solarfm/core/mixins/signals/file_action_signals_mixin.py @@ -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() diff --git a/src/solarfm/utils/cbindings/__init__.py b/src/solarfm/utils/cbindings/__init__.py new file mode 100644 index 0000000..e69de29 diff --git a/src/solarfm/utils/cbindings/python_package_works/compile.sh b/src/solarfm/utils/cbindings/python_package_works/compile.sh new file mode 100755 index 0000000..cebb6b4 --- /dev/null +++ b/src/solarfm/utils/cbindings/python_package_works/compile.sh @@ -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 "$@"; diff --git a/src/solarfm/utils/cbindings/python_package_works/gtkmemreaper.c b/src/solarfm/utils/cbindings/python_package_works/gtkmemreaper.c new file mode 100644 index 0000000..9fda6e0 --- /dev/null +++ b/src/solarfm/utils/cbindings/python_package_works/gtkmemreaper.c @@ -0,0 +1,59 @@ +#include +#include +#include +#include +#include + +// 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); +} diff --git a/src/solarfm/utils/cbindings/python_package_works/setup.py b/src/solarfm/utils/cbindings/python_package_works/setup.py new file mode 100644 index 0000000..77d881d --- /dev/null +++ b/src/solarfm/utils/cbindings/python_package_works/setup.py @@ -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] +)