]> Pileus Git - ~andy/gtk/commitdiff
Fix #136614 in a better way:
authorMatthias Clasen <maclas@gmx.de>
Wed, 10 Mar 2004 00:46:51 +0000 (00:46 +0000)
committerMatthias Clasen <matthiasc@src.gnome.org>
Wed, 10 Mar 2004 00:46:51 +0000 (00:46 +0000)
Wed Mar 10 01:49:27 2004  Matthias Clasen  <maclas@gmx.de>

Fix #136614 in a better way:

* gtk/gtkoptionmenu.c (gtk_option_menu_init): Undo the last change.
* gtk/gtkbutton.c (struct _GtkButtonPrivate): Add a flag, align_set.
* gtk/gtkbutton.c (gtk_button_init): Initialize align_set to 0.
* gtk/gtkbutton.c (maybe_set_alignment): Rework to only set the
alignment if priv->align_set is set.
* gtk/gtkbutton.c (gtk_button_set_alignment): Set align_set to 1.

ChangeLog
ChangeLog.pre-2-10
ChangeLog.pre-2-4
ChangeLog.pre-2-6
ChangeLog.pre-2-8
gtk/gtkbutton.c
gtk/gtkoptionmenu.c

index 16e674d6622a414008d49fa6111f3fbfcf657f77..7262510d8a1e4b0b36a1701218e3f30530dd4ded 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,14 @@
+Wed Mar 10 01:49:27 2004  Matthias Clasen  <maclas@gmx.de>
+
+       Fix #136614 in a better way:
+       
+       * gtk/gtkoptionmenu.c (gtk_option_menu_init): Undo the last change.
+       * gtk/gtkbutton.c (struct _GtkButtonPrivate): Add a flag, align_set.
+       * gtk/gtkbutton.c (gtk_button_init): Initialize align_set to 0.
+       * gtk/gtkbutton.c (maybe_set_alignment): Rework to only set the
+       alignment if priv->align_set is set.
+       * gtk/gtkbutton.c (gtk_button_set_alignment): Set align_set to 1.
+
 Wed Mar 10 01:21:05 2004  Matthias Clasen  <maclas@gmx.de>
 
        * gtk/gtkcombobox.c (gtk_combo_box_menu_position_below): Place
index 16e674d6622a414008d49fa6111f3fbfcf657f77..7262510d8a1e4b0b36a1701218e3f30530dd4ded 100644 (file)
@@ -1,3 +1,14 @@
+Wed Mar 10 01:49:27 2004  Matthias Clasen  <maclas@gmx.de>
+
+       Fix #136614 in a better way:
+       
+       * gtk/gtkoptionmenu.c (gtk_option_menu_init): Undo the last change.
+       * gtk/gtkbutton.c (struct _GtkButtonPrivate): Add a flag, align_set.
+       * gtk/gtkbutton.c (gtk_button_init): Initialize align_set to 0.
+       * gtk/gtkbutton.c (maybe_set_alignment): Rework to only set the
+       alignment if priv->align_set is set.
+       * gtk/gtkbutton.c (gtk_button_set_alignment): Set align_set to 1.
+
 Wed Mar 10 01:21:05 2004  Matthias Clasen  <maclas@gmx.de>
 
        * gtk/gtkcombobox.c (gtk_combo_box_menu_position_below): Place
index 16e674d6622a414008d49fa6111f3fbfcf657f77..7262510d8a1e4b0b36a1701218e3f30530dd4ded 100644 (file)
@@ -1,3 +1,14 @@
+Wed Mar 10 01:49:27 2004  Matthias Clasen  <maclas@gmx.de>
+
+       Fix #136614 in a better way:
+       
+       * gtk/gtkoptionmenu.c (gtk_option_menu_init): Undo the last change.
+       * gtk/gtkbutton.c (struct _GtkButtonPrivate): Add a flag, align_set.
+       * gtk/gtkbutton.c (gtk_button_init): Initialize align_set to 0.
+       * gtk/gtkbutton.c (maybe_set_alignment): Rework to only set the
+       alignment if priv->align_set is set.
+       * gtk/gtkbutton.c (gtk_button_set_alignment): Set align_set to 1.
+
 Wed Mar 10 01:21:05 2004  Matthias Clasen  <maclas@gmx.de>
 
        * gtk/gtkcombobox.c (gtk_combo_box_menu_position_below): Place
index 16e674d6622a414008d49fa6111f3fbfcf657f77..7262510d8a1e4b0b36a1701218e3f30530dd4ded 100644 (file)
@@ -1,3 +1,14 @@
+Wed Mar 10 01:49:27 2004  Matthias Clasen  <maclas@gmx.de>
+
+       Fix #136614 in a better way:
+       
+       * gtk/gtkoptionmenu.c (gtk_option_menu_init): Undo the last change.
+       * gtk/gtkbutton.c (struct _GtkButtonPrivate): Add a flag, align_set.
+       * gtk/gtkbutton.c (gtk_button_init): Initialize align_set to 0.
+       * gtk/gtkbutton.c (maybe_set_alignment): Rework to only set the
+       alignment if priv->align_set is set.
+       * gtk/gtkbutton.c (gtk_button_set_alignment): Set align_set to 1.
+
 Wed Mar 10 01:21:05 2004  Matthias Clasen  <maclas@gmx.de>
 
        * gtk/gtkcombobox.c (gtk_combo_box_menu_position_below): Place
