changeset 12242:976677e67239

[gaim-migrate @ 14544] Rework the notify API close callbacks. They are now called by the core, instead of the UI. Prior to a couple days ago, they weren't actually implemented in the UI at all. As a side note, if anyone knows why gpointer is declared as a T_GaimObj instead of a T_PTR, please let me know. That seems wrong, especially since void * is a T_PTR and gconstpointer is a T_PTR. This may or may not cause problems for the notify change (void * -> gpointer) to user_data. NOTE: I did not change this, even though I think it's wrong. committer: Tailor Script <tailor@pidgin.im>
author Richard Laager <rlaager@wiktel.com>
date Mon, 28 Nov 2005 01:50:56 +0000
parents 4777c5912068
children d3cb077caf3e
files plugins/ChangeLog.API plugins/perl/common/Notify.xs plugins/perl/common/module.h plugins/perl/common/typemap src/gtknotify.c src/notify.c src/notify.h
diffstat 7 files changed, 76 insertions(+), 75 deletions(-) [+]
line wrap: on
line diff
--- a/plugins/ChangeLog.API	Mon Nov 28 01:43:53 2005 +0000
+++ b/plugins/ChangeLog.API	Mon Nov 28 01:50:56 2005 +0000
@@ -60,7 +60,8 @@
 	* All core<->prpl message passing now uses html. This was previously true
 	  for receiving messages, it's now also true for sending them. prpls that
 	  don't support html need to gaim_unescape_html() the message.
-	* Notify API: GCallback -> GHookFunc, void *user_data -> gpointer user_data
+	* Notify API: GCallback -> GaimNotifyCloseCallback,
+	              void *user_data -> gpointer user_data
 
 	Removed:
 	* gaim_gtk_sound_{get,set}_mute() (replaced by the /gaim/gtk/sound/mute
@@ -104,6 +105,8 @@
 	* gaim_gtkpounce_dialog_show()
 	* GaimGtkBuddyList->bpmenu
 	* GaimConvImFlags and GaimConvChatFlags; use GaimMessageFlags instead
+	* cb and user_data from the ops in GaimNotifyUiOps: This is now handled
+	  by the notify API in the core.
 
 	Added:
 	* gaim_prefs_disconnect_by_handle()
--- a/plugins/perl/common/Notify.xs	Mon Nov 28 01:43:53 2005 +0000
+++ b/plugins/perl/common/Notify.xs	Mon Nov 28 01:50:56 2005 +0000
@@ -19,8 +19,8 @@
 	const char *from
 	const char *to
 	const char *url
-	GHookFunc cb
-	void * user_data
+	Gaim::NotifyCloseCallback cb
+	gpointer user_data
  
 
 void *
@@ -32,8 +32,8 @@
 	const char **froms
 	const char **tos
 	const char **urls
-	GHookFunc cb
-	void * user_data
+	Gaim::NotifyCloseCallback cb
+	gpointer user_data
  
 
 void *
@@ -43,8 +43,8 @@
 	const char *primary
 	const char *secondary
 	const char *text
-	GHookFunc cb
-	void * user_data
+	Gaim::NotifyCloseCallback cb
+	gpointer user_data
  
 
 Gaim::NotifyUiOps
@@ -58,8 +58,8 @@
 	const char *title
 	const char *primary
 	const char *secondary
-	GHookFunc cb
-	void * user_data
+	Gaim::NotifyCloseCallback cb
+	gpointer user_data
  
 
 void *
@@ -69,8 +69,8 @@
 	const char *primary
 	const char *secondary
 	Gaim::NotifySearchResults results
-	GHookFunc cb
-	void * user_data
+	Gaim::NotifyCloseCallback cb
+	gpointer user_data
 
 void 
 gaim_notify_set_ui_ops(ops)
@@ -86,7 +86,7 @@
 	Gaim::Connection gc
 	const char *who
 	const char *text
-	GHookFunc cb
-	void * user_data
+	Gaim::NotifyCloseCallback cb
+	gpointer user_data
  
 
--- a/plugins/perl/common/module.h	Mon Nov 28 01:43:53 2005 +0000
+++ b/plugins/perl/common/module.h	Mon Nov 28 01:50:56 2005 +0000
@@ -160,6 +160,7 @@
 typedef GaimLogReadFlags *              Gaim__Log__ReadFlags;
 
 	/* notify.h */
+typedef GaimNotifyCloseCallback		Gaim__NotifyCloseCallback;
 typedef GaimNotifyType          	Gaim__NotifyType;
 typedef GaimNotifyMsgType               Gaim__NotifyMsgType;
 typedef GaimNotifySearchButtonType	Gaim__NotifySearchButtonType;
--- a/plugins/perl/common/typemap	Mon Nov 28 01:43:53 2005 +0000
+++ b/plugins/perl/common/typemap	Mon Nov 28 01:50:56 2005 +0000
@@ -25,7 +25,6 @@
 size_t *				T_PTR
 Gaim::GTK::Widget *			T_PTR
 GCallback				T_PTR
-GHookFunc				T_PTR
 va_list					T_PTR
 GString *					T_PTR
 GData *					T_PTR
@@ -99,6 +98,7 @@
 Gaim::Log::ReadFlags              	T_GaimObj
 
 
+Gaim::NotifyCloseCallback		T_PTR
 Gaim::NotifyType                	T_IV
 Gaim::NotifyMsgType            	 	T_IV
 Gaim::NotifySearchButtonType		T_IV
--- a/src/gtknotify.c	Mon Nov 28 01:43:53 2005 +0000
+++ b/src/gtknotify.c	Mon Nov 28 01:50:56 2005 +0000
@@ -53,9 +53,6 @@
 	GtkListStore *model;
 	GtkWidget *treeview;
 	GtkWidget *window;
-	GHookFunc close_cb;
-	gpointer close_cb_data;
-
 } GaimNotifySearchResultsData;
 
 typedef struct
