[Xfce4-commits] [apps/xfce4-panel-profiles] 114/162: Backup current configuration at startup so it can be rolled back (LP: #1555265)
noreply at xfce.org
noreply at xfce.org
Fri Jul 13 13:10:13 CEST 2018
This is an automated email from the git hooks/post-receive script.
o c h o s i 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 486c0e67674238a00a0d7197ffd4c0e9a48867b4
Author: Sean Davis <smd.seandavis at gmail.com>
Date: Sun Mar 25 22:51:29 2018 -0400
Backup current configuration at startup so it can be rolled back (LP: #1555265)
---
xfpanel-switch/xfpanel-switch.py | 57 ++++++++++++++++++++++++++--------------
1 file changed, 37 insertions(+), 20 deletions(-)
diff --git a/xfpanel-switch/xfpanel-switch.py b/xfpanel-switch/xfpanel-switch.py
index 41ad34b..0c87819 100644
--- a/xfpanel-switch/xfpanel-switch.py
+++ b/xfpanel-switch/xfpanel-switch.py
@@ -29,6 +29,15 @@ from gi.repository import Gtk, GLib, Gio
from panelconfig import PanelConfig
+homedir = GLib.get_home_dir()
+cachedir = GLib.get_user_cache_dir()
+cachefile = os.path.join(cachedir, "xfpanel-switch.tar.gz")
+
+try:
+ if not os.path.exists(cachedir):
+ os.makedirs(cachedir)
+except:
+ pass
class XfpanelSwitch:
@@ -137,7 +146,10 @@ class XfpanelSwitch:
def get_saved_configurations(self):
results = []
now = int(datetime.datetime.now().strftime('%s'))
- results.append(("", _("Current Configuration"), now))
+ if (os.path.isfile(cachefile)):
+ results.append((cachefile, _("Current Configuration"), now))
+ else:
+ results.append(("", _("Current Configuration"), now))
today_delta = datetime.datetime.today() - datetime.timedelta(days=1)
for directory in self.get_data_dirs():
@@ -318,27 +330,27 @@ class PanelSaveDialog(Gtk.MessageDialog):
if __name__ == "__main__":
import sys
+ session_bus = Gio.BusType.SESSION
+ cancellable = None
+ connection = Gio.bus_get_sync(session_bus, cancellable)
+
+ proxy_property = 0
+ interface_properties_array = None
+ destination = 'org.xfce.Xfconf'
+ path = '/org/xfce/Xfconf'
+ interface = destination
+
+ xfconf = Gio.DBusProxy.new_sync(
+ connection,
+ proxy_property,
+ interface_properties_array,
+ destination,
+ path,
+ interface,
+ cancellable)
+
if len(sys.argv) > 1:
if sys.argv[1] in ['save', 'load']:
- session_bus = Gio.BusType.SESSION
- cancellable = None
- connection = Gio.bus_get_sync(session_bus, cancellable)
-
- proxy_property = 0
- interface_properties_array = None
- destination = 'org.xfce.Xfconf'
- path = '/org/xfce/Xfconf'
- interface = destination
-
- xfconf = Gio.DBusProxy.new_sync(
- connection,
- proxy_property,
- interface_properties_array,
- destination,
- path,
- interface,
- cancellable)
-
try:
if sys.argv[1] == 'save':
PanelConfig.from_xfconf(xfconf).to_file(sys.argv[2])
@@ -356,5 +368,10 @@ if __name__ == "__main__":
print('')
exit(-1)
+ try:
+ PanelConfig.from_xfconf(xfconf).to_file(cachefile)
+ except:
+ pass
+
main = XfpanelSwitch()
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