index 16e674d6622a414008d49fa6111f3fbfcf657f77..7262510d8a1e4b0b36a1701218e3f30530dd4ded 100644 (file)
@@ -1,3 +1,14 @@
+Wed Mar 10 01:49:27 2004  Matthias Clasen  <maclas@gmx.de>
+
+       Fix #136614 in a better way:
+       
+       * gtk/gtkoptionmenu.c (gtk_option_menu_init): Undo the last change.
+       * gtk/gtkbutton.c (struct _GtkButtonPrivate): Add a flag, align_set.
+       * gtk/gtkbutton.c (gtk_button_init): Initialize align_set to 0.
+       * gtk/gtkbutton.c (maybe_set_alignment): Rework to only set the
+       alignment if priv->align_set is set.
+       * gtk/gtkbutton.c (gtk_button_set_alignment): Set align_set to 1.
+
 Wed Mar 10 01:21:05 2004  Matthias Clasen  <maclas@gmx.de>
 
        * gtk/gtkcombobox.c (gtk_combo_box_menu_position_below): Place
index 4136445fb774fc692d4b8281e871a40faba6728d..178513dbd4c378a3437147c78237e53382edc657 100644 (file)
@@ -78,6 +78,7 @@ struct _GtkButtonPrivate
   GtkSettings *settings;
   guint        show_image_connection;
   GtkWidget   *image;
+  guint        align_set : 1;
 };
 
 static void gtk_button_class_init     (GtkButtonClass   *klass);
@@ -404,6 +405,7 @@ gtk_button_init (GtkButton *button)
 
   priv->xalign = 0.5;
   priv->yalign = 0.5;
+  priv->align_set = 0;
 }
 
 static void
@@ -452,19 +454,25 @@ gtk_button_child_type  (GtkContainer     *container)
 }
 
 static void
-maybe_set_alignment (GtkWidget *widget,
-                    gfloat     xalign,
-                    gfloat     yalign)
+maybe_set_alignment (GtkButton *button,
+                    GtkWidget *widget)
 {
+  GtkButtonPrivate *priv = GTK_BUTTON_GET_PRIVATE (button);
+
   if (GTK_IS_MISC (widget))
     {
       GtkMisc *misc = GTK_MISC (widget);
-      gtk_misc_set_alignment (misc, xalign, yalign);
+      
+      if (priv->align_set)
+       gtk_misc_set_alignment (misc, priv->xalign, priv->yalign);
     }
   else if (GTK_IS_ALIGNMENT (widget))
     {
       GtkAlignment *alignment = GTK_ALIGNMENT (widget);
-      gtk_alignment_set (alignment, xalign, yalign, alignment->xscale, alignment->yscale);
+
+      if (priv->align_set)
+       gtk_alignment_set (alignment, priv->xalign, priv->yalign, 
+                          alignment->xscale, alignment->yscale);
     }
 }
 
@@ -472,10 +480,8 @@ static void
 gtk_button_add (GtkContainer *container,
                GtkWidget    *widget)
 {
-  GtkButton *button = GTK_BUTTON (container);
-  GtkButtonPrivate *priv = GTK_BUTTON_GET_PRIVATE (button);
+  maybe_set_alignment (GTK_BUTTON (container), widget);
 
-  maybe_set_alignment (widget, priv->xalign, priv->yalign);
   GTK_CONTAINER_CLASS (parent_class)->add (container, widget);
 }
 
@@ -608,8 +614,11 @@ gtk_button_construct_child (GtkButton *button)
                    NULL);
       hbox = gtk_hbox_new (FALSE, 2);
 
-      align = gtk_alignment_new (priv->xalign, priv->yalign, 0.0, 0.0);
-      
+      if (priv->align_set)
+       align = gtk_alignment_new (priv->xalign, priv->yalign, 0.0, 0.0);
+      else
+       align = gtk_alignment_new (0.5, 0.5, 0.0, 0.0);
+       
       gtk_box_pack_start (GTK_BOX (hbox), priv->image, FALSE, FALSE, 0);
       gtk_box_pack_end (GTK_BOX (hbox), label, FALSE, FALSE, 0);
       
@@ -628,7 +637,8 @@ gtk_button_construct_child (GtkButton *button)
   else
     label = gtk_label_new (button->label_text);
   
-  gtk_misc_set_alignment (GTK_MISC (label), priv->xalign, priv->yalign);
+  if (priv->align_set)
+    gtk_misc_set_alignment (GTK_MISC (label), priv->xalign, priv->yalign);
 
   gtk_widget_show (label);
   gtk_container_add (GTK_CONTAINER (button), label);
@@ -1465,8 +1475,9 @@ gtk_button_set_alignment (GtkButton *button,
 
   priv->xalign = xalign;
   priv->yalign = yalign;
+  priv->align_set = 1;
 
-  maybe_set_alignment (GTK_BIN (button)->child, xalign, yalign);
+  maybe_set_alignment (button, GTK_BIN (button)->child);
 
   g_object_freeze_notify (G_OBJECT (button));
   g_object_notify (G_OBJECT (button), "xalign");
index c13b9a2f17953d5f29aab541cdb6cd2a9d4af04d..75bef4edb921d7567241e260ac0327599fff3e51 100644 (file)
@@ -225,12 +225,6 @@ gtk_option_menu_init (GtkOptionMenu *option_menu)
   option_menu->menu_item = NULL;
   option_menu->width = 0;
   option_menu->height = 0;
-  /*
-   * Avoid centering the label that is reparented from the menuitem.
-   * Since gobject doesn't support overriding default values of
-   * properties in a convenient way yet, we simply set the value here.
-   */
-  gtk_button_set_alignment (GTK_BUTTON (option_menu), 0.0, 0.5);
 }
 
 GtkWidget*