Skip to content

Commit

Permalink
Revamp the xlet settings:
Browse files Browse the repository at this point in the history
- xlet settings now open in their own window/process
- matches new style of cinnamon settings
- now supports pages and sections in the settings file
- instances are now automatically highlighted in the panel when the instance is selected in the settings window (uses a new 'highlight' pseudoclass)
- uses the new JSON backend for easier maintenance and simplification of the code
- added support for backendable widgets which were not previously available to the xlet settings api
- updated for newer Gtk versions
- added a new configure function to applets and desklets

xlet settings can now be called with the following commands:
xlet-settings <applet|desklet|extension> <uuid>
xlet-settings <applet|desklet|extension> <uuid> <instanceid>
  • Loading branch information
collinss committed Aug 2, 2016
1 parent fe42958 commit 3478db2
Show file tree
Hide file tree
Showing 13 changed files with 468 additions and 1,729 deletions.
7 changes: 7 additions & 0 deletions data/theme/cinnamon.css
Expand Up @@ -1427,6 +1427,9 @@ StScrollBar StButton#vhandle:hover {
.applet-box:hover {
color: #fff;
}
.applet-box:highlight {
background-color: #aa5555;
}
.applet-label {
font-weight: bold;
color: #ccc;
Expand All @@ -1451,6 +1454,10 @@ StScrollBar StButton#vhandle:hover {
color: #fff;
}

.desklet:highlight, .desklet:highlight-with-borders, .desklet:highlight-with-borders-and-header {
background-color: #aa5555;
}

.desklet-with-borders {
border: 2px solid #a5a5a5;
background-color: rgba(80, 80, 80, 0.8);
Expand Down
2 changes: 2 additions & 0 deletions files/usr/bin/cinnamon-settings
Expand Up @@ -4,6 +4,8 @@ import os, sys

if len(sys.argv) > 1:
module = sys.argv[1]
if module in ("applets", "desklets", "extensions") and len(sys.argv) > 2 and sys.argv[2][0:5] != "panel":
os.execvp("/usr/share/cinnamon/cinnamon-settings/xlet-settings.py", ("", module[0:-1]) + tuple(sys.argv[2:]))
if os.path.exists("/usr/share/cinnamon/cinnamon-settings/modules/cs_%s.py" % module):
os.execvp("/usr/share/cinnamon/cinnamon-settings/cinnamon-settings.py", ("",) + tuple(sys.argv[1:]))
elif os.path.exists("/usr/bin/cinnamon-control-center"):
Expand Down
8 changes: 8 additions & 0 deletions files/usr/bin/xlet-settings
@@ -0,0 +1,8 @@
#!/usr/bin/python3

import os, sys

if len(sys.argv) < 3:
print("usage:\n xlet-settings <xlet_type> <uuid>\nor\n xlet-settings <xlet_type> <uuid> <instance_id>")
else:
os.execvp("/usr/share/cinnamon/cinnamon-settings/xlet-settings.py", ("",) + tuple(sys.argv[1:]))
Expand Up @@ -687,9 +687,7 @@ AppMenuButtonRightClickMenu.prototype = {
let item;
let length;
item = new PopupMenu.PopupIconMenuItem(_("Configure the window list"), "system-run", St.IconType.SYMBOLIC);
item.connect('activate', Lang.bind(this, function() {
Util.spawnCommandLine("cinnamon-settings applets window-list@cinnamon.org " + this._launcher._applet.instance_id);
}));
item.connect('activate', Lang.bind(this._launcher._applet, this._launcher._applet.configureApplet));
this.addMenuItem(item);

this.addMenuItem(new PopupMenu.PopupSeparatorMenuItem());
Expand Down
34 changes: 26 additions & 8 deletions files/usr/share/cinnamon/cinnamon-settings/bin/ExtensionCore.py
Expand Up @@ -14,7 +14,6 @@
gi.require_version("Gtk", "3.0")
from gi.repository import Gio, Gtk, GObject, Gdk, GdkPixbuf, Pango, GLib

import XletSettings
from SettingsWidgets import SidePage, SettingsStack
from Spices import Spice_Harvester

Expand Down Expand Up @@ -53,6 +52,29 @@ def find_extension_subdir(directory):
else:
return os.path.join(directory, ".".join(largest))

translations = {}

def translate(uuid, string):
#check for a translation for this xlet
if uuid not in translations:
try:
translations[uuid] = gettext.translation(uuid, home + "/.local/share/locale").ugettext
except IOError:
try:
translations[uuid] = gettext.translation(uuid, "/usr/share/locale").ugettext
except IOError:
translations[uuid] = None

#do not translate whitespaces
if not string.strip():
return string

if translations[uuid]:
result = translations[uuid](string)
if result != string:
return result
return _(string)

class SurfaceWrapper:
def __init__(self, surface):
self.surface = surface
Expand Down Expand Up @@ -1231,11 +1253,7 @@ def _configure_extension(self, widget = None):
model, treeiter = self.treeview.get_selection().get_selected()
if treeiter:
uuid = model.get_value(treeiter, 0)
settingContainer = XletSettings.XletSetting(uuid, self, self.collection_type)
self.content_box.pack_start(settingContainer.content, True, True, 2)
self.stack.hide()
settingContainer.show()
self._on_signal(None, None, "hide_stack", ())
subprocess.Popen(["xlet-settings", self.collection_type, uuid])

def _external_configure_launch(self, widget = None):
model, treeiter = self.treeview.get_selection().get_selected()
Expand Down Expand Up @@ -1311,8 +1329,8 @@ def load_extensions_in(self, directory, stock_theme = False):
setting_type = 0
data = json.loads(json_data)
extension_uuid = data["uuid"]
extension_name = XletSettings.translate(data["uuid"], data["name"])
extension_description = XletSettings.translate(data["uuid"], data["description"])
extension_name = translate(data["uuid"], data["name"])
extension_description = translate(data["uuid"], data["description"])
try: extension_max_instances = int(data["max-instances"])
except KeyError: extension_max_instances = 1
except ValueError:
Expand Down

0 comments on commit 3478db2

Please sign in to comment.