[seahorse] ItemProperties: Add a delete button



commit 65a57bd07c2ace53aa22c52056e129c59f49da1a
Author: Elias Entrup <elias-git flump de>
Date:   Tue Sep 18 16:12:49 2018 +0200

    ItemProperties: Add a delete button
    
    Add a button that deletes the item and closes
    the dialog. If the deletion fails, an error dialog
    will be shown.
    
    https://gitlab.gnome.org/GNOME/seahorse/issues/198

 gkr/gkr-item-properties.vala        | 24 ++++++++++++++++++++++++
 gkr/seahorse-gkr-item-properties.ui | 19 +++++++++++++++++++
 2 files changed, 43 insertions(+)
---
diff --git a/gkr/gkr-item-properties.vala b/gkr/gkr-item-properties.vala
index 7b14f286..a26ec2f7 100644
--- a/gkr/gkr-item-properties.vala
+++ b/gkr/gkr-item-properties.vala
@@ -247,4 +247,28 @@ public class Seahorse.Gkr.ItemProperties : Gtk.Dialog {
         var clipboard = Gtk.Clipboard.get_default(this.get_display());
         clipboard.set_text(password, -1);
     }
+
+    [GtkCallback]
+    private void on_delete_button_clicked() {
+        var deleter = this.item.create_deleter();
+        var ret = deleter.prompt(this);
+
+        if (!ret)
+            return;
+
+        deleter.delete.begin(null, (obj, res) => {
+            try {
+                deleter.delete.end(res);
+                this.destroy();
+            } catch (GLib.Error e) {
+                var dialog = new Gtk.MessageDialog(this,
+                    Gtk.DialogFlags.MODAL,
+                    Gtk.MessageType.ERROR,
+                    Gtk.ButtonsType.OK,
+                    _("Error deleting the password."));
+                dialog.run();
+                dialog.destroy();
+            }
+        });
+    }
 }
diff --git a/gkr/seahorse-gkr-item-properties.ui b/gkr/seahorse-gkr-item-properties.ui
index d847bcc7..9c04431d 100644
--- a/gkr/seahorse-gkr-item-properties.ui
+++ b/gkr/seahorse-gkr-item-properties.ui
@@ -250,6 +250,25 @@
             <property name="position">0</property>
           </packing>
         </child>
+        <child>
+          <object class="GtkButton">
+            <property name="label" translatable="yes">Delete Password</property>
+            <property name="visible">True</property>
+            <property name="can_focus">True</property>
+            <property name="receives_default">True</property>
+            <property name="halign">end</property>
+            <signal name="clicked" handler="on_delete_button_clicked" swapped="no"/>
+            <style>
+              <class name="destructive-action"/>
+            </style>
+          </object>
+          <packing>
+            <property name="expand">False</property>
+            <property name="fill">True</property>
+            <property name="pack_type">end</property>
+            <property name="position">1</property>
+          </packing>
+        </child>
       </object>
     </child>
   </template>


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