@@ -68,8 +65,7 @@
 static void *gaim_gtk_notify_emails(size_t count, gboolean detailed,
 									const char **subjects,
 									const char **froms, const char **tos,
-									const char **urls, GHookFunc cb,
-									gpointer user_data);
+									const char **urls);
 
 static void
 message_response_cb(GtkDialog *dialog, gint id, GtkWidget *widget)
@@ -129,8 +125,7 @@
 
 static void *
 gaim_gtk_notify_message(GaimNotifyMsgType type, const char *title,
-						const char *primary, const char *secondary,
-						GHookFunc cb, gpointer user_data)
+						const char *primary, const char *secondary)
 {
 	GtkWidget *dialog;
 	GtkWidget *hbox;
@@ -208,22 +203,19 @@
 
 static void *
 gaim_gtk_notify_email(const char *subject, const char *from,
-					  const char *to, const char *url,
-					  GHookFunc cb, gpointer user_data)
+					  const char *to, const char *url)
 {
 	return gaim_gtk_notify_emails(1, TRUE,
 								  (subject == NULL ? NULL : &subject),
 								  (from    == NULL ? NULL : &from),
 								  (to      == NULL ? NULL : &to),
-								  (url     == NULL ? NULL : &url),
-								  cb, user_data);
+								  (url     == NULL ? NULL : &url));
 }
 
 static void *
 gaim_gtk_notify_emails(size_t count, gboolean detailed,
 					   const char **subjects, const char **froms,
-					   const char **tos, const char **urls,
-					   GHookFunc cb, gpointer user_data)
+					   const char **tos, const char **urls)
 {
 	GaimNotifyMailData *data;
 	GtkWidget *dialog;
@@ -354,8 +346,7 @@
 
 static void *
 gaim_gtk_notify_formatted(const char *title, const char *primary,
-						  const char *secondary, const char *text,
-						  GHookFunc cb, gpointer user_data)
+						  const char *secondary, const char *text)
 {
 	GtkWidget *window;
 	GtkWidget *vbox;
@@ -478,8 +469,7 @@
 static void *
 gaim_gtk_notify_searchresults(GaimConnection *gc, const char *title,
 							  const char *primary, const char *secondary,
-							  GaimNotifySearchResults *results, GHookFunc cb,
-							  gpointer user_data)
+							  GaimNotifySearchResults *results)
 {
 	GtkWidget *window;
 	GtkWidget *treeview;
@@ -614,8 +604,6 @@
 	data->model = model;
 	data->treeview = treeview;
 	data->window = window;
-	data->close_cb = cb;
-	data->close_cb_data = user_data;
 
 	/* Insert rows. */
 	gaim_gtk_notify_searchresults_new_rows(gc, results, data, NULL);
@@ -639,15 +627,13 @@
 
 static void *
 gaim_gtk_notify_userinfo(GaimConnection *gc, const char *who,
-						 const char *text,
-						 GHookFunc cb, gpointer user_data)
+						 const char *text)
 {
 	char *primary;
 	void *ui_handle;
 
 	primary = g_strdup_printf(_("Info for %s"), who);
-	ui_handle = gaim_gtk_notify_formatted(_("Buddy Information"), primary, NULL,
-									  text, cb, user_data);
+	ui_handle = gaim_gtk_notify_formatted(_("Buddy Information"), primary, NULL, text);
 	g_free(primary);
 	return ui_handle;
 }
