[seahorse/wip/nielsdg/cleanup-sign-dialog: 1/3] pgp: Port sign dialog to GtkTemplate



commit f48ca96c8f201597d9d26ed8def2855c4ef3950e
Author: Niels De Graef <nielsdegraef gmail com>
Date:   Mon Feb 10 08:02:32 2020 +0100

    pgp: Port sign dialog to GtkTemplate
    
    Get rid of the stuff calling `SeahorseWidget`.

 data/seahorse.gresource.xml                        |   2 +-
 pgp/meson.build                                    |   2 +-
 pgp/seahorse-gpgme-dialogs.h                       |   6 -
 pgp/seahorse-gpgme-sign-dialog.c                   | 305 +++++++++++++++++++++
 pgp/seahorse-gpgme-sign-dialog.h                   |  32 +++
 ...horse-sign.ui => seahorse-gpgme-sign-dialog.ui} | 298 ++++++++++----------
 pgp/seahorse-gpgme-sign.c                          | 244 -----------------
 pgp/seahorse-pgp-key-properties.c                  |  22 +-
 po/POTFILES.in                                     |   4 +-
 9 files changed, 513 insertions(+), 402 deletions(-)
---
diff --git a/data/seahorse.gresource.xml b/data/seahorse.gresource.xml
index b2d3f376..12aafc98 100644
--- a/data/seahorse.gresource.xml
+++ b/data/seahorse.gresource.xml
@@ -30,6 +30,7 @@
     <file alias="seahorse-add-subkey.ui" preprocess="xml-stripblanks">../pgp/seahorse-add-subkey.ui</file>
     <file alias="seahorse-expires.ui" preprocess="xml-stripblanks">../pgp/seahorse-expires.ui</file>
     <file alias="seahorse-gpgme-add-uid.ui" 
preprocess="xml-stripblanks">../pgp/seahorse-gpgme-add-uid.ui</file>
+    <file alias="seahorse-gpgme-sign-dialog.ui" 
preprocess="xml-stripblanks">../pgp/seahorse-gpgme-sign-dialog.ui</file>
     <file alias="seahorse-keyserver-results.ui" 
preprocess="xml-stripblanks">../pgp/seahorse-keyserver-results.ui</file>
     <file alias="seahorse-keyserver-search.ui" 
preprocess="xml-stripblanks">../pgp/seahorse-keyserver-search.ui</file>
     <file alias="seahorse-keyserver-sync.ui" 
preprocess="xml-stripblanks">../pgp/seahorse-keyserver-sync.ui</file>
@@ -37,7 +38,6 @@
     <file alias="seahorse-pgp-private-key-properties.ui" 
preprocess="xml-stripblanks">../pgp/seahorse-pgp-private-key-properties.ui</file>
     <file alias="seahorse-pgp-public-key-properties.ui" 
preprocess="xml-stripblanks">../pgp/seahorse-pgp-public-key-properties.ui</file>
     <file alias="seahorse-revoke.ui" preprocess="xml-stripblanks">../pgp/seahorse-revoke.ui</file>
-    <file alias="seahorse-sign.ui" preprocess="xml-stripblanks">../pgp/seahorse-sign.ui</file>
     <file alias="seahorse-signer.ui" preprocess="xml-stripblanks">../pgp/seahorse-signer.ui</file>
 
     <!-- PKCS#11 -->
