[maemo-commits] [maemo-commits] r15978 - in projects/haf/trunk/sapwood: . src

From: subversion at stage.maemo.org subversion at stage.maemo.org
Date: Wed Sep 3 12:21:23 EEST 2008
Author: herzi
Date: 2008-09-03 12:21:18 +0300 (Wed, 03 Sep 2008)
New Revision: 15978

Modified:
   projects/haf/trunk/sapwood/ChangeLog
   projects/haf/trunk/sapwood/src/sapwood-main.c
   projects/haf/trunk/sapwood/src/sapwood-rc-style.c
   projects/haf/trunk/sapwood/src/sapwood-rc-style.h
   projects/haf/trunk/sapwood/src/sapwood-style.c
   projects/haf/trunk/sapwood/src/sapwood-style.h
Log:
2008-09-03  Sven Herzberg  <sven at imendio.com>

	Use G_DEFINE_DYNAMIC_TYPE
	patch from Christian Dywan

	* src/sapwood-main.c,
	* src/sapwood-rc-style.c,
	* src/sapwood-rc-style.h,
	* src/sapwood-style.c,
	* src/sapwood-style.h: lots of cleanup here


Modified: projects/haf/trunk/sapwood/ChangeLog
===================================================================
--- projects/haf/trunk/sapwood/ChangeLog	2008-09-03 09:17:24 UTC (rev 15977)
+++ projects/haf/trunk/sapwood/ChangeLog	2008-09-03 09:21:18 UTC (rev 15978)
@@ -1,5 +1,16 @@
 2008-09-03  Sven Herzberg  <sven at imendio.com>
 
+	Use G_DEFINE_DYNAMIC_TYPE
+	patch from Christian Dywan
+
+	* src/sapwood-main.c,
+	* src/sapwood-rc-style.c,
+	* src/sapwood-rc-style.h,
+	* src/sapwood-style.c,
+	* src/sapwood-style.h: lots of cleanup here
+
+2008-09-03  Sven Herzberg  <sven at imendio.com>
+
 	Properly indent function signatures
 	based on a patch by Christian Dywan
 

Modified: projects/haf/trunk/sapwood/src/sapwood-main.c
===================================================================
--- projects/haf/trunk/sapwood/src/sapwood-main.c	2008-09-03 09:17:24 UTC (rev 15977)
+++ projects/haf/trunk/sapwood/src/sapwood-main.c	2008-09-03 09:21:18 UTC (rev 15978)
@@ -38,8 +38,8 @@
   };
   const gchar* debug;
 
-  sapwood_rc_style_register_type (module);
-  sapwood_style_register_type (module);
+  sapwood_rc_style_register_types (module);
+  sapwood_style_register_types (module);
 
   debug = g_getenv ("SAPWOOD_DEBUG");
   if (debug)

Modified: projects/haf/trunk/sapwood/src/sapwood-rc-style.c
===================================================================
--- projects/haf/trunk/sapwood/src/sapwood-rc-style.c	2008-09-03 09:17:24 UTC (rev 15977)
+++ projects/haf/trunk/sapwood/src/sapwood-rc-style.c	2008-09-03 09:21:18 UTC (rev 15978)
@@ -27,8 +27,6 @@
 #include "sapwood-style.h"
 #include "sapwood-rc-style.h"
 
