define cellrenderer

svn: r6266
This commit is contained in:
Don Allingham 2006-04-04 23:20:47 +00:00
parent 3a80310d16
commit ca35f8de21

View File

@ -350,6 +350,10 @@ class MonitoredMenu:
self.get_val = get_val self.get_val = get_val
self.obj = obj self.obj = obj
cell = gtk.CellRendererText()
self.obj.pack_start(cell, True)
self.obj.add_attribute(cell, 'text', 0)
self.model = gtk.ListStore(str,int) self.model = gtk.ListStore(str,int)
for t,v in mapping: for t,v in mapping:
self.model.append(row=[t,v]) self.model.append(row=[t,v])
@ -374,8 +378,16 @@ class MonitoredStrMenu:
self.get_val = get_val self.get_val = get_val
self.obj = obj self.obj = obj
self.model = gtk.ListStore(str,int) self.model = gtk.ListStore(str)
self.model.append(row=['',0])
cell = gtk.CellRendererText()
self.obj.pack_start(cell, True)
self.obj.add_attribute(cell, 'text', 0)
if len(mapping) > 20:
self.obj.set_wrap_width(3)
self.model.append(row=[''])
index = 0 index = 0
self.data = [''] self.data = ['']
@ -383,14 +395,14 @@ class MonitoredStrMenu:
active = 0 active = 0
for t,v in mapping: for t,v in mapping:
self.model.append(row=[t,index]) self.model.append(row=[v])
self.data.append(v) self.data.append(t)
if v == default: if v == default:
active = index active = index
index += 1 index += 1
self.obj.set_model(self.model) self.obj.set_model(self.model)
self.obj.set_active(index) self.obj.set_active(active)
self.obj.connect('changed',self.on_change) self.obj.connect('changed',self.on_change)
self.obj.set_sensitive(not readonly) self.obj.set_sensitive(not readonly)