2 * gtkappchooserbutton.h: an app-chooser combobox
4 * Copyright (C) 2010 Red Hat, Inc.
6 * This library is free software; you can redistribute it and/or
7 * modify it under the terms of the GNU Library General Public License as
8 * published by the Free Software Foundation; either version 2 of the
9 * License, or (at your option) any later version.
11 * This library is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 * Library General Public License for more details.
16 * You should have received a copy of the GNU Library General Public
17 * License along with this library. If not, see <http://www.gnu.org/licenses/>.
19 * Authors: Cosimo Cecchi <ccecchi@redhat.com>
23 * SECTION:gtkappchooserbutton
24 * @Title: GtkAppChooserButton
25 * @Short_description: A button to launch an application chooser dialog
27 * The #GtkAppChooserButton is a widget that lets the user select
28 * an application. It implements the #GtkAppChooser interface.
30 * Initially, a #GtkAppChooserButton selects the first application
31 * in its list, which will either be the most-recently used application
32 * or, if #GtkAppChooserButton:show-default-item is %TRUE, the
33 * default application.
35 * The list of applications shown in a #GtkAppChooserButton includes
36 * the recommended applications for the given content type. When
37 * #GtkAppChooserButton:show-default-item is set, the default application
38 * is also included. To let the user chooser other applications,
39 * you can set the #GtkAppChooserButton:show-dialog-item property,
40 * which allows to open a full #GtkAppChooserDialog.
42 * It is possible to add custom items to the list, using
43 * gtk_app_chooser_button_append_custom_item(). These items cause
44 * the #GtkAppChooserButton::custom-item-activated signal to be
45 * emitted when they are selected.
47 * To track changes in the selected application, use the
48 * #GtkComboBox::changed signal.
52 #include "gtkappchooserbutton.h"
54 #include "gtkappchooser.h"
55 #include "gtkappchooserdialog.h"
56 #include "gtkappchooserprivate.h"
57 #include "gtkcelllayout.h"
58 #include "gtkcellrendererpixbuf.h"
59 #include "gtkcellrenderertext.h"
60 #include "gtkcombobox.h"
61 #include "gtkdialog.h"
63 #include "gtkmarshalers.h"
66 PROP_CONTENT_TYPE = 1,
67 PROP_SHOW_DIALOG_ITEM,
68 PROP_SHOW_DEFAULT_ITEM,
73 SIGNAL_CUSTOM_ITEM_ACTIVATED,
87 #define CUSTOM_ITEM_OTHER_APP "gtk-internal-item-other-app"
89 static void app_chooser_iface_init (GtkAppChooserIface *iface);
91 static void real_insert_custom_item (GtkAppChooserButton *self,
98 static void real_insert_separator (GtkAppChooserButton *self,
102 static guint signals[NUM_SIGNALS] = { 0, };
104 G_DEFINE_TYPE_WITH_CODE (GtkAppChooserButton, gtk_app_chooser_button, GTK_TYPE_COMBO_BOX,
105 G_IMPLEMENT_INTERFACE (GTK_TYPE_APP_CHOOSER,
106 app_chooser_iface_init));
108 struct _GtkAppChooserButtonPrivate {
114 gboolean show_dialog_item;
115 gboolean show_default_item;
117 GHashTable *custom_item_names;
121 row_separator_func (GtkTreeModel *model,
127 gtk_tree_model_get (model, iter,
128 COLUMN_SEPARATOR, &separator,
135 get_first_iter (GtkListStore *store,
140 if (!gtk_tree_model_get_iter_first (GTK_TREE_MODEL (store), iter))
142 /* the model is empty, append */
143 gtk_list_store_append (store, iter);
147 gtk_list_store_insert_before (store, &iter2, iter);
153 GtkAppChooserButton *self;
159 select_app_data_free (SelectAppData *data)
161 g_clear_object (&data->self);
162 g_clear_object (&data->info);
164 g_slice_free (SelectAppData, data);
168 select_application_func_cb (GtkTreeModel *model,
173 SelectAppData *data = user_data;
174 GAppInfo *app_to_match = data->info, *app = NULL;
178 gtk_tree_model_get (model, iter,
179 COLUMN_APP_INFO, &app,
180 COLUMN_CUSTOM, &custom,
183 /* custom items are always after GAppInfos, so iterating further here
188 else if (g_app_info_equal (app, app_to_match))
190 gtk_combo_box_set_active_iter (GTK_COMBO_BOX (data->self), iter);
196 g_object_unref (app);
202 gtk_app_chooser_button_select_application (GtkAppChooserButton *self,
207 data = g_slice_new0 (SelectAppData);
208 data->self = g_object_ref (self);
209 data->info = g_object_ref (info);
211 gtk_tree_model_foreach (GTK_TREE_MODEL (self->priv->store),
212 select_application_func_cb, data);
214 select_app_data_free (data);
218 other_application_dialog_response_cb (GtkDialog *dialog,
222 GtkAppChooserButton *self = user_data;
225 if (response_id != GTK_RESPONSE_OK)
227 /* reset the active item, otherwise we are stuck on
228 * 'Other application…'
230 gtk_combo_box_set_active (GTK_COMBO_BOX (self), self->priv->last_active);
231 gtk_widget_destroy (GTK_WIDGET (dialog));
235 info = gtk_app_chooser_get_app_info (GTK_APP_CHOOSER (dialog));
237 gtk_widget_destroy (GTK_WIDGET (dialog));
239 /* refresh the combobox to get the new application */
240 gtk_app_chooser_refresh (GTK_APP_CHOOSER (self));
241 gtk_app_chooser_button_select_application (self, info);
243 g_object_unref (info);
247 other_application_item_activated_cb (GtkAppChooserButton *self)
249 GtkWidget *dialog, *widget;
252 toplevel = GTK_WINDOW (gtk_widget_get_toplevel (GTK_WIDGET (self)));
253 dialog = gtk_app_chooser_dialog_new_for_content_type (toplevel, GTK_DIALOG_DESTROY_WITH_PARENT,
254 self->priv->content_type);
256 gtk_window_set_modal (GTK_WINDOW (dialog), gtk_window_get_modal (toplevel));
257 gtk_app_chooser_dialog_set_heading (GTK_APP_CHOOSER_DIALOG (dialog),
258 self->priv->heading);
260 widget = gtk_app_chooser_dialog_get_widget (GTK_APP_CHOOSER_DIALOG (dialog));
261 g_object_set (widget,
262 "show-fallback", TRUE,
265 gtk_widget_show (dialog);
267 g_signal_connect (dialog, "response",
268 G_CALLBACK (other_application_dialog_response_cb), self);
272 gtk_app_chooser_button_ensure_dialog_item (GtkAppChooserButton *self,
273 GtkTreeIter *prev_iter)
275 GtkTreeIter iter, iter2;
277 if (!self->priv->show_dialog_item || !self->priv->content_type)
280 if (prev_iter == NULL)
281 gtk_list_store_append (self->priv->store, &iter);
283 gtk_list_store_insert_after (self->priv->store, &iter, prev_iter);
285 real_insert_separator (self, FALSE, &iter);
288 gtk_list_store_insert_after (self->priv->store, &iter, &iter2);
289 real_insert_custom_item (self, CUSTOM_ITEM_OTHER_APP,
290 _("Other application…"), NULL,
295 insert_one_application (GtkAppChooserButton *self,
301 icon = g_app_info_get_icon (app);
304 icon = g_themed_icon_new ("application-x-executable");
308 gtk_list_store_set (self->priv->store, iter,
309 COLUMN_APP_INFO, app,
310 COLUMN_LABEL, g_app_info_get_name (app),
312 COLUMN_CUSTOM, FALSE,
315 g_object_unref (icon);
319 gtk_app_chooser_button_populate (GtkAppChooserButton *self)
321 GList *recommended_apps = NULL, *l;
322 GAppInfo *app, *default_app = NULL;
323 GtkTreeIter iter, iter2;
324 gboolean cycled_recommended;
327 if (self->priv->content_type)
328 recommended_apps = g_app_info_get_recommended_for_type (self->priv->content_type);
330 cycled_recommended = FALSE;
332 if (self->priv->show_default_item)
334 default_app = g_app_info_get_default_for_type (self->priv->content_type, FALSE);
336 if (default_app != NULL)
338 get_first_iter (self->priv->store, &iter);
339 cycled_recommended = TRUE;
341 insert_one_application (self, default_app, &iter);
343 g_object_unref (default_app);
347 for (l = recommended_apps; l != NULL; l = l->next)
351 if (default_app != NULL && g_app_info_equal (app, default_app))
354 if (cycled_recommended)
356 gtk_list_store_insert_after (self->priv->store, &iter2, &iter);
361 get_first_iter (self->priv->store, &iter);
362 cycled_recommended = TRUE;
365 insert_one_application (self, app, &iter);
368 if (recommended_apps != NULL)
369 g_list_free_full (recommended_apps, g_object_unref);
371 if (!cycled_recommended)
372 gtk_app_chooser_button_ensure_dialog_item (self, NULL);
374 gtk_app_chooser_button_ensure_dialog_item (self, &iter);
376 gtk_combo_box_set_active (GTK_COMBO_BOX (self), 0);
380 gtk_app_chooser_button_build_ui (GtkAppChooserButton *self)
382 GtkCellRenderer *cell;
385 gtk_combo_box_set_model (GTK_COMBO_BOX (self),
386 GTK_TREE_MODEL (self->priv->store));
388 area = gtk_cell_layout_get_area (GTK_CELL_LAYOUT (self));
390 gtk_combo_box_set_row_separator_func (GTK_COMBO_BOX (self),
391 row_separator_func, NULL, NULL);
393 cell = gtk_cell_renderer_pixbuf_new ();
394 gtk_cell_area_add_with_properties (area, cell,
399 gtk_cell_layout_set_attributes (GTK_CELL_LAYOUT (self), cell,
400 "gicon", COLUMN_ICON,
403 cell = gtk_cell_renderer_text_new ();
404 gtk_cell_area_add_with_properties (area, cell,
408 gtk_cell_layout_set_attributes (GTK_CELL_LAYOUT (self), cell,
409 "text", COLUMN_LABEL,
412 gtk_app_chooser_button_populate (self);
416 gtk_app_chooser_button_remove_non_custom (GtkAppChooserButton *self)
420 gboolean custom, res;
422 model = GTK_TREE_MODEL (self->priv->store);
424 if (!gtk_tree_model_get_iter_first (model, &iter))
428 gtk_tree_model_get (model, &iter,
429 COLUMN_CUSTOM, &custom,
432 res = gtk_tree_model_iter_next (model, &iter);
434 res = gtk_list_store_remove (GTK_LIST_STORE (model), &iter);
439 gtk_app_chooser_button_changed (GtkComboBox *object)
441 GtkAppChooserButton *self = GTK_APP_CHOOSER_BUTTON (object);
447 if (!gtk_combo_box_get_active_iter (object, &iter))
450 gtk_tree_model_get (GTK_TREE_MODEL (self->priv->store), &iter,
452 COLUMN_CUSTOM, &custom,
459 name_quark = g_quark_from_string (name);
460 g_signal_emit (self, signals[SIGNAL_CUSTOM_ITEM_ACTIVATED], name_quark, name);
461 self->priv->last_active = gtk_combo_box_get_active (object);
465 /* trigger the dialog internally */
466 other_application_item_activated_cb (self);
472 self->priv->last_active = gtk_combo_box_get_active (object);
476 gtk_app_chooser_button_refresh (GtkAppChooser *object)
478 GtkAppChooserButton *self = GTK_APP_CHOOSER_BUTTON (object);
480 gtk_app_chooser_button_remove_non_custom (self);
481 gtk_app_chooser_button_populate (self);
485 gtk_app_chooser_button_get_app_info (GtkAppChooser *object)
487 GtkAppChooserButton *self = GTK_APP_CHOOSER_BUTTON (object);
491 if (!gtk_combo_box_get_active_iter (GTK_COMBO_BOX (self), &iter))
494 gtk_tree_model_get (GTK_TREE_MODEL (self->priv->store), &iter,
495 COLUMN_APP_INFO, &info,
502 gtk_app_chooser_button_constructed (GObject *obj)
504 GtkAppChooserButton *self = GTK_APP_CHOOSER_BUTTON (obj);
506 if (G_OBJECT_CLASS (gtk_app_chooser_button_parent_class)->constructed != NULL)
507 G_OBJECT_CLASS (gtk_app_chooser_button_parent_class)->constructed (obj);
509 gtk_app_chooser_button_build_ui (self);
513 gtk_app_chooser_button_set_property (GObject *obj,
518 GtkAppChooserButton *self = GTK_APP_CHOOSER_BUTTON (obj);
522 case PROP_CONTENT_TYPE:
523 self->priv->content_type = g_value_dup_string (value);
525 case PROP_SHOW_DIALOG_ITEM:
526 gtk_app_chooser_button_set_show_dialog_item (self, g_value_get_boolean (value));
528 case PROP_SHOW_DEFAULT_ITEM:
529 gtk_app_chooser_button_set_show_default_item (self, g_value_get_boolean (value));
532 gtk_app_chooser_button_set_heading (self, g_value_get_string (value));
535 G_OBJECT_WARN_INVALID_PROPERTY_ID (obj, property_id, pspec);
541 gtk_app_chooser_button_get_property (GObject *obj,
546 GtkAppChooserButton *self = GTK_APP_CHOOSER_BUTTON (obj);
550 case PROP_CONTENT_TYPE:
551 g_value_set_string (value, self->priv->content_type);
553 case PROP_SHOW_DIALOG_ITEM:
554 g_value_set_boolean (value, self->priv->show_dialog_item);
556 case PROP_SHOW_DEFAULT_ITEM:
557 g_value_set_boolean (value, self->priv->show_default_item);
560 g_value_set_string (value, self->priv->heading);
563 G_OBJECT_WARN_INVALID_PROPERTY_ID (obj, property_id, pspec);
569 gtk_app_chooser_button_finalize (GObject *obj)
571 GtkAppChooserButton *self = GTK_APP_CHOOSER_BUTTON (obj);
573 g_hash_table_destroy (self->priv->custom_item_names);
574 g_free (self->priv->content_type);
575 g_free (self->priv->heading);
577 g_object_unref (self->priv->store);
579 G_OBJECT_CLASS (gtk_app_chooser_button_parent_class)->finalize (obj);
583 app_chooser_iface_init (GtkAppChooserIface *iface)
585 iface->get_app_info = gtk_app_chooser_button_get_app_info;
586 iface->refresh = gtk_app_chooser_button_refresh;
590 gtk_app_chooser_button_class_init (GtkAppChooserButtonClass *klass)
592 GObjectClass *oclass = G_OBJECT_CLASS (klass);
593 GtkComboBoxClass *combo_class = GTK_COMBO_BOX_CLASS (klass);
596 oclass->set_property = gtk_app_chooser_button_set_property;
597 oclass->get_property = gtk_app_chooser_button_get_property;
598 oclass->finalize = gtk_app_chooser_button_finalize;
599 oclass->constructed = gtk_app_chooser_button_constructed;
601 combo_class->changed = gtk_app_chooser_button_changed;
603 g_object_class_override_property (oclass, PROP_CONTENT_TYPE, "content-type");
606 * GtkAppChooserButton:show-dialog-item:
608 * The #GtkAppChooserButton:show-dialog-item property determines
609 * whether the dropdown menu should show an item that triggers
610 * a #GtkAppChooserDialog when clicked.
613 g_param_spec_boolean ("show-dialog-item",
614 P_("Include an 'Other…' item"),
615 P_("Whether the combobox should include an item that triggers a GtkAppChooserDialog"),
617 G_PARAM_READWRITE | G_PARAM_CONSTRUCT | G_PARAM_STATIC_STRINGS);
618 g_object_class_install_property (oclass, PROP_SHOW_DIALOG_ITEM, pspec);
621 * GtkAppChooserButton:show-default-item:
623 * The #GtkAppChooserButton:show-default-item property determines
624 * whether the dropdown menu should show the default application
625 * on top for the provided content type.
630 g_param_spec_boolean ("show-default-item",
631 P_("Show default item"),
632 P_("Whether the combobox should show the default application on top"),
634 G_PARAM_READWRITE | G_PARAM_CONSTRUCT | G_PARAM_STATIC_STRINGS);
635 g_object_class_install_property (oclass, PROP_SHOW_DEFAULT_ITEM, pspec);
639 * GtkAppChooserButton:heading:
641 * The text to show at the top of the dialog that can be
642 * opened from the button. The string may contain Pango markup.
644 pspec = g_param_spec_string ("heading",
646 P_("The text to show at the top of the dialog"),
648 G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS);
649 g_object_class_install_property (oclass, PROP_HEADING, pspec);
653 * GtkAppChooserButton::custom-item-activated:
654 * @self: the object which received the signal
655 * @item_name: the name of the activated item
657 * Emitted when a custom item, previously added with
658 * gtk_app_chooser_button_append_custom_item(), is activated from the
661 signals[SIGNAL_CUSTOM_ITEM_ACTIVATED] =
662 g_signal_new ("custom-item-activated",
663 GTK_TYPE_APP_CHOOSER_BUTTON,
664 G_SIGNAL_RUN_FIRST | G_SIGNAL_DETAILED,
665 G_STRUCT_OFFSET (GtkAppChooserButtonClass, custom_item_activated),
667 _gtk_marshal_VOID__STRING,
671 g_type_class_add_private (klass, sizeof (GtkAppChooserButtonPrivate));
675 gtk_app_chooser_button_init (GtkAppChooserButton *self)
677 self->priv = G_TYPE_INSTANCE_GET_PRIVATE (self, GTK_TYPE_APP_CHOOSER_BUTTON,
678 GtkAppChooserButtonPrivate);
679 self->priv->custom_item_names =
680 g_hash_table_new_full (g_str_hash, g_str_equal,
683 self->priv->store = gtk_list_store_new (NUM_COLUMNS,
685 G_TYPE_STRING, /* name */
686 G_TYPE_STRING, /* label */
688 G_TYPE_BOOLEAN, /* separator */
689 G_TYPE_BOOLEAN); /* custom */
693 app_chooser_button_iter_from_custom_name (GtkAppChooserButton *self,
698 gchar *custom_name = NULL;
700 if (!gtk_tree_model_get_iter_first
701 (GTK_TREE_MODEL (self->priv->store), &iter))
705 gtk_tree_model_get (GTK_TREE_MODEL (self->priv->store), &iter,
706 COLUMN_NAME, &custom_name,
709 if (g_strcmp0 (custom_name, name) == 0)
711 g_free (custom_name);
717 g_free (custom_name);
718 } while (gtk_tree_model_iter_next (GTK_TREE_MODEL (self->priv->store), &iter));
724 real_insert_custom_item (GtkAppChooserButton *self,
733 if (g_hash_table_lookup (self->priv->custom_item_names,
736 g_warning ("Attempting to add custom item %s to GtkAppChooserButton, "
737 "when there's already an item with the same name", name);
741 g_hash_table_insert (self->priv->custom_item_names,
742 g_strdup (name), GINT_TO_POINTER (1));
745 gtk_list_store_set (self->priv->store, iter,
749 COLUMN_CUSTOM, custom,
750 COLUMN_SEPARATOR, FALSE,
755 real_insert_separator (GtkAppChooserButton *self,
759 gtk_list_store_set (self->priv->store, iter,
760 COLUMN_CUSTOM, custom,
761 COLUMN_SEPARATOR, TRUE,
766 * gtk_app_chooser_button_new:
767 * @content_type: the content type to show applications for
769 * Creates a new #GtkAppChooserButton for applications
770 * that can handle content of the given type.
772 * Returns: a newly created #GtkAppChooserButton
777 gtk_app_chooser_button_new (const gchar *content_type)
779 g_return_val_if_fail (content_type != NULL, NULL);
781 return g_object_new (GTK_TYPE_APP_CHOOSER_BUTTON,
782 "content-type", content_type,
787 * gtk_app_chooser_button_append_separator:
788 * @self: a #GtkAppChooserButton
790 * Appends a separator to the list of applications that is shown
796 gtk_app_chooser_button_append_separator (GtkAppChooserButton *self)
800 g_return_if_fail (GTK_IS_APP_CHOOSER_BUTTON (self));
802 gtk_list_store_append (self->priv->store, &iter);
803 real_insert_separator (self, TRUE, &iter);
807 * gtk_app_chooser_button_append_custom_item:
808 * @self: a #GtkAppChooserButton
809 * @name: the name of the custom item
810 * @label: the label for the custom item
811 * @icon: the icon for the custom item
813 * Appends a custom item to the list of applications that is shown
814 * in the popup; the item name must be unique per-widget.
815 * Clients can use the provided name as a detail for the
816 * #GtkAppChooserButton::custom-item-activated signal, to add a
817 * callback for the activation of a particular custom item in the list.
818 * See also gtk_app_chooser_button_append_separator().
823 gtk_app_chooser_button_append_custom_item (GtkAppChooserButton *self,
830 g_return_if_fail (GTK_IS_APP_CHOOSER_BUTTON (self));
831 g_return_if_fail (name != NULL);
833 gtk_list_store_append (self->priv->store, &iter);
834 real_insert_custom_item (self, name, label, icon, TRUE, &iter);
838 * gtk_app_chooser_button_set_active_custom_item:
839 * @self: a #GtkAppChooserButton
840 * @name: the name of the custom item
842 * Selects a custom item previously added with
843 * gtk_app_chooser_button_append_custom_item().
845 * Use gtk_app_chooser_refresh() to bring the selection
846 * to its initial state.
851 gtk_app_chooser_button_set_active_custom_item (GtkAppChooserButton *self,
856 g_return_if_fail (GTK_IS_APP_CHOOSER_BUTTON (self));
857 g_return_if_fail (name != NULL);
859 if (g_hash_table_lookup (self->priv->custom_item_names, name) == NULL ||
860 !app_chooser_button_iter_from_custom_name (self, name, &iter))
862 g_warning ("Can't find the item named %s in the app chooser.",
867 gtk_combo_box_set_active_iter (GTK_COMBO_BOX (self), &iter);
871 * gtk_app_chooser_button_get_show_dialog_item:
872 * @self: a #GtkAppChooserButton
874 * Returns the current value of the #GtkAppChooserButton:show-dialog-item
877 * Returns: the value of #GtkAppChooserButton:show-dialog-item
882 gtk_app_chooser_button_get_show_dialog_item (GtkAppChooserButton *self)
884 g_return_val_if_fail (GTK_IS_APP_CHOOSER_BUTTON (self), FALSE);
886 return self->priv->show_dialog_item;
890 * gtk_app_chooser_button_set_show_dialog_item:
891 * @self: a #GtkAppChooserButton
892 * @setting: the new value for #GtkAppChooserButton:show-dialog-item
894 * Sets whether the dropdown menu of this button should show an
895 * entry to trigger a #GtkAppChooserDialog.
900 gtk_app_chooser_button_set_show_dialog_item (GtkAppChooserButton *self,
903 if (self->priv->show_dialog_item != setting)
905 self->priv->show_dialog_item = setting;
907 g_object_notify (G_OBJECT (self), "show-dialog-item");
909 gtk_app_chooser_refresh (GTK_APP_CHOOSER (self));
914 * gtk_app_chooser_button_get_show_default_item:
915 * @self: a #GtkAppChooserButton
917 * Returns the current value of the #GtkAppChooserButton:show-default-item
920 * Returns: the value of #GtkAppChooserButton:show-default-item
925 gtk_app_chooser_button_get_show_default_item (GtkAppChooserButton *self)
927 g_return_val_if_fail (GTK_IS_APP_CHOOSER_BUTTON (self), FALSE);
929 return self->priv->show_default_item;
933 * gtk_app_chooser_button_set_show_default_item:
934 * @self: a #GtkAppChooserButton
935 * @setting: the new value for #GtkAppChooserButton:show-default-item
937 * Sets whether the dropdown menu of this button should show the
938 * default application for the given content type at top.
943 gtk_app_chooser_button_set_show_default_item (GtkAppChooserButton *self,
946 if (self->priv->show_default_item != setting)
948 self->priv->show_default_item = setting;
950 g_object_notify (G_OBJECT (self), "show-default-item");
952 gtk_app_chooser_refresh (GTK_APP_CHOOSER (self));
957 * gtk_app_chooser_button_set_heading:
958 * @self: a #GtkAppChooserButton
959 * @heading: a string containing Pango markup
961 * Sets the text to display at the top of the dialog.
962 * If the heading is not set, the dialog displays a default text.
965 gtk_app_chooser_button_set_heading (GtkAppChooserButton *self,
966 const gchar *heading)
968 g_return_if_fail (GTK_IS_APP_CHOOSER_BUTTON (self));
970 g_free (self->priv->heading);
971 self->priv->heading = g_strdup (heading);
973 g_object_notify (G_OBJECT (self), "heading");
977 * gtk_app_chooser_button_get_heading:
978 * @self: a #GtkAppChooserButton
980 * Returns the text to display at the top of the dialog.
982 * Returns: the text to display at the top of the dialog,
983 * or %NULL, in which case a default text is displayed
986 gtk_app_chooser_button_get_heading (GtkAppChooserButton *self)
988 g_return_val_if_fail (GTK_IS_APP_CHOOSER_BUTTON (self), NULL);
990 return self->priv->heading;