Пример #1
0
    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()
    def __create_tab(self, tab_name, section_name, tab):
        log.debug(">>> Tab name: %s" % tab_name)
        log.debug(">>>Creating profile editor section: %s" % section_name)

        vbox = HIGVBox()
        table = HIGTable()
        section = HIGSectionLabel(section_name)

        vbox._pack_noexpand_nofill(section)
        vbox._pack_noexpand_nofill(HIGSpacer(table))
        vbox.set_border_width(6)

        tab.fill_table(table, True)
        self.scrollwindow = HIGScrolledWindow()
        self.scrollwindow.set_size_request(600, 300)
        vp = gtk.Viewport()
        vp.add(vbox)
        vp.set_shadow_type(gtk.SHADOW_NONE)
        self.scrollwindow.add(vp)

        vbox_tmp = HIGVBox()
        vbox_tmp.set_border_width(6)
        vbox_tmp.set_spacing(12)
        vbox_tmp.pack_start(self.scrollwindow)

        self.notebook.append_page(vbox_tmp, gtk.Label(tab_name))
    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)
Пример #4
0
    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)
Пример #5
0
 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
Пример #6
0
 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 __init__(self,
                 section_name,
                 profile,
                 listoptions,
                 notebook_parent,
                 new=False):
        """
        A Box Editable contains a options of each tab
        @param section_name: section name <tab>
        @type section_name: str 
        @param profile: A class that view and modify xml file 
        @type profile: ProfileCore
        @param listoptions: The List of Options to update XML (I guess to confirm)
        @type listoptions: ListOptions
        @param notebook_parent: Notebook
        @type notebook_parent: Notebook or Subclass
        @param new: It's a new tab or not 
        @type new: bool
        """

        HIGVBox.__init__(self)
        self._coords = {}
        self._parent = notebook_parent
        self._last = None
        #Profile Core do a manage at profile_editor.xml file
        self._profilecore = None

        self._profile = profile
        self._listoptions = listoptions
        self._table = HIGTable()
        self._section_name = section_name
        if not new:
            self._options = self._profile.get_section(section_name)
        self._table.set_border_width(3)
        c = self.get_colormap()
        color = c.alloc_color(0, 0, 0)
        self._table.modify_fg(gtk.STATE_NORMAL, color)
        #self._fill_table()

        box_tmp = HIGVBox()
        box_tmp.pack_start(self._table, False, False)
        self._sw = HIGScrolledWindow()
        #self._sw.set_size_request(400,200)
        vp = gtk.Viewport()
        vp.add(box_tmp)
        vp.set_shadow_type(gtk.SHADOW_NONE)
        self._sw.add(vp)
        self.pack_start(self._sw, True, True)
        self._old_selected = None
        self._x = 0
        self._y = 0

        self.connect('button-press-event', self._bp)
Пример #8
0
    def _create_option_tv(self):
        self._sw = HIGScrolledWindow()

        self._model = gtk.TreeStore(gobject.TYPE_STRING)
        self._tv = gtk.TreeView(self._model)
        column = gtk.TreeViewColumn()
        column.set_title('Name')
        render = gtk.CellRendererText()
        column.pack_start(render, expand=True)
        column.add_attribute(render, 'text', 0)
        self._tv.append_column(column)
        self._sw.add(self._tv)
        self._sw.show_all()
Пример #9
0
        def buildtv(*args):
            """
            Build treeview and append results.
            """
            lsmodel = gtk.ListStore(str, str, str, str)
            tview = gtk.TreeView(lsmodel)
            columns = 4
            columns_text = (
                _("Inventory"), _("Host"),
                _("First Matched Category"), _("Entry Date")
                )
            tview.columns = [None]*columns

            for n in range(columns):
                tview.columns[n] = gtk.TreeViewColumn(columns_text[n])
                tview.columns[n].cell = gtk.CellRendererText()
                tview.columns[n].pack_start(tview.columns[n].cell, True)
                tview.columns[n].set_attributes(tview.columns[n].cell, text=n)

                tview.append_column(tview.columns[n])

            tview.connect('row-activated', row_activated)

            # layout
            matches = len(args[1])
            word = append_s(_("result"), matches)
            upper_title = gtk.Label()
            upper_title.set_markup(
                    ("<b>%d " % matches) + word + _(" found.") +
                    "</b>")
            hutbox = HIGHBox()
            hutbox._pack_noexpand_nofill(upper_title)
            sw = HIGScrolledWindow()
            sw.add(tview)
            vbox = gtk.VBox()
            vbox.pack_start(hutbox, False, False, 3)
            vbox.pack_start(sw, True, True, 0)

            vbox.show_all()

            # append results to treeview
            results = args[1]

            for res, date in results.items():
                invname = self.invdb.get_inventory_name_for_id(res[0])
                lsmodel.append((invname, res[1], res[2], str(date)))

            title = _("Search: %s") % args[0]
            tab_label = HIGAnimatedTabLabel(title)
            tab_label.connect("close-clicked", close_page, vbox)
            self.viewernb.append_page(vbox, tab_label)
Пример #10
0
    def __create_widgets(self):
        self.vbox = HIGVBox()
        self.hbox = HIGHBox()
        self.notebook = HIGNotebook()
        self.btn_close = HIGButton(stock=gtk.STOCK_CLOSE)
        
        self.written_by_scroll = HIGScrolledWindow()
        self.written_by_text = HIGTextView()
        
        self.design_scroll = HIGScrolledWindow()
        self.design_text = HIGTextView()

        self.soc2007_scroll = HIGScrolledWindow()
        self.soc2007_text = HIGTextView()
        
        self.soc2008_scroll = HIGScrolledWindow()
        self.soc2008_text = HIGTextView()

        self.soc2009_scroll = HIGScrolledWindow()
        self.soc2009_text = HIGTextView()
        
        self.contributors_scroll = HIGScrolledWindow()
        self.contributors_text = HIGTextView()
        
        self.translation_scroll = HIGScrolledWindow()
        self.translation_text = HIGTextView()

        self.nokia_scroll = HIGScrolledWindow()
        self.nokia_text = HIGTextView()
Пример #11
0
    def __init__(self, only_text=True):
        HIGScrolledWindow.__init__(self)

        self._box = HIGVBox()
        vp = gtk.Viewport()

        self._box.set_border_width(6)
        if only_text:
            self._draw_buttons()
            self._pack()
        #ELSE == Algo com icons; ETC! 

        vp.add(self._box)
        vp.set_shadow_type(gtk.SHADOW_NONE)
        self.add(vp)
Пример #12
0
    def __init__(self, only_text=True):
        HIGScrolledWindow.__init__(self)

        self._box = HIGVBox()
        vp = gtk.Viewport()

        self._box.set_border_width(6)
        if only_text:
            self._draw_buttons()
            self._pack()
        #ELSE == Algo com icons; ETC!

        vp.add(self._box)
        vp.set_shadow_type(gtk.SHADOW_NONE)
        self.add(vp)
    def __create_widgets(self):

        self.vbox_main = HIGVBox()

        self.main_frame = HIGFrame("Profiles")
        #self.main_frame.set_shadow_type(gtk.SHADOW_ETCHED_OUT)

        self.align = gtk.Alignment(0.0, 0.0, 1.0, 1.0)
        self.align.set_padding(0, 0, 12, 0)

        self.vbox = HIGVBox()
        self.profiles_sw = HIGScrolledWindow()
        #TreeView
        self.model = gtk.ListStore(gobject.TYPE_STRING, gobject.TYPE_STRING)
        #self.modelfilter = self.model.filter_new()
        self.profiles_tv = gtk.TreeView(self.model)
        renderer = gtk.CellRendererText()
        column = gtk.TreeViewColumn(_("Name"), renderer, text=0)
        self.profiles_tv.append_column(column)
        renderer_hint = gtk.CellRendererText()
        column_hint = gtk.TreeViewColumn(_("Hint"), renderer_hint, text=1)
        self.profiles_tv.append_column(column_hint)
        #self.profiles_tv.set_model(self.modelfilter)
        #Info
        self.hbox_info = HIGHBox()
        self.command_label = HIGEntryLabel('Command: ')
        self.command_entry = HIGTextEntry()
        self.command_entry.set_editable(False)

        #Buttons
        self.hbox_buttons = HIGHBox()

        self.wiz_button = HIGButton(title='Wizard', stock='gtk-convert')
        self.wiz_button.connect("clicked", self.new_wiz)

        self.edit_button = HIGButton(stock='gtk-edit')
        self.edit_button.connect("clicked", self.open_peditor)
        self.new_button = HIGButton(stock='gtk-new')
        self.new_button.connect("clicked", self.open_peditor)
        self.copy_button = HIGButton(stock='gtk-copy')
        self.copy_button.connect("clicked", self.copy_profiles)
        self.delete_button = HIGButton(stock=gtk.STOCK_DELETE)
        self.delete_button.connect('clicked', self.delete_profile)
        #Apply Buttons
        self.cancel_button = HIGButton(stock='gtk-close')
        self.cancel_button.connect("clicked", self.quit)

        self.connect("delete-event", self.quit)
        def buildtv(*args):
            """
            Build treeview and append results.
            """
            lsmodel = gtk.ListStore(str, str, str, str)
            tview = gtk.TreeView(lsmodel)
            columns = 4
            columns_text = (_("Inventory"), _("Host"),
                            _("First Matched Category"), _("Entry Date"))
            tview.columns = [None] * columns

            for n in range(columns):
                tview.columns[n] = gtk.TreeViewColumn(columns_text[n])
                tview.columns[n].cell = gtk.CellRendererText()
                tview.columns[n].pack_start(tview.columns[n].cell, True)
                tview.columns[n].set_attributes(tview.columns[n].cell, text=n)

                tview.append_column(tview.columns[n])

            tview.connect('row-activated', row_activated)

            # layout
            matches = len(args[1])
            word = append_s(_("result"), matches)
            upper_title = gtk.Label()
            upper_title.set_markup(("<b>%d " % matches) + word + _(" found.") +
                                   "</b>")
            hutbox = HIGHBox()
            hutbox._pack_noexpand_nofill(upper_title)
            sw = HIGScrolledWindow()
            sw.add(tview)
            vbox = gtk.VBox()
            vbox.pack_start(hutbox, False, False, 3)
            vbox.pack_start(sw, True, True, 0)

            vbox.show_all()

            # append results to treeview
            results = args[1]

            for res, date in results.items():
                invname = self.invdb.get_inventory_name_for_id(res[0])
                lsmodel.append((invname, res[1], res[2], str(date)))

            title = _("Search: %s") % args[0]
            tab_label = HIGAnimatedTabLabel(title)
            tab_label.connect("close-clicked", close_page, vbox)
            self.viewernb.append_page(vbox, tab_label)
Пример #15
0
    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)
Пример #16
0
    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()
Пример #17
0
    def __create_tab(self, tab_name, section_name, tab):
        log.debug(">>> Tab name: %s" % tab_name)
        log.debug(">>>Creating profile editor section: %s" % section_name)

        vbox = HIGVBox()
        table = HIGTable()
        section = HIGSectionLabel(section_name)

        vbox._pack_noexpand_nofill(section)
        vbox._pack_noexpand_nofill(HIGSpacer(table))
        vbox.set_border_width(6)

        tab.fill_table(table, True)
        self.scrollwindow = HIGScrolledWindow()
        self.scrollwindow.set_size_request(600,300)
        vp = gtk.Viewport()
        vp.add(vbox)
        vp.set_shadow_type(gtk.SHADOW_NONE)
        self.scrollwindow.add(vp)

        vbox_tmp = HIGVBox()
        vbox_tmp.set_border_width(6)
        vbox_tmp.set_spacing(12)
        vbox_tmp.pack_start(self.scrollwindow)


        self.notebook.append_page(vbox_tmp, gtk.Label(tab_name))
Пример #18
0
    def __init__(self):
        """ Constructor """
        HIGHBox.__init__(self)
        self.scroll = HIGScrolledWindow()
        self._box = HIGHBox()
        self._icons_list = []
        self._tabstruct = TabStruct()
        self.__current = [0]
        self.__model = gtk.ListStore(str, gtk.gdk.Pixbuf)
        #self.__model = gtk.ListStore(str, HIGHBox)
        self.__pixmap_d = Path.pixmaps_dir

        self.__icon = gtk.IconView()
        self.__icon.set_model(self.__model)
        self.__icon.set_text_column(0)
        self.__icon.set_pixbuf_column(1)

        self.__icon.set_orientation(gtk.ORIENTATION_VERTICAL)
        self.__icon.set_selection_mode(gtk.SELECTION_SINGLE)

        # Change background color -- FIXME
        #self.__icon.set_name("icon tabs")
        #gtk.rc_parse_string(
        #"""
        #style "iconview"
        #{
        #bg[PRELIGHT] = { 0.75, 3, 1 }
        #}
        #class 'GtkIconView' style 'iconview'

        #""")
        map = self.__icon.get_colormap()

        colour = map.alloc_color("#FFF9E9")  # light red

        style = self.__icon.get_style().copy()
        style.base[gtk.STATE_NORMAL] = colour
        self.__icon.set_style(style)

        #self.cellpb = gtk.CellRendererPixbuf()
        #self.cellpb.set_property('cell-background', 'yellow')

        #self.__icon.pack_start(self.cellpb, False)
        #self.__icon.set_attributes(self.cellpb, pixbuf=0)
        self.pack_start(self.scroll, True, True)
        self.scroll.add(self.__icon)
Пример #19
0
    def __create_widgets(self):
        self.main_vbox = HIGVBox()



        self.command_expander = HIGExpander('<b>'+_('Command')+'</b>')
        self.command_expander.set_expanded(True)
        self.command_entry = gtk.Entry()

        self.notebook = gtk.Notebook()

        # Profile info page
        self.profile_info_vbox = HIGVBox()
        self.profile_info_label = HIGSectionLabel(_('Profile Information'))
        self.profile_name_label = HIGEntryLabel(_('Profile name'))
        self.profile_name_entry = gtk.Entry()
        self.profile_hint_label = HIGEntryLabel(_('Hint'))
        self.profile_hint_entry = gtk.Entry()
        self.profile_description_label = HIGEntryLabel(_('Description'))
        #self.profile_description_label = HIGHBox() 
        self.profile_description_scroll = HIGScrolledWindow()
        self.profile_description_text = HIGTextView()
        self.profile_annotation_label = HIGEntryLabel(_('Annotation'))
        #self.profile_annotation_label = HIGHBox() 
        self.profile_annotation_scroll = HIGScrolledWindow()
        self.profile_annotation_text = HIGTextView()

        # Buttons
        self.buttons_hbox = HIGHBox()

        self.help_button = HIGButton(stock=gtk.STOCK_HELP)
        self.help_button.connect('clicked', self.help)

        #self.delete_button = HIGButton(stock=gtk.STOCK_DELETE)
        #self.delete_button.connect('clicked', self.delete_profile)

        self.cancel_button = HIGButton(stock=gtk.STOCK_CANCEL)
        self.cancel_button.connect('clicked', self.quit_without_saving)

        self.ok_button = HIGButton(stock=gtk.STOCK_OK)
        self.ok_button.connect('clicked', self.save_profile)
    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)