@@ -670,9 +656,6 @@
 
 		gtk_widget_destroy(data->window);
 
-		if (data->close_cb != NULL)
-			data->close_cb(data->close_cb_data);
-
 		g_free(data);
 	}
 	else if (ui_handle != NULL)
--- a/src/notify.c	Mon Nov 28 01:43:53 2005 +0000
+++ b/src/notify.c	Mon Nov 28 01:50:56 2005 +0000
@@ -32,13 +32,14 @@
 	GaimNotifyType type;
 	void *handle;
 	void *ui_handle;
-
+	GaimNotifyCloseCallback cb;
+	gpointer cb_user_data;
 } GaimNotifyInfo;
 
 void *
 gaim_notify_message(void *handle, GaimNotifyMsgType type,
 					const char *title, const char *primary,
-					const char *secondary, GHookFunc cb, gpointer user_data)
+					const char *secondary, GaimNotifyCloseCallback cb, gpointer user_data)
 {
 	GaimNotifyUiOps *ops;
 
@@ -53,7 +54,9 @@
 		info->type      = GAIM_NOTIFY_MESSAGE;
 		info->handle    = handle;
 		info->ui_handle = ops->notify_message(type, title, primary,
-											  secondary, cb, user_data);
+											  secondary);
+		info->cb = cb;
+		info->cb_user_data = user_data;
 
 		handles = g_list_append(handles, info);
 
@@ -65,7 +68,7 @@
 
 void *
 gaim_notify_email(void *handle, const char *subject, const char *from,
-				  const char *to, const char *url, GHookFunc cb,
+				  const char *to, const char *url, GaimNotifyCloseCallback cb,
 				  gpointer user_data)
 {
 	GaimNotifyUiOps *ops;
@@ -78,8 +81,9 @@
 		info            = g_new0(GaimNotifyInfo, 1);
 		info->type      = GAIM_NOTIFY_EMAIL;
 		info->handle    = handle;
-		info->ui_handle = ops->notify_email(subject, from, to, url, cb,
-											user_data);
+		info->ui_handle = ops->notify_email(subject, from, to, url);
+		info->cb = cb;
+		info->cb_user_data = user_data;
 
 		handles = g_list_append(handles, info);
 
@@ -93,7 +97,7 @@
 gaim_notify_emails(void *handle, size_t count, gboolean detailed,
 				   const char **subjects, const char **froms,
 				   const char **tos, const char **urls,
-				   GHookFunc cb, gpointer user_data)
+				   GaimNotifyCloseCallback cb, gpointer user_data)
 {
 	GaimNotifyUiOps *ops;
 
@@ -117,7 +121,9 @@
 		info->type      = GAIM_NOTIFY_EMAILS;
 		info->handle    = handle;
 		info->ui_handle = ops->notify_emails(count, detailed, subjects,
-											 froms, tos, urls, cb, user_data);
+											 froms, tos, urls);
+		info->cb = cb;
+		info->cb_user_data = user_data;
 
 		handles = g_list_append(handles, info);
 
