blob: c7c2ca0941318f6e3a551f25f0bc40c869c6da25 (
plain)
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
|
import gtk
class PluginSettingsUI(gtk.Dialog):
def __init__(self, pluginfo):
#print "Init PluginSettingsUI"
gtk.Dialog.__init__(self)
self.plugin_name = pluginfo.Name
self.Settings = pluginfo.Settings
self.pluginfo = pluginfo
self.plugin_gui = None
if pluginfo.getGUI():
self.plugin_gui = gtk.Builder()
self.plugin_gui.add_from_file(pluginfo.getGUI())
self.dialog = self.plugin_gui.get_object("PluginDialog")
if not self.dialog:
raise Exception("Can't find PluginDialog widget in UI description!")
self.dialog.set_title("%s" % pluginfo.getName())
else:
# we shouldn't get here, but just to be safe
no_ui_label = gtk.Label("No UI for plugin %s" % pluginfo)
self.add(no_ui_label)
no_ui_label.show()
def hydrate(self):
if self.plugin_gui:
if self.pluginfo.Enabled == "yes":
if self.Settings:
#print "Hydrating %s" % self.plugin_name
for key,value in self.Settings.iteritems():
#print "%s:%s" % (key,value)
widget = self.plugin_gui.get_object("conf_%s" % key)
if type(widget) == gtk.Entry:
widget.set_text(value)
elif type(widget) == gtk.CheckButton:
widget.set_active(value == "yes")
elif type(widget) == gtk.ComboBox:
print "combo box is not implemented"
else:
#print "Plugin %s has no configuration." % self.plugin_name
pass
else:
#print "Plugin %s is disabled." % self.plugin_name
pass
else:
print "Nothing to hydrate!"
def dehydrate(self):
#print "dehydrating %s" % self.pluginfo.getName()
if self.Settings:
for key in self.Settings.keys():
#print key
#print "%s:%s" % (key,value)
widget = self.plugin_gui.get_object("conf_%s" % key)
if type(widget) == gtk.Entry:
self.Settings[key] = widget.get_text()
elif type(widget) == gtk.CheckButton:
if widget.get_active():
self.Settings[key] = "yes"
else:
self.Settings[key] = "no"
elif type(widget) == gtk.ComboBox:
print "combo box is not implemented"
def destroy(self):
self.dialog.destroy()
def run(self):
return self.dialog.run()
|