Пример #21
0
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()
    def __create_widgets(self):
        self.main_vbox = HIGVBox()

        self.command_expander = HIGExpander('<b>' + _('Command') + '</b>')
        self.command_expander.set_expanded(True)
        self.command_entry = gtk.Entry()

        self.notebook = gtk.Notebook()

        # Profile info page
        self.profile_info_vbox = HIGVBox()
        self.profile_info_label = HIGSectionLabel(_('Profile Information'))
        self.profile_name_label = HIGEntryLabel(_('Profile name'))
        self.profile_name_entry = gtk.Entry()
        self.profile_hint_label = HIGEntryLabel(_('Hint'))
        self.profile_hint_entry = gtk.Entry()
        self.profile_description_label = HIGEntryLabel(_('Description'))
        #self.profile_description_label = HIGHBox()
        self.profile_description_scroll = HIGScrolledWindow()
        self.profile_description_text = HIGTextView()
        self.profile_annotation_label = HIGEntryLabel(_('Annotation'))
        #self.profile_annotation_label = HIGHBox()
        self.profile_annotation_scroll = HIGScrolledWindow()
        self.profile_annotation_text = HIGTextView()

        # Buttons
        self.buttons_hbox = HIGHBox()

        self.help_button = HIGButton(stock=gtk.STOCK_HELP)
        self.help_button.connect('clicked', self.help)

        #self.delete_button = HIGButton(stock=gtk.STOCK_DELETE)
        #self.delete_button.connect('clicked', self.delete_profile)

        self.cancel_button = HIGButton(stock=gtk.STOCK_CANCEL)
        self.cancel_button.connect('clicked', self.quit_without_saving)

        self.ok_button = HIGButton(stock=gtk.STOCK_OK)
        self.ok_button.connect('clicked', self.save_profile)
    def __init__(self, listoption, profile_editor_file=profile_editor):
        gtk.HBox.__init__(self)
        self._toolbar = ToolBarInterface()
        self._toolbar.set_optionlist(listoption)
        self.profile_editor_file = profile_editor_file
        self._proprieties = None
        self._notebook_tools = None
        self._changed = False
        #MAIN SCROLLED
        self._scroolledmain = HIGScrolledWindow()
        #NOTEBOOKEDITABLE :
        self._profilecore = ProfileCore(profile_editor_file)
        self._toolbar.set_profilecore(self._profilecore)

        self.notebook = NotebookEditable(listoption, self._profilecore)
        self._toolbar.set_notebook(self.notebook)
        self.notebook.connect_after('changed', self.update_toolbar)
        self.notebook.connect_after('need-save', self._need_save)
        self.notebook.load_data()
        self.pack_start(self._toolbar.get_toolbar(), False, True, 0)
        self.pack_start(self._scroolledmain, True, True)
        self._scroolledmain.add_with_viewport(self.notebook)
        self.show_all()
Пример #24
0
    def _create_option_tv(self):
        self._sw = HIGScrolledWindow()


        self._model = gtk.TreeStore(gobject.TYPE_STRING)
        self._tv = gtk.TreeView(self._model)
        column = gtk.TreeViewColumn()
        column.set_title('Name')
        render = gtk.CellRendererText()
        column.pack_start(render, expand=True)
        column.add_attribute(render, 'text', 0)
        self._tv.append_column(column)
        self._sw.add(self._tv)
        self._sw.show_all()
Пример #25
0
    def __init__(self, section_name, profile, listoptions, notebook_parent, new=False):
        """
        A Box Editable contains a options of each tab
        @param section_name: section name <tab>
        @type section_name: str 
        @param profile: A class that view and modify xml file 
        @type profile: ProfileCore
        @param listoptions: The List of Options to update XML (I guess to confirm)
        @type listoptions: ListOptions
        @param notebook_parent: Notebook
        @type notebook_parent: Notebook or Subclass
        @param new: It's a new tab or not 
        @type new: bool
        """

        HIGVBox.__init__(self)
        self._coords = {}
        self._parent = notebook_parent
        self._last = None 
        #Profile Core do a manage at profile_editor.xml file 
        self._profilecore = None 

        self._profile = profile
        self._listoptions = listoptions
        self._table = HIGTable()
        self._section_name = section_name
        if not new :
            self._options = self._profile.get_section(section_name)
        self._table.set_border_width(3)
        c = self.get_colormap()
        color = c.alloc_color(0,0,0)   
        self._table.modify_fg(gtk.STATE_NORMAL,color )
        #self._fill_table()

        box_tmp = HIGVBox()
        box_tmp.pack_start(self._table, False, False)
        self._sw = HIGScrolledWindow()
        #self._sw.set_size_request(400,200)
        vp = gtk.Viewport()
        vp.add(box_tmp)
        vp.set_shadow_type(gtk.SHADOW_NONE)
        self._sw.add(vp)
        self.pack_start(self._sw, True, True)
        self._old_selected = None 
        self._x = 0
        self._y = 0 


        self.connect('button-press-event', self._bp)
Пример #26
0
    def __init__(self):
        """ Constructor """
        HIGHBox.__init__(self)
        self.scroll = HIGScrolledWindow()
        self._box = HIGHBox()
        self._icons_list = []
        self._tabstruct = TabStruct()
        self.__current = [0]
        self.__model = gtk.ListStore(str, gtk.gdk.Pixbuf)
        #self.__model = gtk.ListStore(str, HIGHBox)
        self.__pixmap_d = Path.pixmaps_dir

        self.__icon = gtk.IconView()
        self.__icon.set_model(self.__model)
        self.__icon.set_text_column(0)
        self.__icon.set_pixbuf_column(1)


        self.__icon.set_orientation(gtk.ORIENTATION_VERTICAL)
        self.__icon.set_selection_mode(gtk.SELECTION_SINGLE)

        # Change background color -- FIXME
        #self.__icon.set_name("icon tabs")
        #gtk.rc_parse_string(
#"""
#style "iconview"
#{
  #bg[PRELIGHT] = { 0.75, 3, 1 }
#}
#class 'GtkIconView' style 'iconview'

#""")
        map = self.__icon.get_colormap()

        colour = map.alloc_color("#FFF9E9") # light red

        style = self.__icon.get_style().copy()
        style.base[gtk.STATE_NORMAL] = colour
        self.__icon.set_style(style)


        #self.cellpb = gtk.CellRendererPixbuf()
        #self.cellpb.set_property('cell-background', 'yellow')

        #self.__icon.pack_start(self.cellpb, False)
        #self.__icon.set_attributes(self.cellpb, pixbuf=0)
        self.pack_start(self.scroll, True, True)
        self.scroll.add(self.__icon)
Пример #27
0
    def __create_widgets(self):

        self.vbox_main = HIGVBox()

        self.main_frame = HIGFrame("Profiles")
        #self.main_frame.set_shadow_type(gtk.SHADOW_ETCHED_OUT)

        self.align = gtk.Alignment(0.0, 0.0, 1.0, 1.0)
        self.align.set_padding(0,0,12,0)

        self.vbox = HIGVBox()
        self.profiles_sw = HIGScrolledWindow()
        #TreeView
        self.model = gtk.ListStore(gobject.TYPE_STRING, gobject.TYPE_STRING)
        #self.modelfilter = self.model.filter_new()
        self.profiles_tv = gtk.TreeView(self.model)
        renderer = gtk.CellRendererText()
        column = gtk.TreeViewColumn(_("Name"), renderer, text=0)
        self.profiles_tv.append_column(column)
        renderer_hint = gtk.CellRendererText()
        column_hint = gtk.TreeViewColumn(_("Hint"), renderer_hint, text=1)
        self.profiles_tv.append_column(column_hint)
        #self.profiles_tv.set_model(self.modelfilter)
        #Info 
        self.hbox_info = HIGHBox()
        self.command_label = HIGEntryLabel('Command: ')
        self.command_entry = HIGTextEntry()
        self.command_entry.set_editable(False)

        #Buttons
        self.hbox_buttons = HIGHBox()

        self.wiz_button = HIGButton(title='Wizard', stock='gtk-convert')
        self.wiz_button.connect("clicked", self.new_wiz)

        self.edit_button = HIGButton(stock='gtk-edit')
        self.edit_button.connect("clicked", self.open_peditor)
        self.new_button = HIGButton(stock='gtk-new')
        self.new_button.connect("clicked", self.open_peditor)
        self.copy_button = HIGButton(stock='gtk-copy')
        self.copy_button.connect("clicked", self.copy_profiles)
        self.delete_button = HIGButton(stock=gtk.STOCK_DELETE)
        self.delete_button.connect('clicked', self.delete_profile)	
        #Apply Buttons
        self.cancel_button = HIGButton(stock='gtk-close')
        self.cancel_button.connect("clicked", self.quit)
        
        self.connect("delete-event", self.quit)
Пример #28
0
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()
Пример #29
0
    def __init__(self, listoption, profile_editor_file=profile_editor):
        gtk.HBox.__init__(self)
        self._toolbar = ToolBarInterface()
        self._toolbar.set_optionlist(listoption)
        self.profile_editor_file = profile_editor_file
        self._proprieties = None 
        self._notebook_tools = None 
        self._changed = False
        #MAIN SCROLLED
        self._scroolledmain = HIGScrolledWindow()
        #NOTEBOOKEDITABLE :
        self._profilecore = ProfileCore(profile_editor_file)
        self._toolbar.set_profilecore(self._profilecore)

        self.notebook = NotebookEditable(listoption, self._profilecore)
        self._toolbar.set_notebook(self.notebook)
        self.notebook.connect_after('changed', self.update_toolbar)
        self.notebook.connect_after('need-save',self._need_save)
        self.notebook.load_data()
        self.pack_start(self._toolbar.get_toolbar(), False, True,0)
        self.pack_start(self._scroolledmain, True, True)
        self._scroolledmain.add_with_viewport(self.notebook)
        self.show_all()
Пример #30
0
class ListManager(gtk.Dialog):
    '''
    ListManager - manage the OptionList
    Tricks: 
     - To works with the Command Manager it save at __init__ the list 
       of options. After that. Add to CommandManager when clicked 'Ok Button'
       with the new and old list.
    '''
    def __init__(self, name, section, profilecore, widget, title):
        gtk.Dialog.__init__(self,title)
        self.set_size_request(450, 300)
        self._name = name
        self._section = section
        self._profilecore = profilecore
        self._widget = widget
        self._list = self._profilecore.get_list_opt(self._section, self._name)
        self._new_list = self._profilecore.get_list_opt(self._section, 
                                                        self._name)
        self._create_widgets()
        self.show()
        self._load_option_list()
        self._create_action_area()

    def _create_widgets(self):
        self._optionlist = OptionList()
        label = gtk.Label('Items at the %s ' % self._name)
        self._box = gtk.HPaned()
        ol = self._optionlist
        ol.reload()
        self.vbox.pack_start(label, False, False, 0)
        self._box.add(ol)
        self.vbox.pack_start(self._box)
        self._box.show_all()
        self._move_box = HIGVBox()
        self._add_bt = HIGButton(stock='gtk-add')
        self._add_bt.connect('clicked', self._on_add_press)
        self._remove_bt = HIGButton(stock='gtk-remove')
        self._remove_bt.connect('clicked', self._on_remove_press)
        #XXX - moves don't work yet: lack the connect
        self._move_up_bt = HIGButton(stock='gtk-go-up')
        self._move_down_bt = HIGButton(stock='gtk-go-down')
        self._move_box.pack_start(self._add_bt, False, False)
        self._move_box.pack_start(self._remove_bt, False, False)
        self._move_box.pack_start(self._move_up_bt, False, False)
        self._move_box.pack_start(self._move_down_bt, False, False)
        self._create_option_tv()

        self._box.set_position(200)
        self._box_other = gtk.HPaned()
        self._box.add(self._box_other)
        self._box_other.add(self._move_box)
        self._box_other.add(self._sw)
        self._move_box.show_all()
        self.vbox.show_all()

        label.show()

    def _create_option_tv(self):
        self._sw = HIGScrolledWindow()


        self._model = gtk.TreeStore(gobject.TYPE_STRING)
        self._tv = gtk.TreeView(self._model)
        column = gtk.TreeViewColumn()
        column.set_title('Name')
        render = gtk.CellRendererText()
        column.pack_start(render, expand=True)
        column.add_attribute(render, 'text', 0)
        self._tv.append_column(column)
        self._sw.add(self._tv)
        self._sw.show_all()
    def _load_option_list(self):
        list = self._list

        for i in list : 
            iter = self._model.insert_before(None, None)
            self._model.set_value(iter, 0, i)
    def _create_action_area(self):
        self._button_ok = HIGButton(stock='gtk-ok')
        self._button_cancel = HIGButton(stock='gtk-cancel')
        self._button_cancel.connect('clicked', self._on_cancel_press)
        self._button_ok.connect('clicked', self._on_ok_press)
        self.action_area.pack_start(self._button_cancel)
        self.action_area.pack_start(self._button_ok)
        self.action_area.show_all()

    def _on_add_press(self, widget):
        log.debug('<<< Add Option to OptionList')
        option_selected = self._optionlist.get_selected()
        iter = self._model.insert_before(None, None)
        self._model.set_value(iter, 0, option_selected)
        self._new_list.append(option_selected)

    def get_selected(self):
        """
        Returns the string with name of selected option
        """
        try:
            treeselection = self._tv.get_selection()
            (model,iter) = treeselection.get_selected()	
            return model.get_value(iter,0)
        except:
            return None            

    def get_selected_option(self):
        '''
        @return: iter and model of option treeview selected
        '''
        treeselection = self._tv.get_selection()

        (model,iter) = treeselection.get_selected()
        return model, iter    

    def _on_remove_press(self, widget):
        log.debug('<<< Remove Option from OptionList')
        selected = self.get_selected()
        (model, iter) = self.get_selected_option()
        if selected!=None:
            self._new_list.remove(selected)
            self._model.remove(iter)





    def _on_ok_press(self, widget):
        # Lists:
        list2 = self._list
        list1 = self._new_list

        cmd = CommandUpdateOptionList(self._widget, list1, list2, self._profilecore, True)
        command_manager.add_command(cmd)
        self.destroy()

    def _on_cancel_press(self, widget):
        self.destroy()
    def __create_widgets(self):
        self.vbox = HIGVBox()
        self.hbox = HIGHBox()
        self.notebook = HIGNotebook()
        self.btn_close = HIGButton(stock=gtk.STOCK_CLOSE)

        self.written_by_scroll = HIGScrolledWindow()
        self.written_by_text = HIGTextView()

        self.design_scroll = HIGScrolledWindow()
        self.design_text = HIGTextView()

        self.soc2007_scroll = HIGScrolledWindow()
        self.soc2007_text = HIGTextView()

        self.soc2008_scroll = HIGScrolledWindow()
        self.soc2008_text = HIGTextView()

        self.soc2009_scroll = HIGScrolledWindow()
        self.soc2009_text = HIGTextView()

        self.contributors_scroll = HIGScrolledWindow()
        self.contributors_text = HIGTextView()

        self.translation_scroll = HIGScrolledWindow()
        self.translation_text = HIGTextView()

        self.nokia_scroll = HIGScrolledWindow()
        self.nokia_text = HIGTextView()
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 ProfileManager(HIGWindow):
    """
    Create a Profile Manager 
    """
    def __init__(self, daddy=None):
        HIGWindow.__init__(self, type=gtk.WINDOW_TOPLEVEL)
        self.set_title('Profile Manager')
        self.set_position(gtk.WIN_POS_CENTER)
        self.__create_widgets()
        self.add(self.vbox_main)
        self.__fill_widgets()
        self.__pack_widgets()
        self.__scan_notebook = None

        self.daddy = daddy

    def __create_widgets(self):

        self.vbox_main = HIGVBox()

        self.main_frame = HIGFrame("Profiles")
        #self.main_frame.set_shadow_type(gtk.SHADOW_ETCHED_OUT)

        self.align = gtk.Alignment(0.0, 0.0, 1.0, 1.0)
        self.align.set_padding(0, 0, 12, 0)

        self.vbox = HIGVBox()
        self.profiles_sw = HIGScrolledWindow()
        #TreeView
        self.model = gtk.ListStore(gobject.TYPE_STRING, gobject.TYPE_STRING)
        #self.modelfilter = self.model.filter_new()
        self.profiles_tv = gtk.TreeView(self.model)
        renderer = gtk.CellRendererText()
        column = gtk.TreeViewColumn(_("Name"), renderer, text=0)
        self.profiles_tv.append_column(column)
        renderer_hint = gtk.CellRendererText()
        column_hint = gtk.TreeViewColumn(_("Hint"), renderer_hint, text=1)
        self.profiles_tv.append_column(column_hint)
        #self.profiles_tv.set_model(self.modelfilter)
        #Info
        self.hbox_info = HIGHBox()
        self.command_label = HIGEntryLabel('Command: ')
        self.command_entry = HIGTextEntry()
        self.command_entry.set_editable(False)

        #Buttons
        self.hbox_buttons = HIGHBox()

        self.wiz_button = HIGButton(title='Wizard', stock='gtk-convert')
        self.wiz_button.connect("clicked", self.new_wiz)

        self.edit_button = HIGButton(stock='gtk-edit')
        self.edit_button.connect("clicked", self.open_peditor)
        self.new_button = HIGButton(stock='gtk-new')
        self.new_button.connect("clicked", self.open_peditor)
        self.copy_button = HIGButton(stock='gtk-copy')
        self.copy_button.connect("clicked", self.copy_profiles)
        self.delete_button = HIGButton(stock=gtk.STOCK_DELETE)
        self.delete_button.connect('clicked', self.delete_profile)
        #Apply Buttons
        self.cancel_button = HIGButton(stock='gtk-close')
        self.cancel_button.connect("clicked", self.quit)

        self.connect("delete-event", self.quit)

    def __fill_widgets(self):

        self.profiles = CommandProfile()
        self._reload_profile_list()

        #selection = self.profiles_tv.get_selection()
        #selection.connect("changed", self.change_nmap_command)
        self.profiles_tv.connect("cursor-changed", self.change_nmap_command)

    def __pack_widgets(self):
        """
        Pack all widgets of windows 
        """
        self.vbox_main.pack_start(self.main_frame, True, True)
        self.main_frame.add(self.align)
        self.align.add(self.vbox)
        self.vbox.set_border_width(6)

        self.vbox.pack_start(self.profiles_sw, True, True, 0)

        self.hbox_info.pack_start(self.command_label, False, False, 0)
        self.hbox_info.pack_start(self.command_entry, True, True, 0)
        self.vbox.pack_start(self.hbox_info, False, False, 0)

        self.hbox_buttons.pack_end(self.cancel_button)
        self.hbox_buttons.pack_end(self.copy_button, True, True)
        self.hbox_buttons.pack_end(self.edit_button, True, True)
        self.hbox_buttons.pack_end(self.delete_button, True, True)
        self.hbox_buttons.pack_end(self.new_button, True, True)
        self.hbox_buttons.pack_end(self.wiz_button, True, True)
        self.hbox_buttons.set_spacing(6)
        self.vbox_main.pack_start(self.hbox_buttons, False, False)

        self.profiles_sw.set_size_request(400, 170)
        self.profiles_sw.add(self.profiles_tv)

    def get_selected_profile(self):
        """
        Returns the string with name of selected profile 
        """
        try:
            treeselection = self.profiles_tv.get_selection()
            (model, iter) = treeselection.get_selected()
            return model.get_value(iter, 0)
        except:
            return None

    def change_nmap_command(self, widget_tv):
        """
        Change a nmap command at command entry
        """
        assert widget_tv is not None
        # it call __init__ because when wizard or profile are open,
        # need update profiles
        self.profiles.__init__()
        # update text entry of command
        self.command_entry.set_text(
            self.profiles.get_command(self.get_selected_profile()))

    def new_wiz(self, widget):
        w = Wizard()
        w.set_notebook(None)
        w.set_profilemanager(self.model)
        w.show_all()

    def open_peditor(self, widget):
        """
        Open Profile Editor with a Selected or Non-Selected(New) Item
        """
        assert widget is not None

        if widget.get_label() == "gtk-edit":
            # Edit profile selected
            if self.get_selected_profile() is not None:
                pe = ProfileEditor(self.get_selected_profile())
                pe.set_notebook(self.__scan_notebook)
                pe.set_profilemanager(self.model)
                pe.show_all()
        else:
            # New Profile
            pe = ProfileEditor()
            pe.set_notebook(self.__scan_notebook)
            pe.set_profilemanager(self.model)
            pe.show_all()
            self._reload_profile_list()

    def copy_profiles(self, widget):
        """
        Copy selected Profile
        """
        if self.get_selected_profile() is None:
            return None
        d = ProfileName(_("Insert a profile name"))
        profile_name = d.run()
        if profile_name is None or profile_name == "":
            return None
        #get commands of selected profile
        profile_selected = self.get_selected_profile()
        command = self.profiles.get_command(profile_selected)
        hint = self.profiles.get_hint(profile_selected)
        description = self.profiles.get_description(profile_selected)
        annotation = self.profiles.get_annotation(profile_selected)
        #Options
        prof = self.profiles.get_profile(profile_selected)
        options_used = prof['options']
        options = CommandConstructor(options_used)

        self.profiles.add_profile(profile_name,\
                                  command=command,\
                                  hint=hint,\
                                  description=description,\
                                  annotation=annotation,\
                                  options=options.get_options())

        myiter = self.model.insert_before(None, None)
        self.model.set_value(myiter, 0, profile_name)
        self.model.set_value(myiter, 1, self.profiles.get_hint(profile_name))
        treeselection = self.profiles_tv.get_selection()
        treeselection.select_iter(myiter)
        #(model,iter) = treeselection.get_selected()
        #model.get_value(iter,0)

    def delete_profile(self, widget=None):
        """
        delete profile 
        """
        if self.get_selected_profile() is None:
            return None
        self.profiles.remove_profile(self.get_selected_profile())
        #Update treeview
        treeselection = self.profiles_tv.get_selection()
        (model, iter) = treeselection.get_selected()
        model.remove(iter)
        # update text entry of command
        self.command_entry.set_text('')

    def _reload_profile_list(self):
        """
        Reload a list of profiles
        """
        profiles = []
        all_profiles = self.profiles.sections()
        for profile in all_profiles:
            if self.profiles.get(profile, 'tool') == 'nmap':
                profiles.append(profile)
        profiles.sort()
        self.model.clear()

        for command in profiles:
            myiter = self.model.insert_before(None, None)
            self.model.set_value(myiter, 0, command)
            self.model.set_value(myiter, 1, self.profiles.get_hint(command))
            #self.model.append([command,self.profiles.get_hint(command)])

    def set_notebook(self, notebook):
        self.__scan_notebook = notebook

    def quit(self, widget):
        self.destroy()

    def quit(self, widget, data=None):
        if self.daddy:
            self.daddy.running_pm = False
            self.destroy()
        else:
            gtk.main_quit()
