From e71b54bafcbfffcb352600ebff4be8776de171f9 Mon Sep 17 00:00:00 2001 From: Ondrej Holy Date: Fri, 30 Jul 2021 11:01:42 +0200 Subject: [PATCH] compress-dialog: Update dialog design Let's update the Compress dialog design as per the mockup for the encrypted archives support. The most visible change is `GtkPopover` with `HdyActionRow` rows for the format selection instead of the `GtkRadioButton` buttons. https://gitlab.gnome.org/GNOME/nautilus/-/issues/822 --- src/nautilus-compress-dialog-controller.c | 132 ++++++----- src/resources/ui/nautilus-compress-dialog.ui | 229 ++++++++++--------- 2 files changed, 199 insertions(+), 162 deletions(-) diff --git a/src/nautilus-compress-dialog-controller.c b/src/nautilus-compress-dialog-controller.c index d8aa792ee..154573c0f 100644 --- a/src/nautilus-compress-dialog-controller.c +++ b/src/nautilus-compress-dialog-controller.c @@ -19,6 +19,7 @@ #include #include +#include #include @@ -31,11 +32,15 @@ struct _NautilusCompressDialogController NautilusFileNameWidgetController parent_instance; GtkWidget *compress_dialog; - GtkWidget *description_stack; GtkWidget *name_entry; - GtkWidget *zip_radio_button; - GtkWidget *tar_xz_radio_button; - GtkWidget *seven_zip_radio_button; + GtkWidget *extension_stack; + GtkWidget *zip_label; + GtkWidget *tar_xz_label; + GtkWidget *seven_zip_label; + GtkWidget *extension_popover; + GtkWidget *zip_checkmark; + GtkWidget *tar_xz_checkmark; + GtkWidget *seven_zip_checkmark; const char *extension; @@ -135,32 +140,32 @@ update_selected_format (NautilusCompressDialogController *self, NautilusCompressionFormat format) { const char *extension; - const char *description_label_name; - GtkWidget *active_button; + GtkWidget *active_label; + GtkWidget *active_checkmark; switch (format) { case NAUTILUS_COMPRESSION_ZIP: { extension = ".zip"; - description_label_name = "zip-description-label"; - active_button = self->zip_radio_button; + active_label = self->zip_label; + active_checkmark = self->zip_checkmark; } break; case NAUTILUS_COMPRESSION_TAR_XZ: { extension = ".tar.xz"; - description_label_name = "tar-xz-description-label"; - active_button = self->tar_xz_radio_button; + active_label = self->tar_xz_label; + active_checkmark = self->tar_xz_checkmark; } break; case NAUTILUS_COMPRESSION_7ZIP: { extension = ".7z"; - description_label_name = "seven-zip-description-label"; - active_button = self->seven_zip_radio_button; + active_label = self->seven_zip_label; + active_checkmark = self->seven_zip_checkmark; } break; @@ -173,11 +178,21 @@ update_selected_format (NautilusCompressDialogController *self, self->extension = extension; - gtk_stack_set_visible_child_name (GTK_STACK (self->description_stack), - description_label_name); - - gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (active_button), - TRUE); + gtk_stack_set_visible_child (GTK_STACK (self->extension_stack), + active_label); + + gtk_image_set_from_icon_name (GTK_IMAGE (self->zip_checkmark), + NULL, + GTK_ICON_SIZE_BUTTON); + gtk_image_set_from_icon_name (GTK_IMAGE (self->tar_xz_checkmark), + NULL, + GTK_ICON_SIZE_BUTTON); + gtk_image_set_from_icon_name (GTK_IMAGE (self->seven_zip_checkmark), + NULL, + GTK_ICON_SIZE_BUTTON); + gtk_image_set_from_icon_name (GTK_IMAGE (active_checkmark), + "object-select-symbolic", + GTK_ICON_SIZE_BUTTON); g_settings_set_enum (nautilus_compression_preferences, NAUTILUS_PREFERENCES_DEFAULT_COMPRESSION_FORMAT, @@ -189,52 +204,40 @@ update_selected_format (NautilusCompressDialogController *self, } static void -zip_radio_button_on_toggled (GtkToggleButton *toggle_button, - gpointer user_data) +zip_row_on_activated (HdyActionRow *row, + gpointer user_data) { NautilusCompressDialogController *controller; controller = NAUTILUS_COMPRESS_DIALOG_CONTROLLER (user_data); - if (!gtk_toggle_button_get_active (toggle_button)) - { - return; - } - + gtk_popover_popdown (GTK_POPOVER (controller->extension_popover)); update_selected_format (controller, NAUTILUS_COMPRESSION_ZIP); } static void -tar_xz_radio_button_on_toggled (GtkToggleButton *toggle_button, - gpointer user_data) +tar_xz_row_on_activated (HdyActionRow *row, + gpointer user_data) { NautilusCompressDialogController *controller; controller = NAUTILUS_COMPRESS_DIALOG_CONTROLLER (user_data); - if (!gtk_toggle_button_get_active (toggle_button)) - { - return; - } - + gtk_popover_popdown (GTK_POPOVER (controller->extension_popover)); update_selected_format (controller, NAUTILUS_COMPRESSION_TAR_XZ); } static void -seven_zip_radio_button_on_toggled (GtkToggleButton *toggle_button, - gpointer user_data) +seven_zip_row_on_activated (HdyActionRow *row, + gpointer user_data) { NautilusCompressDialogController *controller; controller = NAUTILUS_COMPRESS_DIALOG_CONTROLLER (user_data); - if (!gtk_toggle_button_get_active (toggle_button)) - { - return; - } - + gtk_popover_popdown (GTK_POPOVER (controller->extension_popover)); update_selected_format (controller, NAUTILUS_COMPRESSION_7ZIP); } @@ -251,10 +254,14 @@ nautilus_compress_dialog_controller_new (GtkWindow *parent_window, GtkWidget *error_label; GtkWidget *name_entry; GtkWidget *activate_button; - GtkWidget *description_stack; - GtkWidget *zip_radio_button; - GtkWidget *tar_xz_radio_button; - GtkWidget *seven_zip_radio_button; + GtkWidget *extension_stack; + GtkWidget *zip_label; + GtkWidget *tar_xz_label; + GtkWidget *seven_zip_label; + GtkWidget *extension_popover; + GtkWidget *zip_checkmark; + GtkWidget *tar_xz_checkmark; + GtkWidget *seven_zip_checkmark; NautilusCompressionFormat format; builder = gtk_builder_new_from_resource ("/org/gnome/nautilus/ui/nautilus-compress-dialog.ui"); @@ -263,10 +270,14 @@ nautilus_compress_dialog_controller_new (GtkWindow *parent_window, error_label = GTK_WIDGET (gtk_builder_get_object (builder, "error_label")); name_entry = GTK_WIDGET (gtk_builder_get_object (builder, "name_entry")); activate_button = GTK_WIDGET (gtk_builder_get_object (builder, "activate_button")); - zip_radio_button = GTK_WIDGET (gtk_builder_get_object (builder, "zip_radio_button")); - tar_xz_radio_button = GTK_WIDGET (gtk_builder_get_object (builder, "tar_xz_radio_button")); - seven_zip_radio_button = GTK_WIDGET (gtk_builder_get_object (builder, "seven_zip_radio_button")); - description_stack = GTK_WIDGET (gtk_builder_get_object (builder, "description_stack")); + extension_stack = GTK_WIDGET (gtk_builder_get_object (builder, "extension_stack")); + zip_label = GTK_WIDGET (gtk_builder_get_object (builder, "zip_label")); + tar_xz_label = GTK_WIDGET (gtk_builder_get_object (builder, "tar_xz_label")); + seven_zip_label = GTK_WIDGET (gtk_builder_get_object (builder, "seven_zip_label")); + extension_popover = GTK_WIDGET (gtk_builder_get_object (builder, "extension_popover")); + zip_checkmark = GTK_WIDGET (gtk_builder_get_object (builder, "zip_checkmark")); + tar_xz_checkmark = GTK_WIDGET (gtk_builder_get_object (builder, "tar_xz_checkmark")); + seven_zip_checkmark = GTK_WIDGET (gtk_builder_get_object (builder, "seven_zip_checkmark")); gtk_window_set_transient_for (GTK_WINDOW (compress_dialog), parent_window); @@ -279,10 +290,15 @@ nautilus_compress_dialog_controller_new (GtkWindow *parent_window, "containing-directory", destination_directory, NULL); self->compress_dialog = compress_dialog; - self->zip_radio_button = zip_radio_button; - self->tar_xz_radio_button = tar_xz_radio_button; - self->seven_zip_radio_button = seven_zip_radio_button; - self->description_stack = description_stack; + self->extension_stack = extension_stack; + self->zip_label = zip_label; + self->tar_xz_label = tar_xz_label; + self->seven_zip_label = seven_zip_label; + self->name_entry = name_entry; + self->extension_popover = extension_popover; + self->zip_checkmark = zip_checkmark; + self->tar_xz_checkmark = tar_xz_checkmark; + self->seven_zip_checkmark = seven_zip_checkmark; self->name_entry = name_entry; self->response_handler_id = g_signal_connect (compress_dialog, @@ -291,20 +307,18 @@ nautilus_compress_dialog_controller_new (GtkWindow *parent_window, self); gtk_builder_add_callback_symbols (builder, - "zip_radio_button_on_toggled", - G_CALLBACK (zip_radio_button_on_toggled), - "tar_xz_radio_button_on_toggled", - G_CALLBACK (tar_xz_radio_button_on_toggled), - "seven_zip_radio_button_on_toggled", - G_CALLBACK (seven_zip_radio_button_on_toggled), + "zip_row_on_activated", + G_CALLBACK (zip_row_on_activated), + "tar_xz_row_on_activated", + G_CALLBACK (tar_xz_row_on_activated), + "seven_zip_row_on_activated", + G_CALLBACK (seven_zip_row_on_activated), NULL); gtk_builder_connect_signals (builder, self); format = g_settings_get_enum (nautilus_compression_preferences, NAUTILUS_PREFERENCES_DEFAULT_COMPRESSION_FORMAT); - update_selected_format (self, format); - if (initial_name != NULL) { gtk_entry_set_text (GTK_ENTRY (name_entry), initial_name); @@ -312,6 +326,8 @@ nautilus_compress_dialog_controller_new (GtkWindow *parent_window, gtk_widget_show_all (compress_dialog); + update_selected_format (self, format); + return self; } diff --git a/src/resources/ui/nautilus-compress-dialog.ui b/src/resources/ui/nautilus-compress-dialog.ui index 526e9eed2..b36539294 100644 --- a/src/resources/ui/nautilus-compress-dialog.ui +++ b/src/resources/ui/nautilus-compress-dialog.ui @@ -1,6 +1,70 @@ + + bottom + none + + + True + 12 + 12 + 12 + 12 + + + True + True + .zip + Compatible with all operating systems. + + + + True + 16 + 12 + 12 + + + + + + + True + True + .tar.xz + Smaller archives but Linux and Mac only. + + + + True + 16 + 12 + 12 + + + + + + + True + True + .7z + Smaller archives but must be installed on Windows and Mac. + + + + True + 16 + 12 + 12 + + + + + + + Create Archive False @@ -9,19 +73,26 @@ True dialog 1 + 500 + 210 vertical - 18 - 12 - 18 - 18 + 30 + 30 + 30 + 30 + 390 + center 6 Archive name True 0 + + + False @@ -30,132 +101,82 @@ - - True - True - - - False - True - 2 - - - - - - - 4 - 4 - True - 0 - - - - - False - True - 3 - - - - + horizontal - True - 0 - - - .zip - True - - - - True - True - 0 - - + 12 - - .tar.xz - zip_radio_button - True - + + True + True + 30 True - True - 1 - - .7z - zip_radio_button - True - + + extension_popover + + + horizontal + 6 + + + + + .zip + 0 + + + + + .tar.xz + 0 + + + + + .7z + 0 + + + + + True + + + + + pan-down-symbolic + + + + - - True - True - 2 - False True - 4 + 2 - - True - False - True - - - True - Compatible with all operating systems. - 0 - - - - zip-description-label - - - - - True - Smaller archives but Linux and Mac only. - 0 - - - - tar-xz-description-label - - + - + + 4 + 4 True - Smaller archives but must be installed on Windows and Mac. 0 - - - seven-zip-description-label - False True - 5 + 3 -- 2.31.1