]> Pileus Git - ~andy/gtk/commitdiff
Add gtk_app_chooser_button_get/set_heading
authorMatthias Clasen <mclasen@redhat.com>
Tue, 25 Jan 2011 00:25:08 +0000 (19:25 -0500)
committerMatthias Clasen <mclasen@redhat.com>
Tue, 25 Jan 2011 00:25:08 +0000 (19:25 -0500)
docs/reference/gtk/gtk3-sections.txt
gtk/gtk.symbols
gtk/gtkappchooserbutton.c
gtk/gtkappchooserbutton.h
gtk/gtkappchooserdialog.c
tests/testappchooserbutton.c

index 585b044c67fd2ae3360c437893fdb97f368a2f49..5bc549854839151c9af1c947492605709be0c7a4 100644 (file)
@@ -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
index ada6a645593a4a066ff15813c70e41fa0f6f14d6..7070e3b988e81e89de587e8388b847b7d645777a 100644 (file)
@@ -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
index 408b09eb5330be9ce7ef74cad1adefb6928654e4..3fe38b95df5d8ea0d0f8f8fab17bc0fb01ec27e7 100644 (file)
@@ -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);
 }
@@ -550,6 +561,20 @@ gtk_app_chooser_button_class_init (GtkAppChooserButtonClass *klass)
                           G_PARAM_READWRITE | G_PARAM_CONSTRUCT | G_PARAM_STATIC_STRINGS);
   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
@@ -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;
+}
index 67fc5de5d5785d0c40fa071d5062d37f0ffe5504..a5e9ed151cab81a5037a93a58b3f36a0604c0f3c 100644 (file)
@@ -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__ */
index a722d472061867401e64a61b6128c6789f567087..181515d7ec5135e72ad082112c12aba0ad6f898f 100644 (file)
@@ -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);
index 0416af72c56e9f8b1b8b4d630d15e4a3b8523d1d..664a3291d243b384707ba212b407f6fccd0f61c2 100644 (file)
@@ -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,