/usr/share/cinnamon/cinnamon-settings/bin/CinnamonGtkSettings.py is in cinnamon-common 3.6.7-8ubuntu1.
This file is owned by root:root, with mode 0o755.
The actual contents of the file can be viewed below.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 | #! /usr/bin/python2
from __future__ import print_function
import os.path
import gi
gi.require_version("Gtk", "3.0") # noqa
from gi.repository import GLib, Gtk
from SettingsWidgets import SettingsWidget
SETTINGS_GROUP_NAME = "Settings"
instance = None
def get_editor():
global instance
if instance is None:
instance = GtkSettingsEditor()
return instance
class GtkSettingsEditor:
def __init__(self):
self._path = os.path.join(GLib.get_user_config_dir(),
"gtk-3.0",
"settings.ini")
def _get_keyfile(self):
keyfile = None
try:
keyfile = GLib.KeyFile()
keyfile.load_from_file(self._path, 0)
except Exception:
pass
finally:
return keyfile
def get_boolean(self, key):
keyfile = self._get_keyfile()
try:
result = keyfile.get_boolean(SETTINGS_GROUP_NAME, key)
except Exception:
result = False
return result
def set_boolean(self, key, value):
print("set", value)
keyfile = self._get_keyfile()
keyfile.set_boolean(SETTINGS_GROUP_NAME, key, value)
try:
data = keyfile.to_data()
GLib.file_set_contents(self._path, data[0])
except Exception:
raise
class GtkSettingsSwitch(SettingsWidget):
def __init__(self, markup, setting_name=None):
self.setting_name = setting_name
super(GtkSettingsSwitch, self).__init__(dep_key=None)
self.content_widget = Gtk.Switch()
self.content_widget.set_valign(Gtk.Align.CENTER)
self.label = Gtk.Label()
self.label.set_markup(markup)
self.pack_start(self.label, False, False, 0)
self.pack_end(self.content_widget, False, False, 0)
self.settings = get_editor()
self.content_widget.set_active(self.settings.get_boolean(self.setting_name))
self.content_widget.connect("notify::active", self.clicked)
def clicked(self, widget, data=None):
self.settings.set_boolean(self.setting_name, self.content_widget.get_active())
|