murrine r53 - in trunk: . src



Author: acimitan
Date: Mon Sep  1 15:35:12 2008
New Revision: 53
URL: http://svn.gnome.org/viewvc/murrine?rev=53&view=rev

Log:
2008-09-01  Andrea Cimitan  <andrea cimitan gmail com>

	* src/murrine_rc_style.c (murrine_rc_style_register_types),
	(murrine_rc_style_finalize), (murrine_rc_style_class_init),
	(murrine_rc_style_class_finalize), (murrine_rc_style_merge):
	* src/murrine_rc_style.h:
	* src/murrine_style.c (murrine_set_widget_parameters),
	(murrine_style_draw_flat_box), (murrine_style_draw_box_gap),
	(murrine_style_draw_extension), (murrine_style_draw_box),
	(murrine_style_draw_slider), (murrine_style_draw_shadow_gap),
	(murrine_style_init_from_rc), (murrine_style_realize),
	(murrine_style_copy), (murrine_style_unrealize),
	(murrine_style_register_types), (murrine_style_class_init),
	(murrine_style_class_finalize):
	* src/murrine_style.h:
	* src/murrine_theme_main.c (theme_init):
	Use G_DEFINE_DYNAMIC_TYPE in murrine, similar patch to bug #549830.
	I hope not to have broken anything :)


Modified:
   trunk/ChangeLog
   trunk/src/murrine_rc_style.c
   trunk/src/murrine_rc_style.h
   trunk/src/murrine_style.c
   trunk/src/murrine_style.h
   trunk/src/murrine_theme_main.c

Modified: trunk/src/murrine_rc_style.c
==============================================================================
--- trunk/src/murrine_rc_style.c	(original)
+++ trunk/src/murrine_rc_style.c	Mon Sep  1 15:35:12 2008
@@ -23,11 +23,9 @@
 
 #include "animation.h"
 
-static void murrine_rc_style_init (MurrineRcStyle *style);
 #ifdef HAVE_ANIMATION
 static void murrine_rc_style_finalize (GObject *object);
 #endif
-static void murrine_rc_style_class_init (MurrineRcStyleClass *klass);
 static GtkStyle *murrine_rc_style_create_style (GtkRcStyle *rc_style);
 static guint murrine_rc_style_parse (GtkRcStyle  *rc_style,
                                      GtkSettings *settings,
@@ -35,10 +33,6 @@
 static void murrine_rc_style_merge (GtkRcStyle *dest,
                                     GtkRcStyle *src);
 
-static GtkRcStyleClass *parent_class;
-
-GType murrine_type_rc_style = 0;
-
 enum
 {
 	TOKEN_ANIMATION = G_TOKEN_LAST + 1,
@@ -126,27 +120,12 @@
 	{ "squaredstyle",        TOKEN_SQUAREDSTYLE }
 };
 
+G_DEFINE_DYNAMIC_TYPE (MurrineRcStyle, murrine_rc_style, GTK_TYPE_RC_STYLE)
+
 void
-murrine_rc_style_register_type (GTypeModule *module)
+murrine_rc_style_register_types (GTypeModule *module)
 {
-	static const GTypeInfo object_info =
-	{
-		sizeof (MurrineRcStyleClass),
-		(GBaseInitFunc) NULL,
-		(GBaseFinalizeFunc) NULL,
-		(GClassInitFunc) murrine_rc_style_class_init,
-		NULL, /* class_finalize */
-		NULL, /* class_data */
-		sizeof (MurrineRcStyle),
-		0, /* n_preallocs */
-		(GInstanceInitFunc) murrine_rc_style_init,
-		NULL
-	};
-
-	murrine_type_rc_style = g_type_module_register_type (module,
-	                                                     GTK_TYPE_RC_STYLE,
-	                                                     "MurrineRcStyle",
-	                                                     &object_info, 0);
+	murrine_rc_style_register_type (module);
 }
 
 static void
@@ -190,8 +169,8 @@
 	/* cleanup all the animation stuff */
 	murrine_animation_cleanup ();
 
-	if (G_OBJECT_CLASS (parent_class)->finalize != NULL)
-		G_OBJECT_CLASS (parent_class)->finalize(object);
+	if (G_OBJECT_CLASS (murrine_rc_style_parent_class)->finalize != NULL)
+		G_OBJECT_CLASS (murrine_rc_style_parent_class)->finalize(object);
 }
 #endif
 
