From 03fd7c00cad8b25195c1ffd9f5026aa219811c08 Mon Sep 17 00:00:00 2001 From: Felix Riemann Date: Sun, 24 Jun 2007 19:10:17 +0000 Subject: Cleanups to my last commit. Fixes bug 450590 (Felix Riemann, Jaap Haitsma) 2007-06-24 Felix Riemann * lib/egg/egg-toolbar-editor.c: (editor_create_item_from_name): Cleanups to my last commit. Fixes bug 450590 (Felix Riemann, Jaap Haitsma) svn path=/trunk/; revision=7094 --- ChangeLog | 6 ++++++ lib/egg/egg-toolbar-editor.c | 43 +++++++++++++++---------------------------- 2 files changed, 21 insertions(+), 28 deletions(-) diff --git a/ChangeLog b/ChangeLog index f635ade9c..23320649f 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,9 @@ +2007-06-24 Felix Riemann + + reviewed by: + + * lib/egg/egg-toolbar-editor.c: (editor_create_item_from_name): + 2007-06-24 Felix Riemann * lib/egg/egg-toolbar-editor.c: (editor_create_item_from_name): diff --git a/lib/egg/egg-toolbar-editor.c b/lib/egg/egg-toolbar-editor.c index a74cbf94a..b08a97b26 100644 --- a/lib/egg/egg-toolbar-editor.c +++ b/lib/egg/egg-toolbar-editor.c @@ -434,8 +434,7 @@ editor_create_item_from_name (EggToolbarEditor *editor, { GtkWidget *item; const char *item_name; - const char *stock_id; - const char *short_label; + char *short_label; const char *collate_key; if (strcmp (name, "_separator") == 0) @@ -444,54 +443,42 @@ editor_create_item_from_name (EggToolbarEditor *editor, icon = _egg_editable_toolbar_new_separator_image (); short_label = _("Separator"); - item_name = strdup (name); + item_name = g_strdup (name); collate_key = g_utf8_collate_key (short_label, -1); item = editor_create_item (editor, GTK_IMAGE (icon), short_label, drag_action); } else { - GValue value = { 0, }; GtkAction *action; GtkWidget *icon; - gboolean is_named = FALSE; + char *stock_id, *icon_name = NULL; action = find_action (editor, name); g_return_val_if_fail (action != NULL, NULL); - g_value_init (&value, G_TYPE_STRING); - g_object_get_property (G_OBJECT (action), "icon-name", &value); - stock_id = g_value_get_string (&value); - - if (!stock_id) { - /* Gtk{Radio,Toggle}Actions only set either of the properties */ - g_value_reset (&value); - g_object_get_property (G_OBJECT (action), "stock-id", &value); - stock_id = g_value_get_string (&value); - is_named = FALSE; - } else { - is_named = TRUE; - } + g_object_get (action, + "icon-name", &icon_name, + "stock-id", &stock_id, + "short-label", &short_label, + NULL); /* This is a workaround to catch named icons. */ - if (is_named) - icon = gtk_image_new_from_icon_name (stock_id, + if (icon_name) + icon = gtk_image_new_from_icon_name (icon_name, GTK_ICON_SIZE_LARGE_TOOLBAR); else icon = gtk_image_new_from_stock (stock_id ? stock_id : GTK_STOCK_DND, GTK_ICON_SIZE_LARGE_TOOLBAR); - g_value_unset (&value); - - g_value_init (&value, G_TYPE_STRING); - g_object_get_property (G_OBJECT (action), "short_label", &value); - short_label = g_value_get_string (&value); - - item_name = strdup (name); + item_name = g_strdup (name); collate_key = g_utf8_collate_key (short_label, -1); item = editor_create_item (editor, GTK_IMAGE (icon), short_label, drag_action); - g_value_unset (&value); + + g_free (short_label); + g_free (stock_id); + g_free (icon_name); } g_object_set_data_full (G_OBJECT (item), "egg-collate-key", -- cgit v1.2.3