[Xfce4-commits] [apps/xfce4-panel-profiles] 01/01: Do not cache current configuration (Bug #16114)

noreply at xfce.org noreply at xfce.org
Tue Nov 26 11:58:39 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 2bd963527c84595292df038465220631cff81bc7
Author: Emanuele Petriglia <inbox at emanuelepetriglia.com>
Date:   Sat Nov 2 14:02:31 2019 +0100

    Do not cache current configuration (Bug #16114)
    
    Do not cache current configuration, instead get the latest properties
    from Xfconf.
    
    Signed-off-by: Emanuele Petriglia <inbox at emanuelepetriglia.com>
    Signed-off-by: Sean Davis <smd.seandavis at gmail.com>
---
 xfce4-panel-profiles/xfce4-panel-profiles.py | 37 +++++++++-------------------
 1 file changed, 11 insertions(+), 26 deletions(-)

diff --git a/xfce4-panel-profiles/xfce4-panel-profiles.py b/xfce4-panel-profiles/xfce4-panel-profiles.py
index 0fa5d61..82f8cb2 100644
--- a/xfce4-panel-profiles/xfce4-panel-profiles.py
+++ b/xfce4-panel-profiles/xfce4-panel-profiles.py
@@ -40,14 +40,6 @@ from panelconfig import PanelConfig
 warnings.filterwarnings("ignore")
 
 homedir = GLib.get_home_dir()
-cachedir = GLib.get_user_cache_dir()
-cachefile = os.path.join(cachedir, "xfce4-panel-profiles.tar.gz")
-
-try:
-    if not os.path.exists(cachedir):
-        os.makedirs(cachedir)
-except:
-    pass
 
 class XfcePanelProfiles:
 
@@ -157,13 +149,9 @@ class XfcePanelProfiles:
         return list(set(dirs))
 
     def get_saved_configurations(self):
-        results = []
         now = int(datetime.datetime.now().strftime('%s'))
-        if (os.path.isfile(cachefile)):
-            results.append((cachefile, _("Current Configuration"), now))
-        else:
-            results.append(("", _("Current Configuration"), now))
 
+        results = [('', _('Current Configuration'), now)]
         for directory in self.get_data_dirs():
             for filename in os.listdir(directory):
                 name, ext = os.path.splitext(filename)
@@ -225,7 +213,7 @@ class XfcePanelProfiles:
         if dialog.run() == Gtk.ResponseType.ACCEPT:
             name = dialog.get_save_name()
             if len(name) > 0:
-                if filename == "":
+                if filename == "": # Current configuration.
                     self.save_configuration(name)
                 else:
                     self.copy_configuration(self.get_selected(), name)
@@ -238,7 +226,7 @@ class XfcePanelProfiles:
         if response == Gtk.ResponseType.ACCEPT:
             selected = self.get_selected_filename()
             filename = dialog.get_filename()
-            if selected == "":
+            if selected == "": # Current configuration.
                 self.save_configuration(filename, False)
             else:
                 self.copy_configuration(self.get_selected(), filename, False)
@@ -290,18 +278,20 @@ class XfcePanelProfiles:
     def on_delete_clicked(self, widget):
         model, treeiter, values = self.get_selected()
         filename = values[0]
-        if filename == "":
+        if filename == "": # Current configuration.
             return
         self.delete_configuration(filename)
         model.remove(treeiter)
 
     def on_saved_configurations_cursor_changed(self, widget):
         filename = self.get_selected_filename()
-        delete = self.builder.get_object("toolbar_delete")
-        if os.access(filename, os.W_OK):
-            delete.set_sensitive(True)
-        else:
-            delete.set_sensitive(False)
+
+        delete = self.builder.get_object('toolbar_delete')
+        delete.set_sensitive(True if os.access(filename, os.W_OK) else False)
+
+        # Current configuration cannot be applied.
+        apply = self.builder.get_object('toolbar_apply')
+        apply.set_sensitive(False if filename == '' else True)
 
     def on_window_destroy(self, *args):
         '''Exit the application when the window is closed.'''
@@ -396,10 +386,5 @@ if __name__ == "__main__":
             print('')
             exit(-1)
 
-    try:
-        PanelConfig.from_xfconf(xfconf).to_file(cachefile)
-    except:
-        pass
-
     main = XfcePanelProfiles()
     Gtk.main()

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


More information about the Xfce4-commits mailing list