# HG changeset patch # User Paul Aurich # Date 1246595145 0 # Node ID 8796eaaca38a6b5aafd4edd6db7367d492e7aa84 # Parent 1643ace55ef88d579de6dd6fc96cccbb3f03d452 Fix the mail_dialog->total_count and use that to tell when the dialog is empty. diff -r 1643ace55ef8 -r 8796eaaca38a pidgin/gtknotify.c --- a/pidgin/gtknotify.c Fri Jul 03 04:21:16 2009 +0000 +++ b/pidgin/gtknotify.c Fri Jul 03 04:25:45 2009 +0000 @@ -554,6 +554,8 @@ gtk_tree_store_remove(treemodel, &iter); advanced = (iter.stamp == 0) ? FALSE : TRUE; #endif + mail_dialog->total_count -= data->count; + if (data->purple_has_handle) purple_notify_close(PURPLE_NOTIFY_EMAILS, data); else @@ -593,7 +595,8 @@ PIDGIN_MAIL_DATA, data, -1); data->account = account; - data->count = count; + /* count == 0 indicates we're adding a single detailed e-mail */ + data->count = count > 0 ? count : 1; if (icon) g_object_unref(icon); @@ -626,7 +629,7 @@ mail_dialog->total_count += count; if (detailed) { - while (count--) { + for ( ; count; --count) { char *to_text = NULL; char *from_text = NULL; char *subject_text = NULL; @@ -687,14 +690,14 @@ } g_free(notification); } else { - GtkTreeIter iter; - /* Clear out all mails for the account */ pidgin_notify_add_mail(mail_dialog->treemodel, account, NULL, NULL, 0, TRUE, NULL); - if (!gtk_tree_model_get_iter_first(GTK_TREE_MODEL(mail_dialog->treemodel), &iter)) { - /* There is no API to clear the headline specifically */ - /* This will trigger reset_mail_dialog() */ + if (mail_dialog->total_count == 0) { + /* + * There is no API to clear the headline specifically + * This will trigger reset_mail_dialog() + */ pidgin_blist_set_headline(NULL, NULL, NULL, NULL, NULL); return NULL; } @@ -1561,15 +1564,11 @@ static void signed_off_cb(PurpleConnection *gc, gpointer unused) { - GtkTreeIter iter; - /* Clear any pending emails for this account */ pidgin_notify_emails(gc, 0, FALSE, NULL, NULL, NULL, NULL); - if (mail_dialog != NULL && - !gtk_tree_model_get_iter_first(GTK_TREE_MODEL(mail_dialog->treemodel), &iter)) { + if (mail_dialog != NULL && mail_dialog->total_count == 0) reset_mail_dialog(NULL); - } } static void*