Commit 9ca5b576 authored by John Stowers's avatar John Stowers

If nautilus uses GSettings AutostartCondition, then we only need to change the key

parent 5e3762e1
......@@ -34,7 +34,10 @@ class DesktopIconTweak(GSettingsSwitchTweak):
self.nautilus = AutostartManager("nautilus.desktop",
exec_cmd="nautilus -n")
self.settings.connect('changed::'+self.key_name, self._on_setting_changed)
#we only need to install the desktop file on old versions of nautilus/gnome-session.
#new ones use the new AutostartCondition and watch the gsettings key automatically
if not self.nautilus.uses_autostart_condition("GSettings"):
self.settings.connect('changed::'+self.key_name, self._on_setting_changed)
def _on_setting_changed(self, setting, key):
......@@ -120,8 +120,16 @@ class AutostartManager:
return l.split("=")[-1].strip()
return None
def uses_autostart_condition(self):
return self.get_autostart_condition() != None
def uses_autostart_condition(self, autostart_type=None):
asc = self.get_autostart_condition()
if autostart_type:
return asc.split(" ", 1)[0] == autostart_type
return asc != None
logging.warning("Testing for expected AutostartCondition failed: Got (%s)" % asc, exc_info=True)
return False
def is_start_at_login_enabled(self):
if os.path.exists(self._user_autostart_file):
......@@ -203,7 +211,7 @@ 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()
print d.desktop_filename, "uses GSettings autostartcondition", d.uses_autostart_condition("GSettings")
print d.desktop_filename, "autostarts", d.is_start_at_login_enabled()
d = AutostartManager("dropbox.desktop")
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment