changeset 14853:910e783fbbc7

[gaim-migrate @ 17622] If you have the debug window open, and you activate some menuitem in the conversation window without focusing on 'Conversation', Gaim freezes. This is a fix for that (re: "Hang w/ Debug Window" in gaim-devel). committer: Tailor Script <tailor@pidgin.im>
author Sadrul Habib Chowdhury <imadil@gmail.com>
date Mon, 30 Oct 2006 00:40:19 +0000
parents cf25420b074d
children cb3f61c55148
files gtk/gtkconv.c
diffstat 1 files changed, 15 insertions(+), 3 deletions(-) [+]
line wrap: on
line diff
--- a/gtk/gtkconv.c	Sun Oct 29 23:35:57 2006 +0000
+++ b/gtk/gtkconv.c	Mon Oct 30 00:40:19 2006 +0000
@@ -166,6 +166,7 @@
 static GdkColor* generate_nick_colors(guint *numcolors, GdkColor background);
 static gboolean color_is_visible(GdkColor foreground, GdkColor background, int color_contrast, int brightness_contrast);
 static void gaim_gtkconv_update_fields(GaimConversation *conv, GaimGtkConvFields fields);
+static void focus_out_from_menubar(GtkWidget *wid, GaimGtkWindow *win);
 
 static GdkColor *get_nick_color(GaimGtkConversation *gtkconv, const char *name) {
 	static GdkColor col;
@@ -2844,15 +2845,24 @@
 
 static void menubar_activated(GtkWidget *item, gpointer data)
 {
-	regenerate_options_items(data);
+	GaimGtkWindow *win = data;
+	regenerate_options_items(win);
+
+	/* The following are to make sure the 'More' submenu is not regenerated every time
+	 * the focus shifts from 'Conversations' to some other menu and back. */
 	g_signal_handlers_block_by_func(G_OBJECT(item), G_CALLBACK(menubar_activated), data);
+	g_signal_connect(G_OBJECT(win->menu.menubar), "deactivate", G_CALLBACK(focus_out_from_menubar), data);
 }
 
 static void
 focus_out_from_menubar(GtkWidget *wid, GaimGtkWindow *win)
 {
+	/* The menubar has been deactivated. Make sure the 'More' submenu is regenerated next time
+	 * the 'Conversation' menu pops up. */
 	GtkWidget *menuitem = gtk_item_factory_get_item(win->menu.item_factory, N_("/Conversation"));
 	g_signal_handlers_unblock_by_func(G_OBJECT(menuitem), G_CALLBACK(menubar_activated), win);
+	g_signal_handlers_disconnect_by_func(G_OBJECT(win->menu.menubar),
+				G_CALLBACK(focus_out_from_menubar), win);
 }
 
 static GtkWidget *
@@ -2878,14 +2888,15 @@
 	g_signal_connect(G_OBJECT(accel_group), "accel-changed",
 	                 G_CALLBACK(gaim_gtk_save_accels_cb), NULL);
 
+	/* Make sure the 'Conversation -> More' menuitems are regenerated whenever
+	 * the 'Conversation' menu pops up because the entries can change after the
+	 * conversation is created. */
 	menuitem = gtk_item_factory_get_item(win->menu.item_factory, N_("/Conversation"));
 	g_signal_connect(G_OBJECT(menuitem), "activate", G_CALLBACK(menubar_activated), win);
 
 	win->menu.menubar =
 		gtk_item_factory_get_widget(win->menu.item_factory, "<main>");
 
-	g_signal_connect(G_OBJECT(win->menu.menubar), "deactivate", G_CALLBACK(focus_out_from_menubar), win);
-
 	win->menu.view_log =
 		gtk_item_factory_get_widget(win->menu.item_factory,
 		                            N_("/Conversation/View Log"));
@@ -7510,6 +7521,7 @@
 	                               gaim_conversation_is_logging(conv));
 
 	generate_send_to_items(win);
+	regenerate_options_items(win);
 
 	gaim_gtkconv_switch_active_conversation(conv);