[1bb7bd]: / configlet / gcwidgets.py  Maximize  Restore  History

Download this file

55 lines (44 with data), 1.6 kB

 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
# GConf widgets
import gconf
import gtk
path = '/apps/rox-media'
client = gconf.client_get_default()
client.add_dir(path, gconf.CLIENT_PRELOAD_NONE)
class CheckButton(gtk.CheckButton):
def __init__(self, key, label = None, underline = True):
gtk.CheckButton.__init__(self, label, underline)
global client, path
self.path = path + '/' + key
client.notify_add(self.path, self.option_changed)
self.set_active(client.get_bool(self.path))
self.connect("toggled", self.toggled)
def option_changed(self, *args, **kwargs):
global client
new_val = client.get_bool(self.path)
if new_val != self.get_active():
self.set_active(new_val)
def toggled(self, *args):
global client
new_val = self.get_active()
if new_val != client.get_bool(self.path):
client.set_bool(self.path, new_val)
class Entry(gtk.Entry):
def __init__(self, key):
gtk.Entry.__init__(self)
global client, path
self.path = path + '/' + key
client.notify_add(self.path, self.update_text)
self.update_text()
self.connect("changed", self.text_changed)
def update_text(self, *args, **kwargs):
global client
t = client.get_string(self.path)
if not t:
t = ""
if t != self.get_text():
self.set_text(t)
def text_changed(self, *args):
global client
new_val = self.get_text()
if new_val != client.get_string(self.path):
client.set_string(self.path, new_val)