2009-04-14 Alberto Garcia <agarcia@igalia.com>
[hildon] / src / hildon-button.c
index de5f1ef..7123152 100644 (file)
@@ -31,9 +31,9 @@
  *
  * The #HildonButton can hold any valid child widget, but it usually
  * contains two labels, named title and value, and it can also contain
- * an image. The contents of the button are packed together and they
- * do not expand by default (they don't use the full space of the
- * button).
+ * an image. The contents of the button are packed together inside a
+ * #GtkAlignment and they do not expand by default (they don't use the
+ * full space of the button).
  *
  * To change the alignment of both labels, use gtk_button_set_alignment()
  *
@@ -243,7 +243,7 @@ hildon_button_class_init                        (HildonButtonClass *klass)
             "Title",
             "Text of the title label inside the button",
             NULL,
-            G_PARAM_READWRITE | G_PARAM_CONSTRUCT));
+            G_PARAM_READWRITE));
 
     g_object_class_install_property (
         gobject_class,
@@ -253,7 +253,7 @@ hildon_button_class_init                        (HildonButtonClass *klass)
             "Value",
             "Text of the value label inside the button",
             NULL,
-            G_PARAM_READWRITE | G_PARAM_CONSTRUCT));
+            G_PARAM_READWRITE));
 
     g_object_class_install_property (
         gobject_class,
@@ -327,6 +327,8 @@ hildon_button_init                              (HildonButton *self)
     gtk_widget_set_name (GTK_WIDGET (priv->title), "hildon-button-title");
     gtk_widget_set_name (GTK_WIDGET (priv->value), "hildon-button-value");
 
+    hildon_button_set_style (self, HILDON_BUTTON_STYLE_NORMAL);
+
     gtk_misc_set_alignment (GTK_MISC (priv->title), 0, 0.5);
     gtk_misc_set_alignment (GTK_MISC (priv->value), 0, 0.5);
 
@@ -345,6 +347,8 @@ hildon_button_init                              (HildonButton *self)
  * @size_group: A #GtkSizeGroup for the button title (main label)
  *
  * Adds the title label of @button to @size_group.
+ *
+ * Since: 2.2
  **/
 void
 hildon_button_add_title_size_group              (HildonButton *button,
@@ -366,6 +370,8 @@ hildon_button_add_title_size_group              (HildonButton *button,
  * @size_group: A #GtkSizeGroup for the button value (secondary label)
  *
  * Adds the value label of @button to @size_group.
+ *
+ * Since: 2.2
  **/
 void
 hildon_button_add_value_size_group              (HildonButton *button,
@@ -388,6 +394,8 @@ hildon_button_add_value_size_group              (HildonButton *button,
  *
  * Adds the image of @button to @size_group. You must add an image
  * using hildon_button_set_image() before calling this function.
+ *
+ * Since: 2.2
  **/
 void
 hildon_button_add_image_size_group              (HildonButton *button,
@@ -414,6 +422,8 @@ hildon_button_add_image_size_group              (HildonButton *button,
  *
  * Convenience function to add title, value and image to size
  * groups. %NULL size groups will be ignored.
+ *
+ * Since: 2.2
  **/
 void
 hildon_button_add_size_groups                   (HildonButton *button,
@@ -508,9 +518,9 @@ hildon_button_set_arrangement                   (HildonButton            *button
 
     /* If we pack both labels with (TRUE, TRUE) or (FALSE, FALSE) they
      * can be painted outside of the button in some situations, see
-     * NB#88126 */
-    gtk_box_pack_start (GTK_BOX (priv->label_box), GTK_WIDGET (priv->title), TRUE, TRUE, 0);
-    gtk_box_pack_start (GTK_BOX (priv->label_box), GTK_WIDGET (priv->value), FALSE, FALSE, 0);
+     * NB#88126 and NB#110689 */
+    gtk_box_pack_start (GTK_BOX (priv->label_box), GTK_WIDGET (priv->title), FALSE, FALSE, 0);
+    gtk_box_pack_start (GTK_BOX (priv->label_box), GTK_WIDGET (priv->value), TRUE, TRUE, 0);
 
     hildon_button_construct_child (button);
 }
@@ -564,7 +574,6 @@ hildon_button_set_title                         (HildonButton *button,
  * If @value is set to %NULL, the value label will be hidden and the
  * title label will be realigned.
  *
- *
  * Since: 2.2
  **/
 void
@@ -761,6 +770,11 @@ hildon_button_set_image_position                (HildonButton    *button,
  * to change @xscale or @yscale you can just use
  * gtk_button_set_alignment() instead.
  *
+ * Note that for this method to work properly the, child widget of
+ * @button must be a #GtkAlignment. That's what #HildonButton uses by
+ * default, so this function will work unless you add a custom widget
+ * to @button.
+ *
  * Since: 2.2
  **/
 void
@@ -779,9 +793,12 @@ hildon_button_set_alignment                     (HildonButton *button,
 
     child = gtk_bin_get_child (GTK_BIN (button));
 
+    /* If the button has no child, use priv->alignment, which is the default one */
+    if (child == NULL)
+        child = priv->alignment;
+
     if (GTK_IS_ALIGNMENT (child)) {
-        gtk_button_set_alignment (GTK_BUTTON (button), xalign, yalign);
-        g_object_set (child, "xscale", xscale, "yscale", yscale, NULL);
+        gtk_alignment_set (GTK_ALIGNMENT (priv->alignment), xalign, yalign, xscale, yscale);
     }
 }