Пример #34
0
class ProfileEditor(HIGWindow):

    def __init__(self, profile_name=None, delete=False):
        HIGWindow.__init__(self)
        self.set_title(_('Profile Editor'))
        self.set_position(gtk.WIN_POS_CENTER)
        self.profile_name=profile_name
        self.__create_widgets()
        self.__pack_widgets()

        self.scan_notebook = None
        self.profilemanager = None

        self.profile = CommandProfile()

        self.deleted = False
        options_used = {}

        if profile_name:
            log.debug("Showing profile %s" % profile_name)
            prof = self.profile.get_profile(profile_name)
            options_used = prof['options']

            # Interface settings
            self.profile_name_entry.set_text(profile_name)
            self.profile_hint_entry.set_text(prof['hint'])
            self.profile_description_text.get_buffer().set_text(prof['description'])
            self.profile_annotation_text.get_buffer().set_text(prof['annotation'])

            if delete:
                # Removing profile. It must be saved again
                self.remove_profile()

        self.constructor = CommandConstructor(options_used)
        self.options = OptionBuilder(profile_editor_file, self.constructor, self.update_command)
        log.debug("Option groups: %s" % str(self.options.groups))
        log.debug("Option section names: %s" % str(self.options.section_names))
        #log.debug("Option tabs: %s" % str(self.options.tabs))

        for tab in self.options.groups:
            self.__create_tab(tab, self.options.section_names[tab], self.options.tabs[tab])

        self.update_command()

    def update_command(self):
        """Regenerate command with target '<target>' and set the value for the command entry"""
        self.command_entry.set_text(self.constructor.get_command('<target>'))

    def help(self, widget):
        """
        Show help documentation of Profile Editor
        """
        show_help(self,"profile_editor.html#introduction")

    def __create_widgets(self):
        self.main_vbox = HIGVBox()



        self.command_expander = HIGExpander('<b>'+_('Command')+'</b>')
        self.command_expander.set_expanded(True)
        self.command_entry = gtk.Entry()

        self.notebook = gtk.Notebook()

        # Profile info page
        self.profile_info_vbox = HIGVBox()
        self.profile_info_label = HIGSectionLabel(_('Profile Information'))
        self.profile_name_label = HIGEntryLabel(_('Profile name'))
        self.profile_name_entry = gtk.Entry()
        self.profile_hint_label = HIGEntryLabel(_('Hint'))
        self.profile_hint_entry = gtk.Entry()
        self.profile_description_label = HIGEntryLabel(_('Description'))
        #self.profile_description_label = HIGHBox() 
        self.profile_description_scroll = HIGScrolledWindow()
        self.profile_description_text = HIGTextView()
        self.profile_annotation_label = HIGEntryLabel(_('Annotation'))
        #self.profile_annotation_label = HIGHBox() 
        self.profile_annotation_scroll = HIGScrolledWindow()
        self.profile_annotation_text = HIGTextView()

        # Buttons
        self.buttons_hbox = HIGHBox()

        self.help_button = HIGButton(stock=gtk.STOCK_HELP)
        self.help_button.connect('clicked', self.help)

        #self.delete_button = HIGButton(stock=gtk.STOCK_DELETE)
        #self.delete_button.connect('clicked', self.delete_profile)

        self.cancel_button = HIGButton(stock=gtk.STOCK_CANCEL)
        self.cancel_button.connect('clicked', self.quit_without_saving)

        self.ok_button = HIGButton(stock=gtk.STOCK_OK)
        self.ok_button.connect('clicked', self.save_profile)

    def __pack_widgets(self):
        self.add(self.main_vbox)

        # Packing widgets to main_vbox

        self.main_vbox._pack_noexpand_nofill(self.command_expander)
        self.main_vbox._pack_expand_fill(self.notebook)
        self.main_vbox._pack_noexpand_nofill(self.buttons_hbox)

        # Packing command_entry on command_expander
        self.command_expander.hbox.pack_start(self.command_entry)

        # Packing profile information tab on notebook
        self.notebook.append_page(self.profile_info_vbox, gtk.Label(_('Profile')))
        self.profile_info_vbox.set_border_width(5)
        table = HIGTable()
        self.profile_info_vbox._pack_noexpand_nofill(self.profile_info_label)
        self.profile_info_vbox._pack_noexpand_nofill(HIGSpacer(table))

        self.profile_annotation_scroll.add(self.profile_annotation_text)
        self.profile_description_scroll.add(self.profile_description_text)

        vbox_desc = HIGVBox()
        vbox_desc._pack_noexpand_nofill(self.profile_description_label)
        vbox_desc._pack_expand_fill(hig_box_space_holder())

        vbox_ann = HIGVBox()
        vbox_ann._pack_noexpand_nofill(self.profile_annotation_label)
        vbox_ann._pack_expand_fill(hig_box_space_holder())
        table.attach(self.profile_name_label,0,1,0,1)
        table.attach(self.profile_name_entry,1,2,0,1)
        #table.attach(self.profile_hint_label,0,1,1,2,xoptions=0)
        table.attach(self.profile_hint_label,0,1,1,2)
        table.attach(self.profile_hint_entry,1,2,1,2)
        table.attach(vbox_desc,0,1,2,3)
        table.attach(self.profile_description_scroll,1,2,2,3)
        table.attach(vbox_ann,0,1,3,4)
        table.attach(self.profile_annotation_scroll,1,2,3,4)

        # Packing buttons on button_hbox
        self.buttons_hbox.pack_start(self.help_button)
        #self.buttons_hbox.pack_start(self.delete_button)
        self.buttons_hbox.pack_start(self.cancel_button)
        self.buttons_hbox.pack_start(self.ok_button)

        self.buttons_hbox.set_border_width(5)
        self.buttons_hbox.set_spacing(6)

    def __create_tab(self, tab_name, section_name, tab):
        log.debug(">>> Tab name: %s" % tab_name)
        log.debug(">>>Creating profile editor section: %s" % section_name)

        vbox = HIGVBox()
        table = HIGTable()
        section = HIGSectionLabel(section_name)

        vbox._pack_noexpand_nofill(section)
        vbox._pack_noexpand_nofill(HIGSpacer(table))
        vbox.set_border_width(6)

        tab.fill_table(table, True)
        self.scrollwindow = HIGScrolledWindow()
        self.scrollwindow.set_size_request(600,300)
        vp = gtk.Viewport()
        vp.add(vbox)
        vp.set_shadow_type(gtk.SHADOW_NONE)
        self.scrollwindow.add(vp)

        vbox_tmp = HIGVBox()
        vbox_tmp.set_border_width(6)
        vbox_tmp.set_spacing(12)
        vbox_tmp.pack_start(self.scrollwindow)


        self.notebook.append_page(vbox_tmp, gtk.Label(tab_name))
    def set_profilemanager(self, model):
        """
        give a model of treeview to update profile manager
        after run wizard
        """
        assert model != None

        self.model = model 
        self.profilemanager = True 

    def update_profilemanager(self):
        """
        Update treeview of ProfileManager"
        """
        assert self.profilemanager;

        profiles = self.profile.sections()
        profiles.sort()
        self.model.clear()


        for command in profiles:
            myiter = self.model.insert_before(None, None)
            self.model.set_value(myiter, 0, command)
            self.model.set_value(myiter,1, self.profile.get_hint(command))


    def save_profile(self, widget):
        profile_name = self.profile_name_entry.get_text()

        if profile_name == '':
            alert = HIGAlertDialog(message_format=_('Unnamed profile'),\
                                   secondary_text=_('You must provide a name \
for this profile.'))

        elif profile_name.lower() == 'default':
            alert = HIGAlertDialog(message_format=_('Reserved profile name'),\
                                   secondary_text=_('Cannot assign "default" \
name to this profile. Please rename it and retry.'))
        else:
            alert = None

        if alert:
            alert.run()
            alert.destroy()

            self.notebook.set_current_page(0)
            self.profile_name_entry.grab_focus()

            return None

        if not self.deleted:
            self.remove_profile()

        command = self.constructor.get_command('%s')
        hint = self.profile_hint_entry.get_text()

        buf = self.profile_description_text.get_buffer()
        description = buf.get_text(buf.get_start_iter(),\
                                   buf.get_end_iter())

        buf = self.profile_annotation_text.get_buffer()
        annotation = buf.get_text(buf.get_start_iter(),\
                                  buf.get_end_iter())
        self.profile.add_profile(profile_name,\
                                 command=command,\
                                 hint=hint,\
                                 description=description,\
                                 annotation=annotation,\
                                 tool='nmap',\
                                 options=self.constructor.get_options())
        self.deleted = False
        if self.profilemanager:
            self.update_profilemanager()

        self.quit()


    def clean_profile_info(self):
        self.profile_name_entry.set_text('')
        self.profile_hint_entry.set_text('')
        self.profile_description_text.get_buffer().set_text('')
        self.profile_annotation_text.get_buffer().set_text('')

    def set_notebook(self, notebook):
        self.scan_notebook = notebook

    def quit(self, widget=None, extra=None):
        if self.deleted:
            dialog = HIGDialog(buttons=(gtk.STOCK_OK, gtk.RESPONSE_OK,
                                        gtk.STOCK_CANCEL, gtk.RESPONSE_CANCEL))
            alert = HIGEntryLabel('<b>'+_("Deleting Profile")+'</b>')
            text = HIGEntryLabel(_('Your profile is going to be deleted! Click\
                                   Ok to continue, or Cancel to go back to Profile Editor.'))
            hbox = HIGHBox()
            hbox.set_border_width(5)
            hbox.set_spacing(12)

            vbox = HIGVBox()
            vbox.set_border_width(5)
            vbox.set_spacing(12)

            image = gtk.Image()
            image.set_from_stock(gtk.STOCK_DIALOG_WARNING, gtk.ICON_SIZE_DIALOG)

            vbox.pack_start(alert)
            vbox.pack_start(text)
            hbox.pack_start(image)
            hbox.pack_start(vbox)

            dialog.vbox.pack_start(hbox)
            dialog.vbox.show_all()

            response = dialog.run()
            dialog.destroy()

            if response == gtk.RESPONSE_CANCEL:
                return None
        self.destroy()       
        if self.scan_notebook != None:

            for i in xrange(self.scan_notebook.get_n_pages()):
                page = self.scan_notebook.get_nth_page(i)
                page.toolbar.profile_entry.update()

        #page.toolbar.scan_profile.profile_entry.child.\
        #    set_text(self.profile_name_entry.get_text())
    def quit_without_saving(self, widget=None):
        self.deleted=False
        self.quit()

    def on_delete(self, widget=None):
        if not self.profile_name:
            return self.on_cancel()

        dialog = HIGDialog(buttons=(gtk.STOCK_OK, gtk.RESPONSE_OK,
                                    gtk.STOCK_CANCEL, gtk.RESPONSE_CANCEL))
        alert = HIGEntryLabel('<b>'+_("Deleting Profile")+'</b>')
        text = HIGEntryLabel(_('Your profile is going to be deleted! Click \
Ok to continue, or Cancel to go back to Profile Editor.'))
        hbox = HIGHBox()
        hbox.set_border_width(5)
        hbox.set_spacing(12)

        vbox = HIGVBox()
        vbox.set_border_width(5)
        vbox.set_spacing(12)

        image = gtk.Image()
        image.set_from_stock(gtk.STOCK_DIALOG_WARNING, gtk.ICON_SIZE_DIALOG)

        vbox.pack_start(alert)
        vbox.pack_start(text)
        hbox.pack_start(image)
        hbox.pack_start(vbox)

        dialog.vbox.pack_start(hbox)
        dialog.vbox.show_all()

        response = dialog.run()
        dialog.destroy()

        if response == gtk.RESPONSE_CANCEL:
            return None

        self.deleted = True
        self.profile.remove_profile(self.profile_name)
        self.on_cancel()


    def on_cancel(self, widget=None):
        self.destroy()
        self.update_profile_entry()

    def update_profile_entry(self):
        page = None
        for i in xrange(self.scan_notebook.get_n_pages()):
            page = self.scan_notebook.get_nth_page(i)

            page.toolbar.profile_entry.update(\
                self.profile_name_entry.get_text())

            list = page.toolbar.profile_entry.get_model()
            length = len(list)
            if self.deleted and length > 0 :
                page.toolbar.profile_entry.set_active(0)
            elif self.deleted and length == 0:
                page.toolbar.profile_entry.child.set_text("")

        if page is not None:
            page.toolbar.profile_entry.update()



    def remove_profile(self,profile_name=None):
        '''
        Remove current profile 
        '''
        if not profile_name:
            profile_name = self.profile_name
        self.profile.remove_profile(profile_name)
        self.deleted = True        

    def delete_profile(self, widget=None):
        """
        delete profile
        """
        self.remove_profile()
        self.deleted=False        
        self.quit()