@@ -130,7 +136,7 @@
 void *
 gaim_notify_formatted(void *handle, const char *title, const char *primary,
 					  const char *secondary, const char *text,
-					  GHookFunc cb, gpointer user_data)
+					  GaimNotifyCloseCallback cb, gpointer user_data)
 {
 	GaimNotifyUiOps *ops;
 
@@ -144,8 +150,9 @@
 		info            = g_new0(GaimNotifyInfo, 1);
 		info->type      = GAIM_NOTIFY_FORMATTED;
 		info->handle    = handle;
-		info->ui_handle = ops->notify_formatted(title, primary, secondary,
-												text, cb, user_data);
+		info->ui_handle = ops->notify_formatted(title, primary, secondary, text);
+		info->cb = cb;
+		info->cb_user_data = user_data;
 
 		handles = g_list_append(handles, info);
 
@@ -158,7 +165,7 @@
 void *
 gaim_notify_searchresults(GaimConnection *gc, const char *title,
 						  const char *primary, const char *secondary,
-						  GaimNotifySearchResults *results, GHookFunc cb, gpointer user_data)
+						  GaimNotifySearchResults *results, GaimNotifyCloseCallback cb, gpointer user_data)
 {
 	GaimNotifyUiOps *ops;
 
@@ -171,8 +178,9 @@
 		info->type      = GAIM_NOTIFY_SEARCHRESULTS;
 		info->handle    = gc;
 		info->ui_handle = ops->notify_searchresults(gc, title, primary,
-													secondary, results,
-													cb, user_data);
+													secondary, results);
+		info->cb = cb;
+		info->cb_user_data = user_data;
 
 		handles = g_list_append(handles, info);
 
@@ -329,7 +337,7 @@
 
 void *
 gaim_notify_userinfo(GaimConnection *gc, const char *who,
-						   const char *text, GHookFunc cb, gpointer user_data)
+						   const char *text, GaimNotifyCloseCallback cb, gpointer user_data)
 {
 	GaimNotifyUiOps *ops;
 
@@ -348,8 +356,9 @@
 		gaim_signal_emit(gaim_notify_get_handle(), "displaying-userinfo",
 						 gaim_connection_get_account(gc), who, &infotext);
 
-		info->ui_handle = ops->notify_userinfo(gc, who,
-											   infotext, cb, user_data);
+		info->ui_handle = ops->notify_userinfo(gc, who, infotext);
+		info->cb = cb;
+		info->cb_user_data = user_data;
 
 		handles = g_list_append(handles, info);
 
@@ -404,6 +413,9 @@
 			if (ops != NULL && ops->close_notify != NULL)
 				ops->close_notify(info->type, ui_handle);
 
+			if (info->cb != NULL)
+				info->cb(info->cb_user_data);
+
 			g_free(info);
 
 			break;
@@ -432,6 +444,9 @@
 			if (ops != NULL && ops->close_notify != NULL)
 				ops->close_notify(info->type, info->ui_handle);
 
+			if (info->cb != NULL)
+				info->cb(info->cb_user_data);
+
 			g_free(info);
 		}
 	}
--- a/src/notify.h	Mon Nov 28 01:43:53 2005 +0000
+++ b/src/notify.h	Mon Nov 28 01:50:56 2005 +0000
@@ -32,6 +32,11 @@
 #include "connection.h"
 
 /**
+ * Notification close callbacks.
+ */
+typedef void  (*GaimNotifyCloseCallback) (gpointer user_data);
+
+/**
  * Notification types.
  */
 typedef enum