diff --git a/pgp/meson.build b/pgp/meson.build
index dd3b6279..ea332723 100644
--- a/pgp/meson.build
+++ b/pgp/meson.build
@@ -16,7 +16,7 @@ pgp_sources = [
   'seahorse-gpgme-photos.c',
   'seahorse-gpgme-revoke.c',
   'seahorse-gpgme-secret-deleter.c',
-  'seahorse-gpgme-sign.c',
+  'seahorse-gpgme-sign-dialog.c',
   'seahorse-gpgme-subkey.c',
   'seahorse-gpgme-uid.c',
   'seahorse-gpg-op.c',
diff --git a/pgp/seahorse-gpgme-dialogs.h b/pgp/seahorse-gpgme-dialogs.h
index fdc8dfd0..b9bb01c0 100644
--- a/pgp/seahorse-gpgme-dialogs.h
+++ b/pgp/seahorse-gpgme-dialogs.h
@@ -33,12 +33,6 @@
 #include "pgp/seahorse-gpgme-uid.h"
 #include "libseahorse/seahorse-widget.h"
 
-void            seahorse_gpgme_sign_prompt         (SeahorseGpgmeKey *key,
-                                                    GtkWindow *parent);
-
-void            seahorse_gpgme_sign_prompt_uid     (SeahorseGpgmeUid *uid,
-                                                    GtkWindow *parent);
-
 void            seahorse_gpgme_generate_register    (void);
 
 void            seahorse_gpgme_generate_show        (SeahorseGpgmeKeyring *keyring,
diff --git a/pgp/seahorse-gpgme-sign-dialog.c b/pgp/seahorse-gpgme-sign-dialog.c
new file mode 100644
index 00000000..1059f29e
--- /dev/null
+++ b/pgp/seahorse-gpgme-sign-dialog.c
@@ -0,0 +1,305 @@
+/*
+ * Seahorse
+ *
+ * Copyright (C) 2003 Jacob Perkins
+ * Copyright (C) 2006 Stefan Walter
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
+ * See the GNU General Public License for more details.
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, see
+ * <http://www.gnu.org/licenses/>.
+ */
+
+#include "config.h"
+
+#include "seahorse-combo-keys.h"
+#include "seahorse-gpgme-sign-dialog.h"
+#include "seahorse-gpgme-key-op.h"
+#include "seahorse-pgp-keysets.h"
+
+#include "seahorse-common.h"
+
+#include "libseahorse/seahorse-util.h"
+
+#include <glib/gi18n.h>
+
+struct _SeahorseGpgmeSignDialog {
+    GtkDialog parent_instance;
+
+    SeahorseObject *to_sign;
+
+    GtkWidget *to_sign_name_label;
+
+    GtkWidget *sign_display_not;
+    GtkWidget *sign_display_casual;
+    GtkWidget *sign_display_careful;
+
+    GtkWidget *sign_choice_not;
+    GtkWidget *sign_choice_casual;
+    GtkWidget *sign_choice_careful;
+
+    GtkWidget *sign_option_local;
+    GtkWidget *sign_option_revocable;
+
+    GtkWidget *signer_select;
+    GtkWidget *signer_frame;
+};
+
+enum {
+    PROP_0,
+    PROP_TO_SIGN,
+    N_PROPS
+};
+static GParamSpec *obj_props[N_PROPS] = { NULL, };
+
+G_DEFINE_TYPE (SeahorseGpgmeSignDialog, seahorse_gpgme_sign_dialog, GTK_TYPE_DIALOG)
+
+
+static void
+on_collection_changed (GcrCollection *collection,
+                       GObject *object,
+                       gpointer user_data)
+{
+    SeahorseGpgmeSignDialog *self = SEAHORSE_GPGME_SIGN_DIALOG (user_data);
+
+    gtk_widget_set_visible (self->signer_frame,
+                            gcr_collection_get_length (collection) > 1);
+}
+
+static void
+on_gpgme_sign_choice_toggled (GtkToggleButton *toggle,
+                              gpointer user_data)
+{
+    SeahorseGpgmeSignDialog *self = SEAHORSE_GPGME_SIGN_DIALOG (user_data);
+
+    /* Figure out choice */
+    gtk_widget_set_visible (self->sign_display_not,
+                            gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (self->sign_choice_not)));
+
+    gtk_widget_set_visible (self->sign_display_casual,
+                            gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (self->sign_choice_casual)));
+
+    gtk_widget_set_visible (self->sign_display_careful,
+                            gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (self->sign_choice_careful)));
+}
+
+static void
+seahorse_gpgme_sign_dialog_response (GtkDialog *dialog, int response)
+{
+    SeahorseGpgmeSignDialog *self = SEAHORSE_GPGME_SIGN_DIALOG (dialog);
+    SeahorseSignCheck check;
+    SeahorseSignOptions options = 0;
+    SeahorsePgpKey *signer;
+    gpgme_error_t err;
+
+    if (response != GTK_RESPONSE_OK)
+        return;
+
+    /* Figure out choice */
+    check = SIGN_CHECK_NO_ANSWER;
+    if (gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (self->sign_choice_not)))
+        check = SIGN_CHECK_NONE;
+    else {
+        if (gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (self->sign_choice_casual)))
+            check = SIGN_CHECK_CASUAL;
+        else {
+            if (gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (self->sign_choice_careful)))
+                check = SIGN_CHECK_CAREFUL;
+        }
+    }
+
+    /* Local signature */
+    if (gtk_switch_get_active (GTK_SWITCH (self->sign_option_local)))
+        options |= SIGN_LOCAL;
+
+    /* Revocable signature */
+    if (!gtk_switch_get_active (GTK_SWITCH (self->sign_option_revocable)))
+        options |= SIGN_NO_REVOKE;
+
+    /* Signer */
+    signer = seahorse_combo_keys_get_active (GTK_COMBO_BOX (self->signer_select));
+
+    g_assert (!signer || (SEAHORSE_GPGME_IS_KEY (signer) &&
+                          seahorse_object_get_usage (SEAHORSE_OBJECT (signer)) == 
SEAHORSE_USAGE_PRIVATE_KEY));
+
+    if (SEAHORSE_GPGME_IS_UID (self->to_sign))
+        err = seahorse_gpgme_key_op_sign_uid (SEAHORSE_GPGME_UID (self->to_sign), SEAHORSE_GPGME_KEY 
(signer), check, options);
+    else if (SEAHORSE_GPGME_IS_KEY (self->to_sign))
+        err = seahorse_gpgme_key_op_sign (SEAHORSE_GPGME_KEY (self->to_sign), SEAHORSE_GPGME_KEY (signer), 
check, options);
+    else
+        g_assert (FALSE);
+
+
+    if (!GPG_IS_OK (err)) {
+        if (gpgme_err_code (err) == GPG_ERR_EALREADY) {
+            GtkWidget *w;
+
+            w = gtk_message_dialog_new (GTK_WINDOW (self), GTK_DIALOG_MODAL, GTK_MESSAGE_INFO, 
GTK_BUTTONS_CLOSE,
+                                        _("This key was already signed by\n“%s”"),
+                                        seahorse_object_get_label (SEAHORSE_OBJECT (signer)));
+            gtk_dialog_run (GTK_DIALOG (w));
+            gtk_widget_destroy (w);
+        } else
+            seahorse_gpgme_handle_error (err, _("Couldn’t sign key"));
+    }
+}
+
+static void
+seahorse_gpgme_sign_dialog_get_property (GObject *object,
+                                         guint prop_id,
+                                         GValue *value,
+                                         GParamSpec *pspec)
+{
+    SeahorseGpgmeSignDialog *self = SEAHORSE_GPGME_SIGN_DIALOG (object);
+
+    switch (prop_id) {
+    case PROP_TO_SIGN:
+        g_value_set_object (value, self->to_sign);
+        break;
+    default:
+        G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
+        break;
+    }
+}
+
+static void
+seahorse_gpgme_sign_dialog_set_property (GObject *object,
+                                         guint prop_id,
+                                         const GValue *value,
+                                         GParamSpec *pspec)
+{
+    SeahorseGpgmeSignDialog *self = SEAHORSE_GPGME_SIGN_DIALOG (object);
+
+    switch (prop_id) {
+    case PROP_TO_SIGN:
+        g_clear_object (&self->to_sign);
+        self->to_sign = g_value_dup_object (value);
+        break;
+    default:
+        G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
+        break;
+    }
+}
+
+static void
+seahorse_gpgme_sign_dialog_finalize (GObject *obj)
+{
+    SeahorseGpgmeSignDialog *self = SEAHORSE_GPGME_SIGN_DIALOG (obj);
+
+    g_clear_object (&self->to_sign);
+
+    G_OBJECT_CLASS (seahorse_gpgme_sign_dialog_parent_class)->finalize (obj);
+}
+
+static void
+seahorse_gpgme_sign_dialog_constructed (GObject *obj)
+{
+    SeahorseGpgmeSignDialog *self = SEAHORSE_GPGME_SIGN_DIALOG (obj);
+    g_autofree char *userid = NULL;
+
+    G_OBJECT_CLASS (seahorse_gpgme_sign_dialog_parent_class)->constructed (obj);
+
+    userid = g_markup_printf_escaped("<i>%s</i>",
+                                     seahorse_object_get_label (self->to_sign));
+    gtk_label_set_markup (GTK_LABEL (self->to_sign_name_label), userid);
+
+    /* Initial choice */
+    on_gpgme_sign_choice_toggled (NULL, self);
+
+    /* Other question's default state */
+    gtk_switch_set_active (GTK_SWITCH (self->sign_option_local), FALSE);
+    gtk_switch_set_active (GTK_SWITCH (self->sign_option_revocable), TRUE);
+}
+
+static void
+seahorse_gpgme_sign_dialog_init (SeahorseGpgmeSignDialog *self)
+{
+    gtk_widget_init_template (GTK_WIDGET (self));
+}
+
+static void
+seahorse_gpgme_sign_dialog_class_init (SeahorseGpgmeSignDialogClass *klass)
+{
+    GObjectClass *gobject_class = G_OBJECT_CLASS (klass);
+    GtkWidgetClass *widget_class = GTK_WIDGET_CLASS (klass);
+    GtkDialogClass *dialog_class = GTK_DIALOG_CLASS (klass);
+
+    gobject_class->constructed = seahorse_gpgme_sign_dialog_constructed;
+    gobject_class->get_property = seahorse_gpgme_sign_dialog_get_property;
+    gobject_class->set_property = seahorse_gpgme_sign_dialog_set_property;
+    gobject_class->finalize = seahorse_gpgme_sign_dialog_finalize;
+
+    obj_props[PROP_TO_SIGN] =
+        g_param_spec_object ("to-sign", "Item to be signed",
+                             "The GPGME key or uid you want to sign",
+                             SEAHORSE_TYPE_OBJECT,
+                             G_PARAM_READWRITE |
+                             G_PARAM_CONSTRUCT_ONLY |
+                             G_PARAM_STATIC_STRINGS);
+
+    g_object_class_install_properties (gobject_class, N_PROPS, obj_props);
+
+    gtk_widget_class_set_template_from_resource (widget_class, 
"/org/gnome/Seahorse/seahorse-gpgme-sign-dialog.ui");
+    gtk_widget_class_bind_template_child (widget_class, SeahorseGpgmeSignDialog, to_sign_name_label);
+    gtk_widget_class_bind_template_child (widget_class, SeahorseGpgmeSignDialog, sign_display_not);
+    gtk_widget_class_bind_template_child (widget_class, SeahorseGpgmeSignDialog, sign_display_casual);
+    gtk_widget_class_bind_template_child (widget_class, SeahorseGpgmeSignDialog, sign_display_careful);
+    gtk_widget_class_bind_template_child (widget_class, SeahorseGpgmeSignDialog, sign_choice_not);
+    gtk_widget_class_bind_template_child (widget_class, SeahorseGpgmeSignDialog, sign_choice_casual);
+    gtk_widget_class_bind_template_child (widget_class, SeahorseGpgmeSignDialog, sign_choice_careful);
+    gtk_widget_class_bind_template_child (widget_class, SeahorseGpgmeSignDialog, sign_option_local);
+    gtk_widget_class_bind_template_child (widget_class, SeahorseGpgmeSignDialog, sign_option_revocable);
+    gtk_widget_class_bind_template_child (widget_class, SeahorseGpgmeSignDialog, signer_frame);
+    gtk_widget_class_bind_template_child (widget_class, SeahorseGpgmeSignDialog, signer_select);
+    gtk_widget_class_bind_template_callback (widget_class, on_gpgme_sign_choice_toggled);
+
+    dialog_class->response = seahorse_gpgme_sign_dialog_response;
+}
+
+SeahorseGpgmeSignDialog *
+seahorse_gpgme_sign_dialog_new (SeahorseObject *to_sign)
+{
+    g_autoptr(SeahorseGpgmeSignDialog) self = NULL;
+    GcrCollection *collection;
+
+    g_return_val_if_fail (SEAHORSE_GPGME_IS_KEY (to_sign) ||
+                          SEAHORSE_GPGME_IS_UID (to_sign), NULL);
+
+    /* If no signing keys then we can't sign */
+    collection = seahorse_keyset_pgp_signers_new ();
+    if (gcr_collection_get_length (collection) == 0) {
+        /* TODO: We should be giving an error message that allows them to
+           generate or import a key */
+        seahorse_util_show_error (NULL, _("No keys usable for signing"),
+                _("You have no personal PGP keys that can be used to indicate your trust of this key."));
+        return NULL;
+    }
+
+    self = g_object_new (SEAHORSE_GPGME_TYPE_SIGN_DIALOG,
+                         "to-sign", to_sign,
+                         "use-header-bar", 1,
+                         NULL);
+
+    /* Signature area */
+    g_signal_connect_object (collection, "added",
+                             G_CALLBACK (on_collection_changed), self, 0);
+    g_signal_connect_object (collection, "removed",
+                             G_CALLBACK (on_collection_changed), self, 0);
+    on_collection_changed (collection, NULL, self);
+
+    /* Signer box */
+    seahorse_combo_keys_attach (GTK_COMBO_BOX (self->signer_select),
+                                collection, NULL);
+
+    g_object_unref (collection);
+
+    return g_steal_pointer (&self);
+}
diff --git a/pgp/seahorse-gpgme-sign-dialog.h b/pgp/seahorse-gpgme-sign-dialog.h
new file mode 100644
index 00000000..f99a81af
--- /dev/null
+++ b/pgp/seahorse-gpgme-sign-dialog.h
@@ -0,0 +1,32 @@
+/*
+ * Seahorse
+ *
+ * Copyright (C) 2020 Niels De Graef
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
+ * See the GNU General Public License for more details.
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, see
+ * <http://www.gnu.org/licenses/>.
+ */
+
+#pragma once
+
+#include <gtk/gtk.h>
+
+#include "pgp/seahorse-gpgme-key.h"
+#include "pgp/seahorse-gpgme-uid.h"
+
+#define SEAHORSE_GPGME_TYPE_SIGN_DIALOG (seahorse_gpgme_sign_dialog_get_type ())
+G_DECLARE_FINAL_TYPE (SeahorseGpgmeSignDialog, seahorse_gpgme_sign_dialog,
+                      SEAHORSE_GPGME, SIGN_DIALOG,
+                      GtkDialog)
+
+SeahorseGpgmeSignDialog*   seahorse_gpgme_sign_dialog_new    (SeahorseObject *to_sign);
diff --git a/pgp/seahorse-sign.ui b/pgp/seahorse-gpgme-sign-dialog.ui
similarity index 52%
rename from pgp/seahorse-sign.ui
rename to pgp/seahorse-gpgme-sign-dialog.ui
index d6cfccb6..cf03894d 100644
--- a/pgp/seahorse-sign.ui
+++ b/pgp/seahorse-gpgme-sign-dialog.ui
@@ -1,26 +1,24 @@
 <?xml version="1.0"?>
 <interface>
   <requires lib="gtk+" version="3.22"/>
