gtk-engines r1247 - in trunk: . engines/clearlooks/src



Author: bberg
Date: Mon Sep  1 15:03:17 2008
New Revision: 1247
URL: http://svn.gnome.org/viewvc/gtk-engines?rev=1247&view=rev

Log:
2008-09-01  Benjamin Berg  <benjamin sipsolutions net>

	* engines/clearlooks/src/clearlooks_rc_style.c:
	* engines/clearlooks/src/clearlooks_rc_style.h:
	* engines/clearlooks/src/clearlooks_style.c:
	* engines/clearlooks/src/clearlooks_style.h:
	* engines/clearlooks/src/clearlooks_theme_main.c:
	Use the G_DEFINE_DYNAMIC_TYPE macro provided by GLib.
	Bug #549830 Patch by Christian Dywan.


Modified:
   trunk/ChangeLog
   trunk/engines/clearlooks/src/clearlooks_rc_style.c
   trunk/engines/clearlooks/src/clearlooks_rc_style.h
   trunk/engines/clearlooks/src/clearlooks_style.c
   trunk/engines/clearlooks/src/clearlooks_style.h
   trunk/engines/clearlooks/src/clearlooks_theme_main.c

Modified: trunk/engines/clearlooks/src/clearlooks_rc_style.c
==============================================================================
--- trunk/engines/clearlooks/src/clearlooks_rc_style.c	(original)
+++ trunk/engines/clearlooks/src/clearlooks_rc_style.c	Mon Sep  1 15:03:17 2008
@@ -31,11 +31,9 @@
 
 #include "animation.h"
 
-static void      clearlooks_rc_style_init         (ClearlooksRcStyle      *style);
 #ifdef HAVE_ANIMATION
 static void      clearlooks_rc_style_finalize     (GObject                *object);
 #endif
-static void      clearlooks_rc_style_class_init   (ClearlooksRcStyleClass *klass);
 static GtkStyle *clearlooks_rc_style_create_style (GtkRcStyle             *rc_style);
 static guint     clearlooks_rc_style_parse        (GtkRcStyle             *rc_style,
                                                    GtkSettings            *settings,
@@ -43,11 +41,6 @@
 static void      clearlooks_rc_style_merge        (GtkRcStyle             *dest,
                                                    GtkRcStyle             *src);
 
-
-static GtkRcStyleClass *clearlooks_parent_rc_class;
-
-GType clearlooks_type_rc_style = 0;
-
 enum
 {
 	TOKEN_FOCUSCOLOR = G_TOKEN_LAST + 1,
@@ -102,27 +95,12 @@
 	"TRUE\0"
 	"FALSE\0";
 
+G_DEFINE_DYNAMIC_TYPE (ClearlooksRcStyle, clearlooks_rc_style, GTK_TYPE_RC_STYLE)
+
 void
-clearlooks_rc_style_register_type (GTypeModule *module)
+clearlooks_rc_style_register_types (GTypeModule *module)
 {
-	static const GTypeInfo object_info =
-	{
-		sizeof (ClearlooksRcStyleClass),
-		(GBaseInitFunc) NULL,
-		(GBaseFinalizeFunc) NULL,
-		(GClassInitFunc) clearlooks_rc_style_class_init,
-		NULL,           /* class_finalize */
-		NULL,           /* class_data */
-		sizeof (ClearlooksRcStyle),
-		0,              /* n_preallocs */
-		(GInstanceInitFunc) clearlooks_rc_style_init,
-		NULL
-	};
-
-	clearlooks_type_rc_style = g_type_module_register_type (module,
-	                                                        GTK_TYPE_RC_STYLE,
-	                                                        "ClearlooksRcStyle",
-	                                                        &object_info, 0);
+  clearlooks_rc_style_register_type (module);
 }
 
 static void
@@ -149,8 +127,8 @@
 	/* cleanup all the animation stuff */
 	clearlooks_animation_cleanup ();
 
-	if (G_OBJECT_CLASS (clearlooks_parent_rc_class)->finalize != NULL)
-		G_OBJECT_CLASS (clearlooks_parent_rc_class)->finalize(object);
+	if (G_OBJECT_CLASS (clearlooks_rc_style_parent_class)->finalize != NULL)
+		G_OBJECT_CLASS (clearlooks_rc_style_parent_class)->finalize (object);
 }
 #endif
 
@@ -163,8 +141,6 @@
 	GObjectClass    *g_object_class = G_OBJECT_CLASS (klass);
 #endif
 
-	clearlooks_parent_rc_class = g_type_class_peek_parent (klass);
-
 	rc_style_class->parse = clearlooks_rc_style_parse;
 	rc_style_class->create_style = clearlooks_rc_style_create_style;
 	rc_style_class->merge = clearlooks_rc_style_merge;
@@ -174,6 +150,11 @@
 #endif
 }
 