@@ -204,8 +183,6 @@
 	GObjectClass    *g_object_class = G_OBJECT_CLASS (klass);
 #endif
 
-	parent_class = g_type_class_peek_parent (klass);
-
 	rc_style_class->parse = murrine_rc_style_parse;
 	rc_style_class->create_style = murrine_rc_style_create_style;
 	rc_style_class->merge = murrine_rc_style_merge;
@@ -215,6 +192,11 @@
 #endif
 }
 
+static void
+murrine_rc_style_class_finalize (MurrineRcStyleClass *klass)
+{
+}
+
 static guint
 theme_parse_boolean (GtkSettings *settings,
                      GScanner     *scanner,
@@ -602,7 +584,7 @@
 	MurrineRcStyle *dest_w, *src_w;
 	MurrineRcFlags flags;
 
-	parent_class->merge (dest, src);
+	GTK_RC_STYLE_CLASS (murrine_rc_style_parent_class)->merge (dest, src);
 
 	if (!MURRINE_IS_RC_STYLE (src))
 		return;

Modified: trunk/src/murrine_rc_style.h
==============================================================================
--- trunk/src/murrine_rc_style.h	(original)
+++ trunk/src/murrine_rc_style.h	Mon Sep  1 15:35:12 2008
@@ -20,12 +20,13 @@
 
 #include <gtk/gtkrc.h>
 
+#ifndef MURRINE_RC_STYLE_H
+#define MURRINE_RC_STYLE_H
+
 typedef struct _MurrineRcStyle MurrineRcStyle;
 typedef struct _MurrineRcStyleClass MurrineRcStyleClass;
 
-G_GNUC_INTERNAL extern GType murrine_type_rc_style;
-
-#define MURRINE_TYPE_RC_STYLE              murrine_type_rc_style
+#define MURRINE_TYPE_RC_STYLE              (murrine_rc_style_get_type ())
 #define MURRINE_RC_STYLE(object)           (G_TYPE_CHECK_INSTANCE_CAST ((object), MURRINE_TYPE_RC_STYLE, MurrineRcStyle))
 #define MURRINE_RC_STYLE_CLASS(klass)      (G_TYPE_CHECK_CLASS_CAST ((klass), MURRINE_TYPE_RC_STYLE, MurrineRcStyleClass))
 #define MURRINE_IS_RC_STYLE(object)        (G_TYPE_CHECK_INSTANCE_TYPE ((object), MURRINE_TYPE_RC_STYLE))
@@ -102,4 +103,6 @@
 	GtkRcStyleClass parent_class;
 };
 
-G_GNUC_INTERNAL void murrine_rc_style_register_type (GTypeModule *module);
+GType murrine_rc_style_get_type	(void);
+
+#endif /* MURRINE_RC_STYLE_H */

Modified: trunk/src/murrine_style.c
==============================================================================
--- trunk/src/murrine_style.c	(original)
+++ trunk/src/murrine_style.c	Mon Sep  1 15:35:12 2008
@@ -68,10 +68,9 @@
 #include "animation.h"
 #endif
 
-#define STYLE_FUNCTION(function) (murrine_style_class->style_functions[params.drawstyle].function)
+#define STYLE_FUNCTION(function) (MURRINE_STYLE_GET_CLASS (style)->style_functions[params.drawstyle].function)
 
-static MurrineStyleClass *murrine_style_class;
-static GtkStyleClass *murrine_parent_class;
+G_DEFINE_DYNAMIC_TYPE (MurrineStyle, murrine_style, GTK_TYPE_STYLE)
 
 static cairo_t *
 murrine_begin_paint (GdkDrawable *window, GdkRectangle *area)
@@ -164,7 +163,7 @@
 	}
 	params->mrn_gradient = mrn_gradient;
 	params->drawstyle = drawstyle;
-	params->style_functions = &(murrine_style_class->style_functions[drawstyle]);
+	params->style_functions = &(MURRINE_STYLE_GET_CLASS (style)->style_functions[drawstyle]);
 
 	/* I want to avoid to have to do this. I need it for GtkEntry, unless I
 	   find out why it doesn't behave the way I expect it to. */
