https://gitlab.gnome.org/GNOME/gnome-commander/-/merge_requests/213 --- gnome-commander-1.18.1/libgcmd/gnome-cmd-plugin.cc.orig +++ gnome-commander-1.18.1/libgcmd/gnome-cmd-plugin.cc @@ -25,76 +25,43 @@ #include "gnome-cmd-state.h" #include "gnome-cmd-plugin.h" -G_DEFINE_TYPE (GnomeCmdPlugin, gnome_cmd_plugin, G_TYPE_OBJECT) -/******************************* - * Gtk class implementation - *******************************/ - -static void gnome_cmd_plugin_class_init (GnomeCmdPluginClass *klass) -{ - GnomeCmdPluginClass *plugin_class; - - plugin_class = GNOME_CMD_PLUGIN_CLASS (klass); - - plugin_class->create_actions = NULL; - plugin_class->create_main_menu = NULL; - plugin_class->create_popup_menu_items = NULL; - plugin_class->configure = NULL; -} - - -static void gnome_cmd_plugin_init (GnomeCmdPlugin *plugin) +void gnome_cmd_plugin_free (GnomeCmdPlugin *plugin) { + if (plugin->free) + plugin->free (plugin); } -/*********************************** - * Public functions - ***********************************/ GSimpleActionGroup *gnome_cmd_plugin_create_actions (GnomeCmdPlugin *plugin, const gchar *name) { - GnomeCmdPluginClass *klass; - - g_return_val_if_fail (GNOME_CMD_IS_PLUGIN (plugin), NULL); - - klass = GNOME_CMD_PLUGIN_GET_CLASS (plugin); - - return klass->create_actions (plugin, name); + if (plugin->create_actions) + return plugin->create_actions (plugin, name); + else + return NULL; } GMenuModel *gnome_cmd_plugin_create_main_menu (GnomeCmdPlugin *plugin, GnomeCmdState *state) { - GnomeCmdPluginClass *klass; - - g_return_val_if_fail (GNOME_CMD_IS_PLUGIN (plugin), NULL); - - klass = GNOME_CMD_PLUGIN_GET_CLASS (plugin); - - return klass->create_main_menu (plugin, state); + if (plugin->create_main_menu) + return plugin->create_main_menu (plugin, state); + else + return NULL; } GMenuModel *gnome_cmd_plugin_create_popup_menu_items (GnomeCmdPlugin *plugin, GnomeCmdState *state) { - GnomeCmdPluginClass *klass; - - g_return_val_if_fail (GNOME_CMD_IS_PLUGIN (plugin), NULL); - - klass = GNOME_CMD_PLUGIN_GET_CLASS (plugin); - - return klass->create_popup_menu_items (plugin, state); + if (plugin->create_popup_menu_items) + return plugin->create_popup_menu_items (plugin, state); + else + return NULL; } void gnome_cmd_plugin_configure (GnomeCmdPlugin *plugin, GtkWindow *parent_window) { - GnomeCmdPluginClass *klass; - - g_return_if_fail (GNOME_CMD_IS_PLUGIN (plugin)); - - klass = GNOME_CMD_PLUGIN_GET_CLASS (plugin); - - klass->configure (plugin, parent_window); + if (plugin->configure) + plugin->configure (plugin, parent_window); } --- gnome-commander-1.18.1/libgcmd/gnome-cmd-plugin.h.orig +++ gnome-commander-1.18.1/libgcmd/gnome-cmd-plugin.h @@ -21,28 +21,13 @@ #pragma once -#define GNOME_CMD_TYPE_PLUGIN (gnome_cmd_plugin_get_type ()) -#define GNOME_CMD_PLUGIN(obj) (G_TYPE_CHECK_INSTANCE_CAST((obj), GNOME_CMD_TYPE_PLUGIN, GnomeCmdPlugin)) -#define GNOME_CMD_PLUGIN_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST((klass), GNOME_CMD_TYPE_PLUGIN, GnomeCmdPluginClass)) -#define GNOME_CMD_IS_PLUGIN(obj) (G_TYPE_CHECK_INSTANCE_TYPE((obj), GNOME_CMD_TYPE_PLUGIN)) -#define GNOME_CMD_IS_PLUGIN_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), GNOME_CMD_TYPE_PLUGIN)) -#define GNOME_CMD_PLUGIN_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS((obj), GNOME_CMD_TYPE_PLUGIN, GnomeCmdPluginClass)) - - typedef struct _GnomeCmdPlugin GnomeCmdPlugin; -typedef struct _GnomeCmdPluginClass GnomeCmdPluginClass; -typedef struct _GnomeCmdPluginPrivate GnomeCmdPluginPrivate; typedef GnomeCmdPlugin *(*PluginConstructorFunc)(void); struct _GnomeCmdPlugin { - GObject parent; -}; - -struct _GnomeCmdPluginClass -{ - GObjectClass parent_class; + void (* free) (GnomeCmdPlugin *plugin); GSimpleActionGroup *(* create_actions) (GnomeCmdPlugin *plugin, const gchar *name); @@ -52,7 +37,7 @@ }; -GType gnome_cmd_plugin_get_type (); +void gnome_cmd_plugin_free (GnomeCmdPlugin *plugin); GSimpleActionGroup *gnome_cmd_plugin_create_actions (GnomeCmdPlugin *plugin, const gchar *name); --- gnome-commander-1.18.1/plugins/fileroller/file-roller-plugin.cc.orig +++ gnome-commander-1.18.1/plugins/fileroller/file-roller-plugin.cc @@ -163,9 +163,10 @@ * The File-Roller-Plugin ***********************************/ - -struct FileRollerPluginPrivate +struct FileRollerPlugin { + GnomeCmdPlugin parent; + gchar *action_group_name; GtkWidget *conf_dialog; @@ -179,10 +180,6 @@ PluginSettings *settings; }; - -G_DEFINE_TYPE_WITH_PRIVATE (FileRollerPlugin, file_roller_plugin, GNOME_CMD_TYPE_PLUGIN) - - gchar *GetGfileAttributeString(GFile *gFile, const char *attribute); static void run_cmd (const gchar *work_dir, const gchar *cmd) @@ -356,10 +353,9 @@ gboolean name_ok = FALSE; GList *files; - FileRollerPlugin *plugin = FILE_ROLLER_PLUGIN (user_data); - FileRollerPluginPrivate *priv = (FileRollerPluginPrivate *) file_roller_plugin_get_instance_private (plugin); + FileRollerPlugin *plugin = (FileRollerPlugin *) user_data; - files = priv->state->active_dir_selected_files; + files = plugin->state->active_dir_selected_files; do { @@ -388,7 +384,7 @@ gtk_widget_show (entry); gtk_box_append (GTK_BOX (gtk_dialog_get_content_area (GTK_DIALOG (dialog))), entry); - gchar *locale_format = g_locale_from_utf8 (priv->file_prefix_pattern, -1, nullptr, nullptr, nullptr); + gchar *locale_format = g_locale_from_utf8 (plugin->file_prefix_pattern, -1, nullptr, nullptr, nullptr); char s[256]; time_t t = time (nullptr); @@ -403,7 +399,7 @@ g_free (locale_format); gchar *file_prefix = g_locale_to_utf8 (s, -1, nullptr, nullptr, nullptr); - gchar *archive_name_tmp = g_strdup_printf("%s%s", file_prefix, priv->default_ext); + gchar *archive_name_tmp = g_strdup_printf("%s%s", file_prefix, plugin->default_ext); auto file_name_tmp = GetGfileAttributeString(GNOME_CMD_FILE_BASE (files->data)->gFile, G_FILE_ATTRIBUTE_STANDARD_DISPLAY_NAME); archive_name = new_string_with_replaced_keyword(archive_name_tmp, "$N", file_name_tmp); gtk_editable_set_text (GTK_EDITABLE (entry), archive_name); @@ -425,7 +421,7 @@ while (name_ok == FALSE && ret == GTK_RESPONSE_OK); if (ret == GTK_RESPONSE_OK) - do_add_to_archive (name, priv->state); + do_add_to_archive (name, plugin->state); gtk_window_destroy (GTK_WINDOW (dialog)); } @@ -433,9 +429,9 @@ static GSimpleActionGroup *create_actions (GnomeCmdPlugin *plugin, const gchar *name) { - FileRollerPluginPrivate *priv = (FileRollerPluginPrivate *) file_roller_plugin_get_instance_private (FILE_ROLLER_PLUGIN (plugin)); + FileRollerPlugin *fr = (FileRollerPlugin *) plugin; - priv->action_group_name = g_strdup (name); + fr->action_group_name = g_strdup (name); GSimpleActionGroup *group = g_simple_action_group_new (); static const GActionEntry entries[] = { @@ -466,7 +462,7 @@ if (num_files <= 0) return nullptr; - FileRollerPluginPrivate *priv = (FileRollerPluginPrivate *) file_roller_plugin_get_instance_private (FILE_ROLLER_PLUGIN (plugin)); + FileRollerPlugin *priv = (FileRollerPlugin *) plugin; priv->state = state; @@ -548,15 +544,13 @@ static void on_configure_close (GtkButton *btn, FileRollerPlugin *plugin) { - FileRollerPluginPrivate *priv = (FileRollerPluginPrivate *) file_roller_plugin_get_instance_private (plugin); - - priv->default_ext = gtk_combo_box_text_get_active_text (GTK_COMBO_BOX_TEXT (priv->conf_combo)); - priv->file_prefix_pattern = g_strdup (get_entry_text (priv->conf_entry, "file_prefix_pattern_entry")); + plugin->default_ext = gtk_combo_box_text_get_active_text (GTK_COMBO_BOX_TEXT (plugin->conf_combo)); + plugin->file_prefix_pattern = g_strdup (get_entry_text (plugin->conf_entry, "file_prefix_pattern_entry")); - g_settings_set_string (priv->settings->file_roller_plugin, GCMD_PLUGINS_FILE_ROLLER_DEFAULT_TYPE, priv->default_ext); - g_settings_set_string (priv->settings->file_roller_plugin, GCMD_PLUGINS_FILE_ROLLER_PREFIX_PATTERN, priv->file_prefix_pattern); + g_settings_set_string (plugin->settings->file_roller_plugin, GCMD_PLUGINS_FILE_ROLLER_DEFAULT_TYPE, plugin->default_ext); + g_settings_set_string (plugin->settings->file_roller_plugin, GCMD_PLUGINS_FILE_ROLLER_PREFIX_PATTERN, plugin->file_prefix_pattern); - gtk_widget_hide (priv->conf_dialog); + gtk_widget_hide (plugin->conf_dialog); } @@ -600,7 +594,7 @@ GtkWidget *dialog, *grid, *cat, *label, *vbox, *entry; GtkWidget *combo; - FileRollerPluginPrivate *priv = (FileRollerPluginPrivate *) file_roller_plugin_get_instance_private (FILE_ROLLER_PLUGIN (plugin)); + FileRollerPlugin *priv = (FileRollerPlugin *) plugin; dialog = gnome_cmd_dialog_new (parent_window, _("Options")); gtk_window_set_modal (GTK_WINDOW (dialog), TRUE); @@ -681,36 +675,21 @@ * Gtk class implementation *******************************/ -static void dispose (GObject *object) -{ - FileRollerPlugin *plugin = FILE_ROLLER_PLUGIN (object); - FileRollerPluginPrivate *priv = (FileRollerPluginPrivate *) file_roller_plugin_get_instance_private (plugin); - - g_clear_pointer (&priv->default_ext, g_free); - g_clear_pointer (&priv->file_prefix_pattern, g_free); - g_clear_pointer (&priv->action_group_name, g_free); - - G_OBJECT_CLASS (file_roller_plugin_parent_class)->dispose (object); -} - - -static void file_roller_plugin_class_init (FileRollerPluginClass *klass) +static void dispose (GnomeCmdPlugin *plugin) { - GObjectClass *object_class = G_OBJECT_CLASS (klass); - GnomeCmdPluginClass *plugin_class = GNOME_CMD_PLUGIN_CLASS (klass); + auto fr = (FileRollerPlugin *) plugin; - object_class->dispose = dispose; + g_clear_pointer (&fr->default_ext, g_free); + g_clear_pointer (&fr->file_prefix_pattern, g_free); + g_clear_pointer (&fr->action_group_name, g_free); - plugin_class->create_actions = create_actions; - plugin_class->create_main_menu = create_main_menu; - plugin_class->create_popup_menu_items = create_popup_menu_items; - plugin_class->configure = configure; + g_free (plugin); } static void file_roller_plugin_init (FileRollerPlugin *plugin) { - FileRollerPluginPrivate *priv = (FileRollerPluginPrivate *) file_roller_plugin_get_instance_private (plugin); + FileRollerPlugin *priv = plugin; priv->settings = plugin_settings_new(); @@ -770,18 +749,27 @@ } -/*********************************** - * Public functions - ***********************************/ - -GnomeCmdPlugin *file_roller_plugin_new () +static GnomeCmdPlugin *file_roller_plugin_new () { - FileRollerPlugin *plugin = (FileRollerPlugin *) g_object_new (file_roller_plugin_get_type (), nullptr); + FileRollerPlugin *plugin = g_new0 (FileRollerPlugin, 1); + + plugin->parent.free = dispose; + + plugin->parent.create_actions = create_actions; + plugin->parent.create_main_menu = create_main_menu; + plugin->parent.create_popup_menu_items = create_popup_menu_items; + plugin->parent.configure = configure; - return GNOME_CMD_PLUGIN (plugin); + file_roller_plugin_init (plugin); + + return (GnomeCmdPlugin *) plugin; } +/*********************************** + * Public functions + ***********************************/ + extern "C" { GnomeCmdPlugin *create_plugin () --- gnome-commander-1.18.1/plugins/fileroller/file-roller-plugin.h.orig +++ gnome-commander-1.18.1/plugins/fileroller/file-roller-plugin.h @@ -25,30 +25,6 @@ G_DECLARE_FINAL_TYPE (PluginSettings, plugin_settings, GCMD, SETTINGS, GObject) PluginSettings *plugin_settings_new (void); -#define FILE_ROLLER_PLUGIN(obj) \ - G_TYPE_CHECK_INSTANCE_CAST (obj, file_roller_plugin_get_type (), FileRollerPlugin) -#define FILE_ROLLER_PLUGIN_CLASS(klass) \ - G_TYPE_CHECK_CLASS_CAST (klass, file_roller_plugin_get_type (), FileRollerPluginClass) -#define IS_FILE_ROLLER_PLUGIN(obj) \ - G_TYPE_CHECK_INSTANCE_TYPE (obj, file_roller_plugin_get_type ()) - - -typedef struct _FileRollerPlugin FileRollerPlugin; -typedef struct _FileRollerPluginClass FileRollerPluginClass; - -struct _FileRollerPlugin -{ - GnomeCmdPlugin parent; -}; - -struct _FileRollerPluginClass -{ - GnomeCmdPluginClass parent_class; -}; - -GType file_roller_plugin_get_type (); - -GnomeCmdPlugin *file_roller_plugin_new (); extern "C" { GnomeCmdPlugin *create_plugin (); --- gnome-commander-1.18.1/plugins/test/test-plugin.cc.orig +++ gnome-commander-1.18.1/plugins/test/test-plugin.cc @@ -42,15 +42,14 @@ WEBPAGE }; -struct TestPluginPrivate +struct TestPlugin { + GnomeCmdPlugin parent; + gchar *action_group_name; }; -G_DEFINE_TYPE_WITH_PRIVATE(TestPlugin, test_plugin, GNOME_CMD_TYPE_PLUGIN) - - static void show_dummy_dialog(GtkWindow *parent_window) { GtkWidget *dialog; @@ -73,7 +72,7 @@ static GSimpleActionGroup *create_actions (GnomeCmdPlugin *plugin, const gchar *name) { - TestPluginPrivate *priv = (TestPluginPrivate *) test_plugin_get_instance_private (TEST_PLUGIN (plugin)); + TestPlugin *priv = (TestPlugin *) plugin; priv->action_group_name = g_strdup (name); @@ -88,7 +87,7 @@ static GMenuModel *create_main_menu (GnomeCmdPlugin *plugin, GnomeCmdState *state) { - TestPluginPrivate *priv = (TestPluginPrivate *) test_plugin_get_instance_private (TEST_PLUGIN (plugin)); + TestPlugin *priv = (TestPlugin *) plugin; GMenu *menu = g_menu_new (); gchar *action_name = g_strdup_printf ("%s.dummy", priv->action_group_name); @@ -100,7 +99,7 @@ static GMenuModel *create_popup_menu_items (GnomeCmdPlugin *plugin, GnomeCmdState *state) { - TestPluginPrivate *priv = (TestPluginPrivate *) test_plugin_get_instance_private (TEST_PLUGIN (plugin)); + TestPlugin *priv = (TestPlugin *) plugin; GMenu *menu = g_menu_new (); gchar *action_name = g_strdup_printf ("%s.dummy", priv->action_group_name); @@ -116,50 +115,34 @@ } - - -/******************************* - * Gtk class implementation - *******************************/ - -static void dispose (GObject *object) +static void dispose (GnomeCmdPlugin *plugin) { - TestPluginPrivate *priv = (TestPluginPrivate *) test_plugin_get_instance_private (TEST_PLUGIN (object)); + TestPlugin *priv = (TestPlugin *) plugin; g_clear_pointer (&priv->action_group_name, g_free); - G_OBJECT_CLASS (test_plugin_parent_class)->dispose (object); + g_free (plugin); } -static void test_plugin_class_init (TestPluginClass *klass) + +static GnomeCmdPlugin *test_plugin_new () { - G_OBJECT_CLASS (klass)->dispose = dispose; + TestPlugin *plugin = g_new0 (TestPlugin, 1); - GnomeCmdPluginClass *plugin_class = GNOME_CMD_PLUGIN_CLASS (klass); + plugin->parent.free = dispose; + plugin->parent.create_actions = create_actions; + plugin->parent.create_main_menu = create_main_menu; + plugin->parent.create_popup_menu_items = create_popup_menu_items; + plugin->parent.configure = configure; - plugin_class->create_actions = create_actions; - plugin_class->create_main_menu = create_main_menu; - plugin_class->create_popup_menu_items = create_popup_menu_items; - plugin_class->configure = configure; + return (GnomeCmdPlugin *) plugin; } -static void test_plugin_init (TestPlugin *plugin) -{ -} - /*********************************** * Public functions ***********************************/ -GnomeCmdPlugin *test_plugin_new () -{ - TestPlugin *plugin = (TestPlugin *) g_object_new (test_plugin_get_type (), NULL); - - return GNOME_CMD_PLUGIN (plugin); -} - - extern "C" { GnomeCmdPlugin *create_plugin () --- gnome-commander-1.18.1/plugins/test/test-plugin.h.orig +++ gnome-commander-1.18.1/plugins/test/test-plugin.h @@ -21,31 +21,6 @@ #pragma once -#define TEST_PLUGIN(obj) \ - G_TYPE_CHECK_INSTANCE_CAST (obj, test_plugin_get_type (), TestPlugin) -#define TEST_PLUGIN_CLASS(klass) \ - G_TYPE_CHECK_CLASS_CAST (klass, test_plugin_get_type (), TestPluginClass) -#define IS_TEST_PLUGIN(obj) \ - G_TYPE_CHECK_INSTANCE_TYPE (obj, test_plugin_get_type ()) - - -typedef struct _TestPlugin TestPlugin; -typedef struct _TestPluginClass TestPluginClass; - -struct _TestPlugin -{ - GnomeCmdPlugin parent; -}; - -struct _TestPluginClass -{ - GnomeCmdPluginClass parent_class; -}; - - -GType test_plugin_get_type (); - -GnomeCmdPlugin *test_plugin_new (); extern "C" { GnomeCmdPlugin *create_plugin ();