-static void      sapwood_rc_style_init         (SapwoodRcStyle      *style);
-static void      sapwood_rc_style_class_init   (SapwoodRcStyleClass *klass);
 static void      sapwood_rc_style_finalize     (GObject            *object);
 static guint     sapwood_rc_style_parse        (GtkRcStyle         *rc_style,
 						GtkSettings  *settings,
@@ -41,8 +39,8 @@
 
 static struct
   {
-    gchar              *name;
-    guint               token;
+    gchar *name;
+    guint  token;
   }
 theme_symbols[] =
 {
@@ -112,30 +110,12 @@
   { "VERTICAL",		TOKEN_VERTICAL },
 };
 
-static GtkRcStyleClass *parent_class;
+G_DEFINE_DYNAMIC_TYPE (SapwoodRcStyle, sapwood_rc_style, GTK_TYPE_RC_STYLE);
 
-GType sapwood_type_rc_style = 0;
-
 void
-sapwood_rc_style_register_type (GTypeModule *module)
+sapwood_rc_style_register_types (GTypeModule *module)
 {
-  static const GTypeInfo object_info =
-  {
-    sizeof (SapwoodRcStyleClass),
-    (GBaseInitFunc) NULL,
-    (GBaseFinalizeFunc) NULL,
-    (GClassInitFunc) sapwood_rc_style_class_init,
-    NULL,           /* class_finalize */
-    NULL,           /* class_data */
-    sizeof (SapwoodRcStyle),
-    0,              /* n_preallocs */
-    (GInstanceInitFunc) sapwood_rc_style_init,
-  };
-
-  sapwood_type_rc_style = g_type_module_register_type (module,
-						      GTK_TYPE_RC_STYLE,
-						      "SapwoodRcStyle",
-						      &object_info, 0);
+  sapwood_rc_style_register_type (module);
 }
 
 static void
@@ -149,8 +129,6 @@
   GtkRcStyleClass *rc_style_class = GTK_RC_STYLE_CLASS (klass);
   GObjectClass *object_class = G_OBJECT_CLASS (klass);
 
-  parent_class = g_type_class_peek_parent (klass);
-
   rc_style_class->parse = sapwood_rc_style_parse;
   rc_style_class->merge = sapwood_rc_style_merge;
   rc_style_class->create_style = sapwood_rc_style_create_style;
@@ -166,9 +144,14 @@
   g_list_foreach (rc_style->img_list, (GFunc) theme_image_unref, NULL);
   g_list_free (rc_style->img_list);
 
-  G_OBJECT_CLASS (parent_class)->finalize (object);
+  G_OBJECT_CLASS (sapwood_rc_style_parent_class)->finalize (object);
 }
 
+static void
+sapwood_rc_style_class_finalize (SapwoodRcStyleClass *klass)
+{
+}
+
 static guint
 theme_parse_file (GtkSettings  *settings,
                   GScanner     *scanner,
@@ -850,7 +833,7 @@
 	}
     }
 
-  parent_class->merge (dest, src);
+  GTK_RC_STYLE_CLASS (sapwood_rc_style_parent_class)->merge (dest, src);
 }
 
 /* Create an empty style suitable to this RC style

Modified: projects/haf/trunk/sapwood/src/sapwood-rc-style.h
===================================================================
--- projects/haf/trunk/sapwood/src/sapwood-rc-style.h	2008-09-03 09:17:24 UTC (rev 15977)
+++ projects/haf/trunk/sapwood/src/sapwood-rc-style.h	2008-09-03 09:21:18 UTC (rev 15978)
@@ -22,14 +22,17 @@
  * Carsten Haitzler <raster at rasterman.com>
  */
 
+#ifndef __SAPWOOD_RC_STYLE_H__
+#define __SAPWOOD_RC_STYLE_H__
+
 #include <gtk/gtk.h>
 
 typedef struct _SapwoodRcStyle SapwoodRcStyle;
 typedef struct _SapwoodRcStyleClass SapwoodRcStyleClass;
 
-extern GType sapwood_type_rc_style G_GNUC_INTERNAL;
+G_BEGIN_DECLS
 
-#define SAPWOOD_TYPE_RC_STYLE              sapwood_type_rc_style
+#define SAPWOOD_TYPE_RC_STYLE              (sapwood_rc_style_get_type ())
 #define SAPWOOD_RC_STYLE(object)           (G_TYPE_CHECK_INSTANCE_CAST ((object), SAPWOOD_TYPE_RC_STYLE, SapwoodRcStyle))
 #define SAPWOOD_RC_STYLE_CLASS(klass)      (G_TYPE_CHECK_CLASS_CAST ((klass), SAPWOOD_TYPE_RC_STYLE, SapwoodRcStyleClass))
 #define SAPWOOD_IS_RC_STYLE(object)        (G_TYPE_CHECK_INSTANCE_TYPE ((object), SAPWOOD_TYPE_RC_STYLE))
@@ -48,4 +51,10 @@
   GtkRcStyleClass parent_class;
 };
 
-void sapwood_rc_style_register_type (GTypeModule *module) G_GNUC_INTERNAL;
+void sapwood_rc_style_register_types   (GTypeModule           *module);
+
+GType sapwood_rc_style_get_type        (void);
+
+G_END_DECLS
+
+#endif /* __SAPWOOD_RC_STYLE_H__ */

Modified: projects/haf/trunk/sapwood/src/sapwood-style.c
===================================================================
--- projects/haf/trunk/sapwood/src/sapwood-style.c	2008-09-03 09:17:24 UTC (rev 15977)
+++ projects/haf/trunk/sapwood/src/sapwood-style.c	2008-09-03 09:21:18 UTC (rev 15978)
@@ -30,11 +30,8 @@
 #include "sapwood-rc-style.h"
 #include "sapwood-style.h"
 