class BoxEditable(HIGVBox):
    def __init__(self,
                 section_name,
                 profile,
                 listoptions,
                 notebook_parent,
                 new=False):
        """
        A Box Editable contains a options of each tab
        @param section_name: section name <tab>
        @type section_name: str 
        @param profile: A class that view and modify xml file 
        @type profile: ProfileCore
        @param listoptions: The List of Options to update XML (I guess to confirm)
        @type listoptions: ListOptions
        @param notebook_parent: Notebook
        @type notebook_parent: Notebook or Subclass
        @param new: It's a new tab or not 
        @type new: bool
        """

        HIGVBox.__init__(self)
        self._coords = {}
        self._parent = notebook_parent
        self._last = None
        #Profile Core do a manage at profile_editor.xml file
        self._profilecore = None

        self._profile = profile
        self._listoptions = listoptions
        self._table = HIGTable()
        self._section_name = section_name
        if not new:
            self._options = self._profile.get_section(section_name)
        self._table.set_border_width(3)
        c = self.get_colormap()
        color = c.alloc_color(0, 0, 0)
        self._table.modify_fg(gtk.STATE_NORMAL, color)
        #self._fill_table()

        box_tmp = HIGVBox()
        box_tmp.pack_start(self._table, False, False)
        self._sw = HIGScrolledWindow()
        #self._sw.set_size_request(400,200)
        vp = gtk.Viewport()
        vp.add(box_tmp)
        vp.set_shadow_type(gtk.SHADOW_NONE)
        self._sw.add(vp)
        self.pack_start(self._sw, True, True)
        self._old_selected = None
        self._x = 0
        self._y = 0

        self.connect('button-press-event', self._bp)

    #Private API
    def _bp(self, widget, event):
        pass

    def _fill_table(self):
        k = 0
        self._old_po = None
        for i in self._options:
            t = SpecialHBox()
            type = i.get_type()
            if type == 'option_check':

                name_option = i.get_option()
                hint = self._listoptions.get_hint(name_option)
                tmp_widget = OptionCheckIcon(i.get_label(), name_option, hint)
                t.pack_start(tmp_widget)
                arg_type = self._listoptions.get_arg_type(name_option)
                if arg_type != '':
                    additional = type_mapping[arg_type]()
                    t.pack_start(additional)
                po = ProfileOption('option_check', i.get_label(), name_option,
                                   arg_type, None)
                po.set_section(self.get_name())
                t.set_profileoption(po)

            elif type == 'option_list':
                eventbox = gtk.EventBox()
                label = HIGEntryLabel(i.get_label())

                eventbox.add(label)
                tmp_widget = OptionList()
                list = []
                for j in i.get_option_list():
                    d = {}
                    d['name'] = j
                    tmp_widget.append(d)
                    list.append(j)
                po = ProfileOption('option_list', i.get_label(), i.get_label(),
                                   None, list)
                po.set_section(self.get_name())
                t.set_profileoption(po)
                t.pack_start(eventbox)
                t.pack_start(tmp_widget)
                #t.drag_source_set(gtk.gdk.BUTTON1_MASK |
                #gtk.gdk.BUTTON3_MASK,
                #target,
                #gtk.gdk.ACTION_COPY |
                #gtk.gdk.ACTION_MOVE)
                #t.connect('drag_data_get', self.source_drag_data_get)

            #XXX : I think that is very important ( I only comment to get focus)
            if self._old_po != None:
                self._old_po.set_next_opt(i.get_label())
            self._old_po = po
            t.set_flags(t.flags() | gtk.CAN_FOCUS)
            t.connect('button-press-event', self._button_press_event)
            t.connect('key-press-event', self._key_press_event)
            t.set_name(i.get_label())
            t.connect('drag_data_received', self.drag_received)
            t.drag_dest_set(gtk.DEST_DEFAULT_ALL, target[:-1],
                            gtk.gdk.ACTION_COPY | gtk.gdk.ACTION_MOVE)

            self._table.attach(t, 0, 2, k, k + 1)
            self._coords[t] = [k, k + 1]
            self._x = k
            self._y = k + 1
            k = k + 1
            self._last = t

    def delete_on_item(self, widget):
        if not widget.is_voidplace():
            # remove widgets like checkbuttons or others and put voidplace
            childs = widget.get_children()
            cmd = CommandAddRemoveOption(widget, childs, self._profilecore,
                                         self, False)
            widget.set_select(False)
            command_manager.add_command(cmd)
            log.debug(
                ' Remove Widgets like CheckButtons or others and put voidplace'
            )

        else:
            # remove voidplace and delete the widget from table/box
            #XXX
            cmd = CommandAddRemoveVoidplace(self, widget, self._coords, False)
            #widget.unload_voidplace()
            command_manager.add_command(cmd)
            log.debug('Remove voidplace and delete the widget from table')

        self._parent.emit('need-save', 'Sent', None)

    def _key_press_event(self, widget, event):
        _keyval = gtk.gdk.keyval_name(event.keyval)
        if _keyval == "Delete" and self._old_selected != None:
            self.delete_on_item(widget)

        #self._table.remove(widget)
        #childs = self._table.get_children()
        #for i in childs:
        #if i.is_voidplace():
        #i.do_resize_voidplace()
    def _button_press_event(self, widget, event):

        widget.set_select(True)
        self._parent.select(False)
        if widget == self._old_selected:
            log.debug('Do nothing')
            if widget.is_voidplace():
                widget.do_draw()
            widget.grab_focus()
            return
        widget.do_draw()
        if self._old_selected != None:
            self._old_selected.set_select(False)
        log.debug('drawing')
        self._old_selected = widget
        widget.grab_focus()
        self._parent.emit('changed', 'Options',
                          self._parent.get_current_page())

    #Public API
    def set_name(self, name):
        self._section_name = name

    def get_name(self):
        return self._section_name

    def get_generic_widget(self, widget, num):
        '''
        Get widget - None Vodplace
        '''
        result = None
        num = num
        x1, y1 = self._coords[widget]
        while True:
            for i in self._coords:
                x, y = self._coords[i]
                if x == (x1 - num) and y == (y1 - num):
                    result = i
                    break
            if result != None and result.is_voidplace():
                num = num + 1
                result = None
            else:
                break
        return result

    def get_next_widget(self, widget):
        '''
        Get the next widget - None Vodplace
        '''
        if widget == self._last:
            return None
        return self.get_generic_widget(widget, -1)

    def get_prev_widget(self, widget):
        '''
        Get a Previews widget - None Voidplace 
        '''
        x, y = self._coords[widget]
        if x == 0 and y == 1:
            return None
        return self.get_generic_widget(widget, 1)

    def can_move_up(self):

        widget = self._old_selected
        x = 0
        if widget != None:
            try:
                x, y = self._coords[widget]
            except KeyError:
                return False
        return x != 0

    def can_move_down(self):

        widget = self._old_selected
        y = len(self._coords)
        if widget != None:
            try:
                x, y = self._coords[widget]
            except KeyError:
                return
        return y != (len(self._coords))

    def send_signal_save(self):
        self._parent.emit('need-save', 'Sent', None)

    def send_signal(self):
        self._parent.emit('changed', 'Options',
                          self._parent.get_current_page())

    def create_item(self):
        t = SpecialHBox()
        e = gtk.EventBox()
        label = gtk.Label('-')
        label.set_size_request(-1, 23)
        #e.add(label)
        t.pack_start(label)
        t.set_flags(t.flags() | gtk.CAN_FOCUS)
        t.connect('button-press-event', self._button_press_event)
        t.connect('key-press-event', self._key_press_event)
        t.connect('drag_data_received', self.drag_received)
        t.drag_dest_set(gtk.DEST_DEFAULT_ALL, target[:-1],
                        gtk.gdk.ACTION_COPY | gtk.gdk.ACTION_MOVE)
        return t

    def add_voidplace(self, position):
        # Create SpecialHBox with Voidplace
        t = self.create_item()
        cmd = CommandVoidPlaceAttach(self, t, self._coords, True)
        command_manager.add_command(cmd)
        self._parent.emit('need-save', 'Sent', None)

        #if position == -1 :
        #x, y = self._x,self._y
        #self._table.attach()
        #else:
        ## Choose the position
        #pass

    def move_item_down(self):
        '''
        Move selected item to down
        '''
        assert self.can_move_down()

        cmd = CommandMove(self, self._old_selected, self._coords,
                          self._profilecore, False)
        command_manager.add_command(cmd)
        self.send_signal()
        self.send_signal_save()

    def move_item_up(self):
        '''
        Move selected item to up
        '''
        assert self.can_move_up()

        cmd = CommandMove(self, self._old_selected, self._coords,
                          self._profilecore, True)
        command_manager.add_command(cmd)
        self.send_signal()
        self.send_signal_save()

    def search_option(self, name):
        '''
        returns widget 
        '''
        list = self._table.get_children()
        result = None
        for i in list:
            if i.get_name() == name:
                result = i
                break
        return result

    def set_profile_core(self, profile_core):
        self._profilecore = profile_core

    def option_builder(self, option_name, type):
        '''
        construct a widget with the name of the option
        @return: A widget
        @rtype: Widget like OptionCheck or others 
        '''
        result = []
        hint = self._listoptions.get_hint(option_name)
        #label, option_name, hint
        tmp_widget = OptionCheckIcon(option_name, option_name, hint)
        result.append(tmp_widget)
        arg_type = self._listoptions.get_arg_type(option_name)
        if arg_type != '':
            additional = type_mapping[arg_type]()
            result.append(additional)
        return result

    def _is_widget(self, name):
        return name[0:4] == '_wid'

    def _create_option_list(self, widget):
        eventbox = gtk.EventBox()
        name = 'New Option List'
        label = HIGEntryLabel(name)

        eventbox.add(label)
        tmp_widget = OptionList()
        list = []
        void = {'name': ''}
        j = 'None'
        d = {}
        d['name'] = j
        tmp_widget.append(void)
        tmp_widget.append(d)
        list.append(j)
        po = ProfileOption('option_list', name, None, None, list)
        po.set_section(self.get_name())
        widget.set_profileoption(po)
        widgets = []
        widgets.append(eventbox)
        widgets.append(tmp_widget)
        widget.set_name(name)
        return widgets

    def exec_option_list(self, w):
        widgets = self._create_option_list(w)
        cmd = CommandAddRemoveOption(w, widgets, self._profile, self, True)
        command_manager.add_command(cmd)

    def exec_checkopt(self, name, w):
        option_name = name
        opt = self._listoptions.get_option_class(name)
        profileoption = option_to_profileoption(opt)
        profileoption.set_section(self.get_name())
        arg_type = self._listoptions.get_arg_type(name)
        widgets = self.option_builder(option_name, arg_type)
        w.set_profileoption(profileoption)
        w.set_name(name)
        cmd = CommandAddRemoveOption(w, widgets, self._profilecore, self, True)
        command_manager.add_command(cmd)

    def drag_received(self, w, context, x, y, data, info, time):
        if not w.is_voidplace():
            return
        option_name = data.data
        if self._is_widget(option_name):
            if option_name == '_widget_option_list':
                self.exec_option_list(w)
                #widgets = self._create_option_list( w)
                #cmd = CommandAddRemoveOption(w,widgets, self._profile,
                #True)
                #command_manager.add_command(cmd)

            return
        name = data.data
        self.exec_checkopt(name, w)

        #Remove child
        #childs = w.get_children()
        #w.remove(childs[0])
        #Add

        #for child in widgets:
        #t = gtk.Label('fsck')
        #tmp_w.pack_start(child)
        #child.show_all()

        #w.unload_voidplace()

    def get_table(self):
        return self._table

    def set_last(self, last):
        self._last = last

    def get_last(self):
        return self._last

    def source_drag_data_get(self, btn, context, selection_data, info, time):
        selection_data.set(selection_data.target, 8, "I'm Data!")
