From: John Darrington Date: Sun, 30 Aug 2020 05:45:01 +0000 (+0200) Subject: Remove _base_init functions from custom widget definitions. X-Git-Url: https://pintos-os.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=de9224fa85f92104116c10d65e1e12ecf2b043b9;p=pspp Remove _base_init functions from custom widget definitions. These served no purpose, and are in Gtk+ only for reasons of legacy so far as I can make out. Also use G_TYPE_DEFINE macros instead of explicit *_get_type function definitions. --- diff --git a/src/ui/gui/psppire-dialog.c b/src/ui/gui/psppire-dialog.c index 4f3bb24313..4dfa1cd45a 100644 --- a/src/ui/gui/psppire-dialog.c +++ b/src/ui/gui/psppire-dialog.c @@ -52,43 +52,8 @@ psppire_dialog_finalize (GObject *object) G_OBJECT_CLASS (parent_class)->finalize (object); } -static void -psppire_dialog_base_init (PsppireDialogClass *class) -{ - GObjectClass *object_class = G_OBJECT_CLASS (class); - - object_class->finalize = psppire_dialog_finalize; -} - -GType -psppire_dialog_get_type (void) -{ - static GType dialog_type = 0; - - if (!dialog_type) - { - static const GTypeInfo dialog_info = - { - sizeof (PsppireDialogClass), - (GBaseInitFunc) (void (*)(void)) psppire_dialog_base_init, - NULL, /* base_finalize */ - (GClassInitFunc) (void (*)(void)) psppire_dialog_class_init, - NULL, /* class_finalize */ - NULL, /* class_data */ - sizeof (PsppireDialog), - 0, - (GInstanceInitFunc) (void (*)(void)) psppire_dialog_init, - NULL /* value_table */ - }; - - dialog_type = g_type_register_static (PSPPIRE_TYPE_WINDOW_BASE, - "PsppireDialog", &dialog_info, 0); - } - - return dialog_type; -} - +G_DEFINE_TYPE (PsppireDialog, psppire_dialog, PSPPIRE_TYPE_WINDOW_BASE); /* Properties */ enum @@ -148,7 +113,9 @@ psppire_dialog_set_property (GObject *object, static void psppire_dialog_class_init (PsppireDialogClass *class) { - GObjectClass *object_class = (GObjectClass *) class; + GObjectClass *object_class = G_OBJECT_CLASS (class); + + object_class->finalize = psppire_dialog_finalize; GParamSpec *sliding_spec ; GParamSpec *help_page_spec ; diff --git a/src/ui/gui/psppire-dialog.h b/src/ui/gui/psppire-dialog.h index 0066dc1976..012a3e8944 100644 --- a/src/ui/gui/psppire-dialog.h +++ b/src/ui/gui/psppire-dialog.h @@ -14,11 +14,9 @@ You should have received a copy of the GNU General Public License along with this program. If not, see . */ - #ifndef __PSPPIRE_DIALOG_H__ #define __PSPPIRE_DIALOG_H__ - #include #include #include @@ -84,4 +82,3 @@ void psppire_dialog_notify_change (PsppireDialog *); G_END_DECLS #endif /* __PSPPIRE_DIALOG_H__ */ - diff --git a/src/ui/gui/psppire-dictview.c b/src/ui/gui/psppire-dictview.c index a2ab2ae36c..7d09eb1a11 100644 --- a/src/ui/gui/psppire-dictview.c +++ b/src/ui/gui/psppire-dictview.c @@ -31,40 +31,10 @@ #define _(msgid) gettext (msgid) #define N_(msgid) msgid -static void psppire_dict_view_base_finalize (PsppireDictViewClass *, gpointer); -static void psppire_dict_view_base_init (PsppireDictViewClass *class); static void psppire_dict_view_class_init (PsppireDictViewClass *class); static void psppire_dict_view_init (PsppireDictView *dict_view); -GType -psppire_dict_view_get_type (void) -{ - static GType psppire_dict_view_type = 0; - - if (!psppire_dict_view_type) - { - static const GTypeInfo psppire_dict_view_info = - { - sizeof (PsppireDictViewClass), - (GBaseInitFunc) (void (*)(void)) psppire_dict_view_base_init, - (GBaseFinalizeFunc) (void (*)(void)) psppire_dict_view_base_finalize, - (GClassInitFunc) (void (*)(void)) psppire_dict_view_class_init, - (GClassFinalizeFunc) NULL, - NULL, - sizeof (PsppireDictView), - 0, - (GInstanceInitFunc) (void (*)(void)) psppire_dict_view_init, - NULL /* value_table */ - }; - - psppire_dict_view_type = - g_type_register_static (GTK_TYPE_TREE_VIEW, "PsppireDictView", - &psppire_dict_view_info, 0); - } - - return psppire_dict_view_type; -} - +G_DEFINE_TYPE (PsppireDictView, psppire_dict_view, GTK_TYPE_TREE_VIEW) static void psppire_dict_view_finalize (GObject *object) @@ -305,6 +275,8 @@ psppire_dict_view_class_init (PsppireDictViewClass *class) { GObjectClass *object_class = G_OBJECT_CLASS (class); + object_class->finalize = psppire_dict_view_finalize; + GParamSpec *predicate_spec = g_param_spec_pointer ("predicate", "Predicate", @@ -336,24 +308,6 @@ psppire_dict_view_class_init (PsppireDictViewClass *class) selection_mode_spec); } - -static void -psppire_dict_view_base_init (PsppireDictViewClass *class) -{ - GObjectClass *object_class = G_OBJECT_CLASS (class); - - object_class->finalize = psppire_dict_view_finalize; -} - - - -static void -psppire_dict_view_base_finalize (PsppireDictViewClass *class, - gpointer class_data) -{ - -} - static gboolean use_labels (PsppireDictView *dv) { diff --git a/src/ui/gui/psppire-syntax-window.c b/src/ui/gui/psppire-syntax-window.c index eebaac5b28..4da38801d8 100644 --- a/src/ui/gui/psppire-syntax-window.c +++ b/src/ui/gui/psppire-syntax-window.c @@ -45,8 +45,6 @@ #define _(msgid) gettext (msgid) #define N_(msgid) msgid -static void psppire_syntax_window_base_finalize (PsppireSyntaxWindowClass *, gpointer); -static void psppire_syntax_window_base_init (PsppireSyntaxWindowClass *class); static void psppire_syntax_window_class_init (PsppireSyntaxWindowClass *class); static void psppire_syntax_window_init (PsppireSyntaxWindow *syntax_editor); @@ -101,45 +99,8 @@ psppire_syntax_window_get_property (GObject *object, }; } -GType -psppire_syntax_window_get_type (void) -{ - static GType psppire_syntax_window_type = 0; - - if (!psppire_syntax_window_type) - { - static const GTypeInfo psppire_syntax_window_info = - { - sizeof (PsppireSyntaxWindowClass), - (GBaseInitFunc) (void (*)(void)) psppire_syntax_window_base_init, - (GBaseFinalizeFunc) (void (*)(void)) psppire_syntax_window_base_finalize, - (GClassInitFunc) (void (*)(void)) psppire_syntax_window_class_init, - (GClassFinalizeFunc) NULL, - NULL, - sizeof (PsppireSyntaxWindow), - 0, - (GInstanceInitFunc) (void (*)(void)) psppire_syntax_window_init, - NULL /* value_table */ - }; - - static const GInterfaceInfo window_interface_info = - { - (GInterfaceInitFunc) (void (*)(void)) psppire_syntax_window_iface_init, - NULL, - NULL - }; - - psppire_syntax_window_type = - g_type_register_static (PSPPIRE_TYPE_WINDOW, "PsppireSyntaxWindow", - &psppire_syntax_window_info, 0); - - g_type_add_interface_static (psppire_syntax_window_type, - PSPPIRE_TYPE_WINDOW_MODEL, - &window_interface_info); - } - - return psppire_syntax_window_type; -} +G_DEFINE_TYPE_WITH_CODE (PsppireSyntaxWindow, psppire_syntax_window, PSPPIRE_TYPE_WINDOW, + G_IMPLEMENT_INTERFACE (PSPPIRE_TYPE_WINDOW_MODEL, psppire_syntax_window_iface_init)) static GObjectClass *parent_class ; @@ -188,6 +149,7 @@ psppire_syntax_window_class_init (PsppireSyntaxWindowClass *class) { GParamSpec *encoding_spec; GObjectClass *gobject_class = G_OBJECT_CLASS (class); + gobject_class->finalize = psppire_syntax_window_finalize; GtkSourceLanguageManager *lm = gtk_source_language_manager_get_default (); @@ -230,22 +192,6 @@ psppire_syntax_window_class_init (PsppireSyntaxWindowClass *class) } -static void -psppire_syntax_window_base_init (PsppireSyntaxWindowClass *class) -{ - GObjectClass *object_class = G_OBJECT_CLASS (class); - object_class->finalize = psppire_syntax_window_finalize; -} - - - -static void -psppire_syntax_window_base_finalize (PsppireSyntaxWindowClass *class, - gpointer class_data) -{ -} - - static void editor_execute_syntax (const PsppireSyntaxWindow *sw, GtkTextIter start, GtkTextIter stop) diff --git a/src/ui/gui/psppire-val-chooser.c b/src/ui/gui/psppire-val-chooser.c index 7e420d09cc..72ffac5111 100644 --- a/src/ui/gui/psppire-val-chooser.c +++ b/src/ui/gui/psppire-val-chooser.c @@ -30,42 +30,12 @@ #define _(msgid) gettext (msgid) #define N_(msgid) msgid -static void psppire_val_chooser_base_finalize (PsppireValChooserClass *, gpointer); -static void psppire_val_chooser_base_init (PsppireValChooserClass *class); static void psppire_val_chooser_class_init (PsppireValChooserClass *class); static void psppire_val_chooser_init (PsppireValChooser *vc); static void psppire_val_chooser_realize (GtkWidget *w); -GType -psppire_val_chooser_get_type (void) -{ - static GType psppire_val_chooser_type = 0; - - if (!psppire_val_chooser_type) - { - static const GTypeInfo psppire_val_chooser_info = - { - sizeof (PsppireValChooserClass), - (GBaseInitFunc) (void (*)(void)) psppire_val_chooser_base_init, - (GBaseFinalizeFunc) (void (*)(void)) psppire_val_chooser_base_finalize, - (GClassInitFunc) (void (*)(void)) psppire_val_chooser_class_init, - (GClassFinalizeFunc) NULL, - NULL, - sizeof (PsppireValChooser), - 0, - (GInstanceInitFunc) (void (*)(void)) psppire_val_chooser_init, - NULL /* value_table */ - }; - - psppire_val_chooser_type = - g_type_register_static (GTK_TYPE_FRAME, "PsppireValChooser", - &psppire_val_chooser_info, 0); - } - - return psppire_val_chooser_type; -} - +G_DEFINE_TYPE (PsppireValChooser, psppire_val_chooser, GTK_TYPE_FRAME) static void psppire_val_chooser_finalize (GObject *object) @@ -158,6 +128,8 @@ static void psppire_val_chooser_class_init (PsppireValChooserClass *class) { GObjectClass *object_class = G_OBJECT_CLASS (class); + + object_class->finalize = psppire_val_chooser_finalize; GtkWidgetClass *widget_class = GTK_WIDGET_CLASS (class); GParamSpec *is_string_spec = @@ -192,24 +164,6 @@ psppire_val_chooser_class_init (PsppireValChooserClass *class) } -static void -psppire_val_chooser_base_init (PsppireValChooserClass *class) -{ - GObjectClass *object_class = G_OBJECT_CLASS (class); - - object_class->finalize = psppire_val_chooser_finalize; -} - - - -static void -psppire_val_chooser_base_finalize (PsppireValChooserClass *class, - gpointer class_data) -{ - -} - - /* Set the focus of B to follow the sensitivity of A */ static void focus_follows_sensitivity (GtkWidget *a, GParamSpec *pspec, GtkWidget *b) diff --git a/src/ui/gui/psppire-var-view.c b/src/ui/gui/psppire-var-view.c index ee245e72fb..0a020008fb 100644 --- a/src/ui/gui/psppire-var-view.c +++ b/src/ui/gui/psppire-var-view.c @@ -29,8 +29,6 @@ #define _(msgid) gettext (msgid) #define N_(msgid) msgid -static void psppire_var_view_base_finalize (PsppireVarViewClass *, gpointer); -static void psppire_var_view_base_init (PsppireVarViewClass *class); static void psppire_var_view_class_init (PsppireVarViewClass *class); static void psppire_var_view_init (PsppireVarView *var_view); @@ -64,44 +62,8 @@ model_init (PsppireSelectDestWidgetIface *iface) iface->contains_var = var_view_contains_var; } -GType -psppire_var_view_get_type (void) -{ - static GType psppire_var_view_type = 0; - - if (!psppire_var_view_type) - { - static const GTypeInfo psppire_var_view_info = - { - sizeof (PsppireVarViewClass), - (GBaseInitFunc) (void (*)(void)) psppire_var_view_base_init, - (GBaseFinalizeFunc) (void (*)(void)) psppire_var_view_base_finalize, - (GClassInitFunc) (void (*)(void)) psppire_var_view_class_init, - (GClassFinalizeFunc) NULL, - NULL, - sizeof (PsppireVarView), - 0, - (GInstanceInitFunc) (void (*)(void)) psppire_var_view_init, - NULL /* value_table */ - }; - - static const GInterfaceInfo var_view_model_info = { - (GInterfaceInitFunc) (void (*)(void)) model_init, /* Fill this in */ - NULL, - NULL - }; - - psppire_var_view_type = - g_type_register_static (GTK_TYPE_TREE_VIEW, "PsppireVarView", - &psppire_var_view_info, 0); - - g_type_add_interface_static (psppire_var_view_type, - PSPPIRE_TYPE_SELECT_DEST_WIDGET, - &var_view_model_info); - } - - return psppire_var_view_type; -} +G_DEFINE_TYPE_WITH_CODE (PsppireVarView, psppire_var_view, GTK_TYPE_TREE_VIEW, + G_IMPLEMENT_INTERFACE (PSPPIRE_TYPE_SELECT_DEST_WIDGET, model_init)) void psppire_var_view_clear (PsppireVarView *vv) @@ -251,6 +213,8 @@ psppire_var_view_class_init (PsppireVarViewClass *class) { GObjectClass *object_class = G_OBJECT_CLASS (class); + object_class->finalize = psppire_var_view_finalize; + GParamSpec *n_cols_spec = g_param_spec_int ("n-cols", "Number of columns", @@ -268,26 +232,6 @@ psppire_var_view_class_init (PsppireVarViewClass *class) n_cols_spec); } - -static void -psppire_var_view_base_init (PsppireVarViewClass *class) -{ - - GObjectClass *object_class = G_OBJECT_CLASS (class); - - object_class->finalize = psppire_var_view_finalize; -} - - - -static void -psppire_var_view_base_finalize (PsppireVarViewClass *class, - gpointer class_data) -{ -} - - - static void psppire_var_view_init (PsppireVarView *vv) { diff --git a/src/ui/gui/psppire-window-base.c b/src/ui/gui/psppire-window-base.c index 7764babc62..e3dcd8da3f 100644 --- a/src/ui/gui/psppire-window-base.c +++ b/src/ui/gui/psppire-window-base.c @@ -33,7 +33,6 @@ #include static void psppire_window_base_class_init (PsppireWindowBaseClass *class); -static void psppire_window_base_init (PsppireWindowBase *window); G_DEFINE_ABSTRACT_TYPE (PsppireWindowBase, psppire_window_base, GTK_TYPE_APPLICATION_WINDOW); diff --git a/src/ui/gui/psppire-window.c b/src/ui/gui/psppire-window.c index ca81692305..8e73ab2a68 100644 --- a/src/ui/gui/psppire-window.c +++ b/src/ui/gui/psppire-window.c @@ -44,42 +44,12 @@ #include "psppire-syntax-window.h" #include "psppire-window-register.h" -static void psppire_window_base_init (PsppireWindowClass *class); static void psppire_window_class_init (PsppireWindowClass *class); static void psppire_window_init (PsppireWindow *window); - static GObjectClass *parent_class; -GType -psppire_window_get_type (void) -{ - static GType psppire_window_type = 0; - - if (!psppire_window_type) - { - static const GTypeInfo psppire_window_info = - { - sizeof (PsppireWindowClass), - (GBaseInitFunc) (void (*)(void)) psppire_window_base_init, - (GBaseFinalizeFunc) NULL, - (GClassInitFunc) (void (*)(void)) psppire_window_class_init, - (GClassFinalizeFunc) NULL, - NULL, - sizeof (PsppireWindow), - 0, - (GInstanceInitFunc) (void (*)(void)) psppire_window_init, - NULL /* value_table */ - }; - - psppire_window_type = - g_type_register_static (PSPPIRE_TYPE_WINDOW_BASE, "PsppireWindow", - &psppire_window_info, G_TYPE_FLAG_ABSTRACT); - } - - return psppire_window_type; -} - +G_DEFINE_ABSTRACT_TYPE (PsppireWindow, psppire_window, PSPPIRE_TYPE_WINDOW_BASE) /* Properties */ enum @@ -269,6 +239,8 @@ psppire_window_class_init (PsppireWindowClass *class) { GObjectClass *object_class = G_OBJECT_CLASS (class); + object_class->finalize = psppire_window_finalize; + GParamSpec *description_spec = null_if_empty_param ("description", "Description", @@ -310,16 +282,6 @@ psppire_window_class_init (PsppireWindowClass *class) } -static void -psppire_window_base_init (PsppireWindowClass *class) -{ - GObjectClass *object_class = G_OBJECT_CLASS (class); - - object_class->finalize = psppire_window_finalize; -} - - - static void insert_menuitem_into_menu (PsppireWindow *window, gpointer key) { @@ -946,4 +908,3 @@ delete_recent (const char *file_name) g_free (uri); } -