[gnome-tweak-tool] Revert "Support AutostartCondition in AutostartManager"



commit 6f064ced20e256ca4aea23ec965d0d03058beb41
Author: John Stowers <john stowers gmail com>
Date:   Mon Jun 6 16:58:45 2011 +1200

    Revert "Support AutostartCondition in AutostartManager"
    
    This reverts commit 68ee4d51321e159c87b34a40ccbef25c70182008.
    
    This causes infinite looping in the Nautilus desktop case. Revert
    until I think of a clean way to prevent that.

 gtweak/utils.py |   46 +++++++++-------------------------------------
 1 files changed, 9 insertions(+), 37 deletions(-)
---
diff --git a/gtweak/utils.py b/gtweak/utils.py
index 90d782a..df357b4 100644
--- a/gtweak/utils.py
+++ b/gtweak/utils.py
@@ -21,8 +21,6 @@ import tempfile
 import shutil
 
 import gtweak
-from gtweak.gsettings import GSettingsSetting
-from gtweak.gconf import GConfSetting
 
 from gi.repository import GLib
 
@@ -111,17 +109,11 @@ class AutostartManager:
         dirs.extend(GLib.get_system_data_dirs())
         return [os.path.join(d, "applications", self.desktop_filename) for d in dirs]
 
-    def get_autostart_condition(self):
-        for f in self._get_system_autostart_files():
-            if os.path.exists(f):
-                with open(f, 'r') as f:
-                    for l in f.readlines():
-                        if l.startswith("AutostartCondition="):
-                            return l.split("=")[-1].strip()
-        return None
-
     def uses_autostart_condition(self):
-        return self.get_autostart_condition() != None
+        for f in self._get_system_autostart_files():
+            if os.path.exists(f) and open(f).read().find("AutostartCondition=") != -1:
+                return True
+        return False
 
     def is_start_at_login_enabled(self):
         if os.path.exists(self._user_autostart_file):
@@ -143,31 +135,15 @@ class AutostartManager:
             logging.info("Removing user autostart file %s" % self._user_autostart_file)
             os.remove(self._user_autostart_file)
 
-        asc = self.get_autostart_condition()
-        if asc:
-            #AutostartCondition=GNOME /desktop/gnome/interface/accessibility
-            #AutostartCondition=GNOME3 if-session gnome-fallback
-            #AutostartCondition=GSettings org.gnome.desktop.background show-desktop-icons
-            method, value = asc.split(" ", 1)
-            try:
-                logging.info("Changing AutostartCondition %s -> %s" % (method, update))
-                if method == "GSettings":
-                    schema, key = value.split(" ")
-                    GSettingsSetting(schema).set_boolean(key, update)
-                elif method == "GNOME":
-                    GConfSetting(shema, bool).set_value(update)
-                else:
-                    raise Exception("Method not supported")
-            except:
-                logging.warning("Autostart desktop file unsupported AutostartCondition (%s)" % asc, exc_info=True)
-
-            return
-
         if update:
             if (not self._desktop_file) or (not os.path.exists(self._desktop_file)):
                 logging.critical("Could not find desktop file: %s" % self._desktop_file)
                 return
 
+            if self.uses_autostart_condition():
+                logging.warning("Autostart desktop file uses AutostartCondition. Skipping")
+                return
+
             logging.info("Adding autostart %s" % self._user_autostart_file)
             #copy the original file to the new file, but add the extra exec args
             old = open(self._desktop_file, "r")
@@ -188,7 +164,6 @@ class AutostartManager:
 
 if __name__ == "__main__":
     gtweak.DATA_DIR = "/usr/share"
-    gtweak.GSETTINGS_SCHEMA_DIR = "/usr/share/glib-2.0/schemas/"
 
     logging.basicConfig(format="%(levelname)-8s: %(message)s", level=logging.DEBUG)
 
@@ -202,14 +177,11 @@ if __name__ == "__main__":
 
     d = AutostartManager("orca.desktop", "orca-autostart.desktop")
     print d.desktop_filename, "uses autostartcondition", d.uses_autostart_condition()
-    print d.desktop_filename, "autostartcondition is:", d.get_autostart_condition()
     print d.desktop_filename, "autostarts", d.is_start_at_login_enabled()
+    d.update_start_at_login(True)
     print d.desktop_filename, "autostarts", d.is_start_at_login_enabled()
 
     d = AutostartManager("dropbox.desktop")
     print d.desktop_filename, "uses autostartcondition", d.uses_autostart_condition()
     print d.desktop_filename, "autostarts", d.is_start_at_login_enabled()
 
-    d = AutostartManager("nautilus.desktop", "nautilus-autostart.desktop")
-    print d.desktop_filename, "uses autostartcondition", d.uses_autostart_condition()
-    d.update_start_at_login(False)



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