Пример #36
0
class Credits(HIGWindow):
    def __init__(self):
        HIGWindow.__init__(self)
        self.set_title(_("Umit credits"))
        self.set_size_request(-1, 450)
        self.set_position(gtk.WIN_POS_CENTER)
        
        self.__create_widgets()
        self.__packing()
        self.set_text()
    
    def __create_widgets(self):
        self.vbox = HIGVBox()
        self.hbox = HIGHBox()
        self.notebook = HIGNotebook()
        self.btn_close = HIGButton(stock=gtk.STOCK_CLOSE)
        
        self.written_by_scroll = HIGScrolledWindow()
        self.written_by_text = HIGTextView()
        
        self.design_scroll = HIGScrolledWindow()
        self.design_text = HIGTextView()

        self.soc2007_scroll = HIGScrolledWindow()
        self.soc2007_text = HIGTextView()
        
        self.soc2008_scroll = HIGScrolledWindow()
        self.soc2008_text = HIGTextView()

        self.soc2009_scroll = HIGScrolledWindow()
        self.soc2009_text = HIGTextView()
        
        self.contributors_scroll = HIGScrolledWindow()
        self.contributors_text = HIGTextView()
        
        self.translation_scroll = HIGScrolledWindow()
        self.translation_text = HIGTextView()

        self.nokia_scroll = HIGScrolledWindow()
        self.nokia_text = HIGTextView()

    def __packing(self):
        self.add(self.vbox)
        self.vbox.set_spacing(12)
        self.vbox._pack_expand_fill(self.notebook)
        self.vbox._pack_noexpand_nofill(self.hbox)
        
        self.hbox._pack_expand_fill(hig_box_space_holder())
        self.hbox._pack_noexpand_nofill(self.btn_close)
        
        self.notebook.append_page(self.written_by_scroll,
                                  gtk.Label(_("Written by")))
        self.notebook.append_page(self.design_scroll,
                                  gtk.Label(_("Design")))
        self.notebook.append_page(self.soc2007_scroll,
                                  gtk.Label(_("SoC 2007")))
        self.notebook.append_page(self.soc2008_scroll,
                                  gtk.Label(_("SoC 2008")))
        self.notebook.append_page(self.soc2009_scroll,
                                  gtk.Label(_("SoC 2009")))
        self.notebook.append_page(self.contributors_scroll,
                                  gtk.Label(_("Contributors")))
        self.notebook.append_page(self.translation_scroll,
                                  gtk.Label(_("Translations")))
        self.notebook.append_page(self.nokia_scroll,
                                  gtk.Label(_("Maemo")))
        
        self.written_by_scroll.add(self.written_by_text)
        self.written_by_text.set_wrap_mode(gtk.WRAP_NONE)
        
        self.design_scroll.add(self.design_text)
        self.design_text.set_wrap_mode(gtk.WRAP_NONE)
        self.soc2007_scroll.add(self.soc2007_text)
        self.soc2007_text.set_wrap_mode(gtk.WRAP_NONE)

        self.soc2008_scroll.add(self.soc2008_text)
        self.soc2008_text.set_wrap_mode(gtk.WRAP_NONE)
        
        self.soc2009_scroll.add(self.soc2009_text)
        self.soc2009_text.set_wrap_mode(gtk.WRAP_NONE)

        self.contributors_scroll.add(self.contributors_text)
        self.contributors_text.set_wrap_mode(gtk.WRAP_NONE)
        
        self.translation_scroll.add(self.translation_text)
        self.translation_text.set_wrap_mode(gtk.WRAP_NONE)
        
        self.nokia_scroll.add(self.nokia_text)
        self.nokia_text.set_wrap_mode(gtk.WRAP_NONE)

        self.btn_close.connect('clicked', lambda x,y=None:self.destroy())
    
    def set_text(self):
        b = self.written_by_text.get_buffer()
        b.set_text("""Adriano Monteiro Marques <*****@*****.**>
Bartosz Skowron <*****@*****.**>
Francesco Piccinno <*****@*****.**>
Guilherme Polo <*****@*****.**>
João Medeiros <*****@*****.**>
Luís A. Bastião Silva <*****@*****.**>""")

        
        b = self.design_text.get_buffer()
        b.set_text(_("""Operating System and Vulnerability Icons:
Takeshi Alexandre Gondo <*****@*****.**>

Logo, Application Icons, Splash screen and Umit GNU/Linux theme:
Virgílio Carlo de Menezes Vasconcelos <*****@*****.**>

The Umit Project Web Site Design:
Joao Paulo Pacheco <*****@*****.**>"""))

        b = self.soc2007_text.get_buffer()
        b.set_text(_("""Independent Features:
Adriano Monteiro Marques <*****@*****.**>
Frederico Silva Ribeiro <*****@*****.**>

Network Inventory:
Guilherme Henrique Polo Gonçalves <*****@*****.**>

Umit Radial Mapper:
João Paulo de Souza Medeiros <*****@*****.**>

Profile/Wizard interface editor:
Luis Antonio Bastião Silva <*****@*****.**>

NSE Facilitator:
Maxim I. Gavrilov <*****@*****.**>

Umit Web:
Rodolfo da Silva Carvalho <*****@*****.**>"""))

        b = self.soc2008_text.get_buffer()
        b.set_text(_("""Packet Manipulation Backend
Bartosz Adam Skowron <*****@*****.**>

Bluetooth Scanner & Vulnerabilities Database System:
Devtar Singh <*****@*****.**>

Umit Plugins and Packet Manipulation Frontend
Francesco Piccinno <*****@*****.**>

Preferences Window and Interface Editor improvements:
Luis Antonio Bastião Silva <*****@*****.**>

UmitWeb Improvements and Independent Features:
Rodolfo da Silva Carvalho <*****@*****.**>
"""))
        
        b = self.soc2009_text.get_buffer()
        b.set_text(_("""UMPA Improvements
Bartosz Adam Skowron <*****@*****.**>

Quick Scan:
Daniel Mendes Cassiano <*****@*****.**>

Bluetooth Sniffer:
Shu Yang Quek <*****@*****.**>

Audits Framework
Francesco Piccinno <*****@*****.**>

ZION
João Paulo de Souza Medeiros <*****@*****.**>

USoC:

Message Sequence Chart
Abhiram Kasina <*****@*****.**>

Independent Features and Test Suite
Mahesh PM <*****@*****.**>
"""))
        
        b = self.contributors_text.get_buffer()
        b.set_text(_("""Sponsored by (SoC 2005, 2006, 2007 and 2008):
Google <*****@*****.**>

Mentor of Umit for Google SoC 2005 and 2006:
Fyodor <*****@*****.**>

Mentor of Umit for Google SoC 2007 Projects:
Adriano Monteiro Marques <*****@*****.**>

Mentor of Umit for Google SoC 2008 Projects:
Adriano Monteiro Marques <*****@*****.**>

Initial development:
Adriano Monteiro Marques <*****@*****.**>
Cleber Rodrigues Rosa Junior <*****@*****.**>

Nmap students from Google SoC 2007 that helped Umit:
Eddie Bell <*****@*****.**>
David Fifield <*****@*****.**>
Kris Katterjohn <*****@*****.**>

The Umit Project WebSite:
Abrao Barbosa dos Santos Neto <*****@*****.**>
Adriano Monteiro Marques <*****@*****.**>
Heitor de Lima Matos <*****@*****.**>
Joao Paulo Pacheco <*****@*****.**>
João Paulo de Souza Medeiros <*****@*****.**>
Luis Antonio Bastião Silva <*****@*****.**>
Rodolfo da Silva Carvalho <*****@*****.**>

Helpers:
Daniel Mendes Cassiano <*****@*****.**>
Luiz Paulo de Souza Medeiros <*****@*****.**>

Beta testers for 0.9.5RC1:
Bartosz Adam Skowron <*****@*****.**>
Denis Kurov <*****@*****.**>
Devtar Singh <*****@*****.**>
Drew Miller <*****@*****.**>
Francesco Piccinno <*****@*****.**>
Igor Feghali <*****@*****.**>
Joao Paulo Pacheco <*****@*****.**>
Luis Antonio Bastião Silva <*****@*****.**>
Rodolfo da Silva Carvalho <*****@*****.**>
Regis Kuramoto Dias <*****@*****.**>
<*****@*****.**>
<*****@*****.**>
<*****@*****.**>

Special thanks to our GSoC volunteers heroes:
Daniel Mendes Cassiano <*****@*****.**>
Túlio Gonçalves <*****@*****.**>

Initial attempt on Maemo port:
Adriano Monteiro Marques <*****@*****.**>
Osvaldo Santana Neto <*****@*****.**>"""))

        b = self.soc2007_text.get_buffer()
        b.set_text("""Independent Features:
Adriano Monteiro Marques <*****@*****.**>
Frederico Silva Ribeiro <*****@*****.**>

Network Inventory:
Guilherme Henrique Polo Gonçalves <*****@*****.**>

Umit Radial Mapper:
João Paulo de Souza Medeiros <*****@*****.**>

Profile/Wizard interface editor:
Luis Antonio Bastião Silva <*****@*****.**>

NSE Facilitator:
Maxim I. Gavrilov <*****@*****.**>

Nmap Python Wrapper:
Pavel Klemenkov <*****@*****.**>

Umit Web:
Rodolfo da Silva Carvalho <*****@*****.**>

Summer of Code's projects Design:
Virgílio Carlo de Menezes Vasconcelos <*****@*****.**>""")

        
        b = self.translation_text.get_buffer()
        b.set_text(_("""Bahasa Indonesia:
Devtar Singh <*****@*****.**>

Bahasa Melayu:
Devtar Singh <*****@*****.**>

Brazilian Portuguese:
Adriano Monteiro Marques <*****@*****.**>
Rodolfo da Silva Carvalho <*****@*****.**>

Italian:
Francesco Piccinno <*****@*****.**>

Polish:
Bartosz Adam Skowron <*****@*****.**>

Portuguese Portugal:
Luis Antonio Bastião Silva <*****@*****.**>

Simplified Chinese:
Devtar Singh <*****@*****.**>
Haoyu Bai <*****@*****.**>
Aron Xu <*****@*****.**>

Swedish:
Daniel Nylander <*****@*****.**>
"""))

        b = self.nokia_text.get_buffer()
        b.set_text("""Adriano Monteiro Marques <*****@*****.**>""")
Пример #37
0
class BoxEditable(HIGVBox):
    def __init__(self, section_name, profile, listoptions, notebook_parent, new=False):
        """
        A Box Editable contains a options of each tab
        @param section_name: section name <tab>
        @type section_name: str 
        @param profile: A class that view and modify xml file 
        @type profile: ProfileCore
        @param listoptions: The List of Options to update XML (I guess to confirm)
        @type listoptions: ListOptions
        @param notebook_parent: Notebook
        @type notebook_parent: Notebook or Subclass
        @param new: It's a new tab or not 
        @type new: bool
        """

        HIGVBox.__init__(self)
        self._coords = {}
        self._parent = notebook_parent
        self._last = None 
        #Profile Core do a manage at profile_editor.xml file 
        self._profilecore = None 

        self._profile = profile
        self._listoptions = listoptions
        self._table = HIGTable()
        self._section_name = section_name
        if not new :
            self._options = self._profile.get_section(section_name)
        self._table.set_border_width(3)
        c = self.get_colormap()
        color = c.alloc_color(0,0,0)   
        self._table.modify_fg(gtk.STATE_NORMAL,color )
        #self._fill_table()

        box_tmp = HIGVBox()
        box_tmp.pack_start(self._table, False, False)
        self._sw = HIGScrolledWindow()
        #self._sw.set_size_request(400,200)
        vp = gtk.Viewport()
        vp.add(box_tmp)
        vp.set_shadow_type(gtk.SHADOW_NONE)
        self._sw.add(vp)
        self.pack_start(self._sw, True, True)
        self._old_selected = None 
        self._x = 0
        self._y = 0 


        self.connect('button-press-event', self._bp)
    #Private API 
    def _bp(self, widget,event):
        pass

    def _fill_table(self):
        k = 0
        self._old_po = None
        for i in self._options:
            t = SpecialHBox()
            type = i.get_type()
            if type== 'option_check':

                name_option = i.get_option()
                hint = self._listoptions.get_hint(name_option)
                tmp_widget = OptionCheckIcon(i.get_label(),name_option,hint)
                t.pack_start(tmp_widget)
                arg_type = self._listoptions.get_arg_type(name_option)
                if arg_type!= '':
                    additional = type_mapping[arg_type]()
                    t.pack_start(additional)
                po = ProfileOption('option_check', i.get_label(),name_option, 
                                   arg_type,None)
                po.set_section(self.get_name())
                t.set_profileoption(po)


            elif type == 'option_list': 
                eventbox = gtk.EventBox()
                label = HIGEntryLabel(i.get_label())

                eventbox.add(label)
                tmp_widget = OptionList()
                list = []
                for j in i.get_option_list():
                    d = {}
                    d['name'] = j 
                    tmp_widget.append(d)
                    list.append(j)
                po = ProfileOption('option_list', i.get_label(),i.get_label(), 
                                   None,list)
                po.set_section(self.get_name())
                t.set_profileoption(po)
                t.pack_start(eventbox)		
                t.pack_start(tmp_widget)
                #t.drag_source_set(gtk.gdk.BUTTON1_MASK |
                                                    #gtk.gdk.BUTTON3_MASK,
                                                    #target, 
                                                    #gtk.gdk.ACTION_COPY |
                                                    #gtk.gdk.ACTION_MOVE)
                #t.connect('drag_data_get', self.source_drag_data_get)

            #XXX : I think that is very important ( I only comment to get focus)
            if self._old_po!=None:
                self._old_po.set_next_opt(i.get_label())
            self._old_po = po
            t.set_flags( t.flags() |  gtk.CAN_FOCUS)
            t.connect('button-press-event', self._button_press_event)
            t.connect('key-press-event', self._key_press_event)
            t.set_name(i.get_label())
            t.connect('drag_data_received', self.drag_received)
            t.drag_dest_set(gtk.DEST_DEFAULT_ALL, target[:-1],
                            gtk.gdk.ACTION_COPY | gtk.gdk.ACTION_MOVE)

            self._table.attach(t, 0,2, k,k+1)
            self._coords[t] = [k, k+1]
            self._x = k 
            self._y = k+1
            k =k +1
            self._last = t 


    def delete_on_item(self, widget):
        if not widget.is_voidplace(): 
            # remove widgets like checkbuttons or others and put voidplace
            childs = widget.get_children()
            cmd = CommandAddRemoveOption(widget,childs,
                                         self._profilecore,self, False)
            widget.set_select(False)
            command_manager.add_command(cmd)
            log.debug(' Remove Widgets like CheckButtons or others and put voidplace')

        else:
            # remove voidplace and delete the widget from table/box
            #XXX 
            cmd = CommandAddRemoveVoidplace(self, 
                                            widget, self._coords, False)
            #widget.unload_voidplace()
            command_manager.add_command(cmd)
            log.debug('Remove voidplace and delete the widget from table')


        self._parent.emit('need-save', 'Sent', None)

    def _key_press_event(self, widget, event):
        _keyval = gtk.gdk.keyval_name(event.keyval)
        if _keyval == "Delete" and self._old_selected!=None :
            self.delete_on_item(widget)


        #self._table.remove(widget)
        #childs = self._table.get_children()
        #for i in childs:
            #if i.is_voidplace():
                #i.do_resize_voidplace()
    def _button_press_event(self,widget, event):

        widget.set_select(True) 
        self._parent.select(False)
        if widget == self._old_selected :
            log.debug('Do nothing')
            if widget.is_voidplace():
                widget.do_draw()
            widget.grab_focus()
            return 
        widget.do_draw()
        if self._old_selected != None:
            self._old_selected.set_select(False)
        log.debug('drawing')
        self._old_selected = widget
        widget.grab_focus()
        self._parent.emit('changed', 'Options', self._parent.get_current_page())
    #Public API 
    def set_name(self, name):
        self._section_name = name 
    def get_name(self):
        return self._section_name

    def get_generic_widget(self, widget, num):
        '''
        Get widget - None Vodplace
        '''
        result = None 
        num  = num 
        x1,y1 = self._coords[widget]
        while True : 
            for i in self._coords:
                x,y = self._coords[i]
                if x == (x1-num) and y == (y1-num):
                    result = i
                    break 
            if result!=None and result.is_voidplace():
                num = num +1 
                result = None 
            else: 
                break 
        return result
    def get_next_widget(self, widget):
        '''
        Get the next widget - None Vodplace
        '''
        if widget == self._last:
            return None 
        return self.get_generic_widget(widget, -1)

    def get_prev_widget(self, widget):
        '''
        Get a Previews widget - None Voidplace 
        '''
        x, y = self._coords[widget]
        if x == 0 and y == 1: 
            return None 
        return self.get_generic_widget(widget, 1)



    def can_move_up(self):

        widget = self._old_selected
        x = 0 
        if widget!= None :
            try:
                x,y = self._coords[widget]
            except KeyError:
                return False
        return x != 0
    def can_move_down(self):

        widget = self._old_selected
        y = len(self._coords)
        if widget!= None :
            try:
                x,y = self._coords[widget]
            except KeyError:
                return 
        return y != (len(self._coords))
    def send_signal_save(self):
        self._parent.emit('need-save', 'Sent', None)
    def send_signal(self):
        self._parent.emit('changed', 'Options', self._parent.get_current_page())
    def create_item(self):
        t = SpecialHBox()
        e = gtk.EventBox()
        label = gtk.Label('-')
        label.set_size_request(-1, 23)
        #e.add(label)
        t.pack_start(label)
        t.set_flags( t.flags() |  gtk.CAN_FOCUS)
        t.connect('button-press-event', self._button_press_event)
        t.connect('key-press-event', self._key_press_event)
        t.connect('drag_data_received', self.drag_received)
        t.drag_dest_set(gtk.DEST_DEFAULT_ALL, target[:-1],
                        gtk.gdk.ACTION_COPY | gtk.gdk.ACTION_MOVE)
        return t 
    def add_voidplace(self, position):
        # Create SpecialHBox with Voidplace
        t = self.create_item()
        cmd = CommandVoidPlaceAttach(self, t, self._coords, True)
        command_manager.add_command(cmd)
        self._parent.emit('need-save', 'Sent', None)

        #if position == -1 : 
            #x, y = self._x,self._y 
            #self._table.attach()
        #else:
            ## Choose the position 
            #pass

    def move_item_down(self):
        '''
        Move selected item to down
        '''
        assert self.can_move_down()

        cmd = CommandMove(self, self._old_selected, self._coords, self._profilecore, False)
        command_manager.add_command(cmd)
        self.send_signal()
        self.send_signal_save()
    def move_item_up(self):
        '''
        Move selected item to up
        '''
        assert self.can_move_up()

        cmd = CommandMove(self, self._old_selected, self._coords, self._profilecore, True)
        command_manager.add_command(cmd)
        self.send_signal()
        self.send_signal_save()


    def search_option(self, name):
        '''
        returns widget 
        '''
        list = self._table.get_children()
        result = None 
        for i in list : 
            if i.get_name() == name : 
                result = i
                break
        return result

    def set_profile_core(self, profile_core):
        self._profilecore = profile_core

    def option_builder(self, option_name, type):
        '''
        construct a widget with the name of the option
        @return: A widget
        @rtype: Widget like OptionCheck or others 
        '''
        result = []
        hint = self._listoptions.get_hint(option_name)
        #label, option_name, hint
        tmp_widget = OptionCheckIcon(option_name,option_name,hint) 
        result.append(tmp_widget)
        arg_type = self._listoptions.get_arg_type(option_name)
        if arg_type!= '':
            additional = type_mapping[arg_type]()
            result.append(additional)
        return result




    def _is_widget(self, name):
        return name[0:4] == '_wid'
    def _create_option_list(self, widget):
        eventbox = gtk.EventBox()
        name = 'New Option List'
        label = HIGEntryLabel(name)

        eventbox.add(label)
        tmp_widget = OptionList()
        list = []
        void = {'name':''}
        j = 'None'
        d = {}
        d['name'] = j 
        tmp_widget.append(void)
        tmp_widget.append(d)
        list.append(j)
        po = ProfileOption('option_list',name ,None, 
                           None,list)
        po.set_section(self.get_name())
        widget.set_profileoption(po)
        widgets = [] 
        widgets.append(eventbox)
        widgets.append(tmp_widget)
        widget.set_name(name)
        return widgets

    def exec_option_list(self, w):
        widgets = self._create_option_list( w)
        cmd = CommandAddRemoveOption(w,widgets, self._profile,self,
                                     True)
        command_manager.add_command(cmd)

    def exec_checkopt(self, name, w):
        option_name = name
        opt = self._listoptions.get_option_class(name)
        profileoption = option_to_profileoption(opt)
        profileoption.set_section(self.get_name())
        arg_type = self._listoptions.get_arg_type(name)
        widgets = self.option_builder(option_name, arg_type)
        w.set_profileoption(profileoption)
        w.set_name(name)
        cmd = CommandAddRemoveOption(w, widgets, self._profilecore, self,True)
        command_manager.add_command(cmd)






    def drag_received(self,w, context, x, y, data, info, time):
        if not w.is_voidplace(): 
            return 
        option_name = data.data
        if self._is_widget(option_name) :
            if option_name == '_widget_option_list':
                self.exec_option_list(w)
                #widgets = self._create_option_list( w)
                #cmd = CommandAddRemoveOption(w,widgets, self._profile,
                                                #True)
                #command_manager.add_command(cmd)

            return
        name = data.data
        self.exec_checkopt(name, w)

        #Remove child 
        #childs = w.get_children()
        #w.remove(childs[0])
        #Add

        #for child in widgets:
            #t = gtk.Label('fsck')
            #tmp_w.pack_start(child)
            #child.show_all()

        #w.unload_voidplace()


    def get_table(self):
        return self._table
    def set_last(self, last):
        self._last = last
    def get_last(self):
        return self._last
    def source_drag_data_get(self, btn, context, selection_data, info, time):
        selection_data.set(selection_data.target, 8, "I'm Data!")    
