changeset 8815:ada0cf2f49fe

[gaim-migrate @ 9577] " This patch creates the subsystem like most of the core to connect to signals and emit them. It also adds a "gtkblist-created" signal so plugins that want to add something to the gtkblist know when it's created. Using the same subsytem setup as the rest of gaim helps plugin authors avoid connecting to the buddy signon even to know when they can connect to the "drawing-menu" signal." --Gary Kramlich committer: Tailor Script <tailor@pidgin.im>
author Luke Schierer <lschiere@pidgin.im>
date Mon, 26 Apr 2004 16:10:16 +0000
parents c61be128dff3
children 7001af79521f
files src/gtkblist.c src/gtkblist.h
diffstat 2 files changed, 39 insertions(+), 12 deletions(-) [+]
line wrap: on
line diff
--- a/src/gtkblist.c	Mon Apr 26 15:46:12 2004 +0000
+++ b/src/gtkblist.c	Mon Apr 26 16:10:16 2004 +0000
@@ -2903,7 +2903,6 @@
 	}
 }
 
-
 /**********************************************************************************
  * Public API Functions                                                           *
  **********************************************************************************/
@@ -2914,13 +2913,6 @@
 	gtkblist = g_new0(GaimGtkBuddyList, 1);
 	blist->ui_data = gtkblist;
 
-	/* Register some of our own. */
-	gaim_signal_register(gtkblist, "drawing-menu",
-						 gaim_marshal_VOID__POINTER_POINTER, NULL, 2,
-						 gaim_value_new(GAIM_TYPE_BOXED, "GtkMenu"),
-						 gaim_value_new(GAIM_TYPE_SUBTYPE,
-										GAIM_SUBTYPE_BLIST_BUDDY));
-
 	/* All of these signal handlers are for the "Raise on Events" option */
 	gaim_signal_connect(gaim_blist_get_handle(), "buddy-signed-on",
 			gtkblist, GAIM_CALLBACK(raise_on_events_cb), NULL);
@@ -3254,6 +3246,9 @@
 						gtkblist, GAIM_CALLBACK(signed_on_off_cb), list);
 	gaim_signal_connect(gaim_connections_get_handle(), "signing-off",
 						gtkblist, GAIM_CALLBACK(signed_on_off_cb), list);
+
+	/* emit our created signal */
+	gaim_signal_emit(gaim_gtk_blist_get_handle(), "gtkblist-created", list);
 }
 
 /* XXX: does this need fixing? */
@@ -4458,13 +4453,19 @@
 	}
 }
 
+void *
+gaim_gtk_blist_get_handle() {
+	static int handle;
+
+	return &handle;
+}
+
 void gaim_gtk_blist_init(void)
 {
-	/* XXX */
-	static int gtk_blist_handle;
+	void *gtk_blist_handle = gaim_gtk_blist_get_handle();
 
 	gaim_signal_connect(gaim_connections_get_handle(), "signed-on",
-						&gtk_blist_handle, GAIM_CALLBACK(account_signon_cb),
+						gtk_blist_handle, GAIM_CALLBACK(account_signon_cb),
 						NULL);
 
 	/* Initialize prefs */
@@ -4486,9 +4487,23 @@
     gaim_prefs_add_int("/gaim/gtk/blist/height", 0);
     gaim_prefs_add_int("/gaim/gtk/blist/tooltip_delay", 500);
 
+	/* Register our signals */
+	gaim_signal_register(gtk_blist_handle, "drawing-menu",
+						 gaim_marshal_VOID__POINTER_POINTER, NULL, 2,
+						 gaim_value_new(GAIM_TYPE_BOXED, "GtkMenu"),
+						 gaim_value_new(GAIM_TYPE_SUBTYPE,
+										GAIM_SUBTYPE_BLIST_BUDDY));
+
+	gaim_signal_register(gtk_blist_handle, "gtkblist-created",
+						 gaim_marshal_VOID__POINTER, NULL, 1,
+						 gaim_value_new(GAIM_TYPE_SUBTYPE,
+										GAIM_SUBTYPE_BLIST));
 }
 
-
+void
+gaim_gtk_blist_uninit(void) {
+	gaim_signals_unregister_by_instance(gaim_gtk_blist_get_handle());
+}
 
 /*********************************************************************
  * Public utility functions                                          *
--- a/src/gtkblist.h	Mon Apr 26 15:46:12 2004 +0000
+++ b/src/gtkblist.h	Mon Apr 26 16:10:16 2004 +0000
@@ -97,11 +97,23 @@
  **************************************************************************/
 
 /**
+ * Get the handle for the GTK+ blist system.
+ *
+ * @return the handle to the blist system
+ */
+void *gaim_gtk_blist_get_handle();
+
+/**
  * Initializes the GTK+ blist system.
  */
 void gaim_gtk_blist_init(void);
 
 /**
+ * Uninitializes the GTK+ blist system.
+ */
+void gaim_gtk_blist_uninit(void);
+
+/**
  * Returns the UI operations structure for the buddy list.
  *
  * @return The GTK list operations structure.