+static void
+clearlooks_rc_style_class_finalize (ClearlooksRcStyleClass *klass)
+{
+}
+
 static guint
 clearlooks_gtk2_rc_parse_boolean (GtkSettings *settings,
                                   GScanner     *scanner,
@@ -455,7 +436,7 @@
 	ClearlooksRcStyle *dest_w, *src_w;
 	ClearlooksRcFlags flags;
 
-	clearlooks_parent_rc_class->merge (dest, src);
+	GTK_RC_STYLE_CLASS (clearlooks_rc_style_parent_class)->merge (dest, src);
 
 	if (!CLEARLOOKS_IS_RC_STYLE (src))
 		return;

Modified: trunk/engines/clearlooks/src/clearlooks_rc_style.h
==============================================================================
--- trunk/engines/clearlooks/src/clearlooks_rc_style.h	(original)
+++ trunk/engines/clearlooks/src/clearlooks_rc_style.h	Mon Sep  1 15:03:17 2008
@@ -27,12 +27,13 @@
 #include <gtk/gtkrc.h>
 #include "clearlooks_types.h"
 
+#ifndef CLEARLOOKS_RC_STYLE_H
+#define CLEARLOOKS_RC_STYLE_H
+
 typedef struct _ClearlooksRcStyle ClearlooksRcStyle;
 typedef struct _ClearlooksRcStyleClass ClearlooksRcStyleClass;
 
-GE_INTERNAL extern GType clearlooks_type_rc_style;
-
-#define CLEARLOOKS_TYPE_RC_STYLE              clearlooks_type_rc_style
+#define CLEARLOOKS_TYPE_RC_STYLE              (clearlooks_rc_style_get_type ())
 #define CLEARLOOKS_RC_STYLE(object)           (G_TYPE_CHECK_INSTANCE_CAST ((object), CLEARLOOKS_TYPE_RC_STYLE, ClearlooksRcStyle))
 #define CLEARLOOKS_RC_STYLE_CLASS(klass)      (G_TYPE_CHECK_CLASS_CAST ((klass), CLEARLOOKS_TYPE_RC_STYLE, ClearlooksRcStyleClass))
 #define CLEARLOOKS_IS_RC_STYLE(object)        (G_TYPE_CHECK_INSTANCE_TYPE ((object), CLEARLOOKS_TYPE_RC_STYLE))
@@ -80,4 +81,7 @@
 	GtkRcStyleClass parent_class;
 };
 
-GE_INTERNAL void clearlooks_rc_style_register_type (GTypeModule *module);
+GE_INTERNAL void  clearlooks_rc_style_register_types (GTypeModule *module);
+GE_INTERNAL GType clearlooks_rc_style_get_type       (void);
+
+#endif /* CLEARLOOKS_RC_STYLE_H */

Modified: trunk/engines/clearlooks/src/clearlooks_style.c
==============================================================================
--- trunk/engines/clearlooks/src/clearlooks_style.c	(original)
+++ trunk/engines/clearlooks/src/clearlooks_style.c	Mon Sep  1 15:03:17 2008
@@ -52,10 +52,9 @@
 #include "animation.h"
 #endif
 
-#define STYLE_FUNCTION(function) (clearlooks_style_class->style_functions[CLEARLOOKS_STYLE (style)->style].function)
+#define STYLE_FUNCTION(function) (CLEARLOOKS_STYLE_GET_CLASS (style)->style_functions[CLEARLOOKS_STYLE (style)->style].function)
 