-static void sapwood_style_init       (SapwoodStyle      *style);
-static void sapwood_style_class_init (SapwoodStyleClass *klass);
+G_DEFINE_DYNAMIC_TYPE (SapwoodStyle, sapwood_style, GTK_TYPE_STYLE);
 
-static GtkStyleClass *parent_class = NULL;
-
 static ThemeImage *
 match_theme_image (GtkStyle       *style,
 		   ThemeMatchData *match_data)
@@ -499,8 +496,8 @@
 			     x1, y, (x2 - x1) + 1, 2);
     }
   else
-    parent_class->draw_hline (style, window, state, area, widget, detail,
-			      x1, x2, y);
+    GTK_STYLE_CLASS (sapwood_style_parent_class)->draw_hline (
+      style, window, state, area, widget, detail, x1, x2, y);
 }
 
 static void
@@ -535,8 +532,8 @@
 			     x, y1, 2, (y2 - y1) + 1);
     }
   else
-    parent_class->draw_vline (style, window, state, area, widget, detail,
-			      y1, y2, x);
+    GTK_STYLE_CLASS (sapwood_style_parent_class)->draw_vline (
+      style, window, state, area, widget, detail, y1, y2, x);
 }
 
 static void
@@ -565,8 +562,8 @@
 
   if (!draw_simple_image (style, window, area, widget, &match_data, FALSE,
 			  x, y, width, height))