-  <object class="GtkDialog" id="sign">
-    <property name="border_width">5</property>
+  <template class="SeahorseGpgmeSignDialog" parent="GtkDialog">
+    <property name="visible">True</property>
     <property name="title" translatable="yes">Sign Key</property>
     <property name="resizable">False</property>
     <property name="use_header_bar">1</property>
-    <property name="window_position">center</property>
-    <property name="type_hint">dialog</property>
     <child internal-child="vbox">
-      <object class="GtkBox" id="dialog-vbox1">
+      <object class="GtkBox">
         <property name="visible">True</property>
         <property name="orientation">vertical</property>
-        <property name="border_width">5</property>
+        <property name="border_width">12</property>
         <property name="spacing">18</property>
         <child>
-          <object class="GtkBox" id="vbox11">
+          <object class="GtkBox">
             <property name="visible">True</property>
             <property name="orientation">vertical</property>
             <property name="spacing">6</property>
             <child>
-              <object class="GtkLabel" id="label13">
+              <object class="GtkLabel">
                 <property name="visible">True</property>
                 <property name="xalign">0</property>
                 <property name="yalign">0</property>
@@ -28,7 +26,7 @@
               </object>
             </child>
             <child>
-              <object class="GtkLabel" id="sign-uid-text">
+              <object class="GtkLabel" id="to_sign_name_label">
                 <property name="visible">True</property>
                 <property name="yalign">0</property>
                 <property name="label" translatable="yes">Key Name</property>
