diff -r -U4 gaim-2.0.0beta2/plugins/notify.c gaim-2.0.0beta2+byte/plugins/notify.c --- gaim-2.0.0beta2/plugins/notify.c 2006-01-20 03:57:44.000000000 +0000 +++ gaim-2.0.0beta2+byte/plugins/notify.c 2006-02-10 19:46:35.000000000 +0000 @@ -131,8 +131,10 @@ /* raise function */ static void handle_raise(GaimGtkWindow *gaimwin); +static int ignore_updates = 0; + /****************************************/ /* Begin doing stuff below this line... */ /****************************************/ static int @@ -160,8 +162,10 @@ if (conv == NULL) return 0; + gaim_debug_misc("notify", "notify(%08x, %s): calling unnotify(..., FALSE)\n", conv, increment ? "TRUE" : "FALSE"); + /* We want to remove the notifications, but not reset the counter */ unnotify(conv, FALSE); gaimwin = GAIM_GTK_CONVERSATION(conv)->win; @@ -175,16 +179,20 @@ g_object_get(G_OBJECT(gaimwin->window), "has-toplevel-focus", &has_focus, NULL); + gaim_debug_misc("notify", "notify(%08x, %s): the window %s focus\n", conv, increment ? "TRUE" : "FALSE", has_focus ? "has" : "does not have"); + 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_debug_misc("notify", "notify(%08x, %s): setting message count to %u\n", conv, increment ? "TRUE" : "FALSE", count); gaim_conversation_set_data(conv, "notify-message-count", GINT_TO_POINTER(count)); } + gaim_debug_misc("notify", "notify(%08x, %s): calling notify_win(%08x)\n", conv, increment ? "TRUE" : "FALSE", gaimwin); notify_win(gaimwin); } return 0; @@ -192,8 +200,10 @@ static void notify_win(GaimGtkWindow *gaimwin) { + gaim_debug_misc("notify", "notify_win(%08x): count is %u\n", gaimwin, count_messages(gaimwin)); + if (count_messages(gaimwin) <= 0) return; if (gaim_prefs_get_bool("/plugins/gtk/X11/notify/method_count")) @@ -211,15 +221,21 @@ { GaimConversation *active_conv = NULL; GaimGtkWindow *gaimwin = NULL; + gaim_debug_misc("notify", "unnotify(%08x, %s)\n", conv, reset ? "TRUE" : "FALSE"); + g_return_if_fail(conv != NULL); gaimwin = GAIM_GTK_CONVERSATION(conv)->win; active_conv = gaim_gtk_conv_window_get_active_conversation(gaimwin); + gaim_debug_misc("notify", "unnotify(%08x, %s): resetting the title\n", conv, reset ? "TRUE" : "FALSE"); + /* reset the conversation window title */ + ignore_updates = ~0; gaim_conversation_autoset_title(active_conv); + ignore_updates = 0; if (reset) { /* Only need to actually remove the urgent hinting here, since removing it * just to have it readded in re-notify is an unnecessary couple extra RTs @@ -233,19 +249,24 @@ static int unnotify_cb(GtkWidget *widget, gpointer data, GaimConversation *conv) { - if (GPOINTER_TO_INT(gaim_conversation_get_data(conv, "notify-message-count")) != 0) + if (GPOINTER_TO_INT(gaim_conversation_get_data(conv, "notify-message-count")) != 0) { + gaim_debug_misc("notify", "unnotify_cb(..., ..., %08x): calling unnotify(..., TRUE)\n", conv); unnotify(conv, TRUE); + } return 0; } static gboolean message_displayed_cb(GaimAccount *account, GaimConversation *conv, const char *message, GaimMessageFlags flags) { - if ((flags & GAIM_MESSAGE_RECV) && !(flags & GAIM_MESSAGE_DELAYED)) + gaim_debug_misc("notify", "message_displayed_cb(..., %08x, ..., ...)\n", conv); + if ((flags & GAIM_MESSAGE_RECV) && !(flags & GAIM_MESSAGE_DELAYED)) { + gaim_debug_misc("notify", "message_displayed_cb(..., %08x, ..., ...): calling notify(..., TRUE)\n", conv); notify(conv, TRUE); + } return FALSE; } @@ -254,8 +275,9 @@ GaimConversation *conv = NULL; if (gaim_prefs_get_bool("/plugins/gtk/X11/notify/notify_send")) { conv = gaim_find_conversation_with_account(GAIM_CONV_TYPE_IM, receiver, account); + gaim_debug_misc("notify", "im_sent_im: calling unnotify(%08x, TRUE)\n", &conv); unnotify(conv, TRUE); } } @@ -265,8 +287,9 @@ GaimConversation *conv = NULL; if (gaim_prefs_get_bool("/plugins/gtk/X11/notify/notify_send")) { conv = gaim_find_chat(gaim_account_get_connection(account), id); + gaim_debug_misc("notify", "chat_sent_im: calling unnotify(%08x, TRUE)\n", &conv); unnotify(conv, TRUE); } } @@ -373,8 +396,9 @@ /* * If the conversation was switched, then make sure we re-notify * because Gaim will have overwritten our custom window title. */ + gaim_debug_misc("notify", "conv_switched(%08x): calling notify(..., FALSE)\n", &conv); notify(conv, FALSE); #if 0 printf("conv_switched - %p - %p\n", old_conv, new_conv); @@ -460,8 +484,20 @@ } #endif static void +title_reset(GaimConversation *conv) +{ + GaimGtkWindow *gaimwin = NULL; + gaim_debug_misc("notify", "title_reset(%08x)%s\n", conv, (ignore_updates ? " (ignoring)" : "")); + if (conv == NULL || GAIM_GTK_CONVERSATION(conv) == NULL) return; + if (ignore_updates) return; + gaimwin = GAIM_GTK_CONVERSATION(conv)->win; + notify_win(gaimwin); + return; +} + +static void handle_string(GaimGtkWindow *gaimwin) { GtkWindow *window = NULL; gchar newtitle[256]; @@ -482,13 +518,17 @@ { GtkWindow *window; char newtitle[256]; + gaim_debug_misc("notify", "handle_count(%08x)\n", gaimwin); + g_return_if_fail(gaimwin != NULL); window = GTK_WINDOW(gaimwin->window); g_return_if_fail(window != NULL); + gaim_debug_misc("notify", "handle_count: prepending count of %u to title\n", count_messages(gaimwin)); + g_snprintf(newtitle, sizeof(newtitle), "[%d] %s", count_messages(gaimwin), gtk_window_get_title(window)); gtk_window_set_title(window, newtitle); } @@ -591,14 +631,17 @@ for (convs = gaim_get_conversations(); convs != NULL; convs = convs->next) { GaimConversation *conv = (GaimConversation *)convs->data; /* remove notifications */ + gaim_debug_misc("notify", "apply_method: calling unnotify(%08x, FALSE)\n", &conv); unnotify(conv, FALSE); gaimwin = GAIM_GTK_CONVERSATION(conv)->win; - if (GPOINTER_TO_INT(gaim_conversation_get_data(conv, "notify-message-count")) != 0) + if (GPOINTER_TO_INT(gaim_conversation_get_data(conv, "notify-message-count")) != 0) { /* reattach appropriate notifications */ + gaim_debug_misc("notify", "apply_method: calling notify(%08x, FALSE)\n", &conv); notify(conv, FALSE); + } } } static void @@ -780,8 +823,12 @@ gaim_signal_connect(conv_handle, "chat-joined", plugin, GAIM_CALLBACK(conv_created), NULL); gaim_signal_connect(conv_handle, "deleting-conversation", plugin, GAIM_CALLBACK(deleting_conv), NULL); + gaim_signal_connect(conv_handle, "conversation-title-reset", plugin, + GAIM_CALLBACK(title_reset), NULL); + gaim_signal_connect(gtk_conv_handle, "conversation-title-reset", plugin, + GAIM_CALLBACK(title_reset), NULL); #if 0 gaim_signal_connect(gtk_conv_handle, "conversation-dragging", plugin, GAIM_CALLBACK(conversation_dragging), NULL); #endif diff -r -U4 gaim-2.0.0beta2/src/conversation.c gaim-2.0.0beta2+byte/src/conversation.c --- gaim-2.0.0beta2/src/conversation.c 2006-01-17 01:54:27.000000000 +0000 +++ gaim-2.0.0beta2+byte/src/conversation.c 2006-02-10 19:24:26.000000000 +0000 @@ -622,8 +622,9 @@ conv->title = g_strdup(title); gaim_conversation_update(conv, GAIM_CONV_UPDATE_TITLE); + gaim_signal_emit(gaim_conversations_get_handle(), "conversation-title-reset", conv); } const char * gaim_conversation_get_title(const GaimConversation *conv) @@ -2084,8 +2085,13 @@ gaim_value_new(GAIM_TYPE_SUBTYPE, GAIM_SUBTYPE_CONVERSATION), gaim_value_new(GAIM_TYPE_UINT)); + gaim_signal_register(handle, "conversation-title-reset", + gaim_marshal_VOID__POINTER, NULL, 1, + gaim_value_new(GAIM_TYPE_SUBTYPE, + GAIM_SUBTYPE_CONVERSATION)); + gaim_signal_register(handle, "deleting-conversation", gaim_marshal_VOID__POINTER, NULL, 1, gaim_value_new(GAIM_TYPE_SUBTYPE, GAIM_SUBTYPE_CONVERSATION)); diff -r -U4 gaim-2.0.0beta2/src/gtkconv.c gaim-2.0.0beta2+byte/src/gtkconv.c --- gaim-2.0.0beta2/src/gtkconv.c 2006-01-22 03:01:26.000000000 +0000 +++ gaim-2.0.0beta2+byte/src/gtkconv.c 2006-02-10 19:46:53.000000000 +0000 @@ -2134,8 +2134,9 @@ update_typing_icon(gtkconv); gtk_window_set_title(GTK_WINDOW(gtkconv->win->window), gtk_label_get_text(GTK_LABEL(gtkconv->tab_label))); + gaim_signal_emit(gaim_conversations_get_handle(), "conversation-title-reset", conv); } static void menu_conv_sel_send_cb(GObject *m, gpointer data) @@ -5648,10 +5649,12 @@ if (gaim_gtk_conv_window_is_active_conversation(conv)) update_typing_icon(gtkconv); gtk_label_set_text(GTK_LABEL(gtkconv->menu_label), title); - if (gaim_gtk_conv_window_is_active_conversation(conv)) + if (gaim_gtk_conv_window_is_active_conversation(conv)) { gtk_window_set_title(GTK_WINDOW(win->window), title); + gaim_signal_emit(gaim_conversations_get_handle(), "conversation-title-reset", conv); + } g_free(title); } } @@ -6513,8 +6516,14 @@ gaim_marshal_VOID__POINTER_POINTER, NULL, 1, gaim_value_new(GAIM_TYPE_SUBTYPE, GAIM_SUBTYPE_CONVERSATION)); + gaim_signal_register(handle, "conversation-title-reset", + gaim_marshal_VOID__POINTER, NULL, 1, + gaim_value_new(GAIM_TYPE_SUBTYPE, + GAIM_SUBTYPE_CONVERSATION)); + + /********************************************************************** * Register commands **********************************************************************/ gaim_cmd_register("say", "S", GAIM_CMD_P_DEFAULT,