diff options
author | Matthias Clasen <mclasen@redhat.com> | 2011-01-24 19:25:08 -0500 |
---|---|---|
committer | Matthias Clasen <mclasen@redhat.com> | 2011-01-24 19:25:08 -0500 |
commit | 9be8bbc9a076f0b8feb7c9690e798239c1bf293e (patch) | |
tree | 5a115efaeaca6623174a571f5a687743b9ae0b35 /gtk | |
parent | 8fdd8dbc3517b8b002714a2bfa19b2b060da3d05 (diff) | |
download | gtk+-9be8bbc9a076f0b8feb7c9690e798239c1bf293e.tar.gz |
Add gtk_app_chooser_button_get/set_heading
Diffstat (limited to 'gtk')
-rw-r--r-- | gtk/gtk.symbols | 2 | ||||
-rw-r--r-- | gtk/gtkappchooserbutton.c | 62 | ||||
-rw-r--r-- | gtk/gtkappchooserbutton.h | 5 | ||||
-rw-r--r-- | gtk/gtkappchooserdialog.c | 3 |
4 files changed, 70 insertions, 2 deletions
diff --git a/gtk/gtk.symbols b/gtk/gtk.symbols index ada6a64559..7070e3b988 100644 --- a/gtk/gtk.symbols +++ b/gtk/gtk.symbols @@ -189,6 +189,8 @@ gtk_app_chooser_button_get_type G_GNUC_CONST; gtk_app_chooser_button_new gtk_app_chooser_button_set_active_custom_item gtk_app_chooser_button_set_show_dialog_item +gtk_app_chooser_button_get_heading +gtk_app_chooser_button_set_heading gtk_app_chooser_dialog_new gtk_app_chooser_dialog_new_for_content_type gtk_app_chooser_dialog_get_type G_GNUC_CONST diff --git a/gtk/gtkappchooserbutton.c b/gtk/gtkappchooserbutton.c index 408b09eb53..3fe38b95df 100644 --- a/gtk/gtkappchooserbutton.c +++ b/gtk/gtkappchooserbutton.c @@ -47,6 +47,7 @@ enum { PROP_CONTENT_TYPE = 1, PROP_SHOW_DIALOG_ITEM, + PROP_HEADING }; enum { @@ -91,6 +92,7 @@ struct _GtkAppChooserButtonPrivate { int last_active; gchar *content_type; gboolean show_dialog_item; + gchar *heading; GHashTable *custom_item_names; }; @@ -226,6 +228,8 @@ other_application_item_activated_cb (GtkAppChooserButton *self) self->priv->content_type); gtk_window_set_modal (GTK_WINDOW (dialog), gtk_window_get_modal (toplevel)); + gtk_app_chooser_dialog_set_heading (GTK_APP_CHOOSER_DIALOG (dialog), + self->priv->heading); widget = gtk_app_chooser_dialog_get_widget (GTK_APP_CHOOSER_DIALOG (dialog)); g_object_set (widget, @@ -474,6 +478,9 @@ gtk_app_chooser_button_set_property (GObject *obj, case PROP_SHOW_DIALOG_ITEM: gtk_app_chooser_button_set_show_dialog_item (self, g_value_get_boolean (value)); break; + case PROP_HEADING: + gtk_app_chooser_button_set_heading (self, g_value_get_string (value)); + break; default: G_OBJECT_WARN_INVALID_PROPERTY_ID (obj, property_id, pspec); break; @@ -496,6 +503,9 @@ gtk_app_chooser_button_get_property (GObject *obj, case PROP_SHOW_DIALOG_ITEM: g_value_set_boolean (value, self->priv->show_dialog_item); break; + case PROP_HEADING: + g_value_set_string (value, self->priv->heading); + break; default: G_OBJECT_WARN_INVALID_PROPERTY_ID (obj, property_id, pspec); break; @@ -509,6 +519,7 @@ gtk_app_chooser_button_finalize (GObject *obj) g_hash_table_destroy (self->priv->custom_item_names); g_free (self->priv->content_type); + g_free (self->priv->heading); G_OBJECT_CLASS (gtk_app_chooser_button_parent_class)->finalize (obj); } @@ -551,6 +562,20 @@ gtk_app_chooser_button_class_init (GtkAppChooserButtonClass *klass) g_object_class_install_property (oclass, PROP_SHOW_DIALOG_ITEM, pspec); /** + * GtkAppChooserButton:heading: + * + * The text to show at the top of the dialog that can be + * opened from the button. The string may contain Pango markup. + */ + pspec = g_param_spec_string ("heading", + P_("Heading"), + P_("The text to show at the top of the dialog"), + NULL, + G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS); + g_object_class_install_property (oclass, PROP_HEADING, pspec); + + + /** * GtkAppChooserButton::custom-item-activated: * @self: the object which received the signal * @item_name: the name of the activated item @@ -801,3 +826,40 @@ gtk_app_chooser_button_set_show_dialog_item (GtkAppChooserButton *self, gtk_app_chooser_refresh (GTK_APP_CHOOSER (self)); } } + +/** + * gtk_app_chooser_button_set_heading: + * @self: a #GtkAppChooserButton + * @heading: a string containing Pango markup + * + * Sets the text to display at the top of the dialog. + * If the heading is not set, the dialog displays a default text. + */ +void +gtk_app_chooser_button_set_heading (GtkAppChooserButton *self, + const gchar *heading) +{ + g_return_if_fail (GTK_IS_APP_CHOOSER_BUTTON (self)); + + g_free (self->priv->heading); + self->priv->heading = g_strdup (heading); + + g_object_notify (G_OBJECT (self), "heading"); +} + +/** + * gtk_app_chooser_button_get_heading: + * @self: a #GtkAppChooserButton + * + * Returns the text to display at the top of the dialog. + * + * Returns: the text to display at the top of the dialog, or %NULL, in which + * case a default text is displayed + */ +const gchar * +gtk_app_chooser_button_get_heading (GtkAppChooserButton *self) +{ + g_return_val_if_fail (GTK_IS_APP_CHOOSER_BUTTON (self), NULL); + + return self->priv->heading; +} diff --git a/gtk/gtkappchooserbutton.h b/gtk/gtkappchooserbutton.h index 67fc5de5d5..a5e9ed151c 100644 --- a/gtk/gtkappchooserbutton.h +++ b/gtk/gtkappchooserbutton.h @@ -74,5 +74,10 @@ void gtk_app_chooser_button_set_active_custom_item (GtkAppChooserButton *sel void gtk_app_chooser_button_set_show_dialog_item (GtkAppChooserButton *self, gboolean setting); gboolean gtk_app_chooser_button_get_show_dialog_item (GtkAppChooserButton *self); +void gtk_app_chooser_button_set_heading (GtkAppChooserButton *self, + const gchar *heading); +const gchar * + gtk_app_chooser_button_get_heading (GtkAppChooserButton *self); + #endif /* __GTK_APP_CHOOSER_BUTTON_H__ */ diff --git a/gtk/gtkappchooserdialog.c b/gtk/gtkappchooserdialog.c index a722d47206..181515d7ec 100644 --- a/gtk/gtkappchooserdialog.c +++ b/gtk/gtkappchooserdialog.c @@ -81,8 +81,7 @@ struct _GtkAppChooserDialogPrivate { enum { PROP_GFILE = 1, PROP_CONTENT_TYPE, - PROP_HEADING, - N_PROPERTIES + PROP_HEADING }; static void gtk_app_chooser_dialog_iface_init (GtkAppChooserIface *iface); |