/soc/2013/ankitkv/gobjectification: fa13e99f8248: Register GtkTi...

Ankit Vani a at nevitus.org
Sat Oct 12 08:23:31 EDT 2013


Changeset: fa13e99f8248306c3c2e1fedec1f3a85f83c47a9
Author:	 Ankit Vani <a at nevitus.org>
Date:	 2013-10-12 17:53 +0530
Branch:	 soc.2013.gobjectification.plugins
URL: https://hg.pidgin.im/soc/2013/ankitkv/gobjectification/rev/fa13e99f8248

Description:

Register GtkTicker type dynamically

diffstat:

 pidgin/plugins/ticker/gtkticker.c |  34 +---------------------------------
 pidgin/plugins/ticker/gtkticker.h |   4 ++++
 pidgin/plugins/ticker/ticker.c    |   2 ++
 3 files changed, 7 insertions(+), 33 deletions(-)

diffs (78 lines):

diff --git a/pidgin/plugins/ticker/gtkticker.c b/pidgin/plugins/ticker/gtkticker.c
--- a/pidgin/plugins/ticker/gtkticker.c
+++ b/pidgin/plugins/ticker/gtkticker.c
@@ -58,39 +58,7 @@ static GType gtk_ticker_child_type   (Gt
 static GtkContainerClass *parent_class = NULL;
 
 
-GType gtk_ticker_get_type (void)
-{
-	static GType ticker_type = 0;
-
-	ticker_type = g_type_from_name("GtkTicker");
-
-	if (!ticker_type)
-	{
-		static const GTypeInfo ticker_info =
-		{
-			sizeof(GtkTickerClass),
-			NULL,
-			NULL,
-			(GClassInitFunc) gtk_ticker_class_init,
-			NULL,
-			NULL,
-			sizeof(GtkTicker),
-			0,
-			(GInstanceInitFunc) gtk_ticker_init,
-			NULL
-		};
-
-		ticker_type = g_type_register_static (GTK_TYPE_CONTAINER, "GtkTicker",
-				&ticker_info, 0);
-	}
-
-	/* kludge to re-initialise the class if it's already registered */
-	else if (parent_class == NULL) {
-		gtk_ticker_class_init((GtkTickerClass *)g_type_class_peek(ticker_type));
-	}
-
-	return ticker_type;
-}
+PURPLE_DEFINE_TYPE(GtkTicker, gtk_ticker, GTK_TYPE_CONTAINER);
 
 static void gtk_ticker_finalize(GObject *object) {
 	gtk_ticker_stop_scroll(GTK_TICKER(object));
diff --git a/pidgin/plugins/ticker/gtkticker.h b/pidgin/plugins/ticker/gtkticker.h
--- a/pidgin/plugins/ticker/gtkticker.h
+++ b/pidgin/plugins/ticker/gtkticker.h
@@ -28,6 +28,7 @@
 #include <gdk/gdk.h>
 #include <gtk/gtk.h>
 
+#include "plugins.h"
 
 #ifdef __cplusplus
 extern "C" {
@@ -72,7 +73,10 @@ struct _GtkTickerChild
 };
 
 
+G_MODULE_EXPORT
 GType      gtk_ticker_get_type          (void);
+void       gtk_ticker_register_type     (PurplePlugin *plugin);
+
 GtkWidget* gtk_ticker_new               (void);
 void       gtk_ticker_add               (GtkTicker       *ticker,
                                         GtkWidget      *widget);
diff --git a/pidgin/plugins/ticker/ticker.c b/pidgin/plugins/ticker/ticker.c
--- a/pidgin/plugins/ticker/ticker.c
+++ b/pidgin/plugins/ticker/ticker.c
@@ -342,6 +342,8 @@ plugin_load(PurplePlugin *plugin, GError
 {
 	void *blist_handle = purple_blist_get_handle();
 
+	gtk_ticker_register_type(plugin);
+
 	purple_signal_connect(purple_connections_get_handle(), "signed-off",
 						plugin, PURPLE_CALLBACK(signoff_cb), NULL);
 	purple_signal_connect(blist_handle, "buddy-signed-on",



More information about the Commits mailing list