[gtk+] Add gtk_app_chooser_button_get/set_heading
- From: Matthias Clasen <matthiasc src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gtk+] Add gtk_app_chooser_button_get/set_heading
- Date: Tue, 25 Jan 2011 00:25:35 +0000 (UTC)
commit 9be8bbc9a076f0b8feb7c9690e798239c1bf293e
Author: Matthias Clasen <mclasen redhat com>
Date: Mon Jan 24 19:25:08 2011 -0500
Add gtk_app_chooser_button_get/set_heading
docs/reference/gtk/gtk3-sections.txt | 2 +
gtk/gtk.symbols | 2 +
gtk/gtkappchooserbutton.c | 62 ++++++++++++++++++++++++++++++++++
gtk/gtkappchooserbutton.h | 5 +++
gtk/gtkappchooserdialog.c | 3 +-
tests/testappchooserbutton.c | 1 +
6 files changed, 73 insertions(+), 2 deletions(-)
---
diff --git a/docs/reference/gtk/gtk3-sections.txt b/docs/reference/gtk/gtk3-sections.txt
index 585b044..5bc5498 100644
--- a/docs/reference/gtk/gtk3-sections.txt
+++ b/docs/reference/gtk/gtk3-sections.txt
@@ -6960,6 +6960,8 @@ gtk_app_chooser_button_append_separator
gtk_app_chooser_button_set_active_custom_item
gtk_app_chooser_button_get_show_dialog_item
gtk_app_chooser_button_set_show_dialog_item
+gtk_app_chooser_button_get_heading
+gtk_app_chooser_button_set_heading
<SUBSECTION Standard>
GtkAppChooserButtonClass
diff --git a/gtk/gtk.symbols b/gtk/gtk.symbols
index ada6a64..7070e3b 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 408b09e..3fe38b9 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 67fc5de..a5e9ed1 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 a722d47..181515d 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);
diff --git a/tests/testappchooserbutton.c b/tests/testappchooserbutton.c
index 0416af7..664a329 100644
--- a/tests/testappchooserbutton.c
+++ b/tests/testappchooserbutton.c
@@ -96,6 +96,7 @@ main (int argc,
sel_name = gtk_label_new (NULL);
gtk_box_pack_start (GTK_BOX (w), sel_name, TRUE, TRUE, 0);
+ gtk_app_chooser_button_set_heading (GTK_APP_CHOOSER_BUTTON (combobox), "Choose one, <i>not</i> two");
gtk_app_chooser_button_append_separator (GTK_APP_CHOOSER_BUTTON (combobox));
gtk_app_chooser_button_append_custom_item (GTK_APP_CHOOSER_BUTTON (combobox),
CUSTOM_ITEM,
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]