[goffice] GUI: Make sure undo/redo buttons change icon size on toolbar reconfig.



commit 4423039095f0f8e16361f81b036316268d9d0f66
Author: Morten Welinder <terra gnome org>
Date:   Fri Jan 31 20:50:59 2014 -0500

    GUI: Make sure undo/redo buttons change icon size on toolbar reconfig.

 ChangeLog                           |    6 +++++
 NEWS                                |    1 +
 goffice/gtk/go-action-combo-stack.c |   41 ++++++++++++++++++++++------------
 3 files changed, 33 insertions(+), 15 deletions(-)
---
diff --git a/ChangeLog b/ChangeLog
index 0c9b0e6..bdabb9a 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,9 @@
+2014-01-31  Morten Welinder  <terra gnome org>
+
+       * goffice/gtk/go-action-combo-stack.c
+       (go_action_combo_stack_create_tool_item): Handler reconfiguration
+       of the toolbar the item is in.
+
 2014-01-17  Jean Brefort  <jean brefort normalesup org>
 
        * goffice/graph/gog-axis-line.c (gog_axis_base_set_property),
diff --git a/NEWS b/NEWS
index b0c087a..83473eb 100644
--- a/NEWS
+++ b/NEWS
@@ -13,6 +13,7 @@ Morten:
          functions.
        * Add go_sinpi, go_cospi, go_tanpi, go_atan2pi.
        * Improve "General" format.
+       * Improve Undo/Redo buttons.
 
 --------------------------------------------------------------------------
 goffice 0.10.9:
diff --git a/goffice/gtk/go-action-combo-stack.c b/goffice/gtk/go-action-combo-stack.c
index db253f7..82b3e98 100644
--- a/goffice/gtk/go-action-combo-stack.c
+++ b/goffice/gtk/go-action-combo-stack.c
@@ -263,17 +263,36 @@ cb_tool_popped (GOToolComboStack *tool, gpointer key, GOActionComboStack *a)
        a->last_selection = NULL;
 }
 
+static void
+cb_reconfig (GOToolComboStack *tool, GtkAction *a)
+{
+       GtkIconSize size = gtk_tool_item_get_icon_size (GTK_TOOL_ITEM (tool));
+       GtkReliefStyle relief = gtk_tool_item_get_relief_style (GTK_TOOL_ITEM (tool));
+       char *stock_id;
+       GtkWidget *image;
+       GtkWidget *child;
+
+       child = gtk_bin_get_child (GTK_BIN (tool->combo->button));
+       if (child)
+               gtk_container_remove (GTK_CONTAINER (tool->combo->button), child);
+
+       g_object_get (G_OBJECT (a), "stock-id", &stock_id, NULL);
+       image = gtk_image_new_from_stock (stock_id, size);
+       g_free (stock_id);
+       gtk_widget_show (image);
+       gtk_container_add (GTK_CONTAINER (tool->combo->button), image);
+
+       go_combo_box_set_relief (GO_COMBO_BOX (tool->combo), relief);
+}
+
+
 static GtkWidget *
 go_action_combo_stack_create_tool_item (GtkAction *a)
 {
        GOActionComboStack *saction = (GOActionComboStack *)a;
-       GtkWidget *image;
        GtkTreeView *tree_view;
        GOToolComboStack *tool = g_object_new (GO_TYPE_TOOL_COMBO_STACK, NULL);
-       char *stock_id;
        gboolean is_sensitive = gtk_tree_model_iter_n_children (saction->model, NULL) > 0;
-       GtkIconSize size;
-       GtkSettings *settings;
 
        tool->combo = g_object_new (GO_TYPE_COMBO_STACK, NULL);
        tree_view = GTK_TREE_VIEW (tool->combo->list);
@@ -285,20 +304,12 @@ go_action_combo_stack_create_tool_item (GtkAction *a)
                        "text", 0,
                        NULL));
 
-       /* FIXME: This probably isn't 100% right as tool isn't mapped yet.  */
-       settings = gtk_widget_get_settings (GTK_WIDGET (tool));
-       g_object_get (settings,
-                     "gtk-toolbar-icon-size", &size,
-                     NULL);
-       g_object_get (G_OBJECT (a), "stock-id", &stock_id, NULL);
-       image = gtk_image_new_from_stock (stock_id, size);
-       g_free (stock_id);
-       gtk_widget_show (image);
-       gtk_container_add (GTK_CONTAINER (tool->combo->button), image);
+       g_signal_connect (tool, "toolbar-reconfigured",
+                         G_CALLBACK (cb_reconfig), a);
+       cb_reconfig (tool, a);
 
        gtk_widget_set_sensitive (GTK_WIDGET (tool), is_sensitive);
 
-       go_combo_box_set_relief (GO_COMBO_BOX (tool->combo), GTK_RELIEF_NONE);
        go_gtk_widget_disable_focus (GTK_WIDGET (tool->combo));
        gtk_container_add (GTK_CONTAINER (tool), GTK_WIDGET (tool->combo));
        gtk_widget_show (GTK_WIDGET (tool->combo));


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]