X-Git-Url: https://vcs.maemo.org/git/?a=blobdiff_plain;f=src%2Fhildon-button.c;h=7123152459d85f13045aec0af5e2492b18af9d42;hb=4650768316a67ef6854cced8d6723f62a70ac0c5;hp=860d7548fd02430adb4b77a52e6febf995d70312;hpb=3e01c35cb8fc31655d51ac915f7739e3bd2381f6;p=hildon diff --git a/src/hildon-button.c b/src/hildon-button.c index 860d754..7123152 100644 --- a/src/hildon-button.c +++ b/src/hildon-button.c @@ -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); @@ -335,6 +337,8 @@ hildon_button_init (HildonButton *self) /* The labels are not shown automatically, see hildon_button_set_(title|value) */ gtk_widget_set_no_show_all (GTK_WIDGET (priv->title), TRUE); gtk_widget_set_no_show_all (GTK_WIDGET (priv->value), TRUE); + + gtk_button_set_focus_on_click (GTK_BUTTON (self), FALSE); } /** @@ -343,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, @@ -364,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, @@ -386,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, @@ -412,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, @@ -506,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); } @@ -562,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 @@ -759,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 @@ -777,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); } }