@@ -58,130 +56,109 @@
               </object>
             </child>
             <child>
-              <object class="GtkAlignment" id="alignment5">
+              <object class="GtkBox">
                 <property name="visible">True</property>
-                <property name="xalign">1</property>
-                <property name="yalign">1</property>
-                <property name="left_padding">12</property>
+                <property name="orientation">vertical</property>
+                <property name="spacing">6</property>
+                <property name="margin-start">12</property>
                 <child>
-                  <object class="GtkBox" id="vbox2">
+                  <object class="GtkBox">
                     <property name="visible">True</property>
                     <property name="orientation">vertical</property>
                     <property name="spacing">6</property>
                     <child>
-                      <object class="GtkBox" id="vbox3">
+                      <object class="GtkBox">
+                        <property name="visible">True</property>
+                        <property name="orientation">horizontal</property>
+                        <property name="spacing">12</property>
+                        <property name="homogeneous">True</property>
+                        <child>
+                          <object class="GtkRadioButton" id="sign_choice_not">
+                            <property name="label" translatable="yes">_Not at all</property>
+                            <property name="visible">True</property>
+                            <property name="can_focus">True</property>
+                            <property name="receives_default">False</property>
+                            <property name="use_underline">True</property>
+                            <property name="draw_indicator">True</property>
+                            <signal name="toggled" handler="on_gpgme_sign_choice_toggled"/>
+                          </object>
+                        </child>
+                        <child>
+                          <object class="GtkRadioButton" id="sign_choice_casual">
+                            <property name="label" translatable="yes">_Casually</property>
+                            <property name="visible">True</property>
+                            <property name="can_focus">True</property>
+                            <property name="receives_default">False</property>
+                            <property name="use_underline">True</property>
+                            <property name="draw_indicator">True</property>
+                            <property name="group">sign_choice_not</property>
+                            <signal name="toggled" handler="on_gpgme_sign_choice_toggled"/>
+                          </object>
+                        </child>
+                        <child>
+                          <object class="GtkRadioButton" id="sign_choice_careful">
+                            <property name="label" translatable="yes">_Very Carefully</property>
+                            <property name="visible">True</property>
+                            <property name="can_focus">True</property>
+                            <property name="receives_default">False</property>
+                            <property name="use_underline">True</property>
+                            <property name="draw_indicator">True</property>
+                            <property name="group">sign_choice_not</property>
+                            <signal name="toggled" handler="on_gpgme_sign_choice_toggled"/>
+                          </object>
+                        </child>
+                      </object>
+                    </child>
+                    <child>
+                      <object class="GtkAlignment" id="alignment2">
                         <property name="visible">True</property>