Пример #38
0
class ListManager(gtk.Dialog):
    '''
    ListManager - manage the OptionList
    Tricks: 
     - To works with the Command Manager it save at __init__ the list 
       of options. After that. Add to CommandManager when clicked 'Ok Button'
       with the new and old list.
    '''
    def __init__(self, name, section, profilecore, widget, title):
        gtk.Dialog.__init__(self, title)
        self.set_size_request(450, 300)
        self._name = name
        self._section = section
        self._profilecore = profilecore
        self._widget = widget
        self._list = self._profilecore.get_list_opt(self._section, self._name)
        self._new_list = self._profilecore.get_list_opt(
            self._section, self._name)
        self._create_widgets()
        self.show()
        self._load_option_list()
        self._create_action_area()

    def _create_widgets(self):
        self._optionlist = OptionList()
        label = gtk.Label('Items at the %s ' % self._name)
        self._box = gtk.HPaned()
        ol = self._optionlist
        ol.reload()
        self.vbox.pack_start(label, False, False, 0)
        self._box.add(ol)
        self.vbox.pack_start(self._box)
        self._box.show_all()
        self._move_box = HIGVBox()
        self._add_bt = HIGButton(stock='gtk-add')
        self._add_bt.connect('clicked', self._on_add_press)
        self._remove_bt = HIGButton(stock='gtk-remove')
        self._remove_bt.connect('clicked', self._on_remove_press)
        #XXX - moves don't work yet: lack the connect
        self._move_up_bt = HIGButton(stock='gtk-go-up')
        self._move_down_bt = HIGButton(stock='gtk-go-down')
        self._move_box.pack_start(self._add_bt, False, False)
        self._move_box.pack_start(self._remove_bt, False, False)
        self._move_box.pack_start(self._move_up_bt, False, False)
        self._move_box.pack_start(self._move_down_bt, False, False)
        self._create_option_tv()

        self._box.set_position(200)
        self._box_other = gtk.HPaned()
        self._box.add(self._box_other)
        self._box_other.add(self._move_box)
        self._box_other.add(self._sw)
        self._move_box.show_all()
        self.vbox.show_all()

        label.show()

    def _create_option_tv(self):
        self._sw = HIGScrolledWindow()

        self._model = gtk.TreeStore(gobject.TYPE_STRING)
        self._tv = gtk.TreeView(self._model)
        column = gtk.TreeViewColumn()
        column.set_title('Name')
        render = gtk.CellRendererText()
        column.pack_start(render, expand=True)
        column.add_attribute(render, 'text', 0)
        self._tv.append_column(column)
        self._sw.add(self._tv)
        self._sw.show_all()

    def _load_option_list(self):
        list = self._list

        for i in list:
            iter = self._model.insert_before(None, None)
            self._model.set_value(iter, 0, i)

    def _create_action_area(self):
        self._button_ok = HIGButton(stock='gtk-ok')
        self._button_cancel = HIGButton(stock='gtk-cancel')
        self._button_cancel.connect('clicked', self._on_cancel_press)
        self._button_ok.connect('clicked', self._on_ok_press)
        self.action_area.pack_start(self._button_cancel)
        self.action_area.pack_start(self._button_ok)
        self.action_area.show_all()

    def _on_add_press(self, widget):
        log.debug('<<< Add Option to OptionList')
        option_selected = self._optionlist.get_selected()
        iter = self._model.insert_before(None, None)
        self._model.set_value(iter, 0, option_selected)
        self._new_list.append(option_selected)

    def get_selected(self):
        """
        Returns the string with name of selected option
        """
        try:
            treeselection = self._tv.get_selection()
            (model, iter) = treeselection.get_selected()
            return model.get_value(iter, 0)
        except:
            return None

    def get_selected_option(self):
        '''
        @return: iter and model of option treeview selected
        '''
        treeselection = self._tv.get_selection()

        (model, iter) = treeselection.get_selected()
        return model, iter

    def _on_remove_press(self, widget):
        log.debug('<<< Remove Option from OptionList')
        selected = self.get_selected()
        (model, iter) = self.get_selected_option()
        if selected != None:
            self._new_list.remove(selected)
            self._model.remove(iter)

    def _on_ok_press(self, widget):
        # Lists:
        list2 = self._list
        list1 = self._new_list

        cmd = CommandUpdateOptionList(self._widget, list1, list2,
                                      self._profilecore, True)
        command_manager.add_command(cmd)
        self.destroy()

    def _on_cancel_press(self, widget):
        self.destroy()
Пример #39
0
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 Credits(HIGWindow):
    def __init__(self):
        HIGWindow.__init__(self)
        self.set_title(_("Umit credits"))
        self.set_size_request(-1, 450)
        self.set_position(gtk.WIN_POS_CENTER)

        self.__create_widgets()
        self.__packing()
        self.set_text()

    def __create_widgets(self):
        self.vbox = HIGVBox()
        self.hbox = HIGHBox()
        self.notebook = HIGNotebook()
        self.btn_close = HIGButton(stock=gtk.STOCK_CLOSE)

        self.written_by_scroll = HIGScrolledWindow()
        self.written_by_text = HIGTextView()

        self.design_scroll = HIGScrolledWindow()
        self.design_text = HIGTextView()

        self.soc2007_scroll = HIGScrolledWindow()
        self.soc2007_text = HIGTextView()

        self.soc2008_scroll = HIGScrolledWindow()
        self.soc2008_text = HIGTextView()

        self.soc2009_scroll = HIGScrolledWindow()
        self.soc2009_text = HIGTextView()

        self.contributors_scroll = HIGScrolledWindow()
        self.contributors_text = HIGTextView()

        self.translation_scroll = HIGScrolledWindow()
        self.translation_text = HIGTextView()

        self.nokia_scroll = HIGScrolledWindow()
        self.nokia_text = HIGTextView()

    def __packing(self):
        self.add(self.vbox)
        self.vbox.set_spacing(12)
        self.vbox._pack_expand_fill(self.notebook)
        self.vbox._pack_noexpand_nofill(self.hbox)

        self.hbox._pack_expand_fill(hig_box_space_holder())
        self.hbox._pack_noexpand_nofill(self.btn_close)

        self.notebook.append_page(self.written_by_scroll,
                                  gtk.Label(_("Written by")))
        self.notebook.append_page(self.design_scroll, gtk.Label(_("Design")))
        self.notebook.append_page(self.soc2007_scroll,
                                  gtk.Label(_("SoC 2007")))
        self.notebook.append_page(self.soc2008_scroll,
                                  gtk.Label(_("SoC 2008")))
        self.notebook.append_page(self.soc2009_scroll,
                                  gtk.Label(_("SoC 2009")))
        self.notebook.append_page(self.contributors_scroll,
                                  gtk.Label(_("Contributors")))
        self.notebook.append_page(self.translation_scroll,
                                  gtk.Label(_("Translations")))
        self.notebook.append_page(self.nokia_scroll, gtk.Label(_("Maemo")))

        self.written_by_scroll.add(self.written_by_text)
        self.written_by_text.set_wrap_mode(gtk.WRAP_NONE)

        self.design_scroll.add(self.design_text)
        self.design_text.set_wrap_mode(gtk.WRAP_NONE)
        self.soc2007_scroll.add(self.soc2007_text)
        self.soc2007_text.set_wrap_mode(gtk.WRAP_NONE)

        self.soc2008_scroll.add(self.soc2008_text)
        self.soc2008_text.set_wrap_mode(gtk.WRAP_NONE)

        self.soc2009_scroll.add(self.soc2009_text)
        self.soc2009_text.set_wrap_mode(gtk.WRAP_NONE)

        self.contributors_scroll.add(self.contributors_text)
        self.contributors_text.set_wrap_mode(gtk.WRAP_NONE)

        self.translation_scroll.add(self.translation_text)
        self.translation_text.set_wrap_mode(gtk.WRAP_NONE)

        self.nokia_scroll.add(self.nokia_text)
        self.nokia_text.set_wrap_mode(gtk.WRAP_NONE)

        self.btn_close.connect('clicked', lambda x, y=None: self.destroy())

    def set_text(self):
        b = self.written_by_text.get_buffer()
        b.set_text("""Adriano Monteiro Marques <*****@*****.**>
Bartosz Skowron <*****@*****.**>
Francesco Piccinno <*****@*****.**>
Guilherme Polo <*****@*****.**>
João Medeiros <*****@*****.**>
Luís A. Bastião Silva <*****@*****.**>""")

        b = self.design_text.get_buffer()
        b.set_text(
            _("""Operating System and Vulnerability Icons:
Takeshi Alexandre Gondo <*****@*****.**>

Logo, Application Icons, Splash screen and Umit GNU/Linux theme:
Virgílio Carlo de Menezes Vasconcelos <*****@*****.**>

The Umit Project Web Site Design:
Joao Paulo Pacheco <*****@*****.**>"""))

        b = self.soc2007_text.get_buffer()
        b.set_text(
            _("""Independent Features:
Adriano Monteiro Marques <*****@*****.**>
Frederico Silva Ribeiro <*****@*****.**>

Network Inventory:
Guilherme Henrique Polo Gonçalves <*****@*****.**>

Umit Radial Mapper:
João Paulo de Souza Medeiros <*****@*****.**>

Profile/Wizard interface editor:
Luis Antonio Bastião Silva <*****@*****.**>

NSE Facilitator:
Maxim I. Gavrilov <*****@*****.**>

Umit Web:
Rodolfo da Silva Carvalho <*****@*****.**>"""))

        b = self.soc2008_text.get_buffer()
        b.set_text(
            _("""Packet Manipulation Backend
Bartosz Adam Skowron <*****@*****.**>

Bluetooth Scanner & Vulnerabilities Database System:
Devtar Singh <*****@*****.**>

Umit Plugins and Packet Manipulation Frontend
Francesco Piccinno <*****@*****.**>

Preferences Window and Interface Editor improvements:
Luis Antonio Bastião Silva <*****@*****.**>

UmitWeb Improvements and Independent Features:
Rodolfo da Silva Carvalho <*****@*****.**>
"""))

        b = self.soc2009_text.get_buffer()
        b.set_text(
            _("""UMPA Improvements
Bartosz Adam Skowron <*****@*****.**>

Quick Scan:
Daniel Mendes Cassiano <*****@*****.**>

Bluetooth Sniffer:
Shu Yang Quek <*****@*****.**>

Audits Framework
Francesco Piccinno <*****@*****.**>

ZION
João Paulo de Souza Medeiros <*****@*****.**>

USoC:

Message Sequence Chart
Abhiram Kasina <*****@*****.**>

Independent Features and Test Suite
Mahesh PM <*****@*****.**>
"""))

        b = self.contributors_text.get_buffer()
        b.set_text(
            _("""Sponsored by (SoC 2005, 2006, 2007 and 2008):
Google <*****@*****.**>

Mentor of Umit for Google SoC 2005 and 2006:
Fyodor <*****@*****.**>

Mentor of Umit for Google SoC 2007 Projects:
Adriano Monteiro Marques <*****@*****.**>

Mentor of Umit for Google SoC 2008 Projects:
Adriano Monteiro Marques <*****@*****.**>

Initial development:
Adriano Monteiro Marques <*****@*****.**>
Cleber Rodrigues Rosa Junior <*****@*****.**>

Nmap students from Google SoC 2007 that helped Umit:
Eddie Bell <*****@*****.**>
David Fifield <*****@*****.**>
Kris Katterjohn <*****@*****.**>

The Umit Project WebSite:
Abrao Barbosa dos Santos Neto <*****@*****.**>
Adriano Monteiro Marques <*****@*****.**>
Heitor de Lima Matos <*****@*****.**>
Joao Paulo Pacheco <*****@*****.**>
João Paulo de Souza Medeiros <*****@*****.**>
Luis Antonio Bastião Silva <*****@*****.**>
Rodolfo da Silva Carvalho <*****@*****.**>

Helpers:
Daniel Mendes Cassiano <*****@*****.**>
Luiz Paulo de Souza Medeiros <*****@*****.**>

Beta testers for 0.9.5RC1:
Bartosz Adam Skowron <*****@*****.**>
Denis Kurov <*****@*****.**>
Devtar Singh <*****@*****.**>
Drew Miller <*****@*****.**>
Francesco Piccinno <*****@*****.**>
Igor Feghali <*****@*****.**>
Joao Paulo Pacheco <*****@*****.**>
Luis Antonio Bastião Silva <*****@*****.**>
Rodolfo da Silva Carvalho <*****@*****.**>
Regis Kuramoto Dias <*****@*****.**>
<*****@*****.**>
<*****@*****.**>
<*****@*****.**>

Special thanks to our GSoC volunteers heroes:
Daniel Mendes Cassiano <*****@*****.**>
Túlio Gonçalves <*****@*****.**>

Initial attempt on Maemo port:
Adriano Monteiro Marques <*****@*****.**>
Osvaldo Santana Neto <*****@*****.**>"""))

        b = self.soc2007_text.get_buffer()
        b.set_text("""Independent Features:
Adriano Monteiro Marques <*****@*****.**>
Frederico Silva Ribeiro <*****@*****.**>

Network Inventory:
Guilherme Henrique Polo Gonçalves <*****@*****.**>

Umit Radial Mapper:
João Paulo de Souza Medeiros <*****@*****.**>

Profile/Wizard interface editor:
Luis Antonio Bastião Silva <*****@*****.**>

NSE Facilitator:
Maxim I. Gavrilov <*****@*****.**>

Nmap Python Wrapper:
Pavel Klemenkov <*****@*****.**>

Umit Web:
Rodolfo da Silva Carvalho <*****@*****.**>

Summer of Code's projects Design:
Virgílio Carlo de Menezes Vasconcelos <*****@*****.**>""")

        b = self.translation_text.get_buffer()
        b.set_text(
            _("""Bahasa Indonesia:
Devtar Singh <*****@*****.**>

Bahasa Melayu:
Devtar Singh <*****@*****.**>

Brazilian Portuguese:
Adriano Monteiro Marques <*****@*****.**>
Rodolfo da Silva Carvalho <*****@*****.**>

Italian:
Francesco Piccinno <*****@*****.**>

Polish:
Bartosz Adam Skowron <*****@*****.**>

Portuguese Portugal:
Luis Antonio Bastião Silva <*****@*****.**>

Simplified Chinese:
Devtar Singh <*****@*****.**>
Haoyu Bai <*****@*****.**>
Aron Xu <*****@*****.**>

Swedish:
Daniel Nylander <*****@*****.**>
"""))

        b = self.nokia_text.get_buffer()
        b.set_text("""Adriano Monteiro Marques <*****@*****.**>""")
