Exemple #1
0
    def create_widgets(self):
        self.store = gtk.ListStore(gtk.gdk.Pixbuf, str, int)
        self.combo = gtk.ComboBox(self.store)

        self.icon = None

        pix = gtk.CellRendererPixbuf()
        txt = gtk.CellRendererText()

        txt.set_property('font',
                         Prefs()['gui.views.property_tab.font'].value \
                         or 'Monospace 8')

        self.combo.pack_start(pix, False)
        self.combo.pack_start(txt)

        self.combo.set_attributes(pix, pixbuf=0)
        self.combo.set_attributes(txt, text=1)

        self.odict = backend.get_field_enumeration_i2s(self.field)
        self.odict.sort()

        idx = 0
        set = False

        for value, key in self.odict:
            self.store.append([self.icon, key, value])

            if not set:
                if self.value == value:
                    set = True
                    continue

                idx += 1

        if set:
            self.combo.set_active(idx)

        self.store.append([self.icon, _("Set manually"), -1])

        self.int_editor = IntEditor((self.protocol, self.field))

        self.undo_btn = MiniButton(stock=gtk.STOCK_UNDO)
        self.undo_btn.set_size_request(24, 24)

        self.int_editor.pack_start(self.undo_btn, False, False)
        self.int_editor.show()