You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
174 lines
6.7 KiB
174 lines
6.7 KiB
2 years ago
|
From f3b1a749669c241ae3802e72a22a4eb7d1a44eed Mon Sep 17 00:00:00 2001
|
||
|
From: Clyde Laforge <clyde.laforge@protonmail.ch>
|
||
|
Date: Mon, 16 Aug 2021 14:41:39 +0200
|
||
|
Subject: [PATCH] compress-dialog: Set keyboard focus on the row with the
|
||
|
selected archive format
|
||
|
|
||
|
Currently the keyboard focus for the type of archive choice is always on
|
||
|
the first element.
|
||
|
|
||
|
This patch allows the focus to be on the currently selected item instead.
|
||
|
|
||
|
Fixes https://gitlab.gnome.org/GNOME/nautilus/-/issues/1944
|
||
|
---
|
||
|
src/nautilus-compress-dialog-controller.c | 62 ++++++++++++++++++++
|
||
|
src/resources/ui/nautilus-compress-dialog.ui | 7 ++-
|
||
|
2 files changed, 66 insertions(+), 3 deletions(-)
|
||
|
|
||
|
diff --git a/src/nautilus-compress-dialog-controller.c b/src/nautilus-compress-dialog-controller.c
|
||
|
index e1ba5a803..3f7711ccb 100644
|
||
|
--- a/src/nautilus-compress-dialog-controller.c
|
||
|
+++ b/src/nautilus-compress-dialog-controller.c
|
||
|
@@ -36,9 +36,13 @@ struct _NautilusCompressDialogController
|
||
|
GtkWidget *error_label;
|
||
|
GtkWidget *name_entry;
|
||
|
GtkWidget *extension_stack;
|
||
|
+ GtkWidget *zip_row;
|
||
|
GtkWidget *zip_label;
|
||
|
+ GtkWidget *encrypted_zip_row;
|
||
|
GtkWidget *encrypted_zip_label;
|
||
|
+ GtkWidget *tar_xz_row;
|
||
|
GtkWidget *tar_xz_label;
|
||
|
+ GtkWidget *seven_zip_row;
|
||
|
GtkWidget *seven_zip_label;
|
||
|
GtkWidget *extension_popover;
|
||
|
GtkWidget *zip_checkmark;
|
||
|
@@ -348,6 +352,50 @@ activate_button_on_sensitive_notify (GObject *gobject,
|
||
|
}
|
||
|
}
|
||
|
|
||
|
+static void
|
||
|
+popover_on_show (GtkWidget *widget,
|
||
|
+ gpointer user_data)
|
||
|
+{
|
||
|
+ NautilusCompressDialogController *self;
|
||
|
+ NautilusCompressionFormat format;
|
||
|
+
|
||
|
+ self = NAUTILUS_COMPRESS_DIALOG_CONTROLLER (user_data);
|
||
|
+ format = g_settings_get_enum (nautilus_compression_preferences,
|
||
|
+ NAUTILUS_PREFERENCES_DEFAULT_COMPRESSION_FORMAT);
|
||
|
+ switch (format)
|
||
|
+ {
|
||
|
+ case NAUTILUS_COMPRESSION_ZIP:
|
||
|
+ {
|
||
|
+ gtk_widget_grab_focus (self->zip_row);
|
||
|
+ }
|
||
|
+ break;
|
||
|
+
|
||
|
+ case NAUTILUS_COMPRESSION_ENCRYPTED_ZIP:
|
||
|
+ {
|
||
|
+ gtk_widget_grab_focus (self->encrypted_zip_row);
|
||
|
+ }
|
||
|
+ break;
|
||
|
+
|
||
|
+ case NAUTILUS_COMPRESSION_TAR_XZ:
|
||
|
+ {
|
||
|
+ gtk_widget_grab_focus (self->tar_xz_row);
|
||
|
+ }
|
||
|
+ break;
|
||
|
+
|
||
|
+ case NAUTILUS_COMPRESSION_7ZIP:
|
||
|
+ {
|
||
|
+ gtk_widget_grab_focus (self->seven_zip_row);
|
||
|
+ }
|
||
|
+ break;
|
||
|
+
|
||
|
+ default:
|
||
|
+ {
|
||
|
+ g_assert_not_reached ();
|
||
|
+ }
|
||
|
+ break;
|
||
|
+ }
|
||
|
+}
|
||
|
+
|
||
|
NautilusCompressDialogController *
|
||
|
nautilus_compress_dialog_controller_new (GtkWindow *parent_window,
|
||
|
NautilusDirectory *destination_directory,
|
||
|
@@ -361,9 +409,13 @@ nautilus_compress_dialog_controller_new (GtkWindow *parent_window,
|
||
|
GtkWidget *name_entry;
|
||
|
GtkWidget *activate_button;
|
||
|
GtkWidget *extension_stack;
|
||
|
+ GtkWidget *zip_row;
|
||
|
GtkWidget *zip_label;
|
||
|
+ GtkWidget *encrypted_zip_row;
|
||
|
GtkWidget *encrypted_zip_label;
|
||
|
+ GtkWidget *tar_xz_row;
|
||
|
GtkWidget *tar_xz_label;
|
||
|
+ GtkWidget *seven_zip_row;
|
||
|
GtkWidget *seven_zip_label;
|
||
|
GtkWidget *extension_popover;
|
||
|
GtkWidget *zip_checkmark;
|
||
|
@@ -392,6 +444,10 @@ nautilus_compress_dialog_controller_new (GtkWindow *parent_window,
|
||
|
seven_zip_checkmark = GTK_WIDGET (gtk_builder_get_object (builder, "seven_zip_checkmark"));
|
||
|
passphrase_label = GTK_WIDGET (gtk_builder_get_object (builder, "passphrase_label"));
|
||
|
passphrase_entry = GTK_WIDGET (gtk_builder_get_object (builder, "passphrase_entry"));
|
||
|
+ zip_row = GTK_WIDGET (gtk_builder_get_object (builder, "zip_row"));
|
||
|
+ encrypted_zip_row = GTK_WIDGET (gtk_builder_get_object (builder, "encrypted_zip_row"));
|
||
|
+ tar_xz_row = GTK_WIDGET (gtk_builder_get_object (builder, "tar_xz_row"));
|
||
|
+ seven_zip_row = GTK_WIDGET (gtk_builder_get_object (builder, "seven_zip_row"));
|
||
|
|
||
|
gtk_window_set_transient_for (GTK_WINDOW (compress_dialog),
|
||
|
parent_window);
|
||
|
@@ -420,6 +476,10 @@ nautilus_compress_dialog_controller_new (GtkWindow *parent_window,
|
||
|
self->name_entry = name_entry;
|
||
|
self->passphrase_label = passphrase_label;
|
||
|
self->passphrase_entry = passphrase_entry;
|
||
|
+ self->zip_row = zip_row;
|
||
|
+ self->encrypted_zip_row = encrypted_zip_row;
|
||
|
+ self->tar_xz_row = tar_xz_row;
|
||
|
+ self->seven_zip_row = seven_zip_row;
|
||
|
|
||
|
self->response_handler_id = g_signal_connect (compress_dialog,
|
||
|
"response",
|
||
|
@@ -441,6 +501,8 @@ nautilus_compress_dialog_controller_new (GtkWindow *parent_window,
|
||
|
G_CALLBACK (passphrase_entry_on_icon_press),
|
||
|
"activate_button_on_sensitive_notify",
|
||
|
G_CALLBACK (activate_button_on_sensitive_notify),
|
||
|
+ "popover_on_show",
|
||
|
+ G_CALLBACK (popover_on_show),
|
||
|
NULL);
|
||
|
gtk_builder_connect_signals (builder, self);
|
||
|
|
||
|
diff --git a/src/resources/ui/nautilus-compress-dialog.ui b/src/resources/ui/nautilus-compress-dialog.ui
|
||
|
index a57765eed..a6bf9c1fb 100644
|
||
|
--- a/src/resources/ui/nautilus-compress-dialog.ui
|
||
|
+++ b/src/resources/ui/nautilus-compress-dialog.ui
|
||
|
@@ -2,6 +2,7 @@
|
||
|
<interface>
|
||
|
<requires lib="gtk+" version="3.14"/>
|
||
|
<object class="GtkPopover" id="extension_popover">
|
||
|
+ <signal name="show" handler="popover_on_show"/>
|
||
|
<property name="position">bottom</property>
|
||
|
<property name="constrain-to">none</property>
|
||
|
<child>
|
||
|
@@ -12,7 +13,7 @@
|
||
|
<property name="margin-start">12</property>
|
||
|
<property name="margin-end">12</property>
|
||
|
<child>
|
||
|
- <object class="HdyActionRow">
|
||
|
+ <object class="HdyActionRow" id="zip_row">
|
||
|
<property name="visible">True</property>
|
||
|
<property name="activatable">True</property>
|
||
|
<property name="title" translatable="no">.zip</property>
|
||
|
@@ -49,7 +50,7 @@
|
||
|
</object>
|
||
|
</child>
|
||
|
<child>
|
||
|
- <object class="HdyActionRow">
|
||
|
+ <object class="HdyActionRow" id="tar_xz_row">
|
||
|
<property name="visible">True</property>
|
||
|
<property name="activatable">True</property>
|
||
|
<property name="title" translatable="no">.tar.xz</property>
|
||
|
@@ -66,7 +67,7 @@
|
||
|
</object>
|
||
|
</child>
|
||
|
<child>
|
||
|
- <object class="HdyActionRow">
|
||
|
+ <object class="HdyActionRow" id="seven_zip_row">
|
||
|
<property name="visible">True</property>
|
||
|
<property name="activatable">True</property>
|
||
|
<property name="title" translatable="no">.7z</property>
|
||
|
--
|
||
|
2.33.1
|
||
|
|