From fb1a906cb28bfcbf6e22794e9e871ad00b6b6060 Mon Sep 17 00:00:00 2001 From: Claudio Saavedra Date: Mon, 6 Oct 2008 13:44:25 +0000 Subject: [PATCH] 2008-10-06 Claudio Saavedra * examples/hildon-picker-button-multicolumn-example.c: (main): Use custom "done" button text. * src/hildon-picker-button.c: (hildon_picker_button_get_property), (hildon_picker_button_set_property), (hildon_picker_button_clicked), (hildon_picker_button_class_init), (hildon_picker_button_init), (+hildon_picker_button_get_done_button_text), (+hildon_picker_button_set_done_button_text): New methods to customize the "done" button label in the launched HildonPickerDialog. Also, make it a property. * src/hildon-picker-button.h: add the public API. --- ChangeLog | 16 +++++ .../hildon-picker-button-multicolumn-example.c | 3 + src/hildon-picker-button.c | 67 ++++++++++++++++++++ src/hildon-picker-button.h | 7 ++ 4 files changed, 93 insertions(+) diff --git a/ChangeLog b/ChangeLog index acdff68..d02c636 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,5 +1,21 @@ 2008-10-06 Claudio Saavedra + * examples/hildon-picker-button-multicolumn-example.c: + (main): Use custom "done" button text. + + * src/hildon-picker-button.c: (hildon_picker_button_get_property), + (hildon_picker_button_set_property), + (hildon_picker_button_clicked), (hildon_picker_button_class_init), + (hildon_picker_button_init), + (+hildon_picker_button_get_done_button_text), + (+hildon_picker_button_set_done_button_text): New methods to customize + the "done" button label in the launched HildonPickerDialog. Also, + make it a property. + + * src/hildon-picker-button.h: add the public API. + +2008-10-06 Claudio Saavedra + * src/hildon-date-selector.h: * src/hildon-picker-dialog.h: * src/hildon-time-selector.h: diff --git a/examples/hildon-picker-button-multicolumn-example.c b/examples/hildon-picker-button-multicolumn-example.c index 9c15435..4fa2d33 100644 --- a/examples/hildon-picker-button-multicolumn-example.c +++ b/examples/hildon-picker-button-multicolumn-example.c @@ -94,6 +94,9 @@ main (int argc, char **args) selector = create_touch_selector (); button = hildon_picker_button_new (HILDON_SIZE_AUTO, HILDON_BUTTON_ARRANGEMENT_VERTICAL); + hildon_picker_button_set_done_button_text (HILDON_PICKER_BUTTON (button), + "We are done"); + hildon_button_set_title (HILDON_BUTTON (button), "Protocol"); hildon_picker_button_set_selector (HILDON_PICKER_BUTTON (button), HILDON_TOUCH_SELECTOR (selector)); diff --git a/src/hildon-picker-button.c b/src/hildon-picker-button.c index 1901509..229dd33 100644 --- a/src/hildon-picker-button.c +++ b/src/hildon-picker-button.c @@ -46,6 +46,7 @@ struct _HildonPickerButtonPrivate { GtkWidget *selector; GtkWidget *dialog; + gchar *done_button_text; }; /* Signals */ @@ -58,6 +59,7 @@ enum enum { PROP_SELECTOR = 1, + PROP_DONE_BUTTON_TEXT }; static guint picker_button_signals[LAST_SIGNAL] = { 0 }; @@ -71,6 +73,10 @@ hildon_picker_button_get_property (GObject * object, guint property_id, g_value_set_object (value, hildon_picker_button_get_selector (HILDON_PICKER_BUTTON (object))); break; + case PROP_DONE_BUTTON_TEXT: + g_value_set_string (value, + hildon_picker_button_get_done_button_text (HILDON_PICKER_BUTTON (object))); + break; default: G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec); } @@ -85,6 +91,10 @@ hildon_picker_button_set_property (GObject * object, guint property_id, hildon_picker_button_set_selector (HILDON_PICKER_BUTTON (object), g_value_get_object (value)); break; + case PROP_DONE_BUTTON_TEXT: + hildon_picker_button_set_done_button_text (HILDON_PICKER_BUTTON (object), + g_value_get_string (value)); + break; default: G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec); } @@ -131,6 +141,10 @@ hildon_picker_button_clicked (GtkButton * button) hildon_picker_dialog_set_selector (HILDON_PICKER_DIALOG (priv->dialog), HILDON_TOUCH_SELECTOR (priv->selector)); + if (priv->done_button_text) { + hildon_picker_dialog_set_done_label (HILDON_PICKER_DIALOG (priv->dialog), + priv->done_button_text); + } gtk_window_set_modal (GTK_WINDOW (priv->dialog), gtk_window_get_modal (GTK_WINDOW (parent))); @@ -172,6 +186,13 @@ hildon_picker_button_class_init (HildonPickerButtonClass * klass) "HildonTouchSelector widget to be launched on button clicked", HILDON_TYPE_TOUCH_SELECTOR, G_PARAM_READWRITE)); + g_object_class_install_property (object_class, + PROP_DONE_BUTTON_TEXT, + g_param_spec_string ("done-button-text", + "HildonPickerDialog \"done\" button text", + "The text for the \"done\" button in the dialog launched", + NULL, + G_PARAM_READWRITE)); /** * HildonPickerButton::value-changed: @@ -198,6 +219,7 @@ hildon_picker_button_init (HildonPickerButton * self) priv->dialog = NULL; priv->selector = NULL; + priv->done_button_text = NULL; } /** @@ -322,3 +344,48 @@ hildon_picker_button_set_active (HildonPickerButton * button, hildon_button_set_value (HILDON_BUTTON (button), text); g_free (text); } + +/** + * hildon_picker_button_get_done_button_text: + * @button: a #HildonPickerButton + * + * Gets the text used in the #HildonPickerDialog that is launched by + * @button. If no custom text is set, then %NULL is returned. + * + * Returns: the custom string to be used, or %NULL if the default + * #HildonPickerDialog::done-button-text is to be used. + **/ +const gchar * +hildon_picker_button_get_done_button_text (HildonPickerButton *button) +{ + HildonPickerButtonPrivate *priv; + + g_return_val_if_fail (HILDON_IS_PICKER_BUTTON (button), NULL); + + priv = GET_PRIVATE (button); + + return priv->done_button_text; +} + +/** + * hildon_picker_button_set_done_button_text: + * @button: a #HildonPickerButton + * @done_button_text: a string + * + * Sets a custom string to be used in the \"done\" button in the #HildonPickerDialog + * launched. If not set, the default HildonPickerButton::done-button-text property + * value will be used. + **/ +void +hildon_picker_button_set_done_button_text (HildonPickerButton *button, + const gchar *done_button_text) +{ + HildonPickerButtonPrivate *priv; + + g_return_if_fail (HILDON_IS_PICKER_BUTTON (button)); + g_return_if_fail (done_button_text != NULL); + + priv = GET_PRIVATE (button); + + priv->done_button_text = done_button_text; +} diff --git a/src/hildon-picker-button.h b/src/hildon-picker-button.h index 0f48b09..9a5c63e 100644 --- a/src/hildon-picker-button.h +++ b/src/hildon-picker-button.h @@ -79,6 +79,13 @@ hildon_picker_button_set_active (HildonPickerButton * button, gint hildon_picker_button_get_active (HildonPickerButton * button); +const gchar * +hildon_picker_button_get_done_button_text (HildonPickerButton * button); + +void +hildon_picker_button_set_done_button_text (HildonPickerButton *button, + const gchar *done_button_text); + G_END_DECLS #endif /* __HILDON_PICKER_BUTTON__ */ -- 1.7.9.5