/dev/twasilczyk/screenshot: 0c93751c7c96: scrncap: reference act...

Tomasz Wasilczyk twasilczyk at pidgin.im
Tue Apr 29 13:42:22 EDT 2014


Changeset: 0c93751c7c961a06308ebd2234b03b8b4205a18f
Author:	 Tomasz Wasilczyk <twasilczyk at pidgin.im>
Date:	 2014-04-29 19:42 +0200
Branch:	 default
URL: https://hg.pidgin.im/dev/twasilczyk/screenshot/rev/0c93751c7c96

Description:

scrncap: reference actions, not their names

diffstat:

 pidgin/gtkwebviewtoolbar.c |  16 ++++++----------
 pidgin/plugins/screencap.c |  26 ++++++++++++++++----------
 2 files changed, 22 insertions(+), 20 deletions(-)

diffs (121 lines):

diff --git a/pidgin/gtkwebviewtoolbar.c b/pidgin/gtkwebviewtoolbar.c
--- a/pidgin/gtkwebviewtoolbar.c
+++ b/pidgin/gtkwebviewtoolbar.c
@@ -1506,8 +1506,7 @@ pidgin_webviewtoolbar_create_wide_view(P
 	for (i = 0; i < G_N_ELEMENTS(layout); i++) {
 		if (layout[i]) {
 			item = GTK_TOOL_ITEM(gtk_action_create_tool_item(layout[i]));
-			g_object_set_data_full(G_OBJECT(item), "action-name",
-				g_strdup(gtk_action_get_name(layout[i])), g_free);
+			g_object_set_data(G_OBJECT(item), "action", layout[i]);
 		} else
 			item = gtk_separator_tool_item_new();
 		gtk_toolbar_insert(GTK_TOOLBAR(priv->wide_view), item, -1);
@@ -1521,8 +1520,7 @@ lean_view_add_menu_item(GtkWidget *menu,
 
 	menuitem = gtk_action_create_menu_item(action);
 	gtk_menu_shell_append(GTK_MENU_SHELL(menu), menuitem);
-	g_object_set_data_full(G_OBJECT(menuitem), "action-name",
-		g_strdup(gtk_action_get_name(action)), g_free);
+	g_object_set_data(G_OBJECT(menuitem), "action", action);
 }
 
 static void
@@ -1545,7 +1543,7 @@ pidgin_webviewtoolbar_create_lean_view(P
 
 	/* Fonts */
 	font_button = gtk_toggle_tool_button_new();
-	g_object_set_data_full(G_OBJECT(font_button), "action-name",
+	g_object_set_data_full(G_OBJECT(font_button), "menu-name",
 		g_strdup("font"), g_free);
 	gtk_toolbar_insert(GTK_TOOLBAR(priv->lean_view), font_button, -1);
 	gtk_tool_item_set_is_important(font_button, TRUE);
@@ -1584,7 +1582,7 @@ pidgin_webviewtoolbar_create_lean_view(P
 
 	/* Insert */
 	insert_button = gtk_toggle_tool_button_new();
-	g_object_set_data_full(G_OBJECT(insert_button), "action-name",
+	g_object_set_data_full(G_OBJECT(insert_button), "menu-name",
 		g_strdup("insert"), g_free);
 	gtk_toolbar_insert(GTK_TOOLBAR(priv->lean_view), insert_button, -1);
 	gtk_tool_item_set_is_important(insert_button, TRUE);
@@ -1611,8 +1609,7 @@ pidgin_webviewtoolbar_create_lean_view(P
 
 	/* Smiley */
 	smiley_button = gtk_action_create_tool_item(priv->smiley);
-	g_object_set_data_full(G_OBJECT(smiley_button), "action-name",
-		g_strdup("smiley"), g_free);
+	g_object_set_data(G_OBJECT(smiley_button), "action", priv->smiley);
 	gtk_toolbar_insert(GTK_TOOLBAR(priv->lean_view),
 	                   GTK_TOOL_ITEM(smiley_button), -1);
 
@@ -1622,8 +1619,7 @@ pidgin_webviewtoolbar_create_lean_view(P
 
 	/* Attention */
 	attention_button = gtk_action_create_tool_item(priv->attention);
-	g_object_set_data_full(G_OBJECT(attention_button), "action-name",
-		g_strdup("attention"), g_free);
+	g_object_set_data(G_OBJECT(attention_button), "action", priv->attention);
 	gtk_toolbar_insert(GTK_TOOLBAR(priv->lean_view),
 	                   GTK_TOOL_ITEM(attention_button), -1);
 }
diff --git a/pidgin/plugins/screencap.c b/pidgin/plugins/screencap.c
--- a/pidgin/plugins/screencap.c
+++ b/pidgin/plugins/screencap.c
@@ -19,6 +19,7 @@
 
 /* TODO: disable, when prpl doesn't support inline images */
 /* TODO: add "Insert screenshot" to the Conversation window menu */
+/* TODO: add a possibility to change brush color */
 
 #include "internal.h"
 
@@ -668,11 +669,13 @@ scrncap_conversation_init(PidginConversa
 	scrncap_conv_set_data(gtkconv, "scrncap-btn-wide", scrncap_btn_wide);
 	for (i = 0; i < gtk_toolbar_get_n_items(wide_view); i++) {
 		GtkToolItem *ref_item = gtk_toolbar_get_nth_item(wide_view, i);
-		const gchar *action_name;
+		GtkAction *action;
 
-		action_name = g_object_get_data(G_OBJECT(ref_item),
-			"action-name");
-		if (g_strcmp0(action_name, "InsertImage") == 0) {
+		action = g_object_get_data(G_OBJECT(ref_item), "action");
+		if (action == NULL)
+			continue;
+
+		if (g_strcmp0(gtk_action_get_name(action), "InsertImage") == 0) {
 			pos = i + 1;
 			break;
 		}
@@ -682,10 +685,10 @@ scrncap_conversation_init(PidginConversa
 
 	for (i = 0; i < gtk_toolbar_get_n_items(lean_view); i++) {
 		GtkToolItem *ref_item = gtk_toolbar_get_nth_item(lean_view, i);
-		const gchar *action_name;
+		const gchar *menu_name;
 
-		action_name = g_object_get_data(G_OBJECT(ref_item), "action-name");
-		if (g_strcmp0(action_name, "insert") == 0) {
+		menu_name = g_object_get_data(G_OBJECT(ref_item), "menu-name");
+		if (g_strcmp0(menu_name, "insert") == 0) {
 			wide_menu = g_object_get_data(G_OBJECT(ref_item), "menu");
 			break;
 		}
@@ -696,10 +699,13 @@ scrncap_conversation_init(PidginConversa
 	wide_children = gtk_container_get_children(GTK_CONTAINER(wide_menu));
 	for (it = wide_children, i = 0; it; it = g_list_next(it), i++) {
 		GtkWidget *child = it->data;
-		const gchar *action_name;
+		GtkAction *action;
 
-		action_name = g_object_get_data(G_OBJECT(child), "action-name");
-		if (g_strcmp0(action_name, "InsertImage") == 0) {
+		action = g_object_get_data(G_OBJECT(child), "action");
+		if (action == NULL)
+			continue;
+
+		if (g_strcmp0(gtk_action_get_name(action), "InsertImage") == 0) {
 			pos = i + 1;
 			break;
 		}



More information about the Commits mailing list