From 18dba17f0bbacebf64b65423b2aee64eb2dcc141 Mon Sep 17 00:00:00 2001 From: Matthias Clasen Date: Sun, 28 Aug 2011 23:49:41 -0400 Subject: [PATCH] GtkAppChooserDialog: handle sensitivity of 'Select' better When the dialog comes up without a selected item, make 'Select' insensitive. Also, don't allow to unselect an item without selecting a different one. --- gtk/gtkappchooserdialog.c | 6 ++++++ gtk/gtkappchooserwidget.c | 2 +- 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/gtk/gtkappchooserdialog.c b/gtk/gtkappchooserdialog.c index 178d291e20..5412e7a91e 100644 --- a/gtk/gtkappchooserdialog.c +++ b/gtk/gtkappchooserdialog.c @@ -486,6 +486,7 @@ build_dialog_ui (GtkAppChooserDialog *self) GtkWidget *vbox; GtkWidget *vbox2; GtkWidget *button, *w; + GAppInfo *info; gtk_container_set_border_width (GTK_CONTAINER (self), 5); @@ -539,6 +540,11 @@ build_dialog_ui (GtkAppChooserDialog *self) _("_Select"), GTK_RESPONSE_OK); + info = gtk_app_chooser_get_app_info (GTK_APP_CHOOSER (self->priv->app_chooser_widget)); + gtk_widget_set_sensitive (self->priv->button, info != NULL); + if (info) + g_object_unref (info); + gtk_dialog_set_default_response (GTK_DIALOG (self), GTK_RESPONSE_OK); } diff --git a/gtk/gtkappchooserwidget.c b/gtk/gtkappchooserwidget.c index 8b3ab9d365..551c1ddbb6 100644 --- a/gtk/gtkappchooserwidget.c +++ b/gtk/gtkappchooserwidget.c @@ -1176,7 +1176,7 @@ gtk_app_chooser_widget_init (GtkAppChooserWidget *self) gtk_widget_show (self->priv->program_list); selection = gtk_tree_view_get_selection (GTK_TREE_VIEW (self->priv->program_list)); - gtk_tree_selection_set_mode (selection, GTK_SELECTION_SINGLE); + gtk_tree_selection_set_mode (selection, GTK_SELECTION_BROWSE); gtk_tree_selection_set_select_function (selection, gtk_app_chooser_selection_func, self, NULL); g_signal_connect_swapped (selection, "changed",