[librsvg] Remove _rsvg_register_types



commit f31e5df57d2527b16beed3181e05ed44a7be2d4b
Author: Christian Persch <chpe gnome org>
Date:   Thu Jan 26 19:45:46 2012 +0100

    Remove _rsvg_register_types
    
    It was only used to work around bug 357406 and bug 362217 in the now-obsolete
    gtk2 engine. Just make that module resident instead, and use proper
    G_DEFINE_TYPE macro for RsvgHandle.

 gtk-engine/svg-main.c |    8 +++++-
 librsvg.def           |    1 -
 rsvg-gobject.c        |   58 ++++++++----------------------------------------
 rsvg-private.h        |    2 -
 4 files changed, 16 insertions(+), 53 deletions(-)
---
diff --git a/gtk-engine/svg-main.c b/gtk-engine/svg-main.c
index 7ca4ae3..3844228 100644
--- a/gtk-engine/svg-main.c
+++ b/gtk-engine/svg-main.c
@@ -21,10 +21,12 @@
  * Carsten Haitzler <raster rasterman com>
  */
 
+#include "config.h"
+
 #include "svg.h"
 #include "svg-style.h"
 #include "svg-rc-style.h"
-#include "rsvg-private.h"
+
 #include <gmodule.h>
 
 G_MODULE_EXPORT const gchar* g_module_check_init (GModule *module);
@@ -35,7 +37,6 @@ G_MODULE_EXPORT GtkRcStyle * theme_create_rc_style (void);
 void
 theme_init (GTypeModule *module)
 {
-  _rsvg_register_types (module); /* HACK to get around bugs 357406 and 362217 */
   rsvg_rc_style_register_type (module);
   rsvg_style_register_type (module);
 }
@@ -58,6 +59,9 @@ theme_create_rc_style (void)
 const gchar*
 g_module_check_init (GModule *module)
 {
+  /* See bugs 357406 and 362217 */
+  g_module_make_resident (module);
+
   return gtk_check_version (GTK_MAJOR_VERSION,
 			    GTK_MINOR_VERSION,
 			    GTK_MICRO_VERSION - GTK_INTERFACE_AGE);
diff --git a/librsvg.def b/librsvg.def
index b58f831..804c102 100644
--- a/librsvg.def
+++ b/librsvg.def
@@ -34,7 +34,6 @@ rsvg_pixbuf_from_file_at_zoom_with_max
 rsvg_handle_render_cairo
 rsvg_handle_render_cairo_sub
 rsvg_handle_get_type
-_rsvg_register_types
 rsvg_defs_lookup
 rsvg_pixbuf_from_data_with_size_data
 rsvg_css_parse_color
diff --git a/rsvg-gobject.c b/rsvg-gobject.c
index 613386b..4628e09 100644
--- a/rsvg-gobject.c
+++ b/rsvg-gobject.c
@@ -60,10 +60,10 @@ enum {
 extern double rsvg_internal_dpi_x;
 extern double rsvg_internal_dpi_y;
 
-static GObjectClass *rsvg_parent_class = NULL;
+G_DEFINE_TYPE (RsvgHandle, rsvg_handle, G_TYPE_OBJECT)
 
 static void
-instance_init (RsvgHandle * self)
+rsvg_handle_init (RsvgHandle * self)
 {
     self->priv = G_TYPE_INSTANCE_GET_PRIVATE (self, RSVG_TYPE_HANDLE, RsvgHandlePrivate);
 
@@ -95,7 +95,7 @@ instance_init (RsvgHandle * self)
 }
 
 static void
-instance_dispose (GObject * instance)
+rsvg_handle_dispose (GObject *instance)
 {
     RsvgHandle *self = (RsvgHandle *) instance;
 
@@ -130,11 +130,11 @@ instance_dispose (GObject * instance)
     }
 
   chain:
-    rsvg_parent_class->dispose (instance);
+    G_OBJECT_CLASS (rsvg_handle_parent_class)->dispose (instance);
 }
 
 static void
-set_property (GObject * instance, guint prop_id, GValue const *value, GParamSpec * pspec)
+rsvg_handle_set_property (GObject * instance, guint prop_id, GValue const *value, GParamSpec * pspec)
 {
     RsvgHandle *self = RSVG_HANDLE (instance);
 
@@ -157,7 +157,7 @@ set_property (GObject * instance, guint prop_id, GValue const *value, GParamSpec
 }
 
 static void
-get_property (GObject * instance, guint prop_id, GValue * value, GParamSpec * pspec)
+rsvg_handle_get_property (GObject * instance, guint prop_id, GValue * value, GParamSpec * pspec)
 {
     RsvgHandle *self = RSVG_HANDLE (instance);
     RsvgDimensionData dim;
@@ -206,17 +206,13 @@ get_property (GObject * instance, guint prop_id, GValue * value, GParamSpec * ps
 }
 
 static void
-class_init (RsvgHandleClass * klass)
+rsvg_handle_class_init (RsvgHandleClass * klass)
 {
     GObjectClass *gobject_class = G_OBJECT_CLASS (klass);
 
-    /* hook gobject vfuncs */
-    gobject_class->dispose = instance_dispose;
-
-    rsvg_parent_class = (GObjectClass *) g_type_class_peek_parent (klass);
-
-    gobject_class->set_property = set_property;
-    gobject_class->get_property = get_property;
+    gobject_class->dispose = rsvg_handle_dispose;
+    gobject_class->set_property = rsvg_handle_set_property;
+    gobject_class->get_property = rsvg_handle_get_property;
 
     /**
      * RsvgHandle:flags:
@@ -307,40 +303,6 @@ class_init (RsvgHandleClass * klass)
     rsvg_SAX_handler_struct_init ();
 }
 
-const GTypeInfo rsvg_type_info = {
-    sizeof (RsvgHandleClass),
-    NULL,                       /* base_init */
-    NULL,                       /* base_finalize */
-    (GClassInitFunc) class_init,
-    NULL,                       /* class_finalize */
-    NULL,                       /* class_data */
-    sizeof (RsvgHandle),
-    0,                          /* n_preallocs */
-    (GInstanceInitFunc) instance_init,
-};
-
-static GType rsvg_type = 0;
-
-/* HACK to get around bugs 357406 and 362217. private API for now. */
-GType
-_rsvg_register_types (GTypeModule * module)
-{
-    rsvg_type = g_type_module_register_type (module,
-                                             G_TYPE_OBJECT,
-                                             "RsvgHandle", &rsvg_type_info, (GTypeFlags) 0);
-    return rsvg_type;
-}
-
-GType
-rsvg_handle_get_type (void)
-{
-    if (!rsvg_type) {
-        rsvg_type =
-            g_type_register_static (G_TYPE_OBJECT, "RsvgHandle", &rsvg_type_info, (GTypeFlags) 0);
-    }
-    return rsvg_type;
-}
-
 /**
  * rsvg_handle_free:
  * @handle: An #RsvgHandle
diff --git a/rsvg-private.h b/rsvg-private.h
index c524948..a08551e 100644
--- a/rsvg-private.h
+++ b/rsvg-private.h
@@ -115,8 +115,6 @@ typedef struct _RsvgNodeChars RsvgNodeChars;
  */
 #define RSVG_ONE_MINUS_EPSILON (1.0 - DBL_EPSILON)
 
-GType _rsvg_register_types (GTypeModule * module);
-
 struct RsvgSaxHandler {
     void (*free) (RsvgSaxHandler * self);
     void (*start_element) (RsvgSaxHandler * self, const char *name, RsvgPropertyBag * atts);



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