def dialog_args(self): ''' Create a dialog ''' d = HIGDialog(_('Arguments')) description_label = HIGEntryLabel( _('Insert the description to argument:')) description_label.show() description_entry = HIGTextEntry() text = self.arguments_entry.get_text() description_entry.set_text(text) description_entry.show() combo_box = gtk.combo_box_new_text() combo_box.set_wrap_width(1) index = -1 j = 0 for i in ARG_TYPES: combo_box.append_text(ARG_TYPES[i]) if i == self.arg_type: index = j j = j + 1 if index > -1: combo_box.set_active(index) combo_box.show() d.vbox.pack_start(description_label, False, False) d.vbox.pack_start(description_entry, False, False) d.vbox.pack_start(combo_box, False, False) d.add_button(gtk.STOCK_CANCEL, gtk.RESPONSE_CANCEL) d.add_button(gtk.STOCK_OK, gtk.RESPONSE_OK) resp = d.run() result = None, None if resp == gtk.RESPONSE_OK: model = combo_box.get_model() active = combo_box.get_active() if active < 0: return None, None combo_selected = model[active][0] for i in ARG_TYPES: if combo_selected == ARG_TYPES[i]: combo_selected = i result = description_entry.get_text(), combo_selected #self.insert_arg_button.set_label('Edit args') #self.insert_arg_button. d.destroy() return result
def dialog_args(self): ''' Create a dialog ''' d = HIGDialog(_('Arguments')) description_label = HIGEntryLabel( _('Insert the description to argument:')) description_label.show() description_entry = HIGTextEntry() text = self.arguments_entry.get_text() description_entry.set_text(text) description_entry.show() combo_box = gtk.combo_box_new_text() combo_box.set_wrap_width(1) index = -1 j = 0 for i in ARG_TYPES: combo_box.append_text(ARG_TYPES[i]) if i == self.arg_type: index = j j = j + 1 if index > -1 : combo_box.set_active(index) combo_box.show() d.vbox.pack_start(description_label, False, False) d.vbox.pack_start(description_entry, False, False) d.vbox.pack_start(combo_box, False, False) d.add_button(gtk.STOCK_CANCEL, gtk.RESPONSE_CANCEL) d.add_button(gtk.STOCK_OK, gtk.RESPONSE_OK) resp = d.run() result = None, None if resp == gtk.RESPONSE_OK: model = combo_box.get_model() active = combo_box.get_active() if active < 0: return None, None combo_selected = model[active][0] for i in ARG_TYPES: if combo_selected == ARG_TYPES[i]: combo_selected = i result = description_entry.get_text(), combo_selected #self.insert_arg_button.set_label('Edit args') #self.insert_arg_button. d.destroy() return result
class Proprieties(HIGScrolledWindow): ''' This box should be configurable if widget is of a type all configuration should be change to this type #tricks: option_list have a icon to fill with options and option_check have a list of options in combo to change ''' def __init__(self): HIGScrolledWindow.__init__(self) self._boxeditable = None vp = gtk.Viewport() self._create_widgets() vp.add(self._box) vp.set_shadow_type(gtk.SHADOW_NONE) self.add(vp) self._profilecore = None self._selected = None def set_profilecore(self, profilecore): self._profilecore = profilecore def _create_widgets(self): ''' Create the main entrys of the option ''' self._box = HIGVBox() self._table = HIGTable() #Name self._label_name = HIGEntryLabel(_('Name')) self._entry_name = HIGTextEntry() self._entry_name.connect('activate', self._update_label) #Type self._label_type = HIGEntryLabel(_('Type')) self._combo_type = gtk.combo_box_new_text() self._combo_type.append_text('') self._combo_type.append_text('Option List') self._combo_type.append_text('Option Check') self._combo_type.set_active(0) self._combo_type.connect('changed', self.change_combo) self._label_opt = HIGEntryLabel(_('Option')) self._entry_opt = HIGTextEntry() self._entry_opt.set_sensitive(False) #For option list open a dialog to add/remove options self._button_list = HIGButton('Edit Option List') img = gtk.Image() img_dir = os.path.join(pixmaps_dir, 'uie', 'combo.png') img.set_from_file(img_dir) self._button_list.set_image(img) self._button_list.connect('button-press-event', self._button_list_clicked) self._table.attach(self._label_name, 0,1,0, 1) self._table.attach(self._entry_name, 1,2,0,1) self._table.attach(self._label_type, 0,1,1,2) self._table.attach(self._combo_type, 1,2,1, 2) self._table.attach(self._button_list, 0,2, 3,4) self._table.attach(self._label_opt, 0,1, 4,5) self._table.attach(self._entry_opt, 1,2,4,5) self._box.pack_start(self._table, False, False) def _button_list_clicked(self, widget, event): section_name = self._boxeditable.get_name() lm = ListManager(self._entry_name.get_text(),section_name, self._profilecore, self._selected, _('List of items')) def _update_label(self, widget): #XXX Replace by Command log.debug("Update Label") selected = self._selected cmd = CommandChangeLabel(selected, self._entry_name.get_text(), self._profilecore,self._boxeditable, True) command_manager.add_command(cmd) def change_combo(self,combo): model = combo.get_model() index = combo.get_active() if index: if model[index][0]=='Option List': log.debug('Show Button List ') self._button_list.show() else: log.debug('Hide Button List ') self._button_list.hide() return def show_notebook_label(self): ''' show proprieties of notebook label and hide others ''' pass def show_item(self): pass def hide_item(self): self._label_opt.hide() self._entry_opt.hide() self._button_list.hide() self._combo_type.hide() self._label_type.hide() self._entry_name.hide() self._label_name.hide() def set_notebooklabel(self, selected): self._entry_name.show() self._label_name.show() self._entry_name.set_text(selected.get_text()) self._button_list.hide() self._combo_type.hide() self._label_type.hide() self._label_opt.hide() self._entry_opt.hide() self._selected = selected def set_item(self, selected): self._entry_name.show() self._label_name.show() self._selected = selected if selected.get_name()!=None: self._entry_name.set_text(selected.get_name()) else: self.hide_item() return childs = selected.get_children() self._combo_type.show() self._label_type.show() child_label = childs[0] if isinstance(child_label, gtk.HBox): #OptionCheck self._label_opt.show() self._entry_opt.show() opt_ = self._profilecore.get_opt_check(self._boxeditable.get_name(), selected.get_name()) self._entry_opt.set_text(opt_) self._button_list.hide() child_label.cbutton.set_label(self._entry_name.get_text()) self._combo_type.set_active(2) #XXX: Put other widget that sensitible = False with option name elif isinstance(child_label, gtk.EventBox): #OptionList self._button_list.show() other = child_label.get_children()[0] other.set_label(self._entry_name.get_text()) self._combo_type.set_active(1) #Disable Combo to change OptionList/OptionChange self._combo_type.set_sensitive(False) def set_boxeditable(self, boxeditable): self._boxeditable = boxeditable def update(self): pass def disable_all(self): self._label_opt.hide() self._entry_opt.hide() self._button_list.hide() self._combo_type.hide() self._label_type.hide() self._entry_name.hide() self._label_name.hide() def load_data(self, option): pass def unload(self,option): pass
class Proprieties(HIGScrolledWindow): ''' This box should be configurable if widget is of a type all configuration should be change to this type #tricks: option_list have a icon to fill with options and option_check have a list of options in combo to change ''' def __init__(self): HIGScrolledWindow.__init__(self) self._boxeditable = None vp = gtk.Viewport() self._create_widgets() vp.add(self._box) vp.set_shadow_type(gtk.SHADOW_NONE) self.add(vp) self._profilecore = None self._selected = None def set_profilecore(self, profilecore): self._profilecore = profilecore def _create_widgets(self): ''' Create the main entrys of the option ''' self._box = HIGVBox() self._table = HIGTable() #Name self._label_name = HIGEntryLabel(_('Name')) self._entry_name = HIGTextEntry() self._entry_name.connect('activate', self._update_label) #Type self._label_type = HIGEntryLabel(_('Type')) self._combo_type = gtk.combo_box_new_text() self._combo_type.append_text('') self._combo_type.append_text('Option List') self._combo_type.append_text('Option Check') self._combo_type.set_active(0) self._combo_type.connect('changed', self.change_combo) self._label_opt = HIGEntryLabel(_('Option')) self._entry_opt = HIGTextEntry() self._entry_opt.set_sensitive(False) #For option list open a dialog to add/remove options self._button_list = HIGButton('Edit Option List') img = gtk.Image() img_dir = os.path.join(pixmaps_dir, 'uie', 'combo.png') img.set_from_file(img_dir) self._button_list.set_image(img) self._button_list.connect('button-press-event', self._button_list_clicked) self._table.attach(self._label_name, 0, 1, 0, 1) self._table.attach(self._entry_name, 1, 2, 0, 1) self._table.attach(self._label_type, 0, 1, 1, 2) self._table.attach(self._combo_type, 1, 2, 1, 2) self._table.attach(self._button_list, 0, 2, 3, 4) self._table.attach(self._label_opt, 0, 1, 4, 5) self._table.attach(self._entry_opt, 1, 2, 4, 5) self._box.pack_start(self._table, False, False) def _button_list_clicked(self, widget, event): section_name = self._boxeditable.get_name() lm = ListManager(self._entry_name.get_text(), section_name, self._profilecore, self._selected, _('List of items')) def _update_label(self, widget): #XXX Replace by Command log.debug("Update Label") selected = self._selected cmd = CommandChangeLabel(selected, self._entry_name.get_text(), self._profilecore, self._boxeditable, True) command_manager.add_command(cmd) def change_combo(self, combo): model = combo.get_model() index = combo.get_active() if index: if model[index][0] == 'Option List': log.debug('Show Button List ') self._button_list.show() else: log.debug('Hide Button List ') self._button_list.hide() return def show_notebook_label(self): ''' show proprieties of notebook label and hide others ''' pass def show_item(self): pass def hide_item(self): self._label_opt.hide() self._entry_opt.hide() self._button_list.hide() self._combo_type.hide() self._label_type.hide() self._entry_name.hide() self._label_name.hide() def set_notebooklabel(self, selected): self._entry_name.show() self._label_name.show() self._entry_name.set_text(selected.get_text()) self._button_list.hide() self._combo_type.hide() self._label_type.hide() self._label_opt.hide() self._entry_opt.hide() self._selected = selected def set_item(self, selected): self._entry_name.show() self._label_name.show() self._selected = selected if selected.get_name() != None: self._entry_name.set_text(selected.get_name()) else: self.hide_item() return childs = selected.get_children() self._combo_type.show() self._label_type.show() child_label = childs[0] if isinstance(child_label, gtk.HBox): #OptionCheck self._label_opt.show() self._entry_opt.show() opt_ = self._profilecore.get_opt_check( self._boxeditable.get_name(), selected.get_name()) self._entry_opt.set_text(opt_) self._button_list.hide() child_label.cbutton.set_label(self._entry_name.get_text()) self._combo_type.set_active(2) #XXX: Put other widget that sensitible = False with option name elif isinstance(child_label, gtk.EventBox): #OptionList self._button_list.show() other = child_label.get_children()[0] other.set_label(self._entry_name.get_text()) self._combo_type.set_active(1) #Disable Combo to change OptionList/OptionChange self._combo_type.set_sensitive(False) def set_boxeditable(self, boxeditable): self._boxeditable = boxeditable def update(self): pass def disable_all(self): self._label_opt.hide() self._entry_opt.hide() self._button_list.hide() self._combo_type.hide() self._label_type.hide() self._entry_name.hide() self._label_name.hide() def load_data(self, option): pass def unload(self, option): pass