@@ -245,10 +244,10 @@
 
 			if (!use_rgba)
 			{
-				murrine_parent_class->draw_flat_box (style, window, state_type,
-				                                     shadow_type,
-				                                     area, widget, detail,
-				                                     x, y, width, height);
+				GTK_STYLE_CLASS (murrine_style_parent_class)->draw_flat_box (style, window, state_type,
+				                                                             shadow_type,
+				                                                             area, widget, detail,
+				                                                             x, y, width, height);
 			}
 			else
 			{
@@ -307,10 +306,10 @@
 		else
 		{
 			// printf( "draw_flat_box: %s %s\n", detail, G_OBJECT_TYPE_NAME (widget));
-			murrine_parent_class->draw_flat_box (style, window, state_type,
-			                                     shadow_type,
-			                                     area, widget, detail,
-			                                     x, y, width, height);
+			GTK_STYLE_CLASS (murrine_style_parent_class)->draw_flat_box (style, window, state_type,
+			                                                             shadow_type,
+			                                                             area, widget, detail,
+			                                                             x, y, width, height);
 		}
 	}
 
@@ -546,10 +545,10 @@
 	}
 	else
 	{
-		murrine_parent_class->draw_box_gap (style, window, state_type, shadow_type,
-		                                    area, widget, detail,
-		                                    x, y, width, height,
-		                                    gap_side, gap_x, gap_width);
+		GTK_STYLE_CLASS (murrine_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);
 	}
 
 	cairo_destroy (cr);
@@ -595,8 +594,8 @@
 	}
 	else
 	{
-		murrine_parent_class->draw_extension (style, window, state_type, shadow_type, area,
-		                                      widget, detail, x, y, width, height, gap_side);
+		GTK_STYLE_CLASS (murrine_style_parent_class)->draw_extension (style, window, state_type, shadow_type, area,
+		                                                              widget, detail, x, y, width, height, gap_side);
 	}
 
 	cairo_destroy (cr);
@@ -1198,8 +1197,8 @@
 	}
 	else
 	{
-		murrine_parent_class->draw_box (style, window, state_type, shadow_type, area,
-		                                widget, detail, x, y, width, height);
+		GTK_STYLE_CLASS (murrine_style_parent_class)->draw_box (style, window, state_type, shadow_type, area,
+		                                                        widget, detail, x, y, width, height);
 	}
 
 	cairo_destroy (cr);
@@ -1214,8 +1213,8 @@
 		                        widget, detail, x, y, width, height);
 	}
 	else
-		murrine_parent_class->draw_slider (style, window, state_type, shadow_type, area,
-		                                   widget, detail, x, y, width, height, orientation);
+		GTK_STYLE_CLASS (murrine_style_parent_class)->draw_slider (style, window, state_type, shadow_type, area,
+		                                                           widget, detail, x, y, width, height, orientation);
 }
 
 static void
@@ -1447,9 +1446,9 @@
 	}
 	else
 	{
-		murrine_parent_class->draw_shadow_gap (style, window, state_type, shadow_type, area,
-		                                       widget, detail, x, y, width, height,
-		                                       gap_side, gap_x, gap_width);
+		GTK_STYLE_CLASS (murrine_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);
 	}
 
 	cairo_destroy (cr);
@@ -1616,7 +1615,7 @@
 {
 	MurrineStyle *murrine_style = MURRINE_STYLE (style);
 
-	murrine_parent_class->init_from_rc (style, rc_style);
+	GTK_STYLE_CLASS (murrine_style_parent_class)->init_from_rc (style, rc_style);
 
 	murrine_style->gradient_shades[0] = MURRINE_RC_STYLE (rc_style)->gradient_shades[0];
 	murrine_style->gradient_shades[1] = MURRINE_RC_STYLE (rc_style)->gradient_shades[1];
@@ -1741,7 +1740,7 @@
 	double contrast;
 	int i;
 
-	murrine_parent_class->realize (style);
+	GTK_STYLE_CLASS (murrine_style_parent_class)->realize (style);
 
 	contrast = MURRINE_RC_STYLE (style->rc_style)->contrast;
 
@@ -1919,13 +1918,13 @@
 	mrn_style->style               = mrn_src->style;
 	mrn_style->toolbarstyle        = mrn_src->toolbarstyle;
 
-	murrine_parent_class->copy (style, src);
+	GTK_STYLE_CLASS (murrine_style_parent_class)->copy (style, src);
 }
 
 static void
 murrine_style_unrealize (GtkStyle * style)
 {
-	murrine_parent_class->unrealize (style);
+	GTK_STYLE_CLASS (murrine_style_parent_class)->unrealize (style);
 }
 
 static GdkPixbuf *
@@ -2076,6 +2075,13 @@
 	return stated;
 }
 
