[nautilus/wip/coreyberla/app-chooser-fixes: 1/9] app-chooser: Remove "reset" ability
- From: António Fernandes <antoniof src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [nautilus/wip/coreyberla/app-chooser-fixes: 1/9] app-chooser: Remove "reset" ability
- Date: Mon, 8 Aug 2022 21:24:02 +0000 (UTC)
commit d8f3e78e5c149c12ba0660f873bc7497341f6cf5
Author: Corey Berla <corey berla me>
Date: Mon Aug 8 11:07:01 2022 -0700
app-chooser: Remove "reset" ability
We are only changing the default after clicking "open" based on the
design. Resetting the default used to make sense when it has a
dedicated button, but it no longer makes sense. Remove the "reset"
ability by setting the GtkSwitch as insenstive for the current
default and only taking action if the switch is active and sensitive.
src/nautilus-app-chooser.c | 18 +++++++++---------
1 file changed, 9 insertions(+), 9 deletions(-)
---
diff --git a/src/nautilus-app-chooser.c b/src/nautilus-app-chooser.c
index 33c2c1646..25fd726cd 100644
--- a/src/nautilus-app-chooser.c
+++ b/src/nautilus-app-chooser.c
@@ -44,29 +44,28 @@ static void
open_button_clicked_cb (GtkButton *button,
NautilusAppChooser *self)
{
- gboolean state;
+ gboolean set_new_default = FALSE;
g_autoptr (GAppInfo) info = NULL;
g_autoptr (GError) error = NULL;
- state = gtk_switch_get_active (GTK_SWITCH (self->set_as_default_switch));
-
if (!self->single_content_type)
{
/* Don't attempt to set an association with multiple content types */
return;
}
- if (state)
+ /* The switch is insensitive if the selected app is already default */
+ if (gtk_widget_get_sensitive (self->set_as_default_switch))
+ {
+ set_new_default = gtk_switch_get_active (GTK_SWITCH (self->set_as_default_switch));
+ }
+
+ if (set_new_default)
{
info = gtk_app_chooser_get_app_info (GTK_APP_CHOOSER (self->app_chooser_widget));
g_app_info_set_as_default_for_type (info, self->content_type,
&error);
}
- else
- {
- g_app_info_reset_type_associations (self->content_type);
- gtk_app_chooser_refresh (GTK_APP_CHOOSER (self->app_chooser_widget));
- }
if (error != NULL)
{
@@ -101,6 +100,7 @@ on_application_selected (GtkAppChooserWidget *widget,
is_default = default_app != NULL && g_app_info_equal (info, default_app);
gtk_switch_set_state (GTK_SWITCH (self->set_as_default_switch), is_default);
+ gtk_widget_set_sensitive (GTK_WIDGET (self->set_as_default_switch), !is_default);
}
static void
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]