diff options
author | Nick Schermer <nick@xfce.org> | 2009-08-22 21:01:29 +0200 |
---|---|---|
committer | Nick Schermer <nick@xfce.org> | 2009-08-22 21:08:15 +0200 |
commit | 3cc156932e03c881a9643e917abf42ff3ad4d48a (patch) | |
tree | d87a954028eef221cc942225764a7eee27d03aef /thunarx | |
parent | 09610f85d7e8016a443510636aeed4554dfcf044 (diff) | |
download | thunar-3cc156932e03c881a9643e917abf42ff3ad4d48a.tar.gz |
Protect and G_DEFINE_ code in thunarx too.
Diffstat (limited to 'thunarx')
-rw-r--r-- | thunarx/thunarx-file-info.c | 37 | ||||
-rw-r--r-- | thunarx/thunarx-menu-provider.c | 33 | ||||
-rw-r--r-- | thunarx/thunarx-preferences-provider.c | 33 | ||||
-rw-r--r-- | thunarx/thunarx-property-page-provider.c | 33 | ||||
-rw-r--r-- | thunarx/thunarx-property-page.c | 36 | ||||
-rw-r--r-- | thunarx/thunarx-provider-factory.c | 41 | ||||
-rw-r--r-- | thunarx/thunarx-provider-module.c | 52 | ||||
-rw-r--r-- | thunarx/thunarx-provider-plugin.c | 32 | ||||
-rw-r--r-- | thunarx/thunarx-renamer-provider.c | 33 | ||||
-rw-r--r-- | thunarx/thunarx-renamer.c | 35 |
10 files changed, 106 insertions, 259 deletions
diff --git a/thunarx/thunarx-file-info.c b/thunarx/thunarx-file-info.c index 5552b4f9..c1d45e8f 100644 --- a/thunarx/thunarx-file-info.c +++ b/thunarx/thunarx-file-info.c @@ -46,30 +46,21 @@ static guint file_info_signals[LAST_SIGNAL]; GType thunarx_file_info_get_type (void) { - static GType type = G_TYPE_INVALID; + static volatile gsize type__volatile = 0; + GType type; - if (G_UNLIKELY (type == G_TYPE_INVALID)) + if (g_once_init_enter (&type__volatile)) { - static const GTypeInfo info = - { - sizeof (ThunarxFileInfoIface), - NULL, - NULL, - NULL, - NULL, - NULL, - 0, - 0, - NULL, - NULL, - }; - - /* register the interface type */ - type = g_type_register_static (G_TYPE_INTERFACE, I_("ThunarxFileInfo"), &info, 0); - - /* implementations must inherit GObject */ - g_type_interface_add_prerequisite (type, G_TYPE_OBJECT); + type = g_type_register_static_simple (G_TYPE_INTERFACE, + I_("ThunarxFileInfo"), + sizeof (ThunarxFileInfoIface), + NULL, + 0, + NULL, + 0); + g_type_interface_add_prerequisite (type, G_TYPE_OBJECT); + /** * ThunarxFileInfo::changed: * @file_info : a #ThunarxFileInfo. @@ -109,9 +100,11 @@ thunarx_file_info_get_type (void) NULL, NULL, g_cclosure_marshal_VOID__VOID, G_TYPE_NONE, 0); + + g_once_init_leave (&type__volatile, type); } - return type; + return type__volatile; } diff --git a/thunarx/thunarx-menu-provider.c b/thunarx/thunarx-menu-provider.c index 5bb5be29..c7cc5804 100644 --- a/thunarx/thunarx-menu-provider.c +++ b/thunarx/thunarx-menu-provider.c @@ -31,30 +31,25 @@ GType thunarx_menu_provider_get_type (void) { - static GType type = G_TYPE_INVALID; + static volatile gsize type__volatile = 0; + GType type; - if (G_UNLIKELY (type == G_TYPE_INVALID)) + if (g_once_init_enter (&type__volatile)) { - static const GTypeInfo info = - { - sizeof (ThunarxMenuProviderIface), - NULL, - NULL, - NULL, - NULL, - NULL, - 0, - 0, - NULL, - NULL, - }; - - /* register the menu provider interface */ - type = g_type_register_static (G_TYPE_INTERFACE, I_("ThunarxMenuProvider"), &info, 0); + type = g_type_register_static_simple (G_TYPE_INTERFACE, + I_("ThunarxMenuProvider"), + sizeof (ThunarxMenuProviderIface), + NULL, + 0, + NULL, + 0); + g_type_interface_add_prerequisite (type, G_TYPE_OBJECT); + + g_once_init_leave (&type__volatile, type); } - return type; + return type__volatile; } diff --git a/thunarx/thunarx-preferences-provider.c b/thunarx/thunarx-preferences-provider.c index 3247b76c..922ddb22 100644 --- a/thunarx/thunarx-preferences-provider.c +++ b/thunarx/thunarx-preferences-provider.c @@ -31,30 +31,25 @@ GType thunarx_preferences_provider_get_type (void) { - static GType type = G_TYPE_INVALID; + static volatile gsize type__volatile = 0; + GType type; - if (G_UNLIKELY (type == G_TYPE_INVALID)) + if (g_once_init_enter (&type__volatile)) { - static const GTypeInfo info = - { - sizeof (ThunarxPreferencesProviderIface), - NULL, - NULL, - NULL, - NULL, - NULL, - 0, - 0, - NULL, - NULL, - }; - - /* register the preferences provider interface */ - type = g_type_register_static (G_TYPE_INTERFACE, I_("ThunarxPreferencesProvider"), &info, 0); + type = g_type_register_static_simple (G_TYPE_INTERFACE, + I_("ThunarxPreferencesProvider"), + sizeof (ThunarxPreferencesProviderIface), + NULL, + 0, + NULL, + 0); + g_type_interface_add_prerequisite (type, G_TYPE_OBJECT); + + g_once_init_leave (&type__volatile, type); } - return type; + return type__volatile; } diff --git a/thunarx/thunarx-property-page-provider.c b/thunarx/thunarx-property-page-provider.c index 0cb9fd87..2a97dd41 100644 --- a/thunarx/thunarx-property-page-provider.c +++ b/thunarx/thunarx-property-page-provider.c @@ -31,30 +31,25 @@ GType thunarx_property_page_provider_get_type (void) { - static GType type = G_TYPE_INVALID; + static volatile gsize type__volatile = 0; + GType type; - if (G_UNLIKELY (type == G_TYPE_INVALID)) + if (g_once_init_enter (&type__volatile)) { - static const GTypeInfo info = - { - sizeof (ThunarxPropertyPageProviderIface), - NULL, - NULL, - NULL, - NULL, - NULL, - 0, - 0, - NULL, - NULL, - }; - - /* register the property page provider interface */ - type = g_type_register_static (G_TYPE_INTERFACE, I_("ThunarxPropertyPageProvider"), &info, 0); + type = g_type_register_static_simple (G_TYPE_INTERFACE, + I_("ThunarxPropertyPageProvider"), + sizeof (ThunarxPropertyPageProviderIface), + NULL, + 0, + NULL, + 0); + g_type_interface_add_prerequisite (type, G_TYPE_OBJECT); + + g_once_init_leave (&type__volatile, type); } - return type; + return type__volatile; } diff --git a/thunarx/thunarx-property-page.c b/thunarx/thunarx-property-page.c index c37902a8..f521a223 100644 --- a/thunarx/thunarx-property-page.c +++ b/thunarx/thunarx-property-page.c @@ -44,8 +44,6 @@ enum -static void thunarx_property_page_class_init (ThunarxPropertyPageClass *klass); -static void thunarx_property_page_init (ThunarxPropertyPage *property_page); static void thunarx_property_page_get_property (GObject *object, guint prop_id, GValue *value, @@ -69,36 +67,7 @@ struct _ThunarxPropertyPagePrivate -static GObjectClass *thunarx_property_page_parent_class; - - - -GType -thunarx_property_page_get_type (void) -{ - static GType type = G_TYPE_INVALID; - - if (G_UNLIKELY (type == G_TYPE_INVALID)) - { - static const GTypeInfo info = - { - sizeof (ThunarxPropertyPageClass), - NULL, - NULL, - (GClassInitFunc) thunarx_property_page_class_init, - NULL, - NULL, - sizeof (ThunarxPropertyPage), - 0, - (GInstanceInitFunc) thunarx_property_page_init, - NULL, - }; - - type = g_type_register_static (GTK_TYPE_BIN, I_("ThunarxPropertyPage"), &info, 0); - } - - return type; -} +G_DEFINE_TYPE (ThunarxPropertyPage, thunarx_property_page, GTK_TYPE_BIN) @@ -109,9 +78,6 @@ thunarx_property_page_class_init (ThunarxPropertyPageClass *klass) GtkWidgetClass *gtkwidget_class; GObjectClass *gobject_class; - /* determine the parent type class */ - thunarx_property_page_parent_class = g_type_class_peek_parent (klass); - /* add our private data to the class type */ g_type_class_add_private (klass, sizeof (ThunarxPropertyPagePrivate)); diff --git a/thunarx/thunarx-provider-factory.c b/thunarx/thunarx-provider-factory.c index ab92a564..4cbdde1e 100644 --- a/thunarx/thunarx-provider-factory.c +++ b/thunarx/thunarx-provider-factory.c @@ -37,7 +37,6 @@ -static void thunarx_provider_factory_class_init (ThunarxProviderFactoryClass *klass); static void thunarx_provider_factory_finalize (GObject *object); static void thunarx_provider_factory_add (ThunarxProviderFactory *factory, ThunarxProviderModule *module); @@ -70,37 +69,11 @@ struct _ThunarxProviderFactory -static GObjectClass *thunarx_provider_factory_parent_class; -static GList *thunarx_provider_modules = NULL; /* list of active provider modules */ +static GList *thunarx_provider_modules = NULL; /* list of active provider modules */ -GType -thunarx_provider_factory_get_type (void) -{ - static GType type = G_TYPE_INVALID; - - if (G_UNLIKELY (type == G_TYPE_INVALID)) - { - static const GTypeInfo info = - { - sizeof (ThunarxProviderFactoryClass), - NULL, - NULL, - (GClassInitFunc) thunarx_provider_factory_class_init, - NULL, - NULL, - sizeof (ThunarxProviderFactory), - 0, - NULL, - NULL, - }; - - type = g_type_register_static (G_TYPE_OBJECT, I_("ThunarxProviderFactory"), &info, 0); - } - - return type; -} +G_DEFINE_TYPE (ThunarxProviderFactory, thunarx_provider_factory, G_TYPE_OBJECT) @@ -109,9 +82,6 @@ thunarx_provider_factory_class_init (ThunarxProviderFactoryClass *klass) { GObjectClass *gobject_class; - /* determine the parent type class */ - thunarx_provider_factory_parent_class = g_type_class_peek_parent (klass); - gobject_class = G_OBJECT_CLASS (klass); gobject_class->finalize = thunarx_provider_factory_finalize; } @@ -119,6 +89,13 @@ thunarx_provider_factory_class_init (ThunarxProviderFactoryClass *klass) static void +thunarx_provider_factory_init (ThunarxProviderFactory *factory) +{ +} + + + +static void thunarx_provider_factory_finalize (GObject *object) { ThunarxProviderFactory *factory = THUNARX_PROVIDER_FACTORY (object); diff --git a/thunarx/thunarx-provider-module.c b/thunarx/thunarx-provider-module.c index 601a085d..b68e4c16 100644 --- a/thunarx/thunarx-provider-module.c +++ b/thunarx/thunarx-provider-module.c @@ -40,7 +40,6 @@ enum -static void thunarx_provider_module_class_init (ThunarxProviderModuleClass *klass); static void thunarx_provider_module_plugin_init (ThunarxProviderPluginIface *iface); static void thunarx_provider_module_get_property (GObject *object, guint prop_id, @@ -78,44 +77,8 @@ struct _ThunarxProviderModule -static GObjectClass *thunarx_provider_module_parent_class; - - - -GType -thunarx_provider_module_get_type (void) -{ - static GType type = G_TYPE_INVALID; - - if (G_UNLIKELY (type == G_TYPE_INVALID)) - { - static const GTypeInfo info = - { - sizeof (ThunarxProviderModuleClass), - NULL, - NULL, - (GClassInitFunc) thunarx_provider_module_class_init, - NULL, - NULL, - sizeof (ThunarxProviderModule), - 0, - NULL, - NULL, - }; - - static const GInterfaceInfo plugin_info = - { - (GInterfaceInitFunc) thunarx_provider_module_plugin_init, - NULL, - NULL, - }; - - type = g_type_register_static (G_TYPE_TYPE_MODULE, I_("ThunarxProviderModule"), &info, 0); - g_type_add_interface_static (type, THUNARX_TYPE_PROVIDER_PLUGIN, &plugin_info); - } - - return type; -} +G_DEFINE_TYPE_WITH_CODE (ThunarxProviderModule, thunarx_provider_module, G_TYPE_TYPE_MODULE, + G_IMPLEMENT_INTERFACE (THUNARX_TYPE_PROVIDER_PLUGIN, thunarx_provider_module_plugin_init)) @@ -125,9 +88,6 @@ thunarx_provider_module_class_init (ThunarxProviderModuleClass *klass) GTypeModuleClass *gtype_module_class; GObjectClass *gobject_class; - /* determine the parent class */ - thunarx_provider_module_parent_class = g_type_class_peek_parent (klass); - gobject_class = G_OBJECT_CLASS (klass); gobject_class->get_property = thunarx_provider_module_get_property; gobject_class->set_property = thunarx_provider_module_set_property; @@ -145,6 +105,14 @@ thunarx_provider_module_class_init (ThunarxProviderModuleClass *klass) static void +thunarx_provider_module_init (ThunarxProviderModule *module) +{ +} + + + + +static void thunarx_provider_module_plugin_init (ThunarxProviderPluginIface *iface) { iface->get_resident = thunarx_provider_module_get_resident; diff --git a/thunarx/thunarx-provider-plugin.c b/thunarx/thunarx-provider-plugin.c index fe80c652..7096ccbe 100644 --- a/thunarx/thunarx-provider-plugin.c +++ b/thunarx/thunarx-provider-plugin.c @@ -37,29 +37,23 @@ static void thunarx_provider_plugin_class_init (gpointer klass); GType thunarx_provider_plugin_get_type (void) { - static GType type = G_TYPE_INVALID; + static volatile gsize type__volatile = 0; + GType type; - if (G_UNLIKELY (type == G_TYPE_INVALID)) + if (g_once_init_enter (&type__volatile)) { - static const GTypeInfo info = - { - sizeof (ThunarxProviderPluginIface), - NULL, - NULL, - (GClassInitFunc) thunarx_provider_plugin_class_init, - NULL, - NULL, - 0, - 0, - NULL, - NULL, - }; - - /* register the provider plugin interface */ - type = g_type_register_static (G_TYPE_INTERFACE, I_("ThunarxProviderPlugin"), &info, 0); + type = g_type_register_static_simple (G_TYPE_INTERFACE, + I_("ThunarxProviderPlugin"), + sizeof (ThunarxProviderPluginIface), + (GClassInitFunc) thunarx_provider_plugin_class_init, + 0, + NULL, + 0); + + g_once_init_leave (&type__volatile, type); } - return type; + return type__volatile; } diff --git a/thunarx/thunarx-renamer-provider.c b/thunarx/thunarx-renamer-provider.c index cc957805..ebcf2e5f 100644 --- a/thunarx/thunarx-renamer-provider.c +++ b/thunarx/thunarx-renamer-provider.c @@ -31,30 +31,25 @@ GType thunarx_renamer_provider_get_type (void) { - static GType type = G_TYPE_INVALID; + static volatile gsize type__volatile = 0; + GType type; - if (G_UNLIKELY (type == G_TYPE_INVALID)) + if (g_once_init_enter (&type__volatile)) { - static const GTypeInfo info = - { - sizeof (ThunarxRenamerProviderIface), - NULL, - NULL, - NULL, - NULL, - NULL, - 0, - 0, - NULL, - NULL, - }; - - /* register the renamer provider interface */ - type = g_type_register_static (G_TYPE_INTERFACE, I_("ThunarxRenamerProvider"), &info, 0); + type = g_type_register_static_simple (G_TYPE_INTERFACE, + I_("ThunarxRenamerProvider"), + sizeof (ThunarxRenamerProviderIface), + NULL, + 0, + NULL, + 0); + g_type_interface_add_prerequisite (type, G_TYPE_OBJECT); + + g_once_init_leave (&type__volatile, type); } - return type; + return type__volatile; } diff --git a/thunarx/thunarx-renamer.c b/thunarx/thunarx-renamer.c index 61d212f9..28acabe6 100644 --- a/thunarx/thunarx-renamer.c +++ b/thunarx/thunarx-renamer.c @@ -51,8 +51,6 @@ enum -static void thunarx_renamer_class_init (ThunarxRenamerClass *klass); -static void thunarx_renamer_init (ThunarxRenamer *renamer); static void thunarx_renamer_finalize (GObject *object); static GObject *thunarx_renamer_constructor (GType type, guint n_construct_properties, @@ -87,37 +85,11 @@ struct _ThunarxRenamerPrivate -static GObjectClass *thunarx_renamer_parent_class; -static guint renamer_signals[LAST_SIGNAL]; +static guint renamer_signals[LAST_SIGNAL]; -GType -thunarx_renamer_get_type (void) -{ - static GType type = G_TYPE_INVALID; - - if (G_UNLIKELY (type == G_TYPE_INVALID)) - { - static const GTypeInfo info = - { - sizeof (ThunarxRenamerClass), - NULL, - NULL, - (GClassInitFunc) thunarx_renamer_class_init, - NULL, - NULL, - sizeof (ThunarxRenamer), - 0, - (GInstanceInitFunc) thunarx_renamer_init, - NULL, - }; - - type = g_type_register_static (GTK_TYPE_VBOX, I_("ThunarxRenamer"), &info, G_TYPE_FLAG_ABSTRACT); - } - - return type; -} +G_DEFINE_ABSTRACT_TYPE (ThunarxRenamer, thunarx_renamer, GTK_TYPE_VBOX) @@ -126,9 +98,6 @@ thunarx_renamer_class_init (ThunarxRenamerClass *klass) { GObjectClass *gobject_class; - /* determine the parent type class */ - thunarx_renamer_parent_class = g_type_class_peek_parent (klass); - /* add private data */ g_type_class_add_private (klass, sizeof (ThunarxRenamerPrivate)); |