class ProfileEditor(HIGWindow):
    def __init__(self, profile_name=None, delete=False):
        HIGWindow.__init__(self)
        self.set_title(_('Profile Editor'))
        self.set_position(gtk.WIN_POS_CENTER)
        self.profile_name = profile_name
        self.__create_widgets()
        self.__pack_widgets()

        self.scan_notebook = None
        self.profilemanager = None

        self.profile = CommandProfile()

        self.deleted = False
        options_used = {}

        if profile_name:
            log.debug("Showing profile %s" % profile_name)
            prof = self.profile.get_profile(profile_name)
            options_used = prof['options']

            # Interface settings
            self.profile_name_entry.set_text(profile_name)
            self.profile_hint_entry.set_text(prof['hint'])
            self.profile_description_text.get_buffer().set_text(
                prof['description'])
            self.profile_annotation_text.get_buffer().set_text(
                prof['annotation'])

            if delete:
                # Removing profile. It must be saved again
                self.remove_profile()

        self.constructor = CommandConstructor(options_used)
        self.options = OptionBuilder(profile_editor_file, self.constructor,
                                     self.update_command)
        log.debug("Option groups: %s" % str(self.options.groups))
        log.debug("Option section names: %s" % str(self.options.section_names))
        #log.debug("Option tabs: %s" % str(self.options.tabs))

        for tab in self.options.groups:
            self.__create_tab(tab, self.options.section_names[tab],
                              self.options.tabs[tab])

        self.update_command()

    def update_command(self):
        """Regenerate command with target '<target>' and set the value for the command entry"""
        self.command_entry.set_text(self.constructor.get_command('<target>'))

    def help(self, widget):
        """
        Show help documentation of Profile Editor
        """
        show_help(self, "profile_editor.html#introduction")

    def __create_widgets(self):
        self.main_vbox = HIGVBox()

        self.command_expander = HIGExpander('<b>' + _('Command') + '</b>')
        self.command_expander.set_expanded(True)
        self.command_entry = gtk.Entry()

        self.notebook = gtk.Notebook()

        # Profile info page
        self.profile_info_vbox = HIGVBox()
        self.profile_info_label = HIGSectionLabel(_('Profile Information'))
        self.profile_name_label = HIGEntryLabel(_('Profile name'))
        self.profile_name_entry = gtk.Entry()
        self.profile_hint_label = HIGEntryLabel(_('Hint'))
        self.profile_hint_entry = gtk.Entry()
        self.profile_description_label = HIGEntryLabel(_('Description'))
        #self.profile_description_label = HIGHBox()
        self.profile_description_scroll = HIGScrolledWindow()
        self.profile_description_text = HIGTextView()
        self.profile_annotation_label = HIGEntryLabel(_('Annotation'))
        #self.profile_annotation_label = HIGHBox()
        self.profile_annotation_scroll = HIGScrolledWindow()
        self.profile_annotation_text = HIGTextView()

        # Buttons
        self.buttons_hbox = HIGHBox()

        self.help_button = HIGButton(stock=gtk.STOCK_HELP)
        self.help_button.connect('clicked', self.help)

        #self.delete_button = HIGButton(stock=gtk.STOCK_DELETE)
        #self.delete_button.connect('clicked', self.delete_profile)

        self.cancel_button = HIGButton(stock=gtk.STOCK_CANCEL)
        self.cancel_button.connect('clicked', self.quit_without_saving)

        self.ok_button = HIGButton(stock=gtk.STOCK_OK)
        self.ok_button.connect('clicked', self.save_profile)

    def __pack_widgets(self):
        self.add(self.main_vbox)

        # Packing widgets to main_vbox

        self.main_vbox._pack_noexpand_nofill(self.command_expander)
        self.main_vbox._pack_expand_fill(self.notebook)
        self.main_vbox._pack_noexpand_nofill(self.buttons_hbox)

        # Packing command_entry on command_expander
        self.command_expander.hbox.pack_start(self.command_entry)

        # Packing profile information tab on notebook
        self.notebook.append_page(self.profile_info_vbox,
                                  gtk.Label(_('Profile')))
        self.profile_info_vbox.set_border_width(5)
        table = HIGTable()
        self.profile_info_vbox._pack_noexpand_nofill(self.profile_info_label)
        self.profile_info_vbox._pack_noexpand_nofill(HIGSpacer(table))

        self.profile_annotation_scroll.add(self.profile_annotation_text)
        self.profile_description_scroll.add(self.profile_description_text)

        vbox_desc = HIGVBox()
        vbox_desc._pack_noexpand_nofill(self.profile_description_label)
        vbox_desc._pack_expand_fill(hig_box_space_holder())

        vbox_ann = HIGVBox()
        vbox_ann._pack_noexpand_nofill(self.profile_annotation_label)
        vbox_ann._pack_expand_fill(hig_box_space_holder())
        table.attach(self.profile_name_label, 0, 1, 0, 1)
        table.attach(self.profile_name_entry, 1, 2, 0, 1)
        #table.attach(self.profile_hint_label,0,1,1,2,xoptions=0)
        table.attach(self.profile_hint_label, 0, 1, 1, 2)
        table.attach(self.profile_hint_entry, 1, 2, 1, 2)
        table.attach(vbox_desc, 0, 1, 2, 3)
        table.attach(self.profile_description_scroll, 1, 2, 2, 3)
        table.attach(vbox_ann, 0, 1, 3, 4)
        table.attach(self.profile_annotation_scroll, 1, 2, 3, 4)

        # Packing buttons on button_hbox
        self.buttons_hbox.pack_start(self.help_button)
        #self.buttons_hbox.pack_start(self.delete_button)
        self.buttons_hbox.pack_start(self.cancel_button)
        self.buttons_hbox.pack_start(self.ok_button)

        self.buttons_hbox.set_border_width(5)
        self.buttons_hbox.set_spacing(6)

    def __create_tab(self, tab_name, section_name, tab):
        log.debug(">>> Tab name: %s" % tab_name)
        log.debug(">>>Creating profile editor section: %s" % section_name)

        vbox = HIGVBox()
        table = HIGTable()
        section = HIGSectionLabel(section_name)

        vbox._pack_noexpand_nofill(section)
        vbox._pack_noexpand_nofill(HIGSpacer(table))
        vbox.set_border_width(6)

        tab.fill_table(table, True)
        self.scrollwindow = HIGScrolledWindow()
        self.scrollwindow.set_size_request(600, 300)
        vp = gtk.Viewport()
        vp.add(vbox)
        vp.set_shadow_type(gtk.SHADOW_NONE)
        self.scrollwindow.add(vp)

        vbox_tmp = HIGVBox()
        vbox_tmp.set_border_width(6)
        vbox_tmp.set_spacing(12)
        vbox_tmp.pack_start(self.scrollwindow)

        self.notebook.append_page(vbox_tmp, gtk.Label(tab_name))

    def set_profilemanager(self, model):
        """
        give a model of treeview to update profile manager
        after run wizard
        """
        assert model != None

        self.model = model
        self.profilemanager = True

    def update_profilemanager(self):
        """
        Update treeview of ProfileManager"
        """
        assert self.profilemanager

        profiles = self.profile.sections()
        profiles.sort()
        self.model.clear()

        for command in profiles:
            myiter = self.model.insert_before(None, None)
            self.model.set_value(myiter, 0, command)
            self.model.set_value(myiter, 1, self.profile.get_hint(command))

    def save_profile(self, widget):
        profile_name = self.profile_name_entry.get_text()

        if profile_name == '':
            alert = HIGAlertDialog(message_format=_('Unnamed profile'),\
                                   secondary_text=_('You must provide a name \
for this profile.'                  ))

        elif profile_name.lower() == 'default':
            alert = HIGAlertDialog(message_format=_('Reserved profile name'),\
                                   secondary_text=_('Cannot assign "default" \
name to this profile. Please rename it and retry.'                                                  ))
        else:
            alert = None

        if alert:
            alert.run()
            alert.destroy()

            self.notebook.set_current_page(0)
            self.profile_name_entry.grab_focus()

            return None

        if not self.deleted:
            self.remove_profile()

        command = self.constructor.get_command('%s')
        hint = self.profile_hint_entry.get_text()

        buf = self.profile_description_text.get_buffer()
        description = buf.get_text(buf.get_start_iter(),\
                                   buf.get_end_iter())

        buf = self.profile_annotation_text.get_buffer()
        annotation = buf.get_text(buf.get_start_iter(),\
                                  buf.get_end_iter())
        self.profile.add_profile(profile_name,\
                                 command=command,\
                                 hint=hint,\
                                 description=description,\
                                 annotation=annotation,\
                                 tool='nmap',\
                                 options=self.constructor.get_options())
        self.deleted = False
        if self.profilemanager:
            self.update_profilemanager()

        self.quit()

    def clean_profile_info(self):
        self.profile_name_entry.set_text('')
        self.profile_hint_entry.set_text('')
        self.profile_description_text.get_buffer().set_text('')
        self.profile_annotation_text.get_buffer().set_text('')

    def set_notebook(self, notebook):
        self.scan_notebook = notebook

    def quit(self, widget=None, extra=None):
        if self.deleted:
            dialog = HIGDialog(buttons=(gtk.STOCK_OK, gtk.RESPONSE_OK,
                                        gtk.STOCK_CANCEL, gtk.RESPONSE_CANCEL))
            alert = HIGEntryLabel('<b>' + _("Deleting Profile") + '</b>')
            text = HIGEntryLabel(
                _('Your profile is going to be deleted! Click\
                                   Ok to continue, or Cancel to go back to Profile Editor.'
                  ))
            hbox = HIGHBox()
            hbox.set_border_width(5)
            hbox.set_spacing(12)

            vbox = HIGVBox()
            vbox.set_border_width(5)
            vbox.set_spacing(12)

            image = gtk.Image()
            image.set_from_stock(gtk.STOCK_DIALOG_WARNING,
                                 gtk.ICON_SIZE_DIALOG)

            vbox.pack_start(alert)
            vbox.pack_start(text)
            hbox.pack_start(image)
            hbox.pack_start(vbox)

            dialog.vbox.pack_start(hbox)
            dialog.vbox.show_all()

            response = dialog.run()
            dialog.destroy()

            if response == gtk.RESPONSE_CANCEL:
                return None
        self.destroy()
        if self.scan_notebook != None:

            for i in xrange(self.scan_notebook.get_n_pages()):
                page = self.scan_notebook.get_nth_page(i)
                page.toolbar.profile_entry.update()

        #page.toolbar.scan_profile.profile_entry.child.\
        #    set_text(self.profile_name_entry.get_text())
    def quit_without_saving(self, widget=None):
        self.deleted = False
        self.quit()

    def on_delete(self, widget=None):
        if not self.profile_name:
            return self.on_cancel()

        dialog = HIGDialog(buttons=(gtk.STOCK_OK, gtk.RESPONSE_OK,
                                    gtk.STOCK_CANCEL, gtk.RESPONSE_CANCEL))
        alert = HIGEntryLabel('<b>' + _("Deleting Profile") + '</b>')
        text = HIGEntryLabel(
            _('Your profile is going to be deleted! Click \
Ok to continue, or Cancel to go back to Profile Editor.'))
        hbox = HIGHBox()
        hbox.set_border_width(5)
        hbox.set_spacing(12)

        vbox = HIGVBox()
        vbox.set_border_width(5)
        vbox.set_spacing(12)

        image = gtk.Image()
        image.set_from_stock(gtk.STOCK_DIALOG_WARNING, gtk.ICON_SIZE_DIALOG)

        vbox.pack_start(alert)
        vbox.pack_start(text)
        hbox.pack_start(image)
        hbox.pack_start(vbox)

        dialog.vbox.pack_start(hbox)
        dialog.vbox.show_all()

        response = dialog.run()
        dialog.destroy()

        if response == gtk.RESPONSE_CANCEL:
            return None

        self.deleted = True
        self.profile.remove_profile(self.profile_name)
        self.on_cancel()

    def on_cancel(self, widget=None):
        self.destroy()
        self.update_profile_entry()

    def update_profile_entry(self):
        page = None
        for i in xrange(self.scan_notebook.get_n_pages()):
            page = self.scan_notebook.get_nth_page(i)

            page.toolbar.profile_entry.update(\
                self.profile_name_entry.get_text())

            list = page.toolbar.profile_entry.get_model()
            length = len(list)
            if self.deleted and length > 0:
                page.toolbar.profile_entry.set_active(0)
            elif self.deleted and length == 0:
                page.toolbar.profile_entry.child.set_text("")

        if page is not None:
            page.toolbar.profile_entry.update()

    def remove_profile(self, profile_name=None):
        '''
        Remove current profile 
        '''
        if not profile_name:
            profile_name = self.profile_name
        self.profile.remove_profile(profile_name)
        self.deleted = True

    def delete_profile(self, widget=None):
        """
        delete profile
        """
        self.remove_profile()
        self.deleted = False
        self.quit()