-    parent_class->draw_shadow (style, window, state, shadow, area, widget, detail,
-			       x, y, width, height);
+    GTK_STYLE_CLASS (sapwood_style_parent_class)->draw_shadow (
+      style, window, state, shadow, area, widget, detail, x, y, width, height);
 }
 
 /* This function makes up for some brokeness in gtkrange.c
@@ -680,8 +677,9 @@
 
       if (!draw_simple_image (style, window, area, widget, &match_data, TRUE,
 			      box_x, box_y, box_width, box_height))
-	parent_class->draw_box (style, window, state, shadow, area, widget, detail,
-				box_x, box_y, box_width, box_height);
+	GTK_STYLE_CLASS (sapwood_style_parent_class)->draw_box (
+          style, window, state, shadow, area, widget, detail,
+          box_x, box_y, box_width, box_height);
     }
 
 #if GTK_CHECK_VERSION(2,9,2)
@@ -700,8 +698,9 @@
 
   if (!draw_simple_image (style, window, area, widget, &match_data, TRUE,
 			  x, y, width, height))
-    parent_class->draw_arrow (style, window, state, shadow, area, widget, detail,
-			      arrow_direction, fill, x, y, width, height);
+    GTK_STYLE_CLASS (sapwood_style_parent_class)->draw_arrow (
+      style, window, state, shadow, area, widget, detail,
+      arrow_direction, fill, x, y, width, height);
 }
 
 static void
@@ -730,8 +729,8 @@
 
   if (!draw_simple_image (style, window, area, widget, &match_data, TRUE,
 			  x, y, width, height))
-    parent_class->draw_diamond (style, window, state, shadow, area, widget, detail,
-				x, y, width, height);
+    GTK_STYLE_CLASS (sapwood_style_parent_class)->draw_diamond (
+      style, window, state, shadow, area, widget, detail, x, y, width, height);
 }
 
 static void
@@ -843,8 +842,8 @@
 
   if (!draw_simple_image (style, window, area, widget, &match_data, TRUE,
 			  x, y, width, height)) {
-    parent_class->draw_box (style, window, state, shadow, area, widget, detail,
-			    x, y, width, height);
+    GTK_STYLE_CLASS (sapwood_style_parent_class)->draw_box (
+      style, window, state, shadow, area, widget, detail, x, y, width, height);
   }
 }
 
@@ -928,8 +927,8 @@
 
   if (!draw_simple_image (style, window, area, widget, &match_data, TRUE,
 			  x, y, width, height))
-    parent_class->draw_flat_box (style, window, state, shadow, area, widget, detail,
-				 x, y, width, height);
+    GTK_STYLE_CLASS (sapwood_style_parent_class)->draw_flat_box (
+      style, window, state, shadow, area, widget, detail, x, y, width, height);
 }
 
 static void
@@ -966,8 +965,8 @@
 
   if (!draw_simple_image (style, window, area, widget, &match_data, TRUE,
 			  x, y, width, height))
-    parent_class->draw_check (style, window, state, shadow, area, widget, detail,
-			      x, y, width, height);
+    GTK_STYLE_CLASS (sapwood_style_parent_class)->draw_check (
+      style, window, state, shadow, area, widget, detail, x, y, width, height);
 }
 
 static void
@@ -1004,8 +1003,8 @@
 
   if (!draw_simple_image (style, window, area, widget, &match_data, TRUE,
 			  x, y, width, height))
-    parent_class->draw_option (style, window, state, shadow, area, widget, detail,
-			       x, y, width, height);
+    GTK_STYLE_CLASS (sapwood_style_parent_class)->draw_option (
+      style, window, state, shadow, area, widget, detail, x, y, width, height);
 }
 
 static void
@@ -1034,8 +1033,8 @@
 
   if (!draw_simple_image (style, window, area, widget, &match_data, TRUE,
 			  x, y, width, height))
-    parent_class->draw_tab (style, window, state, shadow, area, widget, detail,
-			    x, y, width, height);
+    GTK_STYLE_CLASS (sapwood_style_parent_class)->draw_tab (
+      style, window, state, shadow, area, widget, detail, x, y, width, height);
 }
 
 static void
@@ -1067,8 +1066,9 @@
 
   if (!draw_gap_image (style, window, area, widget, &match_data, FALSE,
 		       x, y, width, height, gap_side, gap_x, gap_width))
-    parent_class->draw_shadow_gap (style, window, state, shadow, area, widget, detail,
-				   x, y, width, height, gap_side, gap_x, gap_width);
+    GTK_STYLE_CLASS (sapwood_style_parent_class)->draw_shadow_gap (
+      style, window, state, shadow, area, widget, detail,
+      x, y, width, height, gap_side, gap_x, gap_width);
 }
 
 static void
@@ -1100,8 +1100,9 @@
 
   if (!draw_gap_image (style, window, area, widget, &match_data, TRUE,
 		       x, y, width, height, gap_side, gap_x, gap_width))
-    parent_class->draw_box_gap (style, window, state, shadow, area, widget, detail,
-				x, y, width, height, gap_side, gap_x, gap_width);
+    GTK_STYLE_CLASS (sapwood_style_parent_class)->draw_box_gap (
+      style, window, state, shadow, area, widget, detail,
+      x, y, width, height, gap_side, gap_x, gap_width);
 }
 
 static void
@@ -1150,8 +1151,9 @@
 
   if (!draw_simple_image (style, window, area, widget, &match_data, TRUE,
                           center_x - expander_size/2, center_y - expander_size/2, expander_size, expander_size))
-    parent_class->draw_expander (style, window, state, area, widget, detail,
-                                 center_x, center_y, expander_style);
+    GTK_STYLE_CLASS (sapwood_style_parent_class)->draw_expander (
+      style, window, state, area, widget, detail,
+      center_x, center_y, expander_style);
 }
 
 static void
@@ -1182,8 +1184,9 @@
 
   if (!draw_simple_image (style, window, area, widget, &match_data, TRUE,
 			  x, y, width, height))
-    parent_class->draw_extension (style, window, state, shadow, area, widget, detail,
-				  x, y, width, height, gap_side);
+    GTK_STYLE_CLASS (sapwood_style_parent_class)->draw_extension (
+      style, window, state, shadow, area, widget, detail,
+      x, y, width, height, gap_side);
 }
 
 static void
@@ -1210,8 +1213,8 @@
 
   if (!draw_simple_image (style, window, area, widget, &match_data, TRUE,
 			  x, y, width, height))
-    parent_class->draw_focus (style, window, state, area, widget, detail,
-			      x, y, width, height);
+    GTK_STYLE_CLASS (sapwood_style_parent_class)->draw_focus (
+      style, window, state, area, widget, detail, x, y, width, height);
 }
 
 static void
@@ -1244,8 +1247,9 @@
 
   if (!draw_simple_image (style, window, area, widget, &match_data, TRUE,
 			  x, y, width, height))
-    parent_class->draw_slider (style, window, state, shadow, area, widget, detail,
-			       x, y, width, height, orientation);
+    GTK_STYLE_CLASS (sapwood_style_parent_class)->draw_slider (
+      style, window, state, shadow, area, widget, detail,
+      x, y, width, height, orientation);
 }
 
 
@@ -1279,8 +1283,9 @@
 
   if (!draw_simple_image (style, window, area, widget, &match_data, TRUE,
 			  x, y, width, height))
-    parent_class->draw_handle (style, window, state, shadow, area, widget, detail,
-			       x, y, width, height, orientation);
+    GTK_STYLE_CLASS (sapwood_style_parent_class)->draw_handle (
+      style, window, state, shadow, area, widget, detail,
+      x, y, width, height, orientation);
 }
 
 static GdkPixbuf *
@@ -1306,7 +1311,8 @@
        * a simple background color (white) raster on top
        */
 
