[Xfce4-commits] [apps/xfce4-panel-profiles] 01/01: Add a confirmation dialog and option to create a backup before applying (bug #14559)

noreply at xfce.org noreply at xfce.org
Thu Dec 19 03:34:20 CET 2019


This is an automated email from the git hooks/post-receive script.

b   l   u   e   s   a   b   r   e       p   u   s   h   e   d       a       c   o   m   m   i   t       t   o       b   r   a   n   c   h       m   a   s   t   e   r   
   in repository apps/xfce4-panel-profiles.

commit a440127d0cd90e18bdd193af37d31b61c5eebd19
Author: Emanuele Petriglia <inbox at emanuelepetriglia.com>
Date:   Wed Dec 18 21:34:05 2019 -0500

    Add a confirmation dialog and option to create a backup before applying (bug #14559)
    
    Signed-off-by: Sean Davis <smd.seandavis at gmail.com>
---
 xfce4-panel-profiles/xfce4-panel-profiles.py | 38 +++++++++++++++++++++++++++-
 1 file changed, 37 insertions(+), 1 deletion(-)

diff --git a/xfce4-panel-profiles/xfce4-panel-profiles.py b/xfce4-panel-profiles/xfce4-panel-profiles.py
index 82f8cb2..72645bc 100644
--- a/xfce4-panel-profiles/xfce4-panel-profiles.py
+++ b/xfce4-panel-profiles/xfce4-panel-profiles.py
@@ -269,7 +269,14 @@ class XfcePanelProfiles:
 
     def on_apply_clicked(self, widget):
         filename = self.get_selected_filename()
-        self.load_configuration(filename)
+
+        dialog = PanelConfirmDialog(self.window)
+        if dialog.run() == Gtk.ResponseType.ACCEPT:
+            if dialog.backup.get_active():
+                self.on_save_clicked(dialog)
+
+            self.load_configuration(filename)
+        dialog.destroy()
 
     def delete_configuration(self, filename):
         if os.path.isfile(filename):
@@ -345,6 +352,35 @@ class PanelSaveDialog(Gtk.MessageDialog):
         self.entry.set_text(name.strip())
 
 
+
+class PanelConfirmDialog(Gtk.MessageDialog):
+    '''Ask to the user if he wants to apply a configuration, because the current
+    configuration will be lost.'''
+
+    def __init__(self, parent=None):
+        message = _("Do you want to apply this configuration?\n"
+                    " The current configuration will be lost!")
+
+        Gtk.MessageDialog.__init__(
+            self, transient_for=parent, modal=True,
+            message_type=Gtk.MessageType.QUESTION,
+            text=message)
+
+        self.add_buttons(
+            _("Cancel"), Gtk.ResponseType.CANCEL,
+            _("Apply Configuration"), Gtk.ResponseType.ACCEPT
+        )
+
+        self.set_default_icon_name("dialog-information")
+        self.set_default_response(Gtk.ResponseType.ACCEPT)
+
+        self.backup = Gtk.CheckButton.new()
+        self.backup.set_label(_("Make a backup of the current configuration"))
+
+        box = self.get_message_area()
+        box.pack_start(self.backup, True, True, 0)
+        box.show_all()
+
 if __name__ == "__main__":
     import sys
 

-- 
To stop receiving notification emails like this one, please contact
the administrator of this repository.


More information about the Xfce4-commits mailing list