[dia] [gtk-deprecated] no more GtkType



commit ba30f7fb4d4949b2a3ccc889d25aae6e7bda0d5c
Author: Hans Breuer <hans breuer org>
Date:   Sun Aug 26 22:25:08 2012 +0200

    [gtk-deprecated] no more GtkType

 lib/diadynamicmenu.c       |   28 ++++++++++++++++------------
 lib/diafontselector.c      |   38 ++++++++++++++++++++------------------
 lib/dialinestyleselector.c |   31 +++++++++++++++++--------------
 3 files changed, 53 insertions(+), 44 deletions(-)
---
diff --git a/lib/diadynamicmenu.c b/lib/diadynamicmenu.c
index 2953e0c..195a4a4 100644
--- a/lib/diadynamicmenu.c
+++ b/lib/diadynamicmenu.c
@@ -70,23 +70,27 @@ enum {
 
 static guint ddm_signals[DDM_LAST_SIGNAL] = { 0 };
 
-GtkType
+GType
 dia_dynamic_menu_get_type(void)
 {
-  static GtkType us_type = 0;
+  static GType us_type = 0;
 
   if (!us_type) {
-    static const GtkTypeInfo us_info = {
-      "DiaDynamicMenu",
-      sizeof(DiaDynamicMenu),
+    static const GTypeInfo us_info = {
       sizeof(DiaDynamicMenuClass),
-      (GtkClassInitFunc) dia_dynamic_menu_class_init,
-      (GtkObjectInitFunc) dia_dynamic_menu_init,
-      NULL,
-      NULL,
-      (GtkClassInitFunc) NULL,
+      (GBaseInitFunc) NULL,
+      (GBaseFinalizeFunc) NULL,
+      (GClassInitFunc) dia_dynamic_menu_class_init,
+      NULL,           /* class_finalize */
+      NULL,           /* class_data */
+      sizeof(DiaDynamicMenu),
+      0,              /* n_preallocs */
+      (GInstanceInitFunc)dia_dynamic_menu_init,
     };
-    us_type = gtk_type_unique(gtk_option_menu_get_type(), &us_info);
+    us_type = g_type_register_static(
+			gtk_option_menu_get_type(),
+			"DiaDynamicMenu",
+			&us_info, 0);
   }
   return us_type;
 }
@@ -144,7 +148,7 @@ dia_dynamic_menu_new(DDMCreateItemFunc create,
 
   g_assert(persist != NULL);
 
-  ddm = DIA_DYNAMIC_MENU ( gtk_type_new (dia_dynamic_menu_get_type ()));
+  ddm = DIA_DYNAMIC_MENU ( g_object_new (dia_dynamic_menu_get_type (), NULL));
   
   ddm->create_func = create;
   ddm->userdata = userdata;
diff --git a/lib/diafontselector.c b/lib/diafontselector.c
index d2512e8..d216c2f 100644
--- a/lib/diafontselector.c
+++ b/lib/diafontselector.c
@@ -154,10 +154,9 @@ dia_font_selector_init (DiaFontSelector *fs)
   }
   g_free (families);
   
-  fs->font_omenu =
-      DIA_DYNAMIC_MENU(dia_dynamic_menu_new_listbased(dia_font_selector_create_string_item,
+  fs->font_omenu = dia_dynamic_menu_new_listbased(dia_font_selector_create_string_item,
 				     fs, _("Other fonts"),
-				     fontnames, "font-menu"));
+				     fontnames, "font-menu");
   g_signal_connect(DIA_DYNAMIC_MENU(fs->font_omenu), "value-changed",
 		   G_CALLBACK(dia_font_selector_fontmenu_callback), fs);
   dia_dynamic_menu_add_default_entry(DIA_DYNAMIC_MENU(fs->font_omenu),
@@ -183,24 +182,27 @@ dia_font_selector_init (DiaFontSelector *fs)
   gtk_box_pack_start(GTK_BOX(fs), GTK_WIDGET(fs->style_omenu), TRUE, TRUE, 0);
 }
 
-GtkType
+GType
 dia_font_selector_get_type        (void)
 {
-  static GtkType dfs_type = 0;
+  static GType dfs_type = 0;
 
   if (!dfs_type) {
-    static const GtkTypeInfo dfs_info = {
-      "DiaFontSelector",
-      sizeof (DiaFontSelector),
+    static const GTypeInfo dfs_info = {
       sizeof (DiaFontSelectorClass),
-      (GtkClassInitFunc) dia_font_selector_class_init,
-      (GtkObjectInitFunc) dia_font_selector_init,
-      NULL,
-      NULL,
-      (GtkClassInitFunc) NULL
+      (GBaseInitFunc) NULL,
+      (GBaseFinalizeFunc) NULL,
+      (GClassInitFunc) dia_font_selector_class_init,
+      NULL,           /* class_finalize */
+      NULL,           /* class_data */
+      sizeof (DiaFontSelector),
+      0,              /* n_preallocs */
+      (GInstanceInitFunc) dia_font_selector_init,
     };
     
-    dfs_type = gtk_type_unique (gtk_hbox_get_type (), &dfs_info);
+    dfs_type = g_type_register_static (gtk_hbox_get_type (), 
+				       "DiaFontSelector",
+				       &dfs_info, 0);
   }
   
   return dfs_type;
@@ -209,7 +211,7 @@ dia_font_selector_get_type        (void)
 GtkWidget *
 dia_font_selector_new ()
 {
-  return GTK_WIDGET ( gtk_type_new (dia_font_selector_get_type ()));
+  return GTK_WIDGET ( g_object_new (dia_font_selector_get_type (), NULL));
 }
 
 static PangoFontFamily *
@@ -239,7 +241,7 @@ dia_font_selector_fontmenu_callback(DiaDynamicMenu *ddm, gpointer data)
   DiaFontSelector *fs = DIAFONTSELECTOR(data);
   char *fontname = dia_dynamic_menu_get_entry(ddm);
   dia_font_selector_set_styles(fs, fontname, -1);
-  g_signal_emit(GTK_OBJECT(fs),
+  g_signal_emit(G_OBJECT(fs),
 		dfontsel_signals[DFONTSEL_VALUE_CHANGED], 0);
   g_free(fontname);
 }
@@ -248,7 +250,7 @@ static void
 dia_font_selector_stylemenu_callback(GtkMenu *menu, gpointer data)
 {
   DiaFontSelector *fs = DIAFONTSELECTOR(data);
-  g_signal_emit(GTK_OBJECT(fs),
+  g_signal_emit(G_OBJECT(fs),
 		dfontsel_signals[DFONTSEL_VALUE_CHANGED], 0);
 }
 
@@ -381,7 +383,7 @@ dia_font_selector_set_font(DiaFontSelector *fs, DiaFont *font)
   const gchar *fontname = dia_font_get_family(font);
   /* side effect: adds fontname to presistence list */
   dia_dynamic_menu_select_entry(DIA_DYNAMIC_MENU(fs->font_omenu), fontname);
-  g_signal_emit(GTK_OBJECT(fs),
+  g_signal_emit(G_OBJECT(fs),
 		dfontsel_signals[DFONTSEL_VALUE_CHANGED], 0);
   dia_font_selector_set_styles(fs, fontname, dia_font_get_style (font));
 }
diff --git a/lib/dialinestyleselector.c b/lib/dialinestyleselector.c
index d4e4ea6..f58b5d4 100644
--- a/lib/dialinestyleselector.c
+++ b/lib/dialinestyleselector.c
@@ -176,7 +176,7 @@ dia_line_style_selector_init (DiaLineStyleSelector *fs)
   gtk_box_pack_start(GTK_BOX (box), length, TRUE, TRUE, 0);
   gtk_widget_show (length);
 
-  g_signal_connect(GTK_OBJECT(length), "changed", 
+  g_signal_connect(G_OBJECT(length), "changed", 
 		   G_CALLBACK(linestyle_dashlength_change_callback), fs);
 
   set_linestyle_sensitivity(fs);
@@ -185,33 +185,36 @@ dia_line_style_selector_init (DiaLineStyleSelector *fs)
   
 }
 
-GtkType
+GType
 dia_line_style_selector_get_type (void)
 {
-  static GtkType dfs_type = 0;
+  static GType dfs_type = 0;
 
   if (!dfs_type) {
-    static const GtkTypeInfo dfs_info = {
-      "DiaLineStyleSelector",
-      sizeof (DiaLineStyleSelector),
+    static const GTypeInfo dfs_info = {
       sizeof (DiaLineStyleSelectorClass),
-      (GtkClassInitFunc) dia_line_style_selector_class_init,
-      (GtkObjectInitFunc) dia_line_style_selector_init,
-      NULL,
-      NULL,
-      (GtkClassInitFunc) NULL,
+      (GBaseInitFunc) NULL,
+      (GBaseFinalizeFunc) NULL,
+      (GClassInitFunc) dia_line_style_selector_class_init,
+      NULL, /* class_finalize */
+      NULL, /* class_data */
+      sizeof (DiaLineStyleSelector),
+      0,    /* n_preallocs */
+      (GInstanceInitFunc) dia_line_style_selector_init,
     };
     
-    dfs_type = gtk_type_unique (gtk_vbox_get_type (), &dfs_info);
+    dfs_type = g_type_register_static (gtk_vbox_get_type (), 
+				       "DiaLineStyleSelector",
+				       &dfs_info, 0);
   }
-  
+
   return dfs_type;
 }
 
 GtkWidget *
 dia_line_style_selector_new ()
 {
-  return GTK_WIDGET ( gtk_type_new (dia_line_style_selector_get_type ()));
+  return GTK_WIDGET ( g_object_new (dia_line_style_selector_get_type (), NULL));
 }
 
 



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]