]> Pileus Git - ~andy/gtk/blobdiff - gtk/gtktoolbutton.c
Remove the old widget from the tool button before overwriting it with the
[~andy/gtk] / gtk / gtktoolbutton.c
index 002cc41041c3b6af43cca08fd0837d309dd407e7..8723f893c3455761be0c4b25f4e6023950b9735e 100644 (file)
@@ -20,6 +20,7 @@
  * Boston, MA 02111-1307, USA.
  */
 
+#include <config.h>
 #include "gtktoolbutton.h"
 #include "gtkbutton.h"
 #include "gtkhbox.h"
@@ -176,36 +177,36 @@ gtk_tool_button_class_init (GtkToolButtonClass *klass)
   g_object_class_install_property (object_class,
                                   PROP_LABEL,
                                   g_param_spec_string ("label",
-                                                       _("Label"),
-                                                       _("Text to show in the item."),
+                                                       P_("Label"),
+                                                       P_("Text to show in the item."),
                                                        NULL,
                                                        G_PARAM_READWRITE));
   g_object_class_install_property (object_class,
                                   PROP_USE_UNDERLINE,
                                   g_param_spec_boolean ("use_underline",
-                                                        _("Use underline"),
-                                                        _("If set, an underline in the label property indicates that the next character should be used for the mnemonic accelerator key in the overflow menu"),
+                                                        P_("Use underline"),
+                                                        P_("If set, an underline in the label property indicates that the next character should be used for the mnemonic accelerator key in the overflow menu"),
                                                         FALSE,
                                                         G_PARAM_READWRITE));
   g_object_class_install_property (object_class,
                                   PROP_LABEL_WIDGET,
                                   g_param_spec_object ("label_widget",
-                                                       _("Label widget"),
-                                                       _("Widget to use as the item label"),
+                                                       P_("Label widget"),
+                                                       P_("Widget to use as the item label"),
                                                        GTK_TYPE_WIDGET,
                                                        G_PARAM_READWRITE));
   g_object_class_install_property (object_class,
                                   PROP_STOCK_ID,
                                   g_param_spec_string ("stock_id",
-                                                       _("Stock Id"),
-                                                       _("The stock icon displayed on the item"),
+                                                       P_("Stock Id"),
+                                                       P_("The stock icon displayed on the item"),
                                                        NULL,
                                                        G_PARAM_READWRITE));
   g_object_class_install_property (object_class,
                                   PROP_ICON_WIDGET,
                                   g_param_spec_object ("icon_widget",
-                                                       _("Icon widget"),
-                                                       _("Icon widget to display in the item"),
+                                                       P_("Icon widget"),
+                                                       P_("Icon widget to display in the item"),
                                                        GTK_TYPE_WIDGET,
                                                        G_PARAM_READWRITE));
 
@@ -387,7 +388,8 @@ gtk_tool_button_construct_contents (GtkToolItem *tool_item)
 
     case GTK_TOOLBAR_BOTH_HORIZ:
       box = gtk_hbox_new (FALSE, 0);
-      gtk_box_pack_start (GTK_BOX (box), icon, label? FALSE : TRUE, TRUE, 0);
+      if (icon)
+       gtk_box_pack_start (GTK_BOX (box), icon, label? FALSE : TRUE, TRUE, 0);
       if (label)
        gtk_box_pack_start (GTK_BOX (box), label, TRUE, TRUE, 0);
       gtk_container_add (GTK_CONTAINER (button->priv->button), box);
@@ -441,8 +443,11 @@ static void
 gtk_tool_button_property_notify (GObject          *object,
                                 GParamSpec       *pspec)
 {
-  if (strcmp (pspec->name, "is_important"))
+  if (strcmp (pspec->name, "is-important") == 0)
     gtk_tool_button_construct_contents (GTK_TOOL_ITEM (object));
+
+  if (parent_class->notify)
+    parent_class->notify (object, pspec);
 }
 
 static void
@@ -837,8 +842,16 @@ gtk_tool_button_set_icon_widget (GtkToolButton *button,
   if (icon_widget != button->priv->icon_widget)
     {
       if (button->priv->icon_widget)
-       g_object_unref (G_OBJECT (button->priv->icon_widget));
+       {
+         if (button->priv->icon_widget->parent)
+           {
+             gtk_container_remove (GTK_CONTAINER (button->priv->icon_widget->parent),
+                                   button->priv->icon_widget);
+           }
 
+         g_object_unref (G_OBJECT (button->priv->icon_widget));
+       }
+      
       if (icon_widget)
        {
          g_object_ref (icon_widget);
@@ -876,8 +889,16 @@ gtk_tool_button_set_label_widget (GtkToolButton *button,
   if (label_widget != button->priv->label_widget)
     {
       if (button->priv->label_widget)
-       g_object_unref (button->priv->label_widget);
-
+       {
+         if (button->priv->icon_widget->parent)
+           {
+             gtk_container_remove (GTK_CONTAINER (button->priv->icon_widget->parent),
+                                   button->priv->icon_widget);
+           }
+         
+         g_object_unref (button->priv->label_widget);
+       }
+      
       if (label_widget)
        {
          g_object_ref (label_widget);