libgnt/libgnt

Remove Python support
default tip
4 weeks ago, Gary Kramlich
768a0bf53a98
Parents 03532a6ed456
Children
Remove Python support

This feature was never documented well and therefore was never really adopted.

Testing Done:
Compiled

Reviewed at https://reviews.imfreedom.org/r/3068/
  • +0 -74
    gntwm.c
  • +1 -19
    meson.build
  • --- a/gntwm.c Thu Feb 29 22:08:51 2024 -0600
    +++ b/gntwm.c Tue Apr 09 21:34:39 2024 -0500
    @@ -23,12 +23,6 @@
    #undef GNT_LOG_DOMAIN
    #define GNT_LOG_DOMAIN "WM"
    -#ifdef USE_PYTHON
    -#include <Python.h>
    -#endif
    -
    -/* Python.h may define _GNU_SOURCE and _XOPEN_SOURCE_EXTENDED, so protect
    - * these checks with #ifndef/!defined() */
    #ifndef _GNU_SOURCE
    #define _GNU_SOURCE
    #endif
    @@ -153,9 +147,6 @@
    static gboolean idle_update;
    static GList *act = NULL; /* list of WS with unseen activity */
    static gboolean ignore_keys = FALSE;
    -#ifdef USE_PYTHON
    -static gboolean started_python = FALSE;
    -#endif
    G_DEFINE_TYPE_WITH_PRIVATE(GntWM, gnt_wm, GNT_TYPE_BINDABLE)
    @@ -1394,51 +1385,6 @@
    return TRUE;
    }
    -#ifdef USE_PYTHON
    -static void
    -python_script_selected(GntFileSel *fs, const char *path,
    - G_GNUC_UNUSED const char *f, G_GNUC_UNUSED gpointer n)
    -{
    - char *dir = g_path_get_dirname(path);
    - FILE *file = fopen(path, "r");
    - PyObject *pp = PySys_GetObject("path");
    -#if PY_MAJOR_VERSION >= 3
    - PyObject *dirobj = PyUnicode_FromString(dir);
    -#else
    - PyObject *dirobj = PyString_FromString(dir);
    -#endif
    -
    - PyList_Insert(pp, 0, dirobj);
    - Py_DECREF(dirobj);
    - PyRun_SimpleFile(file, path);
    - fclose(file);
    -
    - if (PyErr_Occurred()) {
    - PyErr_Print();
    - }
    - g_free(dir);
    -
    - gnt_widget_destroy(GNT_WIDGET(fs));
    -}
    -
    -static gboolean
    -run_python(G_GNUC_UNUSED GntBindable *bindable, G_GNUC_UNUSED GList *params)
    -{
    - GntWidget *window = gnt_file_sel_new();
    - GntFileSel *sel = GNT_FILE_SEL(window);
    -
    - g_object_set(window, "vertical", TRUE, NULL);
    - gnt_box_add_widget(GNT_BOX(window), gnt_label_new("Please select the python script you want to run."));
    - gnt_box_set_title(GNT_BOX(window), "Select Python Script...");
    -
    - g_signal_connect(G_OBJECT(sel), "file_selected", G_CALLBACK(python_script_selected), NULL);
    - g_signal_connect_swapped(G_OBJECT(sel), "cancelled",
    - G_CALLBACK(gnt_widget_destroy), sel);
    - gnt_widget_show(window);
    - return TRUE;
    -}
    -#endif /* USE_PYTHON */
    -
    static gboolean
    help_for_bindable(GntWM *wm, GntBindable *bindable)
    {
    @@ -1519,13 +1465,6 @@
    priv->workspaces = NULL;
    g_clear_pointer(&priv->loop, g_main_loop_unref);
    -
    -#ifdef USE_PYTHON
    - if (started_python) {
    - Py_Finalize();
    - started_python = FALSE;
    - }
    -#endif
    }
    static void
    @@ -1696,19 +1635,6 @@
    snprintf(key, sizeof(key), "\033%s", GNT_KEY_BACK_TAB);
    gnt_bindable_class_register_action(GNT_BINDABLE_CLASS(klass), "window-prev-urgent", window_prev_urgent,
    key[1] ? key : NULL, NULL);
    -#ifdef USE_PYTHON
    - gnt_bindable_class_register_action(GNT_BINDABLE_CLASS(klass), "run-python", run_python,
    - GNT_KEY_F3, NULL);
    - if (!Py_IsInitialized()) {
    -#if PY_MAJOR_VERSION >= 3
    - Py_SetProgramName(L"gnt");
    -#else
    - Py_SetProgramName("gnt");
    -#endif
    - Py_Initialize();
    - started_python = TRUE;
    - }
    -#endif
    gnt_style_read_actions(G_OBJECT_CLASS_TYPE(klass), GNT_BINDABLE_CLASS(klass));
    --- a/meson.build Thu Feb 29 22:08:51 2024 -0600
    +++ b/meson.build Tue Apr 09 21:34:39 2024 -0500
    @@ -209,24 +209,6 @@
    libgnt_generated_targets = []
    -# Check for Python headers
    -_PYTHONS = [
    - ['python-3.10-embed', '>=3.10'],
    - ['python-3.9-embed', '>=3.9'],
    - ['python-3.8-embed', '>=3.8'],
    - ['python3-embed', '>=3.8'],
    - ['python3', '>=3.8'],
    - ['python-3.7', '>=3.7'],
    - ['python-3.7m', '>=3.7'],
    -]
    -foreach _PYTHON : _PYTHONS
    - python_dep = dependency(_PYTHON[0], version : _PYTHON[1], required: false)
    - if python_dep.found()
    - break
    - endif
    -endforeach
    -gnt_config.set('USE_PYTHON', python_dep.found())
    -
    configure_file(output : 'gntconfig.h',
    configuration : gnt_config)
    configure_file(input : 'gntversion.h.in', output : 'gntversion.h',
    @@ -279,7 +261,7 @@
    gnt_soversion,
    gnt_minor_version,
    gnt_micro_version),
    - dependencies : [ncurses, libxml, glib, gobject, gmodule, python_dep])
    + dependencies : [ncurses, libxml, glib, gobject, gmodule])
    pkgconfig.generate(
    libgnt,