Пример #42
0
class ProfileManager(HIGWindow):
    """
    Create a Profile Manager 
    """
    def __init__(self, daddy=None):
        HIGWindow.__init__(self, type=gtk.WINDOW_TOPLEVEL)
        self.set_title('Profile Manager')
        self.set_position(gtk.WIN_POS_CENTER)
        self.__create_widgets()
        self.add(self.vbox_main)
        self.__fill_widgets()
        self.__pack_widgets()
        self.__scan_notebook = None
        
        self.daddy = daddy


    def __create_widgets(self):

        self.vbox_main = HIGVBox()

        self.main_frame = HIGFrame("Profiles")
        #self.main_frame.set_shadow_type(gtk.SHADOW_ETCHED_OUT)

        self.align = gtk.Alignment(0.0, 0.0, 1.0, 1.0)
        self.align.set_padding(0,0,12,0)

        self.vbox = HIGVBox()
        self.profiles_sw = HIGScrolledWindow()
        #TreeView
        self.model = gtk.ListStore(gobject.TYPE_STRING, gobject.TYPE_STRING)
        #self.modelfilter = self.model.filter_new()
        self.profiles_tv = gtk.TreeView(self.model)
        renderer = gtk.CellRendererText()
        column = gtk.TreeViewColumn(_("Name"), renderer, text=0)
        self.profiles_tv.append_column(column)
        renderer_hint = gtk.CellRendererText()
        column_hint = gtk.TreeViewColumn(_("Hint"), renderer_hint, text=1)
        self.profiles_tv.append_column(column_hint)
        #self.profiles_tv.set_model(self.modelfilter)
        #Info 
        self.hbox_info = HIGHBox()
        self.command_label = HIGEntryLabel('Command: ')
        self.command_entry = HIGTextEntry()
        self.command_entry.set_editable(False)

        #Buttons
        self.hbox_buttons = HIGHBox()

        self.wiz_button = HIGButton(title='Wizard', stock='gtk-convert')
        self.wiz_button.connect("clicked", self.new_wiz)

        self.edit_button = HIGButton(stock='gtk-edit')
        self.edit_button.connect("clicked", self.open_peditor)
        self.new_button = HIGButton(stock='gtk-new')
        self.new_button.connect("clicked", self.open_peditor)
        self.copy_button = HIGButton(stock='gtk-copy')
        self.copy_button.connect("clicked", self.copy_profiles)
        self.delete_button = HIGButton(stock=gtk.STOCK_DELETE)
        self.delete_button.connect('clicked', self.delete_profile)	
        #Apply Buttons
        self.cancel_button = HIGButton(stock='gtk-close')
        self.cancel_button.connect("clicked", self.quit)
        
        self.connect("delete-event", self.quit)

    def __fill_widgets(self):


        self.profiles = CommandProfile()
        self._reload_profile_list()

        #selection = self.profiles_tv.get_selection()
        #selection.connect("changed", self.change_nmap_command)
        self.profiles_tv.connect("cursor-changed", self.change_nmap_command)

    def __pack_widgets(self):
        """
        Pack all widgets of windows 
        """
        self.vbox_main.pack_start(self.main_frame, True, True)
        self.main_frame.add(self.align)
        self.align.add(self.vbox)
        self.vbox.set_border_width(6)

        self.vbox.pack_start(self.profiles_sw, True, True, 0)

        self.hbox_info.pack_start(self.command_label, False,False,0)
        self.hbox_info.pack_start(self.command_entry, True, True, 0)
        self.vbox.pack_start(self.hbox_info, False,False,0)



        self.hbox_buttons.pack_end(self.cancel_button)    
        self.hbox_buttons.pack_end(self.copy_button, True, True)
        self.hbox_buttons.pack_end(self.edit_button, True, True)
        self.hbox_buttons.pack_end(self.delete_button, True, True)
        self.hbox_buttons.pack_end(self.new_button, True, True)
        self.hbox_buttons.pack_end(self.wiz_button, True, True)
        self.hbox_buttons.set_spacing(6)
        self.vbox_main.pack_start(self.hbox_buttons, False, False)

        self.profiles_sw.set_size_request(400,170)
        self.profiles_sw.add(self.profiles_tv) 


    def get_selected_profile(self):
        """
        Returns the string with name of selected profile 
        """
        try:
            treeselection = self.profiles_tv.get_selection()
            (model,iter) = treeselection.get_selected()	
            return model.get_value(iter,0)
        except:
            return None

    def change_nmap_command(self,widget_tv):
        """
        Change a nmap command at command entry
        """
        assert widget_tv is not None
        # it call __init__ because when wizard or profile are open,  
        # need update profiles
        self.profiles.__init__()
        # update text entry of command
        self.command_entry.set_text(self.profiles.get_command(
            self.get_selected_profile()))	

    def new_wiz(self,widget):
        w = Wizard()
        w.set_notebook(None)
        w.set_profilemanager(self.model)
        w.show_all()

    def open_peditor(self, widget):
        """
        Open Profile Editor with a Selected or Non-Selected(New) Item
        """
        assert widget is not None

        if widget.get_label() == "gtk-edit":
            # Edit profile selected    
            if self.get_selected_profile() is not None:
                pe = ProfileEditor(self.get_selected_profile())
                pe.set_notebook(self.__scan_notebook)
                pe.set_profilemanager(self.model)
                pe.show_all()
        else:
            # New Profile
            pe = ProfileEditor()
            pe.set_notebook(self.__scan_notebook)
            pe.set_profilemanager(self.model)
            pe.show_all()
            self._reload_profile_list()

    def copy_profiles(self, widget):
        """
        Copy selected Profile
        """
        if self.get_selected_profile() is None:
            return None
        d = ProfileName(_("Insert a profile name"))
        profile_name = d.run()
        if profile_name is None or profile_name=="":
            return None
        #get commands of selected profile
        profile_selected = self.get_selected_profile()
        command = self.profiles.get_command(profile_selected)
        hint = self.profiles.get_hint(profile_selected)
        description = self.profiles.get_description(profile_selected)
        annotation = self.profiles.get_annotation(profile_selected)
        #Options
        prof = self.profiles.get_profile(profile_selected)
        options_used = prof['options']
        options = CommandConstructor(options_used)

        self.profiles.add_profile(profile_name,\
                                  command=command,\
                                  hint=hint,\
                                  description=description,\
                                  annotation=annotation,\
                                  options=options.get_options())



        myiter = self.model.insert_before(None, None)
        self.model.set_value(myiter, 0, profile_name)
        self.model.set_value(myiter,1, self.profiles.get_hint(profile_name))
        treeselection = self.profiles_tv.get_selection()
        treeselection.select_iter(myiter)
        #(model,iter) = treeselection.get_selected()	
        #model.get_value(iter,0)


    def delete_profile(self, widget=None):
        """
        delete profile 
        """
        if self.get_selected_profile() is None:
            return None
        self.profiles.remove_profile(self.get_selected_profile())
        #Update treeview
        treeselection = self.profiles_tv.get_selection()
        (model,iter) = treeselection.get_selected()
        model.remove(iter)
        # update text entry of command
        self.command_entry.set_text('')	



    def _reload_profile_list(self):
        """
        Reload a list of profiles
        """
        profiles = []
        all_profiles = self.profiles.sections()
        for profile in all_profiles:
            if self.profiles.get(profile, 'tool') == 'nmap':
                profiles.append(profile)
        profiles.sort()
        self.model.clear()


        for command in profiles:
            myiter = self.model.insert_before(None, None)
            self.model.set_value(myiter, 0, command)
            self.model.set_value(myiter,1, self.profiles.get_hint(command))
            #self.model.append([command,self.profiles.get_hint(command)])

    def set_notebook(self, notebook):
        self.__scan_notebook = notebook
    def quit(self, widget):
        self.destroy()

    def quit(self, widget, data=None):
        if self.daddy:
            self.daddy.running_pm = False
            self.destroy()
        else:
            gtk.main_quit()
Пример #43
0
class ProfileEdit(gtk.HBox):

    def __init__(self, listoption, profile_editor_file=profile_editor):
        gtk.HBox.__init__(self)
        self._toolbar = ToolBarInterface()
        self._toolbar.set_optionlist(listoption)
        self.profile_editor_file = profile_editor_file
        self._proprieties = None 
        self._notebook_tools = None 
        self._changed = False
        #MAIN SCROLLED
        self._scroolledmain = HIGScrolledWindow()
        #NOTEBOOKEDITABLE :
        self._profilecore = ProfileCore(profile_editor_file)
        self._toolbar.set_profilecore(self._profilecore)

        self.notebook = NotebookEditable(listoption, self._profilecore)
        self._toolbar.set_notebook(self.notebook)
        self.notebook.connect_after('changed', self.update_toolbar)
        self.notebook.connect_after('need-save',self._need_save)
        self.notebook.load_data()
        self.pack_start(self._toolbar.get_toolbar(), False, True,0)
        self.pack_start(self._scroolledmain, True, True)
        self._scroolledmain.add_with_viewport(self.notebook)
        self.show_all()
    def _need_save(self, action, others, page):
        self._changed = True
    def get_profilecore(self):
        return self._profilecore
    def set_notebook(self, notebook):
        self._notebook_tools = notebook
    def set_proprieties(self, proprieties):
        self._proprieties = proprieties
        proprieties.disable_all()
    def is_changed(self):
        return self._changed
    def update_toolbar(self, action, others, page):
        #print action
        #print others
        #print page
        boxeditable = self.get_box_editable()
        self._toolbar.set_box_editable(boxeditable)
        self._toolbar.update_toolbar()

        #Update Proprieties box
        if self._notebook_tools != None: 
            self._notebook_tools.set_current_page(2)

        if boxeditable._old_selected!= None :
            #SpecialHBox - Item
            self._proprieties.set_boxeditable(boxeditable)
            self._proprieties.set_item(boxeditable._old_selected)

            log.debug('<<< SpecialHBox Item update')
        elif self.notebook._old_select!= None:
            #Notebook_Label
            self._proprieties.set_notebooklabel(self.notebook._old_select)
            self._proprieties.set_boxeditable(boxeditable)
            log.debug('<<< NotebookLabel update')

    def get_box_editable(self):
        current_page = self.notebook.get_current_page()
        current_box = self.notebook.get_nth_page(current_page)
        return current_box

    def save(self):
        self._profilecore.write_file(self.profile_editor_file)
        log.debug('<<< Saving to file %s ' % self.profile_editor_file)

    def create_events(self):
        #....
        pass
Пример #44
0
class TabsIcon(HIGHBox):
    def __init__(self):
        """ Constructor """
        HIGHBox.__init__(self)
        self.scroll = HIGScrolledWindow()
        self._box = HIGHBox()
        self._icons_list = []
        self._tabstruct = TabStruct()
        self.__current = [0]
        self.__model = gtk.ListStore(str, gtk.gdk.Pixbuf)
        #self.__model = gtk.ListStore(str, HIGHBox)
        self.__pixmap_d = Path.pixmaps_dir

        self.__icon = gtk.IconView()
        self.__icon.set_model(self.__model)
        self.__icon.set_text_column(0)
        self.__icon.set_pixbuf_column(1)


        self.__icon.set_orientation(gtk.ORIENTATION_VERTICAL)
        self.__icon.set_selection_mode(gtk.SELECTION_SINGLE)

        # Change background color -- FIXME
        #self.__icon.set_name("icon tabs")
        #gtk.rc_parse_string(
#"""
#style "iconview"
#{
  #bg[PRELIGHT] = { 0.75, 3, 1 }
#}
#class 'GtkIconView' style 'iconview'

#""")
        map = self.__icon.get_colormap()

        colour = map.alloc_color("#FFF9E9") # light red

        style = self.__icon.get_style().copy()
        style.base[gtk.STATE_NORMAL] = colour
        self.__icon.set_style(style)


        #self.cellpb = gtk.CellRendererPixbuf()
        #self.cellpb.set_property('cell-background', 'yellow')

        #self.__icon.pack_start(self.cellpb, False)
        #self.__icon.set_attributes(self.cellpb, pixbuf=0)
        self.pack_start(self.scroll, True, True)
        self.scroll.add(self.__icon)
    ### Interface - Public Functions ###

    def set_callback(self, func):

        self.on_select = func
        self.__icon.connect('selection-changed', self.on_select, self.__model, self.__current)
        self.__icon.connect('selection-changed', self.on_select, self.__model, self.__current)


    def add_item(self, name, image, iter=None):
        """
        @param name: str with name of option
        @param image: str with name of image (e.g. sample.svg)
        """

        pixmap_file = os.path.join(self.__pixmap_d, "Preferences" ,image)


        # FIXME: only put the color when is selected
        pixbuf = gtk.gdk.pixbuf_new_from_file (pixmap_file)
        pixbuf2 = gtk.gdk.Pixbuf(gtk.gdk.COLORSPACE_RGB,0,8,40,40)
        pixbuf2.fill(0xAAEEEEFF)
        pixbuf2.composite(pixbuf,0,0,35,35,0,0,1,1,gtk.gdk.INTERP_NEAREST,50)


        self.__model.insert_before(iter,[name, pixbuf])

        #self.__icon.modify_bg(gtk.STATE_PRELIGHT, gtk.gdk.color_parse("blue"))
    def remove_item(self, name):
        self.__model.remove(name)
    ### Private Functions ####

    def __create_icon_list(self):

        iconView = gtk.IconView ()
        self._icons_list.append(iconView)
class ProfileEdit(gtk.HBox):
    def __init__(self, listoption, profile_editor_file=profile_editor):
        gtk.HBox.__init__(self)
        self._toolbar = ToolBarInterface()
        self._toolbar.set_optionlist(listoption)
        self.profile_editor_file = profile_editor_file
        self._proprieties = None
        self._notebook_tools = None
        self._changed = False
        #MAIN SCROLLED
        self._scroolledmain = HIGScrolledWindow()
        #NOTEBOOKEDITABLE :
        self._profilecore = ProfileCore(profile_editor_file)
        self._toolbar.set_profilecore(self._profilecore)

        self.notebook = NotebookEditable(listoption, self._profilecore)
        self._toolbar.set_notebook(self.notebook)
        self.notebook.connect_after('changed', self.update_toolbar)
        self.notebook.connect_after('need-save', self._need_save)
        self.notebook.load_data()
        self.pack_start(self._toolbar.get_toolbar(), False, True, 0)
        self.pack_start(self._scroolledmain, True, True)
        self._scroolledmain.add_with_viewport(self.notebook)
        self.show_all()

    def _need_save(self, action, others, page):
        self._changed = True

    def get_profilecore(self):
        return self._profilecore

    def set_notebook(self, notebook):
        self._notebook_tools = notebook

    def set_proprieties(self, proprieties):
        self._proprieties = proprieties
        proprieties.disable_all()

    def is_changed(self):
        return self._changed

    def update_toolbar(self, action, others, page):
        #print action
        #print others
        #print page
        boxeditable = self.get_box_editable()
        self._toolbar.set_box_editable(boxeditable)
        self._toolbar.update_toolbar()

        #Update Proprieties box
        if self._notebook_tools != None:
            self._notebook_tools.set_current_page(2)

        if boxeditable._old_selected != None:
            #SpecialHBox - Item
            self._proprieties.set_boxeditable(boxeditable)
            self._proprieties.set_item(boxeditable._old_selected)

            log.debug('<<< SpecialHBox Item update')
        elif self.notebook._old_select != None:
            #Notebook_Label
            self._proprieties.set_notebooklabel(self.notebook._old_select)
            self._proprieties.set_boxeditable(boxeditable)
            log.debug('<<< NotebookLabel update')

    def get_box_editable(self):
        current_page = self.notebook.get_current_page()
        current_box = self.notebook.get_nth_page(current_page)
        return current_box

    def save(self):
        self._profilecore.write_file(self.profile_editor_file)
        log.debug('<<< Saving to file %s ' % self.profile_editor_file)

    def create_events(self):
        #....
        pass
Пример #46
0
class TabsIcon(HIGHBox):
    def __init__(self):
        """ Constructor """
        HIGHBox.__init__(self)
        self.scroll = HIGScrolledWindow()
        self._box = HIGHBox()
        self._icons_list = []
        self._tabstruct = TabStruct()
        self.__current = [0]
        self.__model = gtk.ListStore(str, gtk.gdk.Pixbuf)
        #self.__model = gtk.ListStore(str, HIGHBox)
        self.__pixmap_d = Path.pixmaps_dir

        self.__icon = gtk.IconView()
        self.__icon.set_model(self.__model)
        self.__icon.set_text_column(0)
        self.__icon.set_pixbuf_column(1)

        self.__icon.set_orientation(gtk.ORIENTATION_VERTICAL)
        self.__icon.set_selection_mode(gtk.SELECTION_SINGLE)

        # Change background color -- FIXME
        #self.__icon.set_name("icon tabs")
        #gtk.rc_parse_string(
        #"""
        #style "iconview"
        #{
        #bg[PRELIGHT] = { 0.75, 3, 1 }
        #}
        #class 'GtkIconView' style 'iconview'

        #""")
        map = self.__icon.get_colormap()

        colour = map.alloc_color("#FFF9E9")  # light red

        style = self.__icon.get_style().copy()
        style.base[gtk.STATE_NORMAL] = colour
        self.__icon.set_style(style)

        #self.cellpb = gtk.CellRendererPixbuf()
        #self.cellpb.set_property('cell-background', 'yellow')

        #self.__icon.pack_start(self.cellpb, False)
        #self.__icon.set_attributes(self.cellpb, pixbuf=0)
        self.pack_start(self.scroll, True, True)
        self.scroll.add(self.__icon)

    ### Interface - Public Functions ###

    def set_callback(self, func):

        self.on_select = func
        self.__icon.connect('selection-changed', self.on_select, self.__model,
                            self.__current)
        self.__icon.connect('selection-changed', self.on_select, self.__model,
                            self.__current)

    def add_item(self, name, image, iter=None):
        """
        @param name: str with name of option
        @param image: str with name of image (e.g. sample.svg)
        """

        pixmap_file = os.path.join(self.__pixmap_d, "Preferences", image)

        # FIXME: only put the color when is selected
        pixbuf = gtk.gdk.pixbuf_new_from_file(pixmap_file)
        pixbuf2 = gtk.gdk.Pixbuf(gtk.gdk.COLORSPACE_RGB, 0, 8, 40, 40)
        pixbuf2.fill(0xAAEEEEFF)
        pixbuf2.composite(pixbuf, 0, 0, 35, 35, 0, 0, 1, 1,
                          gtk.gdk.INTERP_NEAREST, 50)

        self.__model.insert_before(iter, [name, pixbuf])

        #self.__icon.modify_bg(gtk.STATE_PRELIGHT, gtk.gdk.color_parse("blue"))
    def remove_item(self, name):
        self.__model.remove(name)

    ### Private Functions ####

    def __create_icon_list(self):

        iconView = gtk.IconView()
        self._icons_list.append(iconView)