-static ClearlooksStyleClass *clearlooks_style_class;
-static GtkStyleClass *clearlooks_parent_class;
+G_DEFINE_DYNAMIC_TYPE (ClearlooksStyle, clearlooks_style, GTK_TYPE_STYLE)
 
 static void
 clearlooks_set_widget_parameters (const GtkWidget      *widget,
@@ -63,8 +62,8 @@
                                   GtkStateType          state_type,
                                   WidgetParameters     *params)
 {
-	params->style_functions = &(clearlooks_style_class->style_functions[CLEARLOOKS_STYLE (style)->style]);
-	params->style_constants = &(clearlooks_style_class->style_constants[CLEARLOOKS_STYLE (style)->style]);
+	params->style_functions = &(CLEARLOOKS_STYLE_GET_CLASS (style)->style_functions[CLEARLOOKS_STYLE (style)->style]);
+	params->style_constants = &(CLEARLOOKS_STYLE_GET_CLASS (style)->style_constants[CLEARLOOKS_STYLE (style)->style]);
 
 	params->active        = (state_type == GTK_STATE_ACTIVE);
 	params->prelight      = (state_type == GTK_STATE_PRELIGHT);
@@ -141,7 +140,7 @@
 	}
 	else
 	{
-		clearlooks_parent_class->draw_flat_box (style, window, state_type,
+		GTK_STYLE_CLASS (clearlooks_style_parent_class)->draw_flat_box (style, window, state_type,
 		                                        shadow_type,
 		                                        area, widget, detail,
 		                                        x, y, width, height);
@@ -345,7 +344,7 @@
 	}
 	else
 	{
-		clearlooks_parent_class->draw_box_gap (style, window, state_type, shadow_type,
+		GTK_STYLE_CLASS (clearlooks_style_parent_class)->draw_box_gap (style, window, state_type, shadow_type,
 		                                       area, widget, detail,
 		                                       x, y, width, height,
 		                                       gap_side, gap_x, gap_width);
@@ -408,7 +407,7 @@
 	}
 	else
 	{
-		clearlooks_parent_class->draw_extension (style, window, state_type, shadow_type, area,
+		GTK_STYLE_CLASS (clearlooks_style_parent_class)->draw_extension (style, window, state_type, shadow_type, area,
 		                                         widget, detail, x, y, width, height,
 		                                         gap_side);
 	}
@@ -949,7 +948,7 @@
 	}
 	else
 	{
-		clearlooks_parent_class->draw_box (style, window, state_type, shadow_type, area,
+		GTK_STYLE_CLASS (clearlooks_style_parent_class)->draw_box (style, window, state_type, shadow_type, area,
 		                                   widget, detail, x, y, width, height);
 	}
 
@@ -1021,7 +1020,7 @@
 	}
 	else
 	{
-		clearlooks_parent_class->draw_slider (style, window, state_type, shadow_type, area,
+		GTK_STYLE_CLASS (clearlooks_style_parent_class)->draw_slider (style, window, state_type, shadow_type, area,
 		                                      widget, detail, x, y, width, height, orientation);
 	}
 
@@ -1181,7 +1180,7 @@
 	}
 	else
 	{
-		clearlooks_parent_class->draw_shadow_gap (style, window, state_type, shadow_type, area,
+		GTK_STYLE_CLASS (clearlooks_style_parent_class)->draw_shadow_gap (style, window, state_type, shadow_type, area,
 		                                          widget, detail, x, y, width, height,
 		                                          gap_side, gap_x, gap_width);
 	}
@@ -1309,7 +1308,7 @@
 {
 	ClearlooksStyle *clearlooks_style = CLEARLOOKS_STYLE (style);
 
-	clearlooks_parent_class->init_from_rc (style, rc_style);
+	GTK_STYLE_CLASS (clearlooks_style_parent_class)->init_from_rc (style, rc_style);
 
 	g_assert ((CLEARLOOKS_RC_STYLE (rc_style)->style >= 0) && (CLEARLOOKS_RC_STYLE (rc_style)->style < CL_NUM_STYLES));
 	clearlooks_style->style               = CLEARLOOKS_RC_STYLE (rc_style)->style;
@@ -1339,7 +1338,7 @@
 	double contrast;
 	int i;
 
-	clearlooks_parent_class->realize (style);
+	GTK_STYLE_CLASS (clearlooks_style_parent_class)->realize (style);
 
 	contrast = CLEARLOOKS_RC_STYLE (style->rc_style)->contrast;
 
@@ -1565,13 +1564,13 @@
 	cl_style->radius              = cl_src->radius;
 	cl_style->style               = cl_src->style;
 
-	clearlooks_parent_class->copy (style, src);
+	GTK_STYLE_CLASS (clearlooks_style_parent_class)->copy (style, src);
 }
 
 static void
 clearlooks_style_unrealize (GtkStyle * style)
 {
-	clearlooks_parent_class->unrealize (style);
+	GTK_STYLE_CLASS (clearlooks_style_parent_class)->unrealize (style);
 }
 
 static GdkPixbuf *
@@ -1763,6 +1762,12 @@
 	return stated;
 }
 
+void
+clearlooks_style_register_types (GTypeModule *module)
+{
+  clearlooks_style_register_type (module);
+}
+
 static void
 clearlooks_style_init (ClearlooksStyle * style)
 {
@@ -1773,9 +1778,6 @@
 {
 	GtkStyleClass *style_class = GTK_STYLE_CLASS (klass);
 
-	clearlooks_style_class = CLEARLOOKS_STYLE_CLASS (klass);
-	clearlooks_parent_class = g_type_class_peek_parent (klass);
-
 	style_class->copy             = clearlooks_style_copy;
 	style_class->realize          = clearlooks_style_realize;
 	style_class->unrealize        = clearlooks_style_unrealize;
@@ -1799,46 +1801,26 @@
 	style_class->draw_layout      = clearlooks_style_draw_layout;
 	style_class->render_icon      = clearlooks_style_draw_render_icon;
 
-	clearlooks_register_style_classic (&clearlooks_style_class->style_functions[CL_STYLE_CLASSIC],
-	                                   &clearlooks_style_class->style_constants[CL_STYLE_CLASSIC]);
+	clearlooks_register_style_classic (&klass->style_functions[CL_STYLE_CLASSIC],
+	                                   &klass->style_constants[CL_STYLE_CLASSIC]);
 
-	clearlooks_style_class->style_functions[CL_STYLE_GLOSSY] = clearlooks_style_class->style_functions[CL_STYLE_CLASSIC];
-	clearlooks_style_class->style_constants[CL_STYLE_GLOSSY] = clearlooks_style_class->style_constants[CL_STYLE_CLASSIC];
-	clearlooks_register_style_glossy (&clearlooks_style_class->style_functions[CL_STYLE_GLOSSY],
-	                                  &clearlooks_style_class->style_constants[CL_STYLE_GLOSSY]);
-
-	clearlooks_style_class->style_functions[CL_STYLE_INVERTED] = clearlooks_style_class->style_functions[CL_STYLE_CLASSIC];
-	clearlooks_style_class->style_constants[CL_STYLE_INVERTED] = clearlooks_style_class->style_constants[CL_STYLE_CLASSIC];
-	clearlooks_register_style_inverted (&clearlooks_style_class->style_functions[CL_STYLE_INVERTED],
-	                                    &clearlooks_style_class->style_constants[CL_STYLE_INVERTED]);
-
-	clearlooks_style_class->style_functions[CL_STYLE_GUMMY] = clearlooks_style_class->style_functions[CL_STYLE_CLASSIC];
-	clearlooks_style_class->style_constants[CL_STYLE_GUMMY] = clearlooks_style_class->style_constants[CL_STYLE_CLASSIC];
-	clearlooks_register_style_gummy (&clearlooks_style_class->style_functions[CL_STYLE_GUMMY],
-	                                 &clearlooks_style_class->style_constants[CL_STYLE_GUMMY]);
-}
+	klass->style_functions[CL_STYLE_GLOSSY] = klass->style_functions[CL_STYLE_CLASSIC];
+	klass->style_constants[CL_STYLE_GLOSSY] = klass->style_constants[CL_STYLE_CLASSIC];
+	clearlooks_register_style_glossy (&klass->style_functions[CL_STYLE_GLOSSY],
+	                                  &klass->style_constants[CL_STYLE_GLOSSY]);
 
-GType clearlooks_type_style = 0;
+	klass->style_functions[CL_STYLE_INVERTED] = klass->style_functions[CL_STYLE_CLASSIC];
+	klass->style_constants[CL_STYLE_INVERTED] = klass->style_constants[CL_STYLE_CLASSIC];
+	clearlooks_register_style_inverted (&klass->style_functions[CL_STYLE_INVERTED],
+	                                    &klass->style_constants[CL_STYLE_INVERTED]);
 
-void
-clearlooks_style_register_type (GTypeModule * module)
+	klass->style_functions[CL_STYLE_GUMMY] = klass->style_functions[CL_STYLE_CLASSIC];
+	klass->style_constants[CL_STYLE_GUMMY] = klass->style_constants[CL_STYLE_CLASSIC];
+	clearlooks_register_style_gummy (&klass->style_functions[CL_STYLE_GUMMY],
+	                                 &klass->style_constants[CL_STYLE_GUMMY]);
+}
+
+static void
+clearlooks_style_class_finalize (ClearlooksStyleClass *klass)
 {
-	static const GTypeInfo object_info =
-	{
-		sizeof (ClearlooksStyleClass),
-		(GBaseInitFunc) NULL,
-		(GBaseFinalizeFunc) NULL,
-		(GClassInitFunc) clearlooks_style_class_init,
-		NULL,         /* class_finalize */
-		NULL,         /* class_data */
-		sizeof (ClearlooksStyle),
-		0,            /* n_preallocs */
-		(GInstanceInitFunc) clearlooks_style_init,
-		NULL
-	};
-
-	clearlooks_type_style = g_type_module_register_type (module,
-	                                                     GTK_TYPE_STYLE,
-	                                                     "ClearlooksStyle",
-	                                                     &object_info, 0);
 }

Modified: trunk/engines/clearlooks/src/clearlooks_style.h
==============================================================================
--- trunk/engines/clearlooks/src/clearlooks_style.h	(original)
+++ trunk/engines/clearlooks/src/clearlooks_style.h	Mon Sep  1 15:03:17 2008
@@ -34,9 +34,7 @@
 typedef struct _ClearlooksStyle ClearlooksStyle;
 typedef struct _ClearlooksStyleClass ClearlooksStyleClass;
 
-GE_INTERNAL extern GType clearlooks_type_style;
-
-#define CLEARLOOKS_TYPE_STYLE              clearlooks_type_style
+#define CLEARLOOKS_TYPE_STYLE              (clearlooks_style_get_type ())
 #define CLEARLOOKS_STYLE(object)           (G_TYPE_CHECK_INSTANCE_CAST ((object), CLEARLOOKS_TYPE_STYLE, ClearlooksStyle))
 #define CLEARLOOKS_STYLE_CLASS(klass)      (G_TYPE_CHECK_CLASS_CAST ((klass), CLEARLOOKS_TYPE_STYLE, ClearlooksStyleClass))
 #define CLEARLOOKS_IS_STYLE(object)        (G_TYPE_CHECK_INSTANCE_TYPE ((object), CLEARLOOKS_TYPE_STYLE))
@@ -71,6 +69,7 @@
 	ClearlooksStyleConstants style_constants[CL_NUM_STYLES];
 };
 
-GE_INTERNAL void clearlooks_style_register_type (GTypeModule *module);
+GE_INTERNAL void  clearlooks_style_register_types (GTypeModule *module);
+GE_INTERNAL GType clearlooks_style_get_type       (void);
 
 #endif /* CLEARLOOKS_STYLE_H */

Modified: trunk/engines/clearlooks/src/clearlooks_theme_main.c
==============================================================================
--- trunk/engines/clearlooks/src/clearlooks_theme_main.c	(original)
+++ trunk/engines/clearlooks/src/clearlooks_theme_main.c	Mon Sep  1 15:03:17 2008
@@ -7,8 +7,8 @@
 GE_EXPORT void
 theme_init (GTypeModule *module)
 {
-  clearlooks_rc_style_register_type (module);
-  clearlooks_style_register_type (module);
+  clearlooks_rc_style_register_types (module);
+  clearlooks_style_register_types (module);
 }
 
 GE_EXPORT void



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