-                        <property name="orientation">vertical</property>
-                        <property name="spacing">6</property>
+                        <property name="xalign">1</property>
+                        <property name="yalign">1</property>
+                        <property name="left_padding">18</property>
                         <child>
-                          <object class="GtkBox" id="hbox4">
+                          <object class="GtkBox" id="vbox12">
                             <property name="visible">True</property>
-                            <property name="orientation">horizontal</property>
-                            <property name="spacing">12</property>
-                            <property name="homogeneous">True</property>
+                            <property name="orientation">vertical</property>
                             <child>
-                              <object class="GtkRadioButton" id="sign-choice-not">
-                                <property name="label" translatable="yes">_Not at all</property>
-                                <property name="visible">True</property>
+                              <object class="GtkLabel" id="sign_display_not">
                                 <property name="can_focus">True</property>
-                                <property name="receives_default">False</property>
-                                <property name="use_underline">True</property>
-                                <property name="draw_indicator">True</property>
-                                <signal name="toggled" handler="on_gpgme_sign_choice_toggled"/>
+                                <property name="xalign">0</property>
+                                <property name="yalign">0</property>
+                                <property name="label" translatable="yes">&lt;i&gt;Not at all:&lt;/i&gt; 
means you believe the key is owned by the person who claims to own it, but you could not or did not verify 
this to be a fact.</property>
+                                <property name="use_markup">True</property>
+                                <property name="justify">fill</property>
+                                <property name="wrap">True</property>
+                                <property name="max_width_chars">75</property>
+                                <property name="selectable">True</property>
                               </object>
                             </child>
                             <child>
