Skip to content

Commit

Permalink
Merge branch 'xlet-settings-config-dir-fix' of github.com:collinss/Ci…
Browse files Browse the repository at this point in the history
…nnamon
  • Loading branch information
mtwebster committed May 10, 2017
2 parents e8b7a67 + 642519c commit 51eb638
Show file tree
Hide file tree
Showing 2 changed files with 38 additions and 8 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -491,7 +491,6 @@ def load(self, window=None):
self.content_box.show_all()

if not self.themes:
self.spices.scrubConfigDirs(self.enabled_extensions)
try:
Gio.DBusProxy.new_for_bus(Gio.BusType.SESSION, Gio.DBusProxyFlags.NONE, None,
"org.Cinnamon", "/org/Cinnamon", "org.Cinnamon", None, self._on_proxy_ready, None)
Expand Down
45 changes: 38 additions & 7 deletions files/usr/share/cinnamon/cinnamon-settings/xlet-settings.py
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,7 @@ def __init__(self, xlet_type, uuid, instance_id=None):
self.type = xlet_type
self.uuid = uuid
self.selected_instance = None
self.gsettings = Gio.Settings.new("org.cinnamon")

self.load_xlet_data()
self.build_window()
Expand Down Expand Up @@ -197,15 +198,39 @@ def build_window(self):
def load_instances(self):
self.instance_info = []
path = "%s/.cinnamon/configs/%s" % (home, self.uuid)
instances = sorted(os.listdir(path))
instances = 0
dir_items = sorted(os.listdir(path))
try:
multi_instance = int(self.xlet_meta["max-instances"]) != 1
except (KeyError, ValueError):
multi_instance = False

if len(instances) < 2:
self.prev_button.set_no_show_all(True)
self.next_button.set_no_show_all(True)
for item in dir_items:
# ignore anything that isn't json
if item[-5:] != ".json":
continue

instance_id = item[0:-5]
if not multi_instance and instance_id != self.uuid:
continue # for single instance the file name should be [uuid].json

if multi_instance:
try:
int(instance_id)
except:
continue # multi-instance should have file names of the form [instance-id].json

for instance in instances:
instance_id = instance[0:-5]
settings = JSONSettingsHandler(os.path.join(path, instance), self.notify_dbus)
instance_exists = False
enabled = self.gsettings.get_strv('enabled-%ss' % self.type)
for deninition in enabled:
if uuid in deninition and instance_id in deninition.split(':'):
instance_exists = True
break

if not instance_exists:
continue

settings = JSONSettingsHandler(os.path.join(path, item), self.notify_dbus)
settings.instance_id = instance_id
instance_box = Gtk.Box(orientation=Gtk.Orientation.VERTICAL)
self.instance_stack.add_named(instance_box, instance_id)
Expand Down Expand Up @@ -247,6 +272,12 @@ def load_instances(self):
if "stack" in info:
self.stack_switcher.set_stack(info["stack"])

instances += 1

if instances < 2:
self.prev_button.set_no_show_all(True)
self.next_button.set_no_show_all(True)

def build_with_layout(self, settings_map, info, box, first_key):
layout = first_key

Expand Down

0 comments on commit 51eb638

Please sign in to comment.