@@ -106,28 +111,22 @@
 typedef struct
 {
 	void *(*notify_message)(GaimNotifyMsgType type, const char *title,
-							const char *primary, const char *secondary,
-							GHookFunc cb, gpointer user_data);
+							const char *primary, const char *secondary);
 	void *(*notify_email)(const char *subject, const char *from,
-						  const char *to, const char *url,
-						  GHookFunc cb, gpointer user_data);
+						  const char *to, const char *url);
 	void *(*notify_emails)(size_t count, gboolean detailed,
 						   const char **subjects, const char **froms,
-						   const char **tos, const char **urls,
-						   GHookFunc cb, gpointer user_data);
+						   const char **tos, const char **urls);
 	void *(*notify_formatted)(const char *title, const char *primary,
-							  const char *secondary, const char *text,
-							  GHookFunc cb, gpointer user_data);
+							  const char *secondary, const char *text);
 	void *(*notify_searchresults)(GaimConnection *gc, const char *title,
 								  const char *primary, const char *secondary,
-								  GaimNotifySearchResults *results, GHookFunc cb,
-								  gpointer user_data);
+								  GaimNotifySearchResults *results);
 	void (*notify_searchresults_new_rows)(GaimConnection *gc,
 										  GaimNotifySearchResults *results,
 										  void *data, gpointer user_data);
 	void *(*notify_userinfo)(GaimConnection *gc, const char *who,
-							  const char *text,
-							  GHookFunc cb, gpointer user_data);
+							  const char *text);
 	void *(*notify_uri)(const char *uri);
 
 	void (*close_notify)(GaimNotifyType type, void *ui_handle);
@@ -162,7 +161,7 @@
  */
 void *gaim_notify_searchresults(GaimConnection *gc, const char *title,
 								const char *primary, const char *secondary,
-								GaimNotifySearchResults *results, GHookFunc cb,
+								GaimNotifySearchResults *results, GaimNotifyCloseCallback cb,
 								gpointer user_data);
 
 void gaim_notify_searchresults_free(GaimNotifySearchResults *results);
@@ -287,7 +286,7 @@
  */
 void *gaim_notify_message(void *handle, GaimNotifyMsgType type,
 						  const char *title, const char *primary,
-						  const char *secondary, GHookFunc cb,
+						  const char *secondary, GaimNotifyCloseCallback cb,
 						  gpointer user_data);
 
 /**
@@ -306,7 +305,7 @@
  */
 void *gaim_notify_email(void *handle, const char *subject,
 						const char *from, const char *to,
-						const char *url, GHookFunc cb,
+						const char *url, GaimNotifyCloseCallback cb,
 						gpointer user_data);
 
 /**
@@ -329,7 +328,7 @@
 void *gaim_notify_emails(void *handle, size_t count, gboolean detailed,
 						 const char **subjects, const char **froms,
 						 const char **tos, const char **urls,
-						 GHookFunc cb, gpointer user_data);
+						 GaimNotifyCloseCallback cb, gpointer user_data);
 
 /**
  * Displays a notification with formatted text.
@@ -350,7 +349,7 @@
  */
 void *gaim_notify_formatted(void *handle, const char *title,
 							const char *primary, const char *secondary,
-							const char *text, GHookFunc cb, gpointer user_data);
+							const char *text, GaimNotifyCloseCallback cb, gpointer user_data);
 
 /**
  * Displays user information with formatted text, passing information giving
@@ -369,7 +368,7 @@
  * @return A UI-specific handle.
  */
 void *gaim_notify_userinfo(GaimConnection *gc, const char *who,
-						   const char *text, GHookFunc cb,
+						   const char *text, GaimNotifyCloseCallback cb,
 						   gpointer user_data);
 
 /**