Commit 9be8bbc9 authored by Matthias Clasen's avatar Matthias Clasen

Add gtk_app_chooser_button_get/set_heading

parent 8fdd8dbc
......@@ -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
......
......@@ -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
......
......@@ -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;
}
......@@ -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__ */
......@@ -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);
......
......@@ -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,
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment