Skip to content

Commit

Permalink
Merge pull request #1679 from mtwebster/applet-settings
Browse files Browse the repository at this point in the history
[WIP]  Applet settings
  • Loading branch information
clefebvre committed Mar 7, 2013
2 parents 651f663 + 08871da commit 9432ebc
Show file tree
Hide file tree
Showing 26 changed files with 2,817 additions and 157 deletions.
142 changes: 71 additions & 71 deletions files/usr/lib/cinnamon-settings/bin/SettingsWidgets.py
Expand Up @@ -9,7 +9,7 @@
import gettext
from gi.repository import Gio, Gtk, GObject, Gdk
from gi.repository import GdkPixbuf
import gconf
# import gconf
import json
import dbus
import time
Expand Down Expand Up @@ -676,7 +676,7 @@ def on_my_value_changed(self, widget):
class GSettingsColorChooser(Gtk.ColorButton):
def __init__(self, schema, key, dep_key):
Gtk.ColorButton.__init__(self)
self._schema = Gio.Settings(schema)
self._schema = Gio.Settings.new(schema)
self._key = key
self.dep_key = dep_key
self.set_value(self._schema[self._key])
Expand Down Expand Up @@ -708,85 +708,85 @@ def on_dependency_setting_changed(self, settings, dep_key):
else:
self.set_sensitive(not self.dep_settings.get_boolean(self.dep_key))

class GConfFontButton(Gtk.HBox):
def __init__(self, label, key):
self.key = key
super(GConfFontButton, self).__init__()
self.settings = gconf.client_get_default()
self.value = self.settings.get_string(key)
# class GConfFontButton(Gtk.HBox):
# def __init__(self, label, key):
# self.key = key
# super(GConfFontButton, self).__init__()
# self.settings = gconf.client_get_default()
# self.value = self.settings.get_string(key)

self.label = Gtk.Label(label)
# self.label = Gtk.Label(label)

self.content_widget = Gtk.FontButton()
self.content_widget.set_font_name(self.value)
# self.content_widget = Gtk.FontButton()
# self.content_widget.set_font_name(self.value)

if (label != ""):
self.pack_start(self.label, False, False, 2)
self.pack_start(self.content_widget, False, False, 2)
self.content_widget.connect('font-set', self.on_my_value_changed)
self.content_widget.show_all()
def on_my_value_changed(self, widget):
self.settings.set_string(self.key, widget.get_font_name())

class GConfComboBox(Gtk.HBox):
def __init__(self, label, key, options, init_value = ""):
self.key = key
super(GConfComboBox, self).__init__()
self.settings = gconf.client_get_default()
self.value = self.settings.get_string(self.key)
if not self.value:
self.value = init_value
# if (label != ""):
# self.pack_start(self.label, False, False, 2)
# self.pack_start(self.content_widget, False, False, 2)
# self.content_widget.connect('font-set', self.on_my_value_changed)
# self.content_widget.show_all()
# def on_my_value_changed(self, widget):
# self.settings.set_string(self.key, widget.get_font_name())

# class GConfComboBox(Gtk.HBox):
# def __init__(self, label, key, options, init_value = ""):
# self.key = key
# super(GConfComboBox, self).__init__()
# self.settings = gconf.client_get_default()
# self.value = self.settings.get_string(self.key)
# if not self.value:
# self.value = init_value

self.label = Gtk.Label(label)
self.model = Gtk.ListStore(str, str)
selected = None
for option in options:
iter = self.model.insert_before(None, None)
self.model.set_value(iter, 0, option[0])
self.model.set_value(iter, 1, option[1])
if (option[0] == self.value):
selected = iter
# self.label = Gtk.Label(label)
# self.model = Gtk.ListStore(str, str)
# selected = None
# for option in options:
# iter = self.model.insert_before(None, None)
# self.model.set_value(iter, 0, option[0])
# self.model.set_value(iter, 1, option[1])
# if (option[0] == self.value):
# selected = iter

self.content_widget = Gtk.ComboBox.new_with_model(self.model)
renderer_text = Gtk.CellRendererText()
self.content_widget.pack_start(renderer_text, True)
self.content_widget.add_attribute(renderer_text, "text", 1)
# self.content_widget = Gtk.ComboBox.new_with_model(self.model)
# renderer_text = Gtk.CellRendererText()
# self.content_widget.pack_start(renderer_text, True)
# self.content_widget.add_attribute(renderer_text, "text", 1)

if selected is not None:
self.content_widget.set_active_iter(selected)
# if selected is not None:
# self.content_widget.set_active_iter(selected)

if (label != ""):
self.pack_start(self.label, False, False, 2)
self.pack_start(self.content_widget, False, False, 2)
self.content_widget.connect('changed', self.on_my_value_changed)
# The on_my_setting_changed callback raises a segmentation fault, need to investigate that
#self.settings.add_dir(os.path.split(key)[0], gconf.CLIENT_PRELOAD_NONE)
#self.settings.notify_add(self.key, self.on_my_setting_changed)
self.content_widget.show_all()
# if (label != ""):
# self.pack_start(self.label, False, False, 2)
# self.pack_start(self.content_widget, False, False, 2)
# self.content_widget.connect('changed', self.on_my_value_changed)
# # The on_my_setting_changed callback raises a segmentation fault, need to investigate that
# #self.settings.add_dir(os.path.split(key)[0], gconf.CLIENT_PRELOAD_NONE)
# #self.settings.notify_add(self.key, self.on_my_setting_changed)
# self.content_widget.show_all()

def on_my_value_changed(self, widget):
tree_iter = widget.get_active_iter()
if tree_iter != None:
value = self.model[tree_iter][0]
self.settings.set_string(self.key, value)
def on_my_setting_changed(self, client, cnxn_id, entry, args):
print entry

class GConfCheckButton(Gtk.CheckButton):
def __init__(self, label, key):
self.key = key
super(GConfCheckButton, self).__init__(label)
self.settings = gconf.client_get_default()
self.set_active(self.settings.get_bool(self.key))
self.settings.notify_add(self.key, self.on_my_setting_changed)
self.connect('toggled', self.on_my_value_changed)
# def on_my_value_changed(self, widget):
# tree_iter = widget.get_active_iter()
# if tree_iter != None:
# value = self.model[tree_iter][0]
# self.settings.set_string(self.key, value)
# def on_my_setting_changed(self, client, cnxn_id, entry, args):
# print entry

# class GConfCheckButton(Gtk.CheckButton):
# def __init__(self, label, key):
# self.key = key
# super(GConfCheckButton, self).__init__(label)
# self.settings = gconf.client_get_default()
# self.set_active(self.settings.get_bool(self.key))
# self.settings.notify_add(self.key, self.on_my_setting_changed)
# self.connect('toggled', self.on_my_value_changed)

def on_my_setting_changed(self, client, cnxn_id, entry):
value = entry.value.get_bool()
self.set_active(value)
# def on_my_setting_changed(self, client, cnxn_id, entry):
# value = entry.value.get_bool()
# self.set_active(value)

def on_my_value_changed(self, widget):
self.settings.set_bool(self.key, self.get_active())
# def on_my_value_changed(self, widget):
# self.settings.set_bool(self.key, self.get_active())

class DBusCheckButton(Gtk.CheckButton):
def __init__(self, label, service, path, get_method, set_method):
Expand Down
32 changes: 32 additions & 0 deletions files/usr/lib/cinnamon-settings/bin/Spices.py
Expand Up @@ -514,3 +514,35 @@ def url_retrieve(self, url, f, reporthook):

del urlobj
f.close()

def scrubConfigDirs(self, enabled_list):
active_list = {}
for enabled in enabled_list:
panel, align, order, uuid, id = enabled.split(":")
if uuid not in active_list:
id_list = []
active_list[uuid] = id_list
active_list[uuid].append(id)
else:
active_list[uuid].append(id)

for uuid in active_list.keys():
if (os.path.exists(os.path.join(settings_dir, uuid))):
dir_list = os.listdir(os.path.join(settings_dir, uuid))
for id in active_list[uuid]:
fn = str(id) + ".json"
if fn in dir_list:
dir_list.remove(fn)
fn = str(uuid) + ".json"
if fn in dir_list:
dir_list.remove(fn)
for jetsam in dir_list:
try:
os.remove(os.path.join(settings_dir, uuid, jetsam))
except:
pass





0 comments on commit 9432ebc

Please sign in to comment.