Remove _base_init functions from custom widget definitions.
authorJohn Darrington <john@darrington.wattle.id.au>
Sun, 30 Aug 2020 05:45:01 +0000 (07:45 +0200)
committerJohn Darrington <john@darrington.wattle.id.au>
Sun, 30 Aug 2020 05:39:07 +0000 (07:39 +0200)
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.

src/ui/gui/psppire-dialog.c
src/ui/gui/psppire-dialog.h
src/ui/gui/psppire-dictview.c
src/ui/gui/psppire-syntax-window.c
src/ui/gui/psppire-val-chooser.c
src/ui/gui/psppire-var-view.c
src/ui/gui/psppire-window-base.c
src/ui/gui/psppire-window.c

index 4f3bb243132dbe8c85dd69c471ecc2dfebcab696..4dfa1cd45a42af8b83ff6ffacc7838661f7141ad 100644 (file)
@@ -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 ;
index 0066dc19763ee3f6889c07b4ff86941dd6433a6c..012a3e8944db19091502ba0ef58bcbe302c8f1c6 100644 (file)
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>. */
 
-
 #ifndef __PSPPIRE_DIALOG_H__
 #define __PSPPIRE_DIALOG_H__
 
-
 #include <glib.h>
 #include <glib-object.h>
 #include <gtk/gtk.h>
@@ -84,4 +82,3 @@ void           psppire_dialog_notify_change (PsppireDialog *);
 G_END_DECLS
 
 #endif /* __PSPPIRE_DIALOG_H__ */
-
index a2ab2ae36c45f0be9489be18ce2c7dfc9327ab88..7d09eb1a1171787ea12030f590538310f883015d 100644 (file)
 #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)
 {
index eebaac5b28dda4c18b7791496875fcd4648e765b..4da38801d87b0a480ccf169b5174f05caaad0a95 100644 (file)
@@ -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)
index 7e420d09cc5b29e254352cd7d85308a99d2d0f55..72ffac51119d88ae3f1943152bf0cfb36b940b45 100644 (file)
 #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)
index ee245e72fb9a665d3550133776efda599c9d2fce..0a020008fb0c0c0630cca080deb4e7c177120960 100644 (file)
@@ -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)
 {
index 7764babc62cbe3d5a34db53438fccb96d3abd91f..e3dcd8da3f2bb8d41aedd7a308b437dcfc81919c 100644 (file)
@@ -33,7 +33,6 @@
 #include <gtk/gtk.h>
 
 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);
 
index ca81692305052e2596ddff40bebf4029bb7008ae..8e73ab2a68fda84f75bb4c26794fe72e34b0ccc6 100644 (file)
 #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);
 }
-