def __proprieties(self): """ Create a editable options - Proprieties of Options """ #Create a listview with options self.prop_frame_option = gtk.Frame() self.prop_frame_option.set_label("List Options") self.prop_frame_option.set_shadow_type(gtk.SHADOW_ETCHED_OUT) prop_sw = HIGScrolledWindow() prop_sw.set_shadow_type(gtk.SHADOW_ETCHED_IN) prop_sw.set_policy(gtk.POLICY_AUTOMATIC, gtk.POLICY_AUTOMATIC) model = gtk.TreeStore(gobject.TYPE_STRING) treeview = gtk.TreeView(model) renderer = gtk.CellRendererText() column = gtk.TreeViewColumn("Name", renderer, text=0) treeview.append_column(column) self.prop_frame_option.add(treeview) self.prop_frame_option.add(prop_sw) """ Box Edit """ #Frame self.prop_frame = gtk.Frame() self.prop_frame.set_label("Edit Option") self.prop_frame.set_shadow_type(gtk.SHADOW_ETCHED_OUT) self.prop_exp = HIGExpander("Proprieties") label = gtk.Label('s') self.prop_exp.add(label) self.prop_frame.add(self.prop_exp)
def __proprieties(self): """ Create a editable options - Proprieties of Options """ # Create a listview with options self.prop_frame_option = gtk.Frame() self.prop_frame_option.set_label("List Options") self.prop_frame_option.set_shadow_type(gtk.SHADOW_ETCHED_OUT) prop_sw = HIGScrolledWindow() prop_sw.set_shadow_type(gtk.SHADOW_ETCHED_IN) prop_sw.set_policy(gtk.POLICY_AUTOMATIC, gtk.POLICY_AUTOMATIC) model = gtk.TreeStore(gobject.TYPE_STRING) treeview = gtk.TreeView(model) renderer = gtk.CellRendererText() column = gtk.TreeViewColumn("Name", renderer, text=0) treeview.append_column(column) self.prop_frame_option.add(treeview) self.prop_frame_option.add(prop_sw) """ Box Edit """ # Frame self.prop_frame = gtk.Frame() self.prop_frame.set_label("Edit Option") self.prop_frame.set_shadow_type(gtk.SHADOW_ETCHED_OUT) self.prop_exp = HIGExpander("Proprieties") label = gtk.Label("s") self.prop_exp.add(label) self.prop_frame.add(self.prop_exp)
class DependenceOption(HIGDialog): def __init__(self, option, restructfiles, profile, wizard): HIGDialog.__init__(self, _('Dependence of Option ') + option) self.set_size_request(-1, 300) self.restructfiles = restructfiles self._profile = profile self._wizard = wizard self._draw_widgets() self.show_all() def _draw_widgets(self): self._label = gtk.Label( _('There is a problem deleting this option. This options have dependences. ' )) self._label_q = gtk.Label( _('Are you sure that can remove this option? Dependences should be removed too' )) self._label.show() self._label_q.show() self.vbox.pack_start(self._label, False, False) self.vbox.pack_start(self._label_q, False, False) self._treeview_compare() self.add_button(gtk.STOCK_YES, gtk.RESPONSE_YES) self.add_button(gtk.STOCK_NO, gtk.RESPONSE_NO) self.action_area.show_all() def _treeview_compare(self): self._model = gtk.TreeStore(gobject.TYPE_STRING) profile = self._model.append(None, ['Profile']) wizard = self._model.append(None, ['Wizard']) for i in self._profile: parent = self._model.append(profile, [i[0]]) inside = self._model.append(parent, [i[1]]) if len(i) == 3: self._model.append(inside, [i[2]]) for i in self._wizard: parent = self._model.append(wizard, [i[0]]) inside = self._model.append(parent, [i[1]]) if len(i) == 3: self._model.append(inside, [i[2]]) self._treeview = gtk.TreeView(self._model) column = gtk.TreeViewColumn() column.set_title('Name') render_text = gtk.CellRendererText() column.pack_start(render_text, expand=True) column.add_attribute(render_text, 'text', 0) self._treeview.append_column(column) self.__scrolledwindow = HIGScrolledWindow() self.__scrolledwindow.set_policy(gtk.POLICY_AUTOMATIC, gtk.POLICY_AUTOMATIC) self.__scrolledwindow.add(self._treeview) self.vbox.pack_start(self.__scrolledwindow, True, True) self.__scrolledwindow.show_all() self._treeview.show_all() self.vbox.show_all()
class DependenceOption(HIGDialog): def __init__(self, option, restructfiles, profile, wizard): HIGDialog.__init__(self, _('Dependence of Option ') + option ) self.set_size_request(-1,300) self.restructfiles = restructfiles self._profile = profile self._wizard = wizard self._draw_widgets() self.show_all() def _draw_widgets(self): self._label = gtk.Label(_('There is a problem deleting this option. This options have dependences. ')) self._label_q = gtk.Label(_('Are you sure that can remove this option? Dependences should be removed too')) self._label.show() self._label_q.show() self.vbox.pack_start(self._label, False, False) self.vbox.pack_start(self._label_q, False, False) self._treeview_compare() self.add_button(gtk.STOCK_YES, gtk.RESPONSE_YES) self.add_button(gtk.STOCK_NO, gtk.RESPONSE_NO) self.action_area.show_all() def _treeview_compare(self): self._model = gtk.TreeStore(gobject.TYPE_STRING) profile = self._model.append( None, ['Profile']) wizard = self._model.append( None, ['Wizard']) for i in self._profile: parent = self._model.append( profile, [i[0]]) inside = self._model.append( parent, [i[1]] ) if len(i) == 3: self._model.append(inside, [i[2]]) for i in self._wizard: parent = self._model.append( wizard, [i[0]]) inside = self._model.append( parent, [i[1]] ) if len(i) == 3: self._model.append(inside, [i[2]]) self._treeview = gtk.TreeView(self._model) column = gtk.TreeViewColumn() column.set_title('Name') render_text = gtk.CellRendererText() column.pack_start(render_text, expand=True) column.add_attribute(render_text, 'text', 0) self._treeview.append_column(column) self.__scrolledwindow = HIGScrolledWindow() self.__scrolledwindow.set_policy(gtk.POLICY_AUTOMATIC, gtk.POLICY_AUTOMATIC) self.__scrolledwindow.add(self._treeview) self.vbox.pack_start(self.__scrolledwindow, True, True) self.__scrolledwindow.show_all() self._treeview.show_all() self.vbox.show_all()
class OptionList(HIGVBox): """ A treeview with a list of actual options """ def __init__(self, optiondisplay=None): HIGVBox.__init__(self) self.__model = gtk.TreeStore(gtk.gdk.Pixbuf, gobject.TYPE_STRING) self.__treeview = gtk.TreeView(self.__model) self.__treeview.set_headers_visible(True) self.__treeview.drag_source_set( gtk.gdk.BUTTON1_MASK | gtk.gdk.BUTTON3_MASK, target, gtk.gdk.ACTION_COPY | gtk.gdk.ACTION_MOVE) self.__treeview.connect('drag_data_get', self.source_drag_data_get) column = gtk.TreeViewColumn() column.set_title('Name') render_pixbuf = gtk.CellRendererPixbuf() column.pack_start(render_pixbuf, expand=False) column.add_attribute(render_pixbuf, 'pixbuf', 0) render_text = gtk.CellRendererText() column.pack_start(render_text, expand=True) column.add_attribute(render_text, 'text', 1) self.__treeview.append_column(column) self.options = ListOptions(options) self.__scrolledwindow = HIGScrolledWindow() self.__scrolledwindow.set_policy(gtk.POLICY_AUTOMATIC, gtk.POLICY_AUTOMATIC) self.pack_start(self.__scrolledwindow, True, True) self.__scrolledwindow.add(self.__treeview) self.optiondisplay = optiondisplay self.exists_display = (self.optiondisplay != None) #True or False self.set_option_display(optiondisplay) def get_model(self): return self.__model def get_list_option(self): return self.options def source_drag_data_get(self, btn, context, selection_data, info, time): param_send = self.get_selected() #param_send = opt selection_data.set(selection_data.target, 8, param_send) def get_selected_option(self): ''' @return: iter and model of option treeview selected ''' treeselection = self.__treeview.get_selection() (model, iter) = treeselection.get_selected() return model, iter def set_option_display(self, optiondisplay): """ Set a option display to change fields when cursor change @param optiondisplay: it's a mainframe that contains fields to set @type optiondisplay: OptionDisplay """ self.optiondisplay = optiondisplay self.exists_display = (self.optiondisplay != None) #True or False if self.exists_display: log.debug('<<< Cursor changed') self.__treeview.connect("cursor-changed", self.update_option_display) def get_selected(self): """ Returns the string with name of selected option """ try: treeselection = self.__treeview.get_selection() (model, iter) = treeselection.get_selected() return model.get_value(iter, 1) except: return None def update_option_display(self, widget): """ Update option display contents """ if self.get_selected() == None: return option = self.options.get_option(self.get_selected()) self.optiondisplay.set_option_list(option) self.optiondisplay.add_button.set_sensitive(False) self.optiondisplay.update_button.set_sensitive(True) self.optiondisplay.delete_button.set_sensitive(True) def _arg_img(self, arg): if arg == 'str': return 'entry' elif arg == 'int': return 'spinbutton' elif arg == '': return 'checkbutton' return 'label' def reload(self): """ Reload items of treeview """ list = self.options.get_options_list() for i in list: arg = self.options.get_arg_type(i) myiter = self.__model.insert_before(None, None) icon = gtk.Image() s = self._arg_img(arg) img_dir = os.path.join(pixmaps_dir, 'uie', '%s.png' % s) icon.set_from_file(img_dir) icon = icon.get_pixbuf() self.__model.set_value(myiter, 0, icon) self.__model.set_value(myiter, 1, i) def add(self, option): """ Add a new option """ cmd = CommandAddRemoveOptionMode(option, self.options, self.__model, self.optiondisplay, True) command_manager.add_command(cmd) def save(self): """ Save from option treeview to xml file """ self.options.write_file(options)
class OptionList(HIGVBox): """ A treeview with a list of actual options """ def __init__(self, optiondisplay=None): HIGVBox.__init__(self) self.__model = gtk.TreeStore(gtk.gdk.Pixbuf,gobject.TYPE_STRING) self.__treeview = gtk.TreeView(self.__model) self.__treeview.set_headers_visible(True) self.__treeview.drag_source_set(gtk.gdk.BUTTON1_MASK | gtk.gdk.BUTTON3_MASK, target, gtk.gdk.ACTION_COPY | gtk.gdk.ACTION_MOVE) self.__treeview.connect('drag_data_get', self.source_drag_data_get) column = gtk.TreeViewColumn() column.set_title('Name') render_pixbuf = gtk.CellRendererPixbuf() column.pack_start(render_pixbuf, expand=False) column.add_attribute(render_pixbuf, 'pixbuf', 0) render_text = gtk.CellRendererText() column.pack_start(render_text, expand=True) column.add_attribute(render_text, 'text', 1) self.__treeview.append_column(column) self.options = ListOptions(options) self.__scrolledwindow = HIGScrolledWindow() self.__scrolledwindow.set_policy(gtk.POLICY_AUTOMATIC, gtk.POLICY_AUTOMATIC) self.pack_start(self.__scrolledwindow, True, True ) self.__scrolledwindow.add(self.__treeview) self.optiondisplay = optiondisplay self.exists_display = (self.optiondisplay != None ) #True or False self.set_option_display(optiondisplay) def get_model(self): return self.__model def get_list_option(self): return self.options def source_drag_data_get(self, btn, context, selection_data, info, time): param_send = self.get_selected() #param_send = opt selection_data.set(selection_data.target, 8, param_send) def get_selected_option(self): ''' @return: iter and model of option treeview selected ''' treeselection = self.__treeview.get_selection() (model,iter) = treeselection.get_selected() return model, iter def set_option_display(self, optiondisplay): """ Set a option display to change fields when cursor change @param optiondisplay: it's a mainframe that contains fields to set @type optiondisplay: OptionDisplay """ self.optiondisplay = optiondisplay self.exists_display = (self.optiondisplay != None ) #True or False if self.exists_display: log.debug('<<< Cursor changed') self.__treeview.connect("cursor-changed",self.update_option_display) def get_selected(self): """ Returns the string with name of selected option """ try: treeselection = self.__treeview.get_selection() (model,iter) = treeselection.get_selected() return model.get_value(iter,1) except: return None def update_option_display(self, widget): """ Update option display contents """ if self.get_selected()==None : return option = self.options.get_option(self.get_selected()) self.optiondisplay.set_option_list(option) self.optiondisplay.add_button.set_sensitive(False) self.optiondisplay.update_button.set_sensitive(True) self.optiondisplay.delete_button.set_sensitive(True) def _arg_img(self, arg): if arg == 'str': return 'entry' elif arg == 'int': return 'spinbutton' elif arg == '' : return 'checkbutton' return 'label' def reload(self): """ Reload items of treeview """ list = self.options.get_options_list() for i in list: arg = self.options.get_arg_type(i) myiter = self.__model.insert_before(None, None) icon = gtk.Image() s = self._arg_img(arg) img_dir = os.path.join(pixmaps_dir,'uie' ,'%s.png' % s) icon.set_from_file(img_dir) icon = icon.get_pixbuf() self.__model.set_value(myiter, 0, icon) self.__model.set_value(myiter, 1, i) def add(self, option): """ Add a new option """ cmd = CommandAddRemoveOptionMode(option, self.options, self.__model, self.optiondisplay, True) command_manager.add_command(cmd) def save(self): """ Save from option treeview to xml file """ self.options.write_file(options)