diff options
author | António Fernandes <antoniof@gnome.org> | 2021-11-13 00:31:20 +0000 |
---|---|---|
committer | Ondrej Holy <oholy@redhat.com> | 2021-11-19 08:36:50 +0100 |
commit | 7e3dab1f52fe7a556cfd2c285d51606cc3035030 (patch) | |
tree | 23e43ab2eab1d30529c463ab78c805f355bb7620 | |
parent | 9e4e95395bc2f46f358a71ffdc05e0d32621b1fc (diff) | |
download | nautilus-7e3dab1f52fe7a556cfd2c285d51606cc3035030.tar.gz |
operations-ui-manager: Port passphrase dialog to GtkBuilder
This removes usage of the GtkContainer API, preparing for GTK4.
-rw-r--r-- | po/POTFILES.in | 1 | ||||
-rw-r--r-- | src/nautilus-operations-ui-manager.c | 50 | ||||
-rw-r--r-- | src/resources/nautilus.gresource.xml | 1 | ||||
-rw-r--r-- | src/resources/ui/nautilus-operations-ui-manager-request-passphrase.ui | 55 |
4 files changed, 71 insertions, 36 deletions
diff --git a/po/POTFILES.in b/po/POTFILES.in index 03e8a2f13..48e7fd43f 100644 --- a/po/POTFILES.in +++ b/po/POTFILES.in @@ -88,6 +88,7 @@ src/resources/ui/nautilus-files-view-select-items.ui src/resources/ui/nautilus-folder-is-empty.ui src/resources/ui/nautilus-list-view-column-editor.ui src/resources/ui/nautilus-no-search-results.ui +src/resources/ui/nautilus-operations-ui-manager-request-passphrase.ui src/resources/ui/nautilus-pathbar-context-menu.ui src/resources/ui/nautilus-preferences-window.ui src/resources/ui/nautilus-progress-info-widget.ui diff --git a/src/nautilus-operations-ui-manager.c b/src/nautilus-operations-ui-manager.c index 2da579635..0d2afb5af 100644 --- a/src/nautilus-operations-ui-manager.c +++ b/src/nautilus-operations-ui-manager.c @@ -617,7 +617,7 @@ typedef struct ContextInvokeData parent_type; GtkWindow *parent_window; const gchar *basename; - GtkWidget *passphrase_entry; + GtkEntry *passphrase_entry; gchar *passphrase; } PassphraseRequestData; @@ -631,7 +631,7 @@ on_request_passphrase_cb (GtkDialog *dialog, if (response_id != GTK_RESPONSE_CANCEL && response_id != GTK_RESPONSE_DELETE_EVENT) { - data->passphrase = g_strdup (gtk_entry_get_text (GTK_ENTRY (data->passphrase_entry))); + data->passphrase = g_strdup (gtk_entry_get_text (data->passphrase_entry)); } gtk_widget_destroy (GTK_WIDGET (dialog)); @@ -643,43 +643,21 @@ run_passphrase_dialog (gpointer user_data) { PassphraseRequestData *data = user_data; g_autofree gchar *label_str = NULL; - GtkWidget *dialog; - GtkWidget *entry; - GtkWidget *label; - GtkWidget *box; - - dialog = gtk_dialog_new_with_buttons (_("Password Required"), - data->parent_window, - GTK_DIALOG_USE_HEADER_BAR | GTK_DIALOG_MODAL, - _("Cancel"), GTK_RESPONSE_CANCEL, - _("Extract"), GTK_RESPONSE_OK, - NULL); - gtk_dialog_set_default_response (GTK_DIALOG (dialog), GTK_RESPONSE_OK); - - box = gtk_dialog_get_content_area (GTK_DIALOG (dialog)); - gtk_widget_set_margin_start (box, 20); - gtk_widget_set_margin_end (box, 20); - gtk_widget_set_margin_top (box, 20); - gtk_widget_set_margin_bottom (box, 20); + g_autoptr (GtkBuilder) builder = NULL; + GObject *dialog; + GObject *label; + + builder = gtk_builder_new_from_resource ("/org/gnome/nautilus/ui/nautilus-operations-ui-manager-request-passphrase.ui"); + dialog = gtk_builder_get_object (builder, "request_passphrase_dialog"); + label = gtk_builder_get_object (builder, "label"); + data->passphrase_entry = GTK_ENTRY (gtk_builder_get_object (builder, "entry")); label_str = g_strdup_printf (_("“%s” is password-protected."), data->basename); - label = gtk_label_new (label_str); - gtk_label_set_line_wrap (GTK_LABEL (label), TRUE); - gtk_label_set_max_width_chars (GTK_LABEL (label), 60); - gtk_container_add (GTK_CONTAINER (box), label); - - entry = gtk_entry_new (); - gtk_entry_set_activates_default (GTK_ENTRY (entry), TRUE); - gtk_widget_set_valign (entry, GTK_ALIGN_END); - gtk_widget_set_vexpand (entry, TRUE); - gtk_entry_set_placeholder_text (GTK_ENTRY (entry), _("Enter password…")); - gtk_entry_set_visibility (GTK_ENTRY (entry), FALSE); - gtk_entry_set_input_purpose (GTK_ENTRY (entry), GTK_INPUT_PURPOSE_PASSWORD); - gtk_container_add (GTK_CONTAINER (box), entry); - - data->passphrase_entry = entry; + gtk_label_set_text (GTK_LABEL (label), label_str); + g_signal_connect (dialog, "response", G_CALLBACK (on_request_passphrase_cb), data); - gtk_widget_show_all (dialog); + gtk_window_set_transient_for (GTK_WINDOW (dialog), data->parent_window); + gtk_widget_show (GTK_WIDGET (dialog)); return G_SOURCE_REMOVE; } diff --git a/src/resources/nautilus.gresource.xml b/src/resources/nautilus.gresource.xml index c3e8034b5..bb0cf3ea1 100644 --- a/src/resources/nautilus.gresource.xml +++ b/src/resources/nautilus.gresource.xml @@ -26,6 +26,7 @@ <file>ui/nautilus-file-properties-change-permissions.ui</file> <file>ui/nautilus-file-conflict-dialog.ui</file> <file>ui/nautilus-files-view-select-items.ui</file> + <file>ui/nautilus-operations-ui-manager-request-passphrase.ui</file> <file alias="gtk/ui/nautilusgtkplacesview.ui">../gtk/nautilusgtkplacesview.ui</file> <file alias="gtk/ui/nautilusgtkplacesviewrow.ui">../gtk/nautilusgtkplacesviewrow.ui</file> <file alias="icons/thumbnail_frame.png">../../icons/thumbnail_frame.png</file> diff --git a/src/resources/ui/nautilus-operations-ui-manager-request-passphrase.ui b/src/resources/ui/nautilus-operations-ui-manager-request-passphrase.ui new file mode 100644 index 000000000..c66c9cd6c --- /dev/null +++ b/src/resources/ui/nautilus-operations-ui-manager-request-passphrase.ui @@ -0,0 +1,55 @@ +<?xml version="1.0" encoding="UTF-8"?> +<interface> + <requires lib="gtk+" version="3.20"/> + <object class="GtkDialog" id="request_passphrase_dialog"> + <property name="title" translatable="yes">Password Required</property> + <property name="modal">True</property> + <property name="destroy-with-parent">True</property> + <property name="use-header-bar">1</property> + <child internal-child="vbox"> + <object class="GtkBox"> + <property name="visible">True</property> + <property name="margin-top">20</property> + <property name="margin-bottom">20</property> + <property name="margin-start">20</property> + <property name="margin-end">20</property> + <child> + <object class="GtkLabel" id="label"> + <property name="visible">True</property> + <property name="max-width-chars">60</property> + <property name="wrap">True</property> + </object> + </child> + <child> + <object class="GtkEntry" id="entry"> + <property name="visible">True</property> + <property name="activates-default">True</property> + <property name="valign">end</property> + <property name="vexpand">True</property> + <property name="placeholder-text" translatable="yes">Enter password…</property> + <property name="visibility">False</property> + <property name="input-purpose">password</property> + </object> + </child> + </object> + </child> + <child type="action"> + <object class="GtkButton" id="cancel_button"> + <property name="visible">True</property> + <property name="label" translatable="yes">_Cancel</property> + <property name="use-underline">True</property> + </object> + </child> + <child type="action"> + <object class="GtkButton" id="extract_button"> + <property name="visible">True</property> + <property name="can-default">True</property> + <property name="label" translatable="yes">Extract</property> + </object> + </child> + <action-widgets> + <action-widget response="cancel">cancel_button</action-widget> + <action-widget response="ok" default="true">extract_button</action-widget> + </action-widgets> + </object> +</interface> |