# HG changeset patch # User Etan Reisner # Date 1156140414 0 # Node ID d171bdecf17b36a659356508eb135aef6a8a9311 # Parent d7b40a68635517dbcd4a5b9b574995fa93a6700b [gaim-migrate @ 16946] Use the gtk conversation unseen_count instead of keeping my own count. committer: Tailor Script diff -r d7b40a686355 -r d171bdecf17b gtk/plugins/notify.c --- a/gtk/plugins/notify.c Mon Aug 21 05:49:20 2006 +0000 +++ b/gtk/plugins/notify.c Mon Aug 21 06:06:54 2006 +0000 @@ -107,7 +107,7 @@ static GaimPlugin *my_plugin = NULL; /* notification set/unset */ -static int notify(GaimConversation *conv, gboolean increment); +static int notify(GaimConversation *conv); static void notify_win(GaimGtkWindow *gaimwin); static void unnotify(GaimConversation *conv, gboolean reset); static int unnotify_cb(GtkWidget *widget, gpointer data, GaimConversation *conv); @@ -135,28 +135,26 @@ /****************************************/ /* Begin doing stuff below this line... */ /****************************************/ -static int +static guint count_messages(GaimGtkWindow *gaimwin) { - gint count = 0; - GList *convs = NULL, *l; + guint count = 0; + GList *gtkconvs = NULL; - for (convs = gaimwin->gtkconvs; convs != NULL; convs = convs->next) { - GaimGtkConversation *conv = convs->data; - for (l = conv->convs; l != NULL; l = l->next) { - count += GPOINTER_TO_INT(gaim_conversation_get_data(l->data, "notify-message-count")); - } + for (gtkconvs = gaimwin->gtkconvs; gtkconvs != NULL; + gtkconvs = gtkconvs->next) { + GaimGtkConversation *gtkconv = gtkconvs->data; + count += gtkconv->unseen_count; } return count; } static int -notify(GaimConversation *conv, gboolean increment) +notify(GaimConversation *conv) { + gboolean has_focus; GaimGtkWindow *gaimwin = NULL; - gint count; - gboolean has_focus; if (conv == NULL) return 0; @@ -178,12 +176,6 @@ if (gaim_prefs_get_bool("/plugins/gtk/X11/notify/type_focused") || !has_focus) { - if (increment) { - count = GPOINTER_TO_INT(gaim_conversation_get_data(conv, "notify-message-count")); - count++; - gaim_conversation_set_data(conv, "notify-message-count", GINT_TO_POINTER(count)); - } - notify_win(gaimwin); } @@ -225,7 +217,6 @@ * just to have it readded in re-notify is an unnecessary couple extra RTs * to the server */ handle_urgent(gaimwin, FALSE); - gaim_conversation_set_data(conv, "notify-message-count", GINT_TO_POINTER(0)); } return; @@ -234,7 +225,11 @@ static int unnotify_cb(GtkWidget *widget, gpointer data, GaimConversation *conv) { - if (GPOINTER_TO_INT(gaim_conversation_get_data(conv, "notify-message-count")) != 0) + GaimGtkConversation *gtkconv = NULL; + + gtkconv = GAIM_GTK_CONVERSATION(conv); + + if (gtkconv->unseen_count > 0) unnotify(conv, TRUE); return 0; @@ -250,7 +245,7 @@ return FALSE; if ((flags & GAIM_MESSAGE_RECV) && !(flags & GAIM_MESSAGE_DELAYED)) - notify(conv, TRUE); + notify(conv); return FALSE; } @@ -353,8 +348,6 @@ g_signal_handler_disconnect(gtkconv->entry, GPOINTER_TO_INT(l->data)); g_slist_free(ids); - gaim_conversation_set_data(conv, "notify-message-count", GINT_TO_POINTER(0)); - gaim_conversation_set_data(conv, "notify-imhtml-signals", NULL); gaim_conversation_set_data(conv, "notify-entry-signals", NULL); } @@ -362,8 +355,6 @@ static void conv_created(GaimConversation *conv) { - gaim_conversation_set_data(conv, "notify-message-count", GINT_TO_POINTER(0)); - /* always attach the signals, notify() will take care of conversation type * checking */ attach_signals(conv); @@ -380,7 +371,7 @@ * If the conversation was switched, then make sure we re-notify * because Gaim will have overwritten our custom window title. */ - notify(conv, FALSE); + notify(conv); #if 0 printf("conv_switched - %p - %p\n", old_conv, new_conv); @@ -406,7 +397,6 @@ gaimwin = GAIM_GTK_CONVERSATION(conv)->win; handle_urgent(gaimwin, FALSE); - gaim_conversation_set_data(conv, "notify-message-count", GINT_TO_POINTER(0)); return; @@ -592,18 +582,21 @@ static void apply_method() { GList *convs; - GaimGtkWindow *gaimwin = NULL; for (convs = gaim_get_conversations(); convs != NULL; convs = convs->next) { - GaimConversation *conv = (GaimConversation *)convs->data; + GaimConversation *conv = NULL; + GaimGtkConversation *gtkconv = NULL; + + conv = (GaimConversation *) convs->data; + gtkconv = GAIM_GTK_CONVERSATION(conv); /* remove notifications */ unnotify(conv, FALSE); - gaimwin = GAIM_GTK_CONVERSATION(conv)->win; - if (GPOINTER_TO_INT(gaim_conversation_get_data(conv, "notify-message-count")) != 0) + if (gtkconv->unseen_count > 0) { /* reattach appropriate notifications */ - notify(conv, FALSE); + notify(conv); + } } }