+void
+murrine_style_register_types (GTypeModule *module)
+{
+	murrine_style_register_type (module);
+}
+
+
 static void
 murrine_style_init (MurrineStyle * style)
 {
@@ -2086,9 +2092,6 @@
 {
 	GtkStyleClass *style_class = GTK_STYLE_CLASS (klass);
 
-	murrine_style_class = MURRINE_STYLE_CLASS (klass);
-	murrine_parent_class = g_type_class_peek_parent (klass);
-
 	style_class->copy             = murrine_style_copy;
 	style_class->realize          = murrine_style_realize;
 	style_class->unrealize        = murrine_style_unrealize;
@@ -2112,29 +2115,12 @@
 	style_class->draw_layout      = murrine_style_draw_layout;
 	style_class->render_icon      = murrine_style_draw_render_icon;
 
-	murrine_register_style_murrine (&murrine_style_class->style_functions[MRN_DRAW_STYLE_MURRINE]);
-	murrine_style_class->style_functions[MRN_DRAW_STYLE_RGBA] = murrine_style_class->style_functions[MRN_DRAW_STYLE_MURRINE];
-	murrine_register_style_rgba (&murrine_style_class->style_functions[MRN_DRAW_STYLE_RGBA]);
+	murrine_register_style_murrine (&klass->style_functions[MRN_DRAW_STYLE_MURRINE]);
+	klass->style_functions[MRN_DRAW_STYLE_RGBA] = klass->style_functions[MRN_DRAW_STYLE_MURRINE];
+	murrine_register_style_rgba (&klass->style_functions[MRN_DRAW_STYLE_RGBA]);
 }
 
-GType murrine_type_style = 0;
-
-void
-murrine_style_register_type (GTypeModule * module)
+static void
+murrine_style_class_finalize (MurrineStyleClass *klass)
 {
-	static const GTypeInfo object_info =
-	{
-		sizeof (MurrineStyleClass),
-		(GBaseInitFunc) NULL,
-		(GBaseFinalizeFunc) NULL,
-		(GClassInitFunc) murrine_style_class_init,
-		NULL, /* class_finalize */
-		NULL, /* class_data */
-		sizeof (MurrineStyle),
-		0, /* n_preallocs */
-		(GInstanceInitFunc) murrine_style_init,
-		NULL
-	};
-
-	murrine_type_style = g_type_module_register_type (module, GTK_TYPE_STYLE, "MurrineStyle", &object_info, 0);
 }

Modified: trunk/src/murrine_style.h
==============================================================================
--- trunk/src/murrine_style.h	(original)
+++ trunk/src/murrine_style.h	Mon Sep  1 15:35:12 2008
@@ -29,9 +29,7 @@
 typedef struct _MurrineStyle MurrineStyle;
 typedef struct _MurrineStyleClass MurrineStyleClass;
 
-G_GNUC_INTERNAL extern GType murrine_type_style;
-
-#define MURRINE_TYPE_STYLE              murrine_type_style
+#define MURRINE_TYPE_STYLE              (murrine_style_get_type())
 #define MURRINE_STYLE(object)           (G_TYPE_CHECK_INSTANCE_CAST ((object), MURRINE_TYPE_STYLE, MurrineStyle))
 #define MURRINE_STYLE_CLASS(klass)      (G_TYPE_CHECK_CLASS_CAST ((klass), MURRINE_TYPE_STYLE, MurrineStyleClass))
 #define MURRINE_IS_STYLE(object)        (G_TYPE_CHECK_INSTANCE_TYPE ((object), MURRINE_TYPE_STYLE))
@@ -82,6 +80,6 @@
 	MurrineStyleFunctions style_functions[MRN_NUM_DRAW_STYLES];
 };
 
-G_GNUC_INTERNAL void murrine_style_register_type (GTypeModule *module);
+GType murrine_style_get_type (void);
 
 #endif /* MURRINE_STYLE_H */

Modified: trunk/src/murrine_theme_main.c
==============================================================================
--- trunk/src/murrine_theme_main.c	(original)
+++ trunk/src/murrine_theme_main.c	Mon Sep  1 15:35:12 2008
@@ -27,8 +27,8 @@
 G_MODULE_EXPORT void
 theme_init (GTypeModule *module)
 {
-	murrine_rc_style_register_type (module);
-	murrine_style_register_type (module);
+	murrine_rc_style_register_types (module);
+	murrine_style_register_types (module);
 }
 
 G_MODULE_EXPORT void



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