changeset 15199:b52cdf3cff4f

[gaim-migrate @ 17989] - Fix a crash when 'detailed' is FALSE - Google Talk will return details for the first 30 e-mails, and give you the total count of new e-mails I made it so that if the total count is > 30, it doesn't show details, and takes you directly to the Inbox - I still need to integrate getting multiple non-detailed mail notifications committer: Tailor Script <tailor@pidgin.im>
author Sean Egan <seanegan@gmail.com>
date Wed, 13 Dec 2006 21:54:52 +0000
parents c9bb2131bdf3
children 6a647ede0a76
files gtk/gtknotify.c libgaim/protocols/jabber/google.c
diffstat 2 files changed, 36 insertions(+), 4 deletions(-) [+]
line wrap: on
line diff
--- a/gtk/gtknotify.c	Wed Dec 13 21:29:16 2006 +0000
+++ b/gtk/gtknotify.c	Wed Dec 13 21:54:52 2006 +0000
@@ -306,6 +306,21 @@
 								  (url     == NULL ? NULL : &url));
 }
 
+struct inbox_info {
+	char *url;
+	void *handle;
+};
+
+static void
+open_inbox_cb(struct inbox_info *inbox)
+{
+	if (inbox->url)
+		gaim_notify_uri(inbox->handle, inbox->url);
+	g_free(inbox->url);
+	g_free(inbox);
+}
+
+
 static void *
 gaim_gtk_notify_emails(GaimConnection *gc, size_t count, gboolean detailed,
 					   const char **subjects, const char **froms,
@@ -322,6 +337,22 @@
 
 	account = gaim_connection_get_account(gc);
 
+	if (!detailed) {
+		struct inbox_info *inbox = g_new0(struct inbox_info, 1);
+		GdkPixbuf *pixbuf = gtk_widget_render_icon(gaim_gtk_blist_get_default_gtk_blist()->headline_hbox, 
+				                           GAIM_STOCK_ICON_ONLINE_MSG, GTK_ICON_SIZE_BUTTON, NULL);
+		char *label_text = g_strdup_printf(ngettext("<b>You have %d new e-mail.</b>",
+							    "<b>You have %d new e-mails.</b>",
+							    count),count);
+		
+		inbox->handle = gc;
+		inbox->url = urls ? g_strdup(urls[0]) : NULL;
+		gaim_gtk_blist_set_headline(label_text, 
+					    pixbuf, G_CALLBACK(open_inbox_cb), inbox);
+		g_object_unref(pixbuf);
+		return;
+	}
+
 	if (mail_dialog == NULL || !detailed)
 	{
 		GtkCellRenderer *rend;
--- a/libgaim/protocols/jabber/google.c	Wed Dec 13 21:29:16 2006 +0000
+++ b/libgaim/protocols/jabber/google.c	Wed Dec 13 21:54:52 2006 +0000
@@ -70,7 +70,7 @@
 	url = xmlnode_get_attrib(child, "url");
 	if (!url || !*url)
 		url = "http://www.gmail.com";
-
+	
 	message= xmlnode_get_child(child, "mail-thread-info");
 	for (i=0; message; message = xmlnode_get_next_twin(message), i++) {
 		subject_node = xmlnode_get_child(message, "subject");
@@ -106,9 +106,10 @@
 		}
 	}
 
-	if (i>0)
-		gaim_notify_emails(js->gc, returned_count, TRUE, subjects, froms, tos, 
-				   urls, NULL, js->gc->account);
+	if (i>0) 
+		gaim_notify_emails(js->gc, count, count == returned_count, subjects, froms, tos, 
+				   	   urls, NULL, NULL);
+
 	g_free(to_name);
 	g_free(tos);
 	g_free(froms);