-                              <object class="GtkRadioButton" id="sign-choice-casual">
-                                <property name="label" translatable="yes">_Casually</property>
-                                <property name="visible">True</property>
+                              <object class="GtkLabel" id="sign_display_casual">
                                 <property name="can_focus">True</property>
-                                <property name="receives_default">False</property>
-                                <property name="use_underline">True</property>
-                                <property name="draw_indicator">True</property>
-                                <property name="group">sign-choice-not</property>
-                                <signal name="toggled" handler="on_gpgme_sign_choice_toggled"/>
+                                <property name="xalign">0</property>
+                                <property name="yalign">0</property>
+                                <property name="label" translatable="yes">&lt;i&gt;Casually:&lt;/i&gt; means 
you have done a casual verification that the key is owned by the person who claims to own it. For example, 
you could read the key fingerprint to the owner over the phone.</property>
+                                <property name="use_markup">True</property>
+                                <property name="justify">fill</property>
+                                <property name="wrap">True</property>
+                                <property name="max_width_chars">75</property>
+                                <property name="selectable">True</property>
                               </object>
                             </child>
                             <child>
-                              <object class="GtkRadioButton" id="sign-choice-careful">
-                                <property name="label" translatable="yes">_Very Carefully</property>
-                                <property name="visible">True</property>
-                                <property name="can_focus">True</property>
-                                <property name="receives_default">False</property>
-                                <property name="use_underline">True</property>
-                                <property name="draw_indicator">True</property>
-                                <property name="group">sign-choice-not</property>
-                                <signal name="toggled" handler="on_gpgme_sign_choice_toggled"/>
-                              </object>
-                            </child>
-                          </object>
-                        </child>
-                        <child>
-                          <object class="GtkAlignment" id="alignment2">
-                            <property name="visible">True</property>
-                            <property name="xalign">1</property>
-                            <property name="yalign">1</property>
-                            <property name="left_padding">18</property>
-                            <child>
-                              <object class="GtkBox" id="vbox12">
-                                <property name="visible">True</property>
+                              <object class="GtkBox" id="sign_display_careful">
+                                <property name="spacing">6</property>
                                 <property name="orientation">vertical</property>
                                 <child>
-                                  <object class="GtkLabel" id="sign-display-not">
-                                    <property name="can_focus">True</property>
-                                    <property name="xalign">0</property>
-                                    <property name="yalign">0</property>
-                                    <property name="label" translatable="yes">&lt;i&gt;Not at all:&lt;/i&gt; 
means you believe the key is owned by the person who claims to own it, but you could not or did not verify 
this to be a fact.</property>
-                                    <property name="use_markup">True</property>
-                                    <property name="justify">fill</property>
-                                    <property name="wrap">True</property>
-                                    <property name="max_width_chars">75</property>
-                                    <property name="selectable">True</property>
-                                  </object>
-                                </child>
-                                <child>
-                                  <object class="GtkLabel" id="sign-display-casual">
-                                    <property name="can_focus">True</property>
-                                    <property name="xalign">0</property>
-                                    <property name="yalign">0</property>
-                                    <property name="label" translatable="yes">&lt;i&gt;Casually:&lt;/i&gt; 
means you have done a casual verification that the key is owned by the person who claims to own it. For 
example, you could read the key fingerprint to the owner over the phone.</property>
-                                    <property name="use_markup">True</property>
-                                    <property name="justify">fill</property>
-                                    <property name="wrap">True</property>
-                                    <property name="max_width_chars">75</property>
-                                    <property name="selectable">True</property>
-                                  </object>
-                                </child>
-                                <child>
-                                  <object class="GtkBox" id="sign-display-careful">
-                                    <property name="spacing">6</property>
-                                    <property name="orientation">vertical</property>
+                                  <object class="GtkEventBox" id="eventbox1">
+                                    <property name="visible">True</property>
                                     <child>
-                                      <object class="GtkEventBox" id="eventbox1">
-                                        <property name="visible">True</property>
-                                        <child>
-                                          <object class="GtkLabel" id="label7">
-                                            <property name="visible">True</property>
-                                            <property name="can_focus">True</property>
-                                            <property name="xalign">0</property>
-                                            <property name="yalign">0</property>
-                                            <property name="label" translatable="yes">&lt;i&gt;Very 
Carefully:&lt;/i&gt; Select this only if you are absolutely sure that this key is genuine.</property>
-                                            <property name="use_markup">True</property>
-                                            <property name="justify">fill</property>
-                                            <property name="wrap">True</property>
-                                            <property name="max_width_chars">75</property>
-                                            <property name="selectable">True</property>
-                                          </object>
-                                        </child>
-                                      </object>
-                                    </child>
-                                    <child>
-                                      <object class="GtkLabel" id="label12">
+                                      <object class="GtkLabel" id="label7">
                                         <property name="visible">True</property>
                                         <property name="can_focus">True</property>
                                         <property name="xalign">0</property>
                                         <property name="yalign">0</property>
