[nautilus/wip/oholy/encrypted-archives] wip
- From: Ondrej Holy <oholy src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [nautilus/wip/oholy/encrypted-archives] wip
- Date: Wed, 28 Jul 2021 15:45:31 +0000 (UTC)
commit 452cb59f50f70d2d2bd973c501d2d5d7ec6d2391
Author: Ondrej Holy <oholy redhat com>
Date: Tue Jul 27 13:52:02 2021 +0200
wip
src/nautilus-compress-dialog-controller.c | 169 +++++++++++--------
src/resources/ui/nautilus-compress-dialog.ui | 240 ++++++++++++++++++---------
2 files changed, 261 insertions(+), 148 deletions(-)
---
diff --git a/src/nautilus-compress-dialog-controller.c b/src/nautilus-compress-dialog-controller.c
index 7f3d8b571..42469c60e 100644
--- a/src/nautilus-compress-dialog-controller.c
+++ b/src/nautilus-compress-dialog-controller.c
@@ -19,6 +19,7 @@
#include <glib/gi18n.h>
#include <gnome-autoar/gnome-autoar.h>
+#include <libhandy-1/handy.h>
#include <eel/eel-vfs-extensions.h>
@@ -32,10 +33,16 @@ struct _NautilusCompressDialogController
GtkWidget *compress_dialog;
GtkWidget *name_entry;
- GtkWidget *zip_radio_button;
- GtkWidget *encrypted_zip_radio_button;
- GtkWidget *tar_xz_radio_button;
- GtkWidget *seven_zip_radio_button;
+ GtkWidget *extension_stack;
+ GtkWidget *zip_label;
+ GtkWidget *encrypted_zip_box;
+ GtkWidget *tar_xz_label;
+ GtkWidget *seven_zip_label;
+ GtkWidget *extension_popover;
+ GtkWidget *zip_checkmark;
+ GtkWidget *encrypted_zip_checkmark;
+ GtkWidget *tar_xz_checkmark;
+ GtkWidget *seven_zip_checkmark;
GtkWidget *passphrase_label;
GtkWidget *passphrase_entry;
@@ -146,37 +153,42 @@ update_selected_format (NautilusCompressDialogController *self,
NautilusCompressionFormat format)
{
const char *extension;
- GtkWidget *active_button;
- gboolean passphrase_sensitive = FALSE;
+ GtkWidget *active_label;
+ GtkWidget *active_checkmark;
+ gboolean show_passphrase = FALSE;
switch (format)
{
case NAUTILUS_COMPRESSION_ZIP:
{
extension = ".zip";
- active_button = self->zip_radio_button;
+ active_label = self->zip_label;
+ active_checkmark = self->zip_checkmark;
}
break;
case NAUTILUS_COMPRESSION_ENCRYPTED_ZIP:
{
extension = ".zip";
- active_button = self->encrypted_zip_radio_button;
- passphrase_sensitive = TRUE;
+ active_label = self->encrypted_zip_box;
+ active_checkmark = self->encrypted_zip_checkmark;
+ show_passphrase = TRUE;
}
break;
case NAUTILUS_COMPRESSION_TAR_XZ:
{
extension = ".tar.xz";
- 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";
- active_button = self->seven_zip_radio_button;
+ active_label = self->seven_zip_label;
+ active_checkmark = self->seven_zip_checkmark;
}
break;
@@ -189,19 +201,35 @@ update_selected_format (NautilusCompressDialogController *self,
self->extension = extension;
- gtk_widget_set_sensitive (self->passphrase_label, passphrase_sensitive);
- gtk_widget_set_sensitive (self->passphrase_entry, passphrase_sensitive);
- gtk_entry_set_icon_from_icon_name (GTK_ENTRY (self->passphrase_entry),
- GTK_ENTRY_ICON_SECONDARY,
- passphrase_sensitive ? "view-conceal" : "");
- if (!passphrase_sensitive)
+ gtk_widget_set_visible (self->passphrase_label, show_passphrase);
+ gtk_widget_set_visible (self->passphrase_entry, show_passphrase);
+ if (!show_passphrase)
{
gtk_entry_set_text (GTK_ENTRY (self->passphrase_entry), "");
gtk_entry_set_visibility (GTK_ENTRY (self->passphrase_entry), FALSE);
+ gtk_entry_set_icon_from_icon_name (GTK_ENTRY (self->passphrase_entry),
+ GTK_ENTRY_ICON_SECONDARY,
+ "view-conceal");
}
- 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->encrypted_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,
@@ -213,71 +241,55 @@ 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;
- }
-
update_selected_format (controller,
NAUTILUS_COMPRESSION_ZIP);
+ gtk_popover_popdown (GTK_POPOVER (controller->extension_popover));
}
static void
-encrypted_zip_radio_button_on_toggled (GtkToggleButton *toggle_button,
- gpointer user_data)
+encrypted_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;
- }
-
update_selected_format (controller,
NAUTILUS_COMPRESSION_ENCRYPTED_ZIP);
+ gtk_popover_popdown (GTK_POPOVER (controller->extension_popover));
}
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;
- }
-
update_selected_format (controller,
NAUTILUS_COMPRESSION_TAR_XZ);
+ gtk_popover_popdown (GTK_POPOVER (controller->extension_popover));
}
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;
- }
-
update_selected_format (controller,
NAUTILUS_COMPRESSION_7ZIP);
+ gtk_popover_popdown (GTK_POPOVER (controller->extension_popover));
}
static void
@@ -325,10 +337,16 @@ nautilus_compress_dialog_controller_new (GtkWindow *parent_window,
GtkWidget *error_label;
GtkWidget *name_entry;
GtkWidget *activate_button;
- GtkWidget *zip_radio_button;
- GtkWidget *encrypted_zip_radio_button;
- GtkWidget *tar_xz_radio_button;
- GtkWidget *seven_zip_radio_button;
+ GtkWidget *extension_stack;
+ GtkWidget *zip_label;
+ GtkWidget *encrypted_zip_box;
+ GtkWidget *tar_xz_label;
+ GtkWidget *seven_zip_label;
+ GtkWidget *extension_popover;
+ GtkWidget *zip_checkmark;
+ GtkWidget *encrypted_zip_checkmark;
+ GtkWidget *tar_xz_checkmark;
+ GtkWidget *seven_zip_checkmark;
GtkWidget *passphrase_label;
GtkWidget *passphrase_entry;
NautilusCompressionFormat format;
@@ -339,10 +357,16 @@ 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"));
- encrypted_zip_radio_button = GTK_WIDGET (gtk_builder_get_object (builder, "encrypted_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"));
+ extension_stack = GTK_WIDGET (gtk_builder_get_object (builder, "extension_stack"));
+ zip_label = GTK_WIDGET (gtk_builder_get_object (builder, "zip_label"));
+ encrypted_zip_box = GTK_WIDGET (gtk_builder_get_object (builder, "encrypted_zip_box"));
+ 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"));
+ encrypted_zip_checkmark = GTK_WIDGET (gtk_builder_get_object (builder, "encrypted_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"));
passphrase_label = GTK_WIDGET (gtk_builder_get_object (builder, "passphrase_label"));
passphrase_entry = GTK_WIDGET (gtk_builder_get_object (builder, "passphrase_entry"));
@@ -357,10 +381,17 @@ 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->encrypted_zip_radio_button = encrypted_zip_radio_button;
- self->tar_xz_radio_button = tar_xz_radio_button;
- self->seven_zip_radio_button = seven_zip_radio_button;
+ self->extension_stack = extension_stack;
+ self->zip_label = zip_label;
+ self->encrypted_zip_box = encrypted_zip_box;
+ 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->encrypted_zip_checkmark = encrypted_zip_checkmark;
+ self->tar_xz_checkmark = tar_xz_checkmark;
+ self->seven_zip_checkmark = seven_zip_checkmark;
self->name_entry = name_entry;
self->passphrase_label = passphrase_label;
self->passphrase_entry = passphrase_entry;
@@ -371,14 +402,14 @@ 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),
- "encrypted_zip_radio_button_on_toggled",
- G_CALLBACK (encrypted_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),
+ "encrypted_zip_row_on_activated",
+ G_CALLBACK (encrypted_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),
"passphrase_entry_on_changed",
G_CALLBACK (passphrase_entry_on_changed),
"passphrase_entry_on_icon_press",
@@ -389,8 +420,6 @@ nautilus_compress_dialog_controller_new (GtkWindow *parent_window,
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);
@@ -398,6 +427,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 d46437f07..f890de697 100644
--- a/src/resources/ui/nautilus-compress-dialog.ui
+++ b/src/resources/ui/nautilus-compress-dialog.ui
@@ -1,6 +1,87 @@
<?xml version="1.0" encoding="UTF-8"?>
<interface>
<requires lib="gtk+" version="3.14"/>
+ <object class="GtkPopover" id="extension_popover">
+ <property name="position">bottom</property>
+ <property name="constrain-to">none</property>
+ <child>
+ <object class="HdyPreferencesGroup">
+ <property name="visible">True</property>
+ <property name="margin-top">12</property>
+ <property name="margin-bottom">12</property>
+ <property name="margin-start">12</property>
+ <property name="margin-end">12</property>
+ <child>
+ <object class="HdyActionRow">
+ <property name="visible">True</property>
+ <property name="activatable">True</property>
+ <property name="title" translatable="no">.zip</property>
+ <property name="subtitle" translatable="yes">Compatible with all operating systems.</property>
+ <signal name="activated" handler="zip_row_on_activated"/>
+ <child>
+ <object class="GtkImage" id="zip_checkmark">
+ <property name="visible">True</property>
+ <property name="width-request">16</property>
+ <property name="margin-start">12</property>
+ <property name="margin-end">12</property>
+ </object>
+ </child>
+ </object>
+ </child>
+ <child>
+ <object class="HdyActionRow">
+ <property name="visible">True</property>
+ <property name="activatable">True</property>
+ <property name="title" translatable="yes" comments="Translators: Keep '.zip' unmodified.">.zip
(Password Protected)</property>
+ <property name="subtitle" translatable="yes">Encrypted .zip format, must be installed on Windows
and Mac.</property>
+ <signal name="activated" handler="encrypted_zip_row_on_activated"/>
+ <child>
+ <object class="GtkImage" id="encrypted_zip_checkmark">
+ <property name="visible">True</property>
+ <property name="width-request">16</property>
+ <property name="margin-start">12</property>
+ <property name="margin-end">12</property>
+ </object>
+ </child>
+ </object>
+ </child>
+ <child>
+ <object class="HdyActionRow">
+ <property name="visible">True</property>
+ <property name="activatable">True</property>
+ <property name="title" translatable="no">.tar.xz</property>
+ <property name="subtitle" translatable="yes">Smaller archives but Linux and Mac only.</property>
+ <signal name="activated" handler="tar_xz_row_on_activated"/>
+ <child>
+ <object class="GtkImage" id="tar_xz_checkmark">
+ <property name="visible">True</property>
+ <property name="width-request">16</property>
+ <property name="margin-start">12</property>
+ <property name="margin-end">12</property>
+ </object>
+ </child>
+ </object>
+ </child>
+ <child>
+ <object class="HdyActionRow">
+ <property name="visible">True</property>
+ <property name="activatable">True</property>
+ <property name="title" translatable="no">.7z</property>
+ <property name="subtitle" translatable="yes">Smaller archives but must be installed on Windows
and Mac.</property>
+ <signal name="activated" handler="seven_zip_row_on_activated"/>
+ <child>
+ <object class="GtkImage" id="seven_zip_checkmark">
+ <property name="visible">True</property>
+ <property name="width-request">16</property>
+ <property name="margin-start">12</property>
+ <property name="margin-end">12</property>
+ </object>
+ </child>
+ </object>
+ </child>
+ </object>
+ </child>
+ </object>
<object class="GtkDialog" id="compress_dialog">
<property name="title" translatable="yes">Create Archive</property>
<property name="resizable">False</property>
@@ -9,13 +90,14 @@
<property name="destroy_with_parent">True</property>
<property name="type_hint">dialog</property>
<property name="use-header-bar">1</property>
+ <property name="default_height">200</property>
<child internal-child="vbox">
<object class="GtkBox" id="vbox">
<property name="orientation">vertical</property>
- <property name="margin_top">18</property>
- <property name="margin_bottom">18</property>
- <property name="margin_start">84</property>
- <property name="margin_end">84</property>
+ <property name="margin_top">30</property>
+ <property name="margin_bottom">42</property>
+ <property name="margin_start">48</property>
+ <property name="margin_end">48</property>
<property name="spacing">6</property>
<child>
<object class="GtkLabel" id="name_label">
@@ -33,9 +115,77 @@
</packing>
</child>
<child>
- <object class="GtkEntry" id="name_entry">
- <property name="visible">True</property>
- <property name="can_focus">True</property>
+ <object class="GtkBox">
+ <property name="orientation">horizontal</property>
+ <property name="spacing">12</property>
+ <child>
+ <object class="GtkEntry" id="name_entry">
+ <property name="visible">True</property>
+ <property name="can_focus">True</property>
+ <property name="width-chars">30</property>
+ </object>
+ <packing>
+ <property name="expand">True</property>
+ </packing>
+ </child>
+ <child>
+ <object class="GtkMenuButton" id="extension_button">
+ <property name="popover">extension_popover</property>
+ <child>
+ <object class="GtkBox">
+ <property name="orientation">horizontal</property>
+ <property name="spacing">6</property>
+ <child>
+ <object class="GtkStack" id="extension_stack">
+ <child>
+ <object class="GtkLabel" id="zip_label">
+ <property name="label" translatable="no">.zip</property>
+ <property name="xalign">0</property>
+ </object>
+ </child>
+ <child>
+ <object class="GtkBox" id="encrypted_zip_box">
+ <property name="orientation">horizontal</property>
+ <property name="spacing">6</property>
+ <child>
+ <object class="GtkLabel">
+ <property name="label" translatable="no">.zip</property>
+ <property name="xalign">0</property>
+ </object>
+ </child>
+ <child>
+ <object class="GtkImage">
+ <property name="icon-name">system-lock-screen-symbolic</property>
+ </object>
+ </child>
+ </object>
+ </child>
+ <child>
+ <object class="GtkLabel" id="tar_xz_label">
+ <property name="label" translatable="no">.tar.xz</property>
+ <property name="xalign">0</property>
+ </object>
+ </child>
+ <child>
+ <object class="GtkLabel" id="seven_zip_label">
+ <property name="label" translatable="no">.7z</property>
+ <property name="xalign">0</property>
+ </object>
+ </child>
+ </object>
+ <packing>
+ <property name="expand">True</property>
+ </packing>
+ </child>
+ <child>
+ <object class="GtkImage">
+ <property name="icon-name">pan-down-symbolic</property>
+ </object>
+ </child>
+ </object>
+ </child>
+ </object>
+ </child>
</object>
<packing>
<property name="expand">False</property>
@@ -60,98 +210,30 @@
<property name="position">3</property>
</packing>
</child>
- <child>
- <object class="HdyPreferencesGroup">
- <property name="margin-top">12</property>
- <property name="margin-bottom">12</property>
- <child>
- <object class="HdyActionRow">
- <property name="title" translatable="no">.zip</property>
- <property name="subtitle" translatable="yes">Compatible with all operating
systems.</property>
- <property name="activatable-widget">zip_radio_button</property>
- <child type="prefix">
- <object class="GtkRadioButton" id="zip_radio_button">
- <property name="draw-indicator">True</property>
- <property name="can-focus">False</property>
- <signal name="toggled" handler="zip_radio_button_on_toggled"/>
- </object>
- </child>
- </object>
- </child>
- <child>
- <object class="HdyActionRow">
- <property name="title" translatable="yes" comments="Translators: Keep '.zip'
unmodified.">.zip (Password Protected)</property>
- <property name="subtitle" translatable="yes">Encrypted .zip format.</property>
- <property name="activatable-widget">encrypted_zip_radio_button</property>
- <child type="prefix">
- <object class="GtkRadioButton" id="encrypted_zip_radio_button">
- <property name="draw-indicator">True</property>
- <property name="can-focus">False</property>
- <property name="group">zip_radio_button</property>
- <signal name="toggled" handler="encrypted_zip_radio_button_on_toggled"/>
- </object>
- </child>
- </object>
- </child>
- <child>
- <object class="HdyActionRow">
- <property name="title" translatable="no">.tar.xz</property>
- <property name="subtitle" translatable="yes">Smaller archives but Linux and Mac
only.</property>
- <property name="activatable-widget">tar_xz_radio_button</property>
- <child type="prefix">
- <object class="GtkRadioButton" id="tar_xz_radio_button">
- <property name="draw-indicator">True</property>
- <property name="can-focus">False</property>
- <property name="group">zip_radio_button</property>
- <signal name="toggled" handler="tar_xz_radio_button_on_toggled"/>
- </object>
- </child>
- </object>
- </child>
- <child>
- <object class="HdyActionRow">
- <property name="title" translatable="no">.7z</property>
- <property name="subtitle" translatable="yes">Smaller archives but must be installed on
Windows and Mac.</property>
- <property name="activatable-widget">seven_zip_radio_button</property>
- <child type="prefix">
- <object class="GtkRadioButton" id="seven_zip_radio_button">
- <property name="draw-indicator">True</property>
- <property name="can-focus">False</property>
- <property name="group">zip_radio_button</property>
- <signal name="toggled" handler="seven_zip_radio_button_on_toggled"/>
- </object>
- </child>
- </object>
- </child>
- </object>
- <packing>
- <property name="expand">False</property>
- <property name="fill">True</property>
- <property name="position">4</property>
- </packing>
- </child>
<child>
<object class="GtkLabel" id="passphrase_label">
<property name="label" translatable="yes">Password</property>
+ <property name="margin-top">6</property>
<property name="xalign">0</property>
</object>
<packing>
<property name="expand">False</property>
<property name="fill">True</property>
- <property name="position">5</property>
+ <property name="position">4</property>
</packing>
</child>
<child>
<object class="GtkEntry" id="passphrase_entry">
<property name="input-purpose">GTK_INPUT_PURPOSE_PASSWORD</property>
<property name="visibility">False</property>
+ <property name="secondary-icon-name">view-conceal</property>
<signal name="changed" handler="passphrase_entry_on_changed"/>
<signal name="icon-press" handler="passphrase_entry_on_icon_press"/>
</object>
<packing>
<property name="expand">False</property>
<property name="fill">True</property>
- <property name="position">6</property>
+ <property name="position">5</property>
</packing>
</child>
</object>
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]