changeset 2652:4635d9347338

Addl fix #444: User-definable toolbar https://github.com/BestImageViewer/geeqie/issues/444 .desktop file icons are displayed. Still problems with other icons.
author Colin Clark <colin.clark@cclark.uk>
date Thu, 02 Nov 2017 11:37:53 +0000
parents 0dc5dd177e54
children 1599ac7f5846
files src/toolbar.c
diffstat 1 files changed, 14 insertions(+), 3 deletions(-) [+]
line wrap: on
line diff
--- a/src/toolbar.c	Thu Nov 02 11:04:25 2017 +0000
+++ b/src/toolbar.c	Thu Nov 02 11:37:53 2017 +0000
@@ -240,6 +240,13 @@
 	g_free(tbbd);
 }
 
+static void toolbar_button_free(GtkWidget *widget)
+{
+	g_free(g_object_get_data(G_OBJECT(widget), "toolbar_add_name"));
+	g_free(g_object_get_data(G_OBJECT(widget), "toolbar_add_label"));
+	g_free(g_object_get_data(G_OBJECT(widget), "toolbar_add_stock_id"));
+}
+
 static void toolbarlist_add_button(const gchar *name, const gchar *label,
 									const gchar *stock_id, GtkBox *box)
 {
@@ -330,7 +337,7 @@
 		if (g_strcmp0(name, editor->key) == 0)
 			{
 			*label = g_strdup(editor->name);
-			*stock_id = g_strdup(editor->icon);
+			*stock_id = g_strconcat(editor->icon, ".desktop", NULL);
 			break;
 			}
 		work = work->next;
@@ -357,6 +364,7 @@
 		g_object_set_data(G_OBJECT(item), "toolbar_add_name", g_strdup(list->name));
 		g_object_set_data(G_OBJECT(item), "toolbar_add_label", g_strdup(list->label));
 		g_object_set_data(G_OBJECT(item), "toolbar_add_stock_id", g_strdup(list->stock_id));
+		g_signal_connect(G_OBJECT(item), "destroy", G_CALLBACK(toolbar_button_free), item);
 		list++;
 		}
 
@@ -368,11 +376,14 @@
 		const EditorDescription *editor = work->data;
 
 		GtkWidget *item;
-		item = menu_item_add_stock(menu, editor->name, editor->icon,
+		gchar *icon = g_strconcat(editor->icon, ".desktop", NULL);
+
+		item = menu_item_add_stock(menu, editor->name, icon,
 										G_CALLBACK(toolbarlist_add_cb), toolbarlist);
 		g_object_set_data(G_OBJECT(item), "toolbar_add_name", g_strdup(editor->key));
 		g_object_set_data(G_OBJECT(item), "toolbar_add_label", g_strdup(editor->name));
-		g_object_set_data(G_OBJECT(item), "toolbar_add_stock_id", g_strdup(editor->icon));
+		g_object_set_data(G_OBJECT(item), "toolbar_add_stock_id", icon);
+		g_signal_connect(G_OBJECT(item), "destroy", G_CALLBACK(toolbar_button_free), item);
 		work = work->next;
 		}
 	g_list_free(editors_list);