-                                        <property name="label" translatable="yes">You could use a hard to 
forge photo identification (such as a passport) to personally check that the name on the key is correct. You 
should have also used email to check that the email address belongs to the owner.</property>
+                                        <property name="label" translatable="yes">&lt;i&gt;Very 
Carefully:&lt;/i&gt; Select this only if you are absolutely sure that this key is genuine.</property>
                                         <property name="use_markup">True</property>
                                         <property name="justify">fill</property>
                                         <property name="wrap">True</property>
@@ -191,6 +168,20 @@
                                     </child>
                                   </object>
                                 </child>
+                                <child>
+                                  <object class="GtkLabel" id="label12">
+                                    <property name="visible">True</property>
+                                    <property name="can_focus">True</property>
+                                    <property name="xalign">0</property>
+                                    <property name="yalign">0</property>
+                                    <property name="label" translatable="yes">You could use a hard to forge 
photo identification (such as a passport) to personally check that the name on the key is correct. You should 
have also used email to check that the email address belongs to the owner.</property>
+                                    <property name="use_markup">True</property>
+                                    <property name="justify">fill</property>
+                                    <property name="wrap">True</property>
+                                    <property name="max_width_chars">75</property>
+                                    <property name="selectable">True</property>
+                                  </object>
+                                </child>
                               </object>
                             </child>
                           </object>
@@ -204,7 +195,7 @@
           </object>
         </child>
         <child>
-          <object class="GtkBox" id="vbox8">
+          <object class="GtkBox">
             <property name="visible">True</property>
             <property name="orientation">vertical</property>
             <property name="spacing">12</property>
@@ -219,50 +210,73 @@
               </object>
             </child>
             <child>
-              <object class="GtkAlignment" id="alignment6">
+              <object class="GtkGrid">
                 <property name="visible">True</property>
-                <property name="left_padding">12</property>
+                <property name="row-spacing">12</property>
+                <property name="column-spacing">12</property>
+                <property name="margin-start">12</property>
                 <child>
-                  <object class="GtkBox" id="vbox7">
+                  <object class="GtkLabel">
                     <property name="visible">True</property>
-                    <property name="orientation">vertical</property>
-                    <property name="spacing">12</property>
-                    <child>
-                      <object class="GtkCheckButton" id="sign-option-local">
-                        <property name="label" translatable="yes">_Others may not see this 
signature</property>
-                        <property name="visible">True</property>
-                        <property name="can_focus">True</property>
-                        <property name="receives_default">False</property>
-                        <property name="tooltip_text">If signature is local to the key ring and won't be 
exported with the key</property>
-                        <property name="use_underline">True</property>
-                        <property name="draw_indicator">True</property>
-                      </object>
-                    </child>
-                    <child>
-                      <object class="GtkCheckButton" id="sign-option-revocable">
-                        <property name="label" translatable="yes">I can _revoke this signature at a later 
date.</property>
-                        <property name="visible">True</property>
-                        <property name="can_focus">True</property>
-                        <property name="receives_default">False</property>
-                        <property name="tooltip_text">If signature can be revoked</property>
-                        <property name="use_underline">True</property>
-                        <property name="active">True</property>
-                        <property name="draw_indicator">True</property>
-                      </object>
-                    </child>
+                    <property name="xalign">0</property>
+                    <property name="label" translatable="yes">_Others may not see this signature</property>
+                    <property name="tooltip_text">If signature is local to the key ring and won't be 
exported with the key</property>
+                    <property name="use_underline">True</property>
+                    <property name="mnemonic-widget">sign_option_local</property>
+                  </object>
+                  <packing>
+                    <property name="top_attach">0</property>
+                    <property name="left_attach">0</property>
+                  </packing>
+                </child>
+                <child>
+                  <object class="GtkSwitch" id="sign_option_local">
+                    <property name="visible">True</property>
+                    <property name="can_focus">True</property>
+                    <property name="receives_default">False</property>
+                    <property name="tooltip_text">If signature is local to the key ring and won't be 
exported with the key</property>
+                  </object>
+                  <packing>
+                    <property name="top_attach">0</property>
+                    <property name="left_attach">1</property>
+                  </packing>
+                </child>
+                <child>
+                  <object class="GtkLabel">
+                    <property name="visible">True</property>
+                    <property name="xalign">0</property>
+                    <property name="label" translatable="yes">I can _revoke this signature at a later 
date.</property>
+                    <property name="tooltip_text">If signature can be revoked</property>
+                    <property name="use_underline">True</property>
+                    <property name="mnemonic-widget">sign_option_revocable</property>
+                  </object>
+                  <packing>
+                    <property name="top_attach">1</property>
+                    <property name="left_attach">0</property>
+                  </packing>
+                </child>
+                <child>
+                  <object class="GtkSwitch" id="sign_option_revocable">
+                    <property name="visible">True</property>
+                    <property name="tooltip_text">If signature can be revoked</property>
+                    <property name="active">True</property>
                   </object>
+                  <packing>
+                    <property name="top_attach">1</property>
+                    <property name="left_attach">1</property>
+                  </packing>
                 </child>
               </object>
             </child>
           </object>
         </child>
         <child>
