Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
import os
import gettext
import glob
import json
from optparse import OptionParser
import shutil
import subprocess
Expand Down Expand Up @@ -415,20 +416,42 @@ def launcher_cb(self, success, dest_path):
self.end()

def panel_launcher_cb(self, success, dest_path):
if success:
settings = JsonSettingsWidgets.JSONSettingsHandler(self.json_path)
launchers = settings.get_value("launcherList")
if self.desktop_file is None:
launchers.append(os.path.split(dest_path)[1])
else:
i = launchers.index(self.desktop_file)
if i >= 0:
del launchers[i]
launchers.insert(i, os.path.split(dest_path)[1])
settings.save_settings()
if self.desktop_file is None:
self.ask_menu_launcher(dest_path)
self.end()
try:
if success:
settings = JsonSettingsWidgets.JSONSettingsHandler(self.json_path)
launchers = settings.get_value("launcherList")
new_name = os.path.split(dest_path)[1]
if self.desktop_file is None:
launchers.append(new_name)
else:
try:
i = launchers.index(self.desktop_file)
except ValueError:
# The entry we were asked to edit is no longer in the
# list (a previous edit may have already replaced it) -
# add the new launcher instead of dropping the edit.
if new_name not in launchers:
launchers.append(new_name)
else:
launchers[i] = new_name
settings.save_settings()
self.notify_cinnamon(launchers)
if self.desktop_file is None:
self.ask_menu_launcher(dest_path)
finally:
self.end()

def notify_cinnamon(self, launchers):
# Cinnamon does not monitor the settings file for external changes -
# tell it to reload, the same way xlet-settings.py does after saving.
uuid = os.path.basename(os.path.dirname(self.json_path))
instance_id = os.path.splitext(os.path.basename(self.json_path))[0]
try:
proxy = Gio.DBusProxy.new_for_bus_sync(Gio.BusType.SESSION, Gio.DBusProxyFlags.NONE, None,
"org.Cinnamon", "/org/Cinnamon", "org.Cinnamon", None)
proxy.updateSetting('(ssss)', uuid, instance_id, "launcherList", json.dumps(launchers))
except GLib.Error as e:
print("Could not notify Cinnamon of launcher list change: %s" % e.message)

def nemo_launcher_cb(self, success, dest_path):
if success:
Expand Down
Loading