GtkAppChooserButton: Add a way to include the default app

This is necessary to use an app chooser button for selecting
default apps in the control center. Also, beef up the docs
for this widget family.

https://bugzilla.gnome.org/show_bug.cgi?id=642706
This commit is contained in:
Matthias Clasen
2011-09-10 01:40:05 -04:00
parent e97ed4374f
commit f9379adca2
9 changed files with 215 additions and 43 deletions

View File

@ -26,7 +26,7 @@ static GFile *file;
static GtkWidget *grid, *file_l, *open;
static GtkWidget *radio_file, *radio_content, *dialog;
static GtkWidget *app_chooser_widget;
static GtkWidget *recommended, *fallback, *other, *all;
static GtkWidget *def, *recommended, *fallback, *other, *all;
static void
dialog_response (GtkDialog *d,
@ -58,6 +58,9 @@ dialog_response (GtkDialog *d,
static void
bind_props (void)
{
g_object_bind_property (def, "active",
app_chooser_widget, "show-default",
G_BINDING_SYNC_CREATE);
g_object_bind_property (recommended, "active",
app_chooser_widget, "show-recommended",
G_BINDING_SYNC_CREATE);
@ -208,6 +211,11 @@ main (int argc, char **argv)
gtk_grid_attach_next_to (GTK_GRID (grid), all,
other, GTK_POS_RIGHT, 1, 1);
def = gtk_check_button_new_with_label ("Show default");
gtk_grid_attach_next_to (GTK_GRID (grid), def,
all, GTK_POS_RIGHT, 1, 1);
g_object_set (recommended, "active", TRUE, NULL);
prepare_dialog ();
g_signal_connect (open, "clicked",
G_CALLBACK (display_dialog), NULL);

View File

@ -111,6 +111,8 @@ main (int argc,
gtk_app_chooser_button_set_show_dialog_item (GTK_APP_CHOOSER_BUTTON (combobox),
TRUE);
gtk_app_chooser_button_set_show_default_item (GTK_APP_CHOOSER_BUTTON (combobox),
TRUE);
/* connect to the detailed signal */
g_signal_connect (combobox, "custom-item-activated::" CUSTOM_ITEM,
@ -123,9 +125,10 @@ main (int argc,
/* test refresh on a combo */
gtk_app_chooser_refresh (GTK_APP_CHOOSER (combobox));
#if 0
gtk_app_chooser_button_set_active_custom_item (GTK_APP_CHOOSER_BUTTON (combobox),
CUSTOM_ITEM);
#endif
gtk_widget_show_all (toplevel);
g_signal_connect (toplevel, "delete-event",