-          <object class="GtkBox" id="signer-frame">
+          <object class="GtkBox" id="signer_frame">
             <property name="visible">True</property>
             <property name="orientation">vertical</property>
             <property name="spacing">12</property>
             <child>
-              <object class="GtkLabel" id="label10">
+              <object class="GtkLabel">
                 <property name="visible">True</property>
                 <property name="xalign">0</property>
                 <property name="label" translatable="yes">Sign key as:</property>
@@ -285,11 +299,11 @@
                         <property name="visible">True</property>
                         <property name="label" translatable="yes">_Signer:</property>
                         <property name="use_underline">True</property>
-                        <property name="mnemonic_widget">signer-select</property>
+                        <property name="mnemonic_widget">signer_select</property>
                       </object>
                     </child>
                     <child>
-                      <object class="GtkComboBox" id="signer-select">
+                      <object class="GtkComboBox" id="signer_select">
                         <property name="visible">True</property>
                       </object>
                     </child>
@@ -326,5 +340,5 @@
       <action-widget response="-6">cancel_button</action-widget>
       <action-widget response="-5" default="true">ok_button</action-widget>
     </action-widgets>
-  </object>
+  </template>
 </interface>
diff --git a/pgp/seahorse-pgp-key-properties.c b/pgp/seahorse-pgp-key-properties.c
index 20bdf08b..98152978 100644
--- a/pgp/seahorse-pgp-key-properties.c
+++ b/pgp/seahorse-pgp-key-properties.c
@@ -29,6 +29,7 @@
 #include "seahorse-gpgme-exporter.h"
 #include "seahorse-gpgme-key.h"
 #include "seahorse-gpgme-key-op.h"
+#include "seahorse-gpgme-sign-dialog.h"
 #include "seahorse-pgp-backend.h"
 #include "seahorse-gpg-op.h"
 #include "seahorse-pgp-dialogs.h"
@@ -294,13 +295,17 @@ on_uids_sign (GSimpleAction *action, GVariant *param, gpointer user_data)
 {
     SeahorsePgpKeyProperties *self = SEAHORSE_PGP_KEY_PROPERTIES (user_data);
     SeahorsePgpUid *uid;
+    SeahorseGpgmeSignDialog *dialog;
 
     uid = names_get_selected_uid (self);
-    if (uid != NULL) {
-        g_return_if_fail (SEAHORSE_GPGME_IS_UID (uid));
-        seahorse_gpgme_sign_prompt_uid (SEAHORSE_GPGME_UID (uid),
-                                        GTK_WINDOW (self));
-    }
+    if (uid == NULL)
+        return;
+
+    g_return_if_fail (SEAHORSE_GPGME_IS_UID (uid));
+
+    dialog = seahorse_gpgme_sign_dialog_new (SEAHORSE_OBJECT (uid));
+    gtk_dialog_run (GTK_DIALOG (dialog));
+    gtk_widget_destroy (GTK_WIDGET (dialog));
 }
 
 static void
@@ -1424,9 +1429,14 @@ static void
 on_sign_key (GSimpleAction *action, GVariant *param, gpointer user_data)
 {
     SeahorsePgpKeyProperties *self = SEAHORSE_PGP_KEY_PROPERTIES (user_data);
+    SeahorseGpgmeSignDialog *dialog;
 
     g_return_if_fail (SEAHORSE_GPGME_IS_KEY (self->key));
-    seahorse_gpgme_sign_prompt (SEAHORSE_GPGME_KEY (self->key), GTK_WINDOW (self));
+
+    dialog = seahorse_gpgme_sign_dialog_new (SEAHORSE_OBJECT (self->key));
+
+    gtk_dialog_run (GTK_DIALOG (dialog));
+    gtk_widget_destroy (GTK_WIDGET (dialog));
 }
 
 /* When the 'only display trusted' check is checked, hide untrusted rows */
diff --git a/po/POTFILES.in b/po/POTFILES.in
index 87a6936b..1b3df726 100644
--- a/po/POTFILES.in
+++ b/po/POTFILES.in
@@ -53,7 +53,8 @@ pgp/seahorse-gpgme-keyring.c
 pgp/seahorse-gpgme-photos.c
 pgp/seahorse-gpgme-revoke.c
 pgp/seahorse-gpgme-secret-deleter.c
-pgp/seahorse-gpgme-sign.c
+pgp/seahorse-gpgme-sign-dialog.c
+pgp/seahorse-gpgme-sign-dialog.ui
 pgp/seahorse-gpgme-subkey.c
 pgp/seahorse-gpg-options.c
 pgp/seahorse-hkp-source.c
@@ -76,7 +77,6 @@ pgp/seahorse-revoke.ui
 pgp/seahorse-server-source.c
 pgp/seahorse-signer.c
 pgp/seahorse-signer.ui
-pgp/seahorse-sign.ui
 pgp/seahorse-transfer.c
 pgp/seahorse-unknown.c
 pgp/seahorse-unknown-source.c



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]