/usr/share/pyshared/gnomeblog/gconf_widgets.py is in gnome-blog 0.9.1-5.1.
This file is owned by root:root, with mode 0o644.
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 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 | import gtk
import gconf
class OptionMenu(gtk.OptionMenu):
def __init__(self, gconf_key):
gtk.OptionMenu.__init__(self)
self.gconf_key = gconf_key
self.client = gconf.client_get_default()
self.notify = self.client.notify_add(self.gconf_key, self._onGConfChange)
self.connect("changed", self._onChanged)
def setStringValuePairs (self, string_value_pairs):
self.menu = gtk.Menu()
self.set_menu(self.menu)
self.values = []
for string_value_pair in string_value_pairs:
string = string_value_pair[0]
value = string_value_pair[1]
if string == "-":
self.menu.append(gtk.SeparatorMenuItem())
else:
self.menu.append(gtk.MenuItem(string))
self.values.append(value)
self.menu.show_all()
gconf_value = self.client.get_string(self.gconf_key)
self._setMenuFromValue(gconf_value)
def _setMenuFromValue (self, gconf_value):
if not self.values:
return
i = 0
value_set = 0
for value in self.values:
if value == gconf_value:
self.set_history(i)
value_set = 1
break
i = i + 1
if not value_set:
self.set_history(0)
self.client.set_string(self.gconf_key, self.values[0])
def _onGConfChange (self, client, cnxn_id, entry, what):
gconf_value = entry.value.get_string()
self._setMenuFromValue(gconf_value)
def _onChanged(self, optionmenu):
index = optionmenu.get_history()
value = self.values[index]
self.client.set_string(self.gconf_key, value)
class Entry(gtk.Entry):
def _onGConfChange (self, client, cnxn_id, entry, what):
self.set_text(entry.value.get_string())
def _onEntryChange (self, entry):
text = entry.get_text()
self.client.set_string(self.gconf_key, text)
def __init__(self, gconf_key, is_password=0):
gtk.Entry.__init__(self)
if is_password:
self.set_visibility(False)
self.set_invisible_char(u"*")
self.gconf_key = gconf_key
self.client = gconf.client_get_default()
self.notify = self.client.notify_add(self.gconf_key, self._onGConfChange)
string = self.client.get_string(self.gconf_key)
if string != None:
self.set_text(string)
self.connect("changed", self._onEntryChange)
class CheckButton(gtk.CheckButton):
def _onGConfChange (self, client, cnxn_id, entry, what):
self.set_active(entry.value.get_bool())
def _onCheckboxToggled (self, checkbox):
toggled = checkbox.get_active()
self.client.set_bool(self.gconf_key, toggled)
def __init__(self, label, gconf_key):
gtk.CheckButton.__init__(self, label)
self.gconf_key = gconf_key
self.client = gconf.client_get_default()
self.notify = self.client.notify_add(self.gconf_key, self._onGConfChange)
bool = self.client.get_bool(self.gconf_key)
if bool != None:
self.set_active(bool)
self.connect("toggled", self._onCheckboxToggled)
|