diff options
author | Chris Lumens <clumens@redhat.com> | 2012-09-12 14:18:03 -0400 |
---|---|---|
committer | Chris Lumens <clumens@redhat.com> | 2012-09-13 10:00:27 -0400 |
commit | 06d36a69d89f0db288a95ee65e802168c3382201 (patch) | |
tree | 631aef1c2484d2849d766693ca49df2040b66f45 /widgets | |
parent | 4c036d4e779cd14d6578c624dbce2bd621e995ee (diff) | |
download | anaconda-06d36a69d89f0db288a95ee65e802168c3382201.tar.gz anaconda-06d36a69d89f0db288a95ee65e802168c3382201.tar.xz anaconda-06d36a69d89f0db288a95ee65e802168c3382201.zip |
Add a property to SpokeWindow for setting the single button's label.
Diffstat (limited to 'widgets')
-rw-r--r-- | widgets/src/SpokeWindow.c | 60 |
1 files changed, 55 insertions, 5 deletions
diff --git a/widgets/src/SpokeWindow.c b/widgets/src/SpokeWindow.c index e39f5a103..6f4a6e3ee 100644 --- a/widgets/src/SpokeWindow.c +++ b/widgets/src/SpokeWindow.c @@ -40,29 +40,56 @@ */ enum { + PROP_BUTTON_LABEL = 1 +}; + +#define DEFAULT_BUTTON_LABEL _("Back") + +enum { SIGNAL_BUTTON_CLICKED, LAST_SIGNAL }; -#define DEFAULT_BUTTON_TEXT _("Back") - static guint window_signals[LAST_SIGNAL] = { 0 }; struct _AnacondaSpokeWindowPrivate { GtkWidget *button; }; +G_DEFINE_TYPE(AnacondaSpokeWindow, anaconda_spoke_window, ANACONDA_TYPE_BASE_WINDOW) + +static void anaconda_spoke_window_get_property(GObject *object, guint prop_id, GValue *value, GParamSpec *pspec); +static void anaconda_spoke_window_set_property(GObject *object, guint prop_id, const GValue *value, GParamSpec *pspec); + static void anaconda_spoke_window_button_clicked(GtkButton *button, AnacondaSpokeWindow *win); -G_DEFINE_TYPE(AnacondaSpokeWindow, anaconda_spoke_window, ANACONDA_TYPE_BASE_WINDOW) - static void anaconda_spoke_window_class_init(AnacondaSpokeWindowClass *klass) { GObjectClass *object_class = G_OBJECT_CLASS(klass); + object_class->set_property = anaconda_spoke_window_set_property; + object_class->get_property = anaconda_spoke_window_get_property; + klass->button_clicked = NULL; /** + * AnacondaSpokeWindow:button-label: + * + * The :button-label string is the text used to label the button displayed + * in the upper lefthand of the window. By default, this is a back button + * but could be anything else appropriate. + * + * Since: 1.0 + */ + g_object_class_install_property(object_class, + PROP_BUTTON_LABEL, + g_param_spec_string("button-label", + P_("Button Label"), + P_("Label to appear on the upper left button"), + DEFAULT_BUTTON_LABEL, + G_PARAM_READWRITE)); + + /** * AnacondaSpokeWindow::button-clicked: * @window: the window that received the signal * @@ -107,7 +134,7 @@ static void anaconda_spoke_window_init(AnacondaSpokeWindow *win) { gtk_window_set_modal(GTK_WINDOW(win), TRUE); /* Create the buttons. */ - win->priv->button = gtk_button_new_with_mnemonic(DEFAULT_BUTTON_TEXT); + win->priv->button = gtk_button_new_with_mnemonic(DEFAULT_BUTTON_LABEL); gtk_widget_set_halign(win->priv->button, GTK_ALIGN_START); /* Hook up some signals for that button. The signal handlers here will @@ -125,3 +152,26 @@ static void anaconda_spoke_window_button_clicked(GtkButton *button, AnacondaSpokeWindow *win) { g_signal_emit(win, window_signals[SIGNAL_BUTTON_CLICKED], 0); } + +static void anaconda_spoke_window_get_property(GObject *object, guint prop_id, GValue *value, GParamSpec *pspec) { + AnacondaSpokeWindow *widget = ANACONDA_SPOKE_WINDOW(object); + AnacondaSpokeWindowPrivate *priv = widget->priv; + + switch(prop_id) { + case PROP_BUTTON_LABEL: + g_value_set_string (value, gtk_button_get_label(GTK_BUTTON(priv->button))); + break; + } +} + +static void anaconda_spoke_window_set_property(GObject *object, guint prop_id, const GValue *value, GParamSpec *pspec) { + AnacondaSpokeWindow *widget = ANACONDA_SPOKE_WINDOW(object); + AnacondaSpokeWindowPrivate *priv = widget->priv; + + switch(prop_id) { + case PROP_BUTTON_LABEL: + gtk_button_set_label(GTK_BUTTON(priv->button), g_value_get_string(value)); + gtk_button_set_use_underline(GTK_BUTTON(priv->button), TRUE); + break; + } +} |