From 1d07407c3e97611bbf7c15ed6c1d6b8a37b0e228 Mon Sep 17 00:00:00 2001
From: Cyrille Bagard <nocbos@gmail.com>
Date: Tue, 3 Jan 2023 22:16:24 +0100
Subject: Fix Python bindings loading without GTK support.

---
 plugins/pychrysalide/analysis/loaded.c | 2 ++
 plugins/pychrysalide/analysis/module.c | 3 +++
 plugins/pychrysalide/core.c            | 4 ++++
 plugins/pychrysalide/glibext/module.c  | 4 ++++
 4 files changed, 13 insertions(+)

diff --git a/plugins/pychrysalide/analysis/loaded.c b/plugins/pychrysalide/analysis/loaded.c
index 4a5d8f9..84c9bfd 100644
--- a/plugins/pychrysalide/analysis/loaded.c
+++ b/plugins/pychrysalide/analysis/loaded.c
@@ -1586,8 +1586,10 @@ bool ensure_python_loaded_content_is_registered(void)
 
         dict = PyModule_GetDict(module);
 
+#ifdef HAVE_GTK_SUPPORT
         if (!ensure_python_named_widget_is_registered())
             return false;
+#endif
 
         if (!register_class_for_pygobject(dict, G_TYPE_LOADED_CONTENT, type, &PyGObject_Type))
             return false;
diff --git a/plugins/pychrysalide/analysis/module.c b/plugins/pychrysalide/analysis/module.c
index 9632956..6b8e441 100644
--- a/plugins/pychrysalide/analysis/module.c
+++ b/plugins/pychrysalide/analysis/module.c
@@ -41,6 +41,7 @@
 #include "contents/module.h"
 #include "db/module.h"
 #include "disass/module.h"
+#include "scan/module.h"
 #include "storage/module.h"
 #include "types/module.h"
 #include "../helpers.h"
@@ -86,6 +87,7 @@ bool add_analysis_module(PyObject *super)
     if (result) result = add_analysis_contents_module(module);
     if (result) result = add_analysis_db_module(module);
     if (result) result = add_analysis_disass_module(module);
+    if (result) result = add_analysis_scan_module(module);
     if (result) result = add_analysis_storage_module(module);
     if (result) result = add_analysis_types_module(module);
 
@@ -131,6 +133,7 @@ bool populate_analysis_module(void)
     if (result) result = populate_analysis_contents_module();
     if (result) result = populate_analysis_db_module();
     if (result) result = populate_analysis_disass_module();
+    if (result) result = populate_analysis_scan_module();
     if (result) result = populate_analysis_storage_module();
     if (result) result = populate_analysis_types_module();
 
diff --git a/plugins/pychrysalide/core.c b/plugins/pychrysalide/core.c
index c062d15..66dbdf0 100644
--- a/plugins/pychrysalide/core.c
+++ b/plugins/pychrysalide/core.c
@@ -485,8 +485,10 @@ PyMODINIT_FUNC PyInit_pychrysalide(void)
     if (status) status = add_debug_module(result);
     if (status) status = add_format_module(result);
     if (status) status = add_glibext_module(result);
+#ifdef HAVE_GTK_SUPPORT
     if (status) status = add_gtkext_module(result);
     if (status) status = add_gui_module(result);
+#endif
     if (status) status = add_mangling_module(result);
     if (status) status = add_plugins_module(result);
 
@@ -500,8 +502,10 @@ PyMODINIT_FUNC PyInit_pychrysalide(void)
     if (status) status = populate_debug_module();
     if (status) status = populate_format_module();
     if (status) status = populate_glibext_module();
+#ifdef HAVE_GTK_SUPPORT
     if (status) status = populate_gtkext_module();
     if (status) status = populate_gui_module();
+#endif
     if (status) status = populate_mangling_module();
     if (status) status = populate_plugins_module();
 
diff --git a/plugins/pychrysalide/glibext/module.c b/plugins/pychrysalide/glibext/module.c
index 634cf5c..9d3f004 100644
--- a/plugins/pychrysalide/glibext/module.c
+++ b/plugins/pychrysalide/glibext/module.c
@@ -111,14 +111,18 @@ bool populate_glibext_module(void)
     if (result) result = ensure_python_binary_portion_is_registered();
     if (result) result = ensure_python_buffer_cache_is_registered();
     if (result) result = ensure_python_buffer_line_is_registered();
+#ifdef HAVE_GTK_SUPPORT
     if (result) result = ensure_python_buffer_view_is_registered();
+#endif
     if (result) result = ensure_python_config_param_is_registered();
     if (result) result = ensure_python_config_param_iterator_is_registered();
     if (result) result = ensure_python_generic_config_is_registered();
     if (result) result = ensure_python_line_cursor_is_registered();
     if (result) result = ensure_python_line_generator_is_registered();
+#ifdef HAVE_GTK_SUPPORT
     if (result) result = ensure_python_loaded_panel_is_registered();
     if (result) result = ensure_python_named_widget_is_registered();
+#endif
     if (result) result = ensure_python_singleton_factory_is_registered();
 
     assert(result);
-- 
cgit v0.11.2-87-g4458