/dev/twasilczyk/screenshot: 0820b9492599: scrncap: fix menu acti...

Tomasz Wasilczyk twasilczyk at pidgin.im
Tue Apr 29 18:11:05 EDT 2014


Changeset: 0820b9492599f2b94213694cb37267af327c3e32
Author:	 Tomasz Wasilczyk <twasilczyk at pidgin.im>
Date:	 2014-04-30 00:10 +0200
Branch:	 default
URL: https://hg.pidgin.im/dev/twasilczyk/screenshot/rev/0820b9492599

Description:

scrncap: fix menu action for new windows

diffstat:

 pidgin/gtkconv.c           |   7 +++++++
 pidgin/plugins/screencap.c |  23 ++++++++++++++++++-----
 2 files changed, 25 insertions(+), 5 deletions(-)

diffs (99 lines):

diff --git a/pidgin/gtkconv.c b/pidgin/gtkconv.c
--- a/pidgin/gtkconv.c
+++ b/pidgin/gtkconv.c
@@ -8843,6 +8843,10 @@ pidgin_conversations_init(void)
 						 G_TYPE_BOOLEAN, 3, PURPLE_TYPE_CONVERSATION,
 						 G_TYPE_STRING, G_TYPE_UINT);
 
+	purple_signal_register(handle, "conversation-window-created",
+		purple_marshal_VOID__POINTER, G_TYPE_NONE, 1,
+		G_TYPE_POINTER); /* (PidginConvWindow *) */
+
 
 	/**********************************************************************
 	 * Register commands
@@ -10312,6 +10316,9 @@ pidgin_conv_window_new()
 		gtk_window_iconify(GTK_WINDOW(win->window));
 #endif
 
+	purple_signal_emit(pidgin_conversations_get_handle(),
+		"conversation-window-created", win);
+
 	return win;
 }
 
diff --git a/pidgin/plugins/screencap.c b/pidgin/plugins/screencap.c
--- a/pidgin/plugins/screencap.c
+++ b/pidgin/plugins/screencap.c
@@ -17,7 +17,6 @@
  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02111-1301 USA
  */
 
-/* TODO: add "Insert screenshot" to detached conversations */
 /* TODO: add a possibility to change brush color */
 
 #include "internal.h"
@@ -645,6 +644,9 @@ scrncap_convwin_switch(GtkNotebook *note
 	GtkAction *action;
 
 	gtkconv = pidgin_conv_window_get_active_gtkconv(win);
+	if (gtkconv == NULL)
+		return;
+
 	webview = PIDGIN_WEBVIEW(gtkconv->entry);
 	action = g_object_get_data(G_OBJECT(win->menu->menubar),
 		"insert-screenshot-action");
@@ -840,8 +842,6 @@ scrncap_conversation_init(PidginConversa
 	gtk_menu_shell_insert(GTK_MENU_SHELL(wide_menu),
 		GTK_WIDGET(scrncap_btn_lean), pos);
 	gtk_widget_show(GTK_WIDGET(scrncap_btn_lean));
-
-	scrncap_convwin_init(gtkconv->win);
 }
 
 static void
@@ -861,8 +861,6 @@ scrncap_conversation_uninit(PidginConver
 
 	scrncap_conv_set_data(gtkconv, "scrncap-btn-wide", NULL);
 	scrncap_conv_set_data(gtkconv, "scrncap-btn-lean", NULL);
-
-	scrncap_convwin_uninit(gtkconv->win);
 }
 
 /******************************************************************************
@@ -877,6 +875,9 @@ scrncap_plugin_load(PurplePlugin *plugin
 	purple_signal_connect(pidgin_conversations_get_handle(),
 		"conversation-displayed", plugin,
 		PURPLE_CALLBACK(scrncap_conversation_init), NULL);
+	purple_signal_connect(pidgin_conversations_get_handle(),
+		"conversation-window-created", plugin,
+		PURPLE_CALLBACK(scrncap_convwin_init), NULL);
 
 	it = purple_conversations_get_all();
 	for (; it; it = g_list_next(it)) {
@@ -887,6 +888,12 @@ scrncap_plugin_load(PurplePlugin *plugin
 		scrncap_conversation_init(PIDGIN_CONVERSATION(conv));
 	}
 
+	it = pidgin_conv_windows_get_list();
+	for (; it; it = g_list_next(it)) {
+		PidginConvWindow *win = it->data;
+		scrncap_convwin_init(win);
+	}
+
 	return TRUE;
 }
 
@@ -909,6 +916,12 @@ scrncap_plugin_unload(PurplePlugin *plug
 		scrncap_conversation_uninit(PIDGIN_CONVERSATION(conv));
 	}
 
+	it = pidgin_conv_windows_get_list();
+	for (; it; it = g_list_next(it)) {
+		PidginConvWindow *win = it->data;
+		scrncap_convwin_uninit(win);
+	}
+
 	return TRUE;
 }
 



More information about the Commits mailing list