-      pixbuf = parent_class->render_icon (style, source, direction, GTK_STATE_NORMAL, size, widget, detail);
+      pixbuf = GTK_STYLE_CLASS (sapwood_style_parent_class)->render_icon (
+        style, source, direction, GTK_STATE_NORMAL, size, widget, detail);
       if (!pixbuf)
 	return NULL;
 
@@ -1348,7 +1354,8 @@
       return stated;
     }
   else
-    return parent_class->render_icon (style, source, direction, state, size, widget, detail);
+    return GTK_STYLE_CLASS (sapwood_style_parent_class)->render_icon (
+      style, source, direction, state, size, widget, detail);
 }
 
 static void
@@ -1378,28 +1385,10 @@
     gdk_gc_set_clip_rectangle (gc, NULL);
 }
 
-GType sapwood_type_style = 0;
-
 void
-sapwood_style_register_type (GTypeModule *module)
+sapwood_style_register_types (GTypeModule *module)
 {
-  static const GTypeInfo object_info =
-  {
-    sizeof (SapwoodStyleClass),
-    (GBaseInitFunc) NULL,
-    (GBaseFinalizeFunc) NULL,
-    (GClassInitFunc) sapwood_style_class_init,
-    NULL,           /* class_finalize */
-    NULL,           /* class_data */
-    sizeof (SapwoodStyle),
-    0,              /* n_preallocs */
-    (GInstanceInitFunc) sapwood_style_init,
-  };
-  
-  sapwood_type_style = g_type_module_register_type (module,
-						   GTK_TYPE_STYLE,
-						   "SapwoodStyle",
-						   &object_info, 0);
+  sapwood_style_register_type (module);
 }
 
 static void
@@ -1412,8 +1401,6 @@
 {
   GtkStyleClass *style_class = GTK_STYLE_CLASS (klass);
 
-  parent_class = g_type_class_peek_parent (klass);
-
   style_class->draw_hline = draw_hline;
   style_class->draw_vline = draw_vline;
   style_class->draw_shadow = draw_shadow;
@@ -1435,3 +1422,8 @@
   style_class->draw_expander = draw_expander;
   style_class->draw_layout = draw_layout;
 }
+
+static void
+sapwood_style_class_finalize (SapwoodStyleClass *klass)
+{
+}

Modified: projects/haf/trunk/sapwood/src/sapwood-style.h
===================================================================
--- projects/haf/trunk/sapwood/src/sapwood-style.h	2008-09-03 09:17:24 UTC (rev 15977)
+++ projects/haf/trunk/sapwood/src/sapwood-style.h	2008-09-03 09:21:18 UTC (rev 15978)
@@ -22,14 +22,17 @@
  * Carsten Haitzler <raster at rasterman.com>
  */
 
+#ifndef __SAPWOOD_STYLE_H__
+#define __SAPWOOD_STYLE_H__
+
 #include <gtk/gtkstyle.h>
 
 typedef struct _SapwoodStyle SapwoodStyle;
 typedef struct _SapwoodStyleClass SapwoodStyleClass;
 
-extern GType sapwood_type_style G_GNUC_INTERNAL;
+G_BEGIN_DECLS
 
-#define SAPWOOD_TYPE_STYLE              sapwood_type_style
+#define SAPWOOD_TYPE_STYLE              (sapwood_style_get_type ())
 #define SAPWOOD_STYLE(object)           (G_TYPE_CHECK_INSTANCE_CAST ((object), SAPWOOD_TYPE_STYLE, SapwoodStyle))
 #define SAPWOOD_STYLE_CLASS(klass)      (G_TYPE_CHECK_CLASS_CAST ((klass), SAPWOOD_TYPE_STYLE, SapwoodStyleClass))
 #define SAPWOOD_IS_STYLE(object)        (G_TYPE_CHECK_INSTANCE_TYPE ((object), SAPWOOD_TYPE_STYLE))
@@ -46,4 +49,10 @@
   GtkStyleClass parent_class;
 };
 
-void sapwood_style_register_type (GTypeModule *module) G_GNUC_INTERNAL;
+void sapwood_style_register_types   (GTypeModule           *module);
+
+GType sapwood_style_get_type        (void);
+
+G_END_DECLS
+
+#endif /* __SAPWOOD_STYLE_H__ */


More information about the maemo-commits mailing list