def create_and_attach_widgets(self):
        self.option_label = HIGSectionLabel('New Option')
        self.attach(self.option_label, 0, 3, 0, 1)

        self.name_label = HIGEntryLabel(_('Name:'))
        self.name_entry = HIGTextEntry()
        self.attach(self.name_label, 0, 1, 1, 2)
        self.attach(self.name_entry, 1, 3, 1, 2)

        self.hint_label = HIGEntryLabel(_('Hint:'))
        self.hint_entry = HIGTextEntry()
        self.attach(self.hint_label, 0, 1, 2, 3)
        self.attach(self.hint_entry, 1, 3, 2, 3)

        self.need_root = gtk.CheckButton(_('Need root'))
        self.attach(self.need_root, 0, 1, 3, 4)

        self.options_label = HIGEntryLabel(_('Options:'))
        hbox = HIGHBox()
        self.options_entry = HIGTextEntry()
        self.insert_arg_button = HIGButton(title='Args', stock='gtk-add')
        self.insert_arg_button.connect('clicked', self.update_args)
        self.attach(self.options_label, 0, 1, 4, 5)
        self.attach(self.options_entry, 1, 2, 4, 5)
        self.attach(self.insert_arg_button, 2, 3, 4, 5)

        self.aguments_label = HIGEntryLabel(_('Arguments:'))
        self.arguments_entry = HIGTextEntry()
        self.arguments_entry.set_editable(False)
        self.attach(self.aguments_label, 0, 1, 5, 6)
        self.attach(self.arguments_entry, 1, 3, 5, 6)
Beispiel #2
0
    def __create_widgets(self):

        self.general_hbox = HIGHBox()
        self.version_hbox = HIGHBox()

        ################
        #Version Section
        self.version_section = HIGSectionLabel(_("Version"))
        self.version_table = HIGTable()
        self.version_label = HIGEntryLabel(_("Software Version:"))
        self.version2_label = HIGEntryLabel()
        self.testver_label = HIGEntryLabel(_("Service Test Version:"))
        self.testver2_label = HIGEntryLabel()
        self.attribute_label = HIGEntryLabel(_("Agent Attribute:"))
        self.attribute2_label = HIGEntryLabel()

        ################
        #General Section
        self.general_section = HIGSectionLabel(_("General"))
        self.general_table = HIGTable()

        self.startup_check = gtk.CheckButton(
            _("Startup OpenMonitor on system startup"))
        self.notification_check = gtk.CheckButton(
            _("Show Desktop Notifications"))
        self.login_ckeck = gtk.CheckButton(_("Enable Auto login"))
    def __create_widgets(self):
        """"""

        self.update_switch_hbox = HIGHBox()
        self.update_settings_hbox = HIGHBox()
        self.update_db_hbox = HIGHBox()

        self.update_switch_section = HIGSectionLabel(_("Update News Detect"))
        self.update_switch_table = HIGTable()
        self.update_settings_section = HIGSectionLabel(_("Update Settings"))
        self.update_settings_table = HIGTable()
        self.update_db_section = HIGSectionLabel(_("Update Database"))
        self.update_db_table = HIGTable()

        self.update_check = gtk.CheckButton(_("Automatically update"))
        self.update_switch_check = gtk.CheckButton(
            _("Software Update Detect Switch"))
        self.update_times_label = HIGEntryLabel(_("Auto detect update news"))
        self.update_method_label = HIGEntryLabel(_("Update method"))

        self.update_time_store = gtk.ListStore(str)
        self.update_time_entry = gtk.ComboBoxEntry(self.update_time_store, 0)
        self.update_method_store = gtk.ListStore(str)
        self.update_method_entry = gtk.ComboBoxEntry(self.update_method_store,
                                                     0)

        self.update_db_label = HIGEntryLabel()
        self.update_db_clear_button = gtk.Button(_("Clear Update Information"))
class HIGExpanderRNet(gtk.Expander):
    def __init__(self, label=''):
        gtk.Expander.__init__(self)

        self.__label = HIGSectionLabel(label)
        self.set_label_widget(self.__label)

        self.__alignment = gtk.Alignment(0, 0, 1, 1)
        self.__alignment.set_padding(12, 0, 24, 0)

        self.add(self.__alignment)


    def _set_label_text(self, text):
        self.__label._set_text(text)


    def _add(self, widget):
        if len(self.__alignment.get_children()) > 0:
            self.__alignment.remove(self.__alignment.get_children()[0])

        self.__alignment.add(widget)


    def _no_padding(self):
        self.__alignment.set_padding(0, 0, 0, 0)
Beispiel #5
0
    def __create_widgets(self):
        """
        """
        self.__content = HIGVBox()
        self.__head = HIGHBox(spacing=2)

        self.__notebook = NodeNotebook(self.__node)

        # create head elements

        # icon with node's score color
        self.__color_box = gtk.EventBox()
        self.__color_image = gtk.Image()
        self.__color_image.set_from_file(self.__icon.get_icon('border'))
        self.__color_box.add(self.__color_image)
        self.__color_box.set_size_request(15, 15)
        r, g, b = drawing.cairo_to_gdk_color(
            self.__node.get_draw_info('color'))
        self.__color_box.modify_bg(gtk.STATE_NORMAL, gtk.gdk.Color(r, g, b))

        # title with the node ip and hostname
        self.__title = ""

        if self.__node.get_info('hostname') is not None:
            self.__title = self.__node.get_info('hostname') + ' - '

        self.__title += self.__node.get_info('ip')

        self.__title_label = HIGSectionLabel(self.__title)
        self.__title_label.modify_font(self.__title_font)

        # icon to collapse window
        self.__collapse_box = gtk.EventBox()
        self.__collapse_img = gtk.Image()
        self.__collapse_img.set_from_file(self.__icon.get_icon('collapse'))
        self.__collapse_box.add(self.__collapse_img)
        self.__collapse_box.connect('button_press_event', self.collapse_window)
        self.__collapse_box.add_events(gtk.gdk.BUTTON_PRESS_MASK)

        # icon to close window
        self.__close_box = gtk.EventBox()
        self.__close_img = gtk.Image()
        self.__close_img.set_from_file(self.__icon.get_icon('close'))
        self.__close_box.add(self.__close_img)
        self.__close_box.connect('button_press_event', self.close_window)
        self.__close_box.add_events(gtk.gdk.BUTTON_PRESS_MASK)

        # packing head elements
        self.__head._pack_noexpand_nofill(self.__color_box)
        self.__head._pack_expand_fill(self.__title_label)
        self.__head._pack_noexpand_nofill(self.__collapse_box)
        self.__head._pack_noexpand_nofill(self.__close_box)

        # packing all to content
        self.__content._pack_noexpand_nofill(self.__head)
        self.__content._pack_expand_fill(self.__notebook)

        # add context to window
        self.add(self.__content)
    def __init__(self, label=''):
        gtk.Expander.__init__(self)

        self.__label = HIGSectionLabel(label)
        self.set_label_widget(self.__label)

        self.__alignment = gtk.Alignment(0, 0, 1, 1)
        self.__alignment.set_padding(12, 0, 24, 0)

        self.add(self.__alignment)
Beispiel #7
0
    def __create_widgets(self):
        """"""
        self.peerinfo_hbox = HIGHBox()
        self.cloudagg_hbox = HIGHBox()
        self.superpeers_hbox = HIGHBox()
        self.pref_location_hbox = HIGHBox()

        self.peerinfo_section = HIGSectionLabel(_("Peer Info"))
        self.peerinfo_table = HIGTable()

        self.pref_location_section = HIGSectionLabel(_("Preferred Locations"))
        self.pref_location_table = HIGTable()

        self.cloudagg_section = HIGSectionLabel(_("Cloud Aggregator"))
        self.cloudagg_table = HIGTable()
        self.cloudagg_subhbox = HIGHBox()
        self.superpeers_section = HIGSectionLabel(_("Super Peers"))
        self.superpeers_table = HIGTable()

        self.peerid_label = HIGEntryLabel(_("Peer ID:"))
        self.email_label = HIGEntryLabel(_("Email Address:"))
        self.test_version_label = HIGEntryLabel(_("Test Sets Version:"))
        self.peerid_label2 = HIGEntryLabel()
        self.email_entry = gtk.Entry()
        self.test_version_label2 = HIGEntryLabel()

        self.longitude_label = HIGLabel(_("longitude:"))
        self.longitude_entry = gtk.Entry()
        self.latitude_label = HIGLabel(_("latitude:"))
        self.latitude_entry = gtk.Entry()

        self.cloudagg_entry = gtk.Entry()
        self.cloudagg_button = HIGButton(_("Reset"))
        self.cloudagg_button.connect('clicked',
                                     lambda w: self.reset_aggregator_url())

        self.cloudagg_button.set_size_request(80, 28)

        self.superpeers_ip_label = HIGLabel(_("IP:"))
        self.superpeers_ip_entry = gtk.Entry()
        self.superpeers_ip_entry.set_size_request(160, 26)
        self.superpeers_port_label = HIGLabel(_("Port:"))
        self.superpeers_port_entry = gtk.Entry()
        self.superpeers_port_entry.set_size_request(80, 26)

        self.superpeers_subhbox = HIGHBox()
        self.btn_box = gtk.HButtonBox()
        self.superpeers_button1 = HIGButton(_("Add"))
        self.superpeers_button1.connect('clicked',
                                        lambda w: self.add_superpeer())

        self.superpeers_button2 = HIGButton(_("Show all"))
        self.superpeers_button2.connect(
            'clicked', lambda w: self.show_super_peer_list_window())
    def create_and_attach_widgets(self):
        self.option_label = HIGSectionLabel('New Option')
        self.attach(self.option_label, 0, 3, 0, 1)

        self.name_label = HIGEntryLabel(_('Name:'))
        self.name_entry = HIGTextEntry()
        self.attach(self.name_label, 0,1,1,2)
        self.attach(self.name_entry, 1,3,1,2)

        self.hint_label = HIGEntryLabel(_('Hint:'))
        self.hint_entry = HIGTextEntry()
        self.attach(self.hint_label, 0,1,2,3)
        self.attach(self.hint_entry,1,3,2,3)

        self.need_root = gtk.CheckButton(_('Need root'))
        self.attach(self.need_root, 0,1,3,4)	



        self.options_label = HIGEntryLabel(_('Options:'))
        hbox = HIGHBox()
        self.options_entry = HIGTextEntry()
        self.insert_arg_button = HIGButton(title='Args', stock='gtk-add')
        self.insert_arg_button.connect('clicked', self.update_args)
        self.attach(self.options_label,0,1,4,5)
        self.attach(self.options_entry, 1,2,4,5)
        self.attach(self.insert_arg_button, 2,3, 4, 5)

        self.aguments_label = HIGEntryLabel(_('Arguments:'))
        self.arguments_entry = HIGTextEntry()
        self.arguments_entry.set_editable(False)
        self.attach(self.aguments_label, 0,1, 5,6)
        self.attach(self.arguments_entry, 1,3,5,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))
Beispiel #10
0
 def _create_widgets(self):
     self.hbox = HIGHBox()
     self.lbl_diff = HIGSectionLabel("<b>%s</b>" % _("Diff Result"))
     self.scrolled = gtk.ScrolledWindow()
     self.txt_diff_result = gtk.TextView()
     self.txg_tag = gtk.TextTag("diff_style")
     self.txg_added = gtk.TextTag('added style')
     self.txg_removed = gtk.TextTag('removed style')
Beispiel #11
0
    def __create_widgets(self):
        """
        """
        self.__content = HIGVBox()
        self.__head = HIGHBox(spacing=2)

        self.__notebook = NodeNotebook(self.__node)

        # create head elements

        # icon with node's score color
        self.__color_box = gtk.EventBox()
        self.__color_image = gtk.Image()
        self.__color_image.set_from_file(self.__icon.get_icon('border'))
        self.__color_box.add(self.__color_image)
        self.__color_box.set_size_request(15, 15)
        r, g, b = drawing.cairo_to_gdk_color(self.__node.get_draw_info('color'))
        self.__color_box.modify_bg(gtk.STATE_NORMAL, gtk.gdk.Color(r, g, b))

        # title with the node ip and hostname
        self.__title = ""

        if self.__node.get_info('hostname') is not None:
            self.__title = self.__node.get_info('hostname') + ' - '

        self.__title += self.__node.get_info('ip')

        self.__title_label = HIGSectionLabel(self.__title)
        self.__title_label.modify_font(self.__title_font)

        # icon to collapse window
        self.__collapse_box = gtk.EventBox()
        self.__collapse_img = gtk.Image()
        self.__collapse_img.set_from_file(self.__icon.get_icon('collapse'))
        self.__collapse_box.add(self.__collapse_img)
        self.__collapse_box.connect('button_press_event', self.collapse_window)
        self.__collapse_box.add_events(gtk.gdk.BUTTON_PRESS_MASK)

        # icon to close window
        self.__close_box = gtk.EventBox()
        self.__close_img = gtk.Image()
        self.__close_img.set_from_file(self.__icon.get_icon('close'))
        self.__close_box.add(self.__close_img)
        self.__close_box.connect('button_press_event', self.close_window)
        self.__close_box.add_events(gtk.gdk.BUTTON_PRESS_MASK)

        # packing head elements
        self.__head._pack_noexpand_nofill(self.__color_box)
        self.__head._pack_expand_fill(self.__title_label)
        self.__head._pack_noexpand_nofill(self.__collapse_box)
        self.__head._pack_noexpand_nofill(self.__close_box)

        # packing all to content
        self.__content._pack_noexpand_nofill(self.__head)
        self.__content._pack_expand_fill(self.__notebook)

        # add context to window
        self.add(self.__content)
Beispiel #12
0
 def _create_widgets(self):
     self.diff_box = HIGHBox()
     self.diff_title = HIGSectionLabel("Comparison")
     self.diff_scrolled = gtk.ScrolledWindow()
     self.diff_tree = gtk.TreeStore(str, str, str, str, str, str)
     self.diff_view = gtk.TreeView(self.diff_tree)
     self.diff_column1 = gtk.TreeViewColumn("")
     self.diff_column2 = gtk.TreeViewColumn(_("Section"))
     self.diff_column3 = gtk.TreeViewColumn(_("Property"))
     self.diff_column4 = gtk.TreeViewColumn(_("Original value"))
     self.diff_column5 = gtk.TreeViewColumn(_("Current value"))
     self.diff_cell = gtk.CellRendererText()
Beispiel #13
0
 def _create_widgets(self):
     self.lbl_scan = HIGSectionLabel("%s %s" %
                                     (_("Scan Result"), str(self.num)))
     self.hbox = HIGHBox()
     self.table = HIGTable()
     self.list_scan = gtk.ListStore(str)
     self.combo_scan = gtk.ComboBoxEntry(self.list_scan, 0)
     self.btn_open_scan = gtk.Button(stock=gtk.STOCK_OPEN)
     self.exp_scan = gtk.Expander(_("Scan Result Visualization"))
     self.scrolled = gtk.ScrolledWindow()
     self.txt_scan_result = gtk.TextView()
     self.txg_tag = gtk.TextTag("scan_style")
Beispiel #14
0
    def _create_widgets(self):
        self.opt_vbox = HIGVBox()
        self.opt_local_hbox = HIGHBox()
        self.opt_base_hbox = HIGHBox()
        self.opt_local_section = HIGSectionLabel(_("Local files"))
        self.opt_local_table = HIGTable()
        self.opt_base_section = HIGSectionLabel(_("Database"))
        self.opt_base_table = HIGTable()

        self.opt_path_label = HIGEntryLabel(_("Directory"))
        self.opt_extension_label = HIGEntryLabel(_("File extension"))
        self.opt_savetime_label = HIGEntryLabel(_("Save results for"))

        self.opt_path_entry = PathEntry()
        self.opt_extension_entry = gtk.Entry()
        self.opt_savetime_entry = SaveTime()
        self.opt_save_check = gtk.CheckButton(
            _("Save scan results in data \
base for latter search"))
        self.opt_search_check = gtk.CheckButton(
            _("Search saved scan results \
in data base"))
    def __create_widgets(self):
        """"""
        self.timer_hbox = HIGHBox()
        self.timer_section = HIGSectionLabel(_("Timeout Setting (seconds)"))
        self.timer_table = HIGTable()
        self.other_hbox = HIGHBox()
        self.other_section = HIGSectionLabel(_("Others"))
        self.other_table = HIGTable()

        self.task_assign_label = HIGEntryLabel(_("Task Assign"))
        self.task_scheduler_label = HIGEntryLabel(_("Task Scheduler"))
        self.report_uploader_label = HIGEntryLabel(_("Report Uploader"))
        self.test_fetch_label = HIGEntryLabel(_("Test sets Fetch"))

        self.task_assign_entry = gtk.Entry()
        self.task_scheduler_entry = gtk.Entry()
        self.report_uploader_entry = gtk.Entry()
        self.test_fetch_entry = gtk.Entry()

        self.language_label = HIGEntryLabel(_("Language"))
        self.language_store = gtk.ListStore(str)
        self.language_entry = gtk.ComboBoxEntry(self.language_store, 0)
    def __init__(self):
        HIGWindow.__init__(self)

        self.tooltips = gtk.Tooltips()
        self.data_lbl = HIGSectionLabel(_("Delete data older than"))
        self.days_lbl = HIGSectionLabel(_("days"))
        self.days = gtk.SpinButton(
            gtk.Adjustment(value=get_decays()[1],
                           lower=0,
                           upper=5000,
                           step_incr=1), 1)

        self.tooltips.set_tip(self.days,
                              _("Set value as 0 to disable data removal"))

        self.cancel = HIGButton(stock=gtk.STOCK_CANCEL)
        self.apply = HIGButton(stock=gtk.STOCK_APPLY)

        self.cancel.connect("clicked", self._exit)
        self.apply.connect("clicked", self._set_new_decay)

        self.__set_props()
        self.__do_layout()
    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)
Beispiel #18
0
class OptionDisplay(HIGTable):
    def __init__(self, option=None):
        HIGTable.__init__(self)
        self.create_and_attach_widgets()
        self.set_border_width(5)
        self.arg_type=None

    def create_and_attach_widgets(self):
        self.option_label = HIGSectionLabel('New Option')
        self.attach(self.option_label, 0, 3, 0, 1)

        self.name_label = HIGEntryLabel(_('Name:'))
        self.name_entry = HIGTextEntry()
        self.attach(self.name_label, 0,1,1,2)
        self.attach(self.name_entry, 1,3,1,2)

        self.hint_label = HIGEntryLabel(_('Hint:'))
        self.hint_entry = HIGTextEntry()
        self.attach(self.hint_label, 0,1,2,3)
        self.attach(self.hint_entry,1,3,2,3)

        self.need_root = gtk.CheckButton(_('Need root'))
        self.attach(self.need_root, 0,1,3,4)	



        self.options_label = HIGEntryLabel(_('Options:'))
        hbox = HIGHBox()
        self.options_entry = HIGTextEntry()
        self.insert_arg_button = HIGButton(title='Args', stock='gtk-add')
        self.insert_arg_button.connect('clicked', self.update_args)
        self.attach(self.options_label,0,1,4,5)
        self.attach(self.options_entry, 1,2,4,5)
        self.attach(self.insert_arg_button, 2,3, 4, 5)

        self.aguments_label = HIGEntryLabel(_('Arguments:'))
        self.arguments_entry = HIGTextEntry()
        self.arguments_entry.set_editable(False)
        self.attach(self.aguments_label, 0,1, 5,6)
        self.attach(self.arguments_entry, 1,3,5,6)


    def update_args(self, widget):
        '''
        Update aguments entry and option entry
        '''

        cursor_index = self.options_entry.get_position()
        text_entry = self.options_entry.get_text()
        arg_description, arg_key = self.dialog_args()
        if arg_key != None :
            #Update arguments

            self.arg_type = arg_key
            if text_entry.find('%s') == -1: 
                left = text_entry[0:cursor_index]
                right = text_entry[cursor_index:len(text_entry)]
                final = left + "%s" + right
                self.options_entry.set_text(final)
            self.arguments_entry.set_text(arg_description)


    def dialog_args(self):
        '''
        Create a dialog
        '''

        d = HIGDialog(_('Arguments'))
        description_label = HIGEntryLabel(
            _('Insert the description to argument:'))
        description_label.show()
        description_entry = HIGTextEntry()
        text = self.arguments_entry.get_text()
        description_entry.set_text(text)
        description_entry.show()

        combo_box = gtk.combo_box_new_text()
        combo_box.set_wrap_width(1)
        index = -1 
        j = 0 
        for i in ARG_TYPES:
            combo_box.append_text(ARG_TYPES[i])
            if i == self.arg_type:
                index = j 
            j = j + 1
        if index > -1 : 
            combo_box.set_active(index)
        combo_box.show()
        d.vbox.pack_start(description_label, False, False)
        d.vbox.pack_start(description_entry, False, False)
        d.vbox.pack_start(combo_box, False, False)
        d.add_button(gtk.STOCK_CANCEL, gtk.RESPONSE_CANCEL)
        d.add_button(gtk.STOCK_OK, gtk.RESPONSE_OK)
        resp = d.run()
        result  = None, None 
        if resp == gtk.RESPONSE_OK:
            model = combo_box.get_model()
            active = combo_box.get_active()
            if active < 0:
                return None, None 
            combo_selected =  model[active][0]

            for i in ARG_TYPES:
                if combo_selected == ARG_TYPES[i]:
                    combo_selected = i

            result = description_entry.get_text(), combo_selected
            #self.insert_arg_button.set_label('Edit args')
            #self.insert_arg_button.
        d.destroy()
        return result 

    def clear(self):
        """ 
        Clear Option Display
        """
        self.option_label.set_new_text('New Option')
        self.name_entry.set_text('')
        self.hint_entry.set_text('')
        self.arguments_entry.set_text('')
        self.need_root.set_active(False)
        self.options_entry.set_text('')


    def set_option_list(self, list):
        """
        set option list from a dictionarie 

        @param list: Elements of a option
        @type list: Dictionarie with elements
        """
        self.clear()
        self.option_label.set_new_text(list['name'])
        self.name_entry.set_text(list['name'])
        self.hint_entry.set_text(list['hint'])

        for i in list['arguments']:
            i = self.arguments_entry.get_text() + i
            self.arguments_entry.set_text(i)

        self.options_entry.set_text(list['option'])
        self.need_root.set_active(list['need_root'])
        self.arg_type = list['arg_type']


    def set_option(self,name, hint,
                   arguments, need_root,
                   options, arg_type):
        """
        fill fields
        buggy arguments.
        """
        self.clear()
        self.options_entry.set_label(name)
        self.name_entry.set_text(name)
        self.hint_entry.set_text(hint)
        self.arguments_entry.set_text(arguments)
        self.need_root.set_active(need_root)
        self.arg_type = arg_type
class OptionDisplay(HIGTable):
    def __init__(self, option=None):
        HIGTable.__init__(self)
        self.create_and_attach_widgets()
        self.set_border_width(5)
        self.arg_type = None

    def create_and_attach_widgets(self):
        self.option_label = HIGSectionLabel('New Option')
        self.attach(self.option_label, 0, 3, 0, 1)

        self.name_label = HIGEntryLabel(_('Name:'))
        self.name_entry = HIGTextEntry()
        self.attach(self.name_label, 0, 1, 1, 2)
        self.attach(self.name_entry, 1, 3, 1, 2)

        self.hint_label = HIGEntryLabel(_('Hint:'))
        self.hint_entry = HIGTextEntry()
        self.attach(self.hint_label, 0, 1, 2, 3)
        self.attach(self.hint_entry, 1, 3, 2, 3)

        self.need_root = gtk.CheckButton(_('Need root'))
        self.attach(self.need_root, 0, 1, 3, 4)

        self.options_label = HIGEntryLabel(_('Options:'))
        hbox = HIGHBox()
        self.options_entry = HIGTextEntry()
        self.insert_arg_button = HIGButton(title='Args', stock='gtk-add')
        self.insert_arg_button.connect('clicked', self.update_args)
        self.attach(self.options_label, 0, 1, 4, 5)
        self.attach(self.options_entry, 1, 2, 4, 5)
        self.attach(self.insert_arg_button, 2, 3, 4, 5)

        self.aguments_label = HIGEntryLabel(_('Arguments:'))
        self.arguments_entry = HIGTextEntry()
        self.arguments_entry.set_editable(False)
        self.attach(self.aguments_label, 0, 1, 5, 6)
        self.attach(self.arguments_entry, 1, 3, 5, 6)

    def update_args(self, widget):
        '''
        Update aguments entry and option entry
        '''

        cursor_index = self.options_entry.get_position()
        text_entry = self.options_entry.get_text()
        arg_description, arg_key = self.dialog_args()
        if arg_key != None:
            #Update arguments

            self.arg_type = arg_key
            if text_entry.find('%s') == -1:
                left = text_entry[0:cursor_index]
                right = text_entry[cursor_index:len(text_entry)]
                final = left + "%s" + right
                self.options_entry.set_text(final)
            self.arguments_entry.set_text(arg_description)

    def dialog_args(self):
        '''
        Create a dialog
        '''

        d = HIGDialog(_('Arguments'))
        description_label = HIGEntryLabel(
            _('Insert the description to argument:'))
        description_label.show()
        description_entry = HIGTextEntry()
        text = self.arguments_entry.get_text()
        description_entry.set_text(text)
        description_entry.show()

        combo_box = gtk.combo_box_new_text()
        combo_box.set_wrap_width(1)
        index = -1
        j = 0
        for i in ARG_TYPES:
            combo_box.append_text(ARG_TYPES[i])
            if i == self.arg_type:
                index = j
            j = j + 1
        if index > -1:
            combo_box.set_active(index)
        combo_box.show()
        d.vbox.pack_start(description_label, False, False)
        d.vbox.pack_start(description_entry, False, False)
        d.vbox.pack_start(combo_box, False, False)
        d.add_button(gtk.STOCK_CANCEL, gtk.RESPONSE_CANCEL)
        d.add_button(gtk.STOCK_OK, gtk.RESPONSE_OK)
        resp = d.run()
        result = None, None
        if resp == gtk.RESPONSE_OK:
            model = combo_box.get_model()
            active = combo_box.get_active()
            if active < 0:
                return None, None
            combo_selected = model[active][0]

            for i in ARG_TYPES:
                if combo_selected == ARG_TYPES[i]:
                    combo_selected = i

            result = description_entry.get_text(), combo_selected
            #self.insert_arg_button.set_label('Edit args')
            #self.insert_arg_button.
        d.destroy()
        return result

    def clear(self):
        """ 
        Clear Option Display
        """
        self.option_label.set_new_text('New Option')
        self.name_entry.set_text('')
        self.hint_entry.set_text('')
        self.arguments_entry.set_text('')
        self.need_root.set_active(False)
        self.options_entry.set_text('')

    def set_option_list(self, list):
        """
        set option list from a dictionarie 

        @param list: Elements of a option
        @type list: Dictionarie with elements
        """
        self.clear()
        self.option_label.set_new_text(list['name'])
        self.name_entry.set_text(list['name'])
        self.hint_entry.set_text(list['hint'])

        for i in list['arguments']:
            i = self.arguments_entry.get_text() + i
            self.arguments_entry.set_text(i)

        self.options_entry.set_text(list['option'])
        self.need_root.set_active(list['need_root'])
        self.arg_type = list['arg_type']

    def set_option(self, name, hint, arguments, need_root, options, arg_type):
        """
        fill fields
        buggy arguments.
        """
        self.clear()
        self.options_entry.set_label(name)
        self.name_entry.set_text(name)
        self.hint_entry.set_text(hint)
        self.arguments_entry.set_text(arguments)
        self.need_root.set_active(need_root)
        self.arg_type = arg_type
Beispiel #20
0
    def _create_widgets(self):
        # Main widgets
        self.hpaned = gtk.HPaned()
        self.main_vbox = HIGVBox()

        # Results section
        self.result_section = HIGSectionLabel(_("Results"))
        self.result_vbox = HIGVBox()
        self.result_hbox = HIGHBox()
        self.result_list = gtk.ListStore(str, str, int) # title, date, id
        self.result_view = gtk.TreeView(self.result_list)
        self.result_scrolled = gtk.ScrolledWindow()
        self.result_title_column = gtk.TreeViewColumn(_("Scan"))
        self.result_date_column = gtk.TreeViewColumn(_("Date"))

        # Search notebook
        self.search_vbox = HIGVBox()
        self.search_notebook = gtk.Notebook()
        self.search_button = HIGButton(stock=gtk.STOCK_FIND)

        # General page
        self.general_vbox = HIGVBox()
        self.general_hbox = HIGHBox()
        #self.general_start_hbox = HIGHBox()
        #self.general_finish_hbox = HIGHBox()
        
        self.general_section = HIGSectionLabel(_("General search parameters"))
        
        self.general_table = HIGTable()

        self.general_option_label = HIGEntryLabel(_("Option"))
        self.general_profile_label = HIGEntryLabel(_("Profile"))
        #self.general_finished_label = HIGEntryLabel(_("Finished"))
        #self.general_started_label = HIGEntryLabel(_("Started"))
        self.general_keyword_label = HIGEntryLabel(_("Keyword"))

        self.general_keyword_entry = gtk.Entry()
        self.general_option_combo = OptionCombo()
        self.general_profile_combo = ProfileCombo()
        #self.general_started_range = DateRange()
        #self.general_finished_range = DateRange()

        # Host page
        self.host_vbox = HIGVBox()
        self.host_hbox = HIGHBox()
        #self.host_uptime_hbox = HIGHBox()
        #self.host_lastboot_hbox = HIGHBox()
        
        self.host_section = HIGSectionLabel(_("Host search parameters"))
        
        self.host_table = HIGTable()

        self.host_target_label = HIGEntryLabel(_("Target"))
        self.host_mac_label = HIGEntryLabel(_("MAC"))
        self.host_ipv4_label = HIGEntryLabel(_("IPv4"))
        self.host_ipv6_label = HIGEntryLabel(_("IPv6"))
        #self.host_uptime_label = HIGEntryLabel(_("Uptime"))
        #self.host_lastboot_label = HIGEntryLabel(_("Last boot"))

        self.host_target_combo = TargetCombo()
        self.host_mac_entry = gtk.Entry()
        self.host_ipv4_entry = gtk.Entry()
        self.host_ipv6_entry = gtk.Entry()
        #self.host_uptime_range = DateRange()
        #self.host_lastboot_range = DateRange()


        # Service
        self.serv_vbox = HIGVBox()
        self.serv_hbox = HIGHBox()
        self.serv_section = HIGSectionLabel(_("Service search parameters"))
        self.serv_table = HIGTable()

        self.serv_port_label = HIGEntryLabel(_("Port number"))
        self.serv_service_label = HIGEntryLabel(_("Service"))
        self.serv_product_label = HIGEntryLabel(_("Product"))
        self.serv_portstate_label = HIGEntryLabel(_("Port state"))
        
        self.serv_port_entry = gtk.Entry()
        self.serv_service_combo = ServiceCombo()
        self.serv_product_entry = gtk.Entry()
        self.serv_portstate_check = PortState()


        # OS
        self.os_vbox = HIGVBox()
        self.os_hbox = HIGHBox()
        self.os_section = HIGSectionLabel(_("Operating System search \
parameters"))
        self.os_table = HIGTable()
        
        self.os_osclass_label = HIGEntryLabel(_("OS class"))
        self.os_osmatch_label = HIGEntryLabel(_("OS match"))
        
        self.os_osclass_combo = OSClassCombo()
        self.os_osmatch_combo = OSMatchCombo()


        # Search options page
        self.opt_vbox = HIGVBox()
        self.opt_local_hbox = HIGHBox()
        self.opt_base_hbox = HIGHBox()
        self.opt_local_section = HIGSectionLabel(_("Local files"))
        self.opt_local_table = HIGTable()
        self.opt_base_section = HIGSectionLabel(_("Database"))
        self.opt_base_table = HIGTable()

        self.opt_path_label = HIGEntryLabel(_("Directory"))
        self.opt_extension_label = HIGEntryLabel(_("File extension"))
        self.opt_savetime_label = HIGEntryLabel(_("Save results for"))

        self.opt_path_entry = PathEntry()
        self.opt_extension_entry = gtk.Entry()
        self.opt_savetime_entry = SaveTime()
        self.opt_save_check = gtk.CheckButton(_("Save scan results in data \
base for latter search"))
        self.opt_search_check = gtk.CheckButton(_("Search saved scan results \
in data base"))
    def __create_widgets(self):
        self.suggestion_hbox = HIGHBox()
        self.report_hbox = HIGHBox()

        self.suggestion_section = HIGSectionLabel(_("Test Suggestion"))
        self.suggestion_table = HIGTable()
        self.report_section = HIGSectionLabel(_("Bug Report"))
        self.report_table = HIGTable()

        # Website Suggestion
        self.website_suggestion_table = HIGTable()
        self.website_suggestion_slabel = HIGSectionLabel(
            _("Website Suggestion"))
        self.website_url_subhbox = HIGHBox()
        self.website_url_label = HIGEntryLabel(_("URL:"))
        self.website_url_entry = gtk.Entry()
        self.website_suggestion_sendbtn = HIGButton(_('Send'))
        self.website_suggestion_sendbtn.set_size_request(60, 25)
        self.website_suggestion_sendbtn.connect(
            'clicked', lambda x: self.send_website_suggestion())
        # Service Suggestion
        self.service_suggestion_table = HIGTable()
        self.service_suggestion_slabel = HIGSectionLabel(
            _("Service Suggestion"))
        self.service_name_subhbox = HIGHBox()
        self.service_name_label = HIGEntryLabel(_("Name:"))
        self.service_list_store = gtk.ListStore(str)
        self.service_name_entry = gtk.ComboBoxEntry(self.service_list_store, 0)
        self.service_host_subhbox = HIGHBox()
        self.service_host_label = HIGEntryLabel(_("Hostname:"))
        self.service_host_entry = gtk.Entry()
        self.service_ip_subhbox = HIGHBox()
        self.service_ip_label = HIGEntryLabel(_("IP:"))
        self.service_ip_entry = gtk.Entry()
        self.service_port_label = HIGEntryLabel(_("PORT:"))
        self.service_port_entry = gtk.Entry()
        self.service_suggestion_sendbtn = HIGButton(_('Send'))
        self.service_suggestion_sendbtn.set_size_request(60, 25)
        self.service_suggestion_sendbtn.connect(
            'clicked', lambda x: self.send_service_suggestion())

        self.report_namelabel = HIGEntryLabel(_("Your Name:"))
        self.report_nameentry = gtk.Entry()
        #self.report_nameentry.set_has_frame(True)
        self.report_nameentry.set_size_request(100, 26)
        self.report_emaillabel = HIGEntryLabel(_("Email:"))
        self.report_emailentry = gtk.Entry()
        self.report_emailentry.set_size_request(198, 26)
        self.report_subhbox1 = HIGHBox()

        self.report_sw = gtk.ScrolledWindow()
        self.report_sw.set_policy(gtk.POLICY_AUTOMATIC, gtk.POLICY_AUTOMATIC)
        self.report_textview = gtk.TextView()
        self.report_textbuffer = self.report_textview.get_buffer()
        self.report_textview.set_editable(True)
        self.report_textview.set_wrap_mode(True)
        self.report_textview.set_border_width(2)
        self.report_sw.add(self.report_textview)
        self.report_sw.show()
        self.report_textview.show()
        self.report_subhbox2 = HIGHBox()
        self.report_sendbtn = HIGButton(_('Send'))
        self.report_sendbtn.set_size_request(60, 25)
        self.report_sendbtn.connect('clicked',
                                    lambda x: self.send_bug_report())
        self.report_subhbox3 = HIGHBox()
Beispiel #22
0
class NodeWindow(HIGWindow):
    """
    """
    def __init__(self, node, position, parent):
        """
        """
        HIGWindow.__init__(self, gtk.WINDOW_POPUP)
        self.set_decorated(False)
        self.set_keep_above(True)
        self.set_skip_taskbar_hint(True)
        self.move(position[0], position[1])
        self.set_size_request(DIMENSION_NORMAL[0], DIMENSION_NORMAL[1])

        self.__button_press_position = self.get_pointer()

        self.__is_compacted = True
        self.__is_collapsed = False

        self.__node = node
        self.__pressed = False
        self.__parent = parent

        self.connect('button_press_event', self.button_press)
        self.connect('button_release_event', self.button_release)
        self.connect('enter_notify_event', self.enter_notify)
        self.connect('leave_notify_event', self.leave_notify)
        self.connect('motion_notify_event', self.motion_notify)

        self.__title_font = pango.FontDescription('Monospace Bold')

        self.add_events(gtk.gdk.BUTTON_PRESS_MASK |
                        gtk.gdk.BUTTON_RELEASE_MASK |
                        gtk.gdk.POINTER_MOTION_MASK |
                        gtk.gdk.ENTER_NOTIFY |
                        gtk.gdk.LEAVE_NOTIFY |
                        gtk.gdk.POINTER_MOTION_HINT_MASK)

        self.__icon = Application()
        self.__create_widgets()


    def __create_widgets(self):
        """
        """
        self.__content = HIGVBox()
        self.__head = HIGHBox(spacing=2)

        self.__notebook = NodeNotebook(self.__node)

        # create head elements

        # icon with node's score color
        self.__color_box = gtk.EventBox()
        self.__color_image = gtk.Image()
        self.__color_image.set_from_file(self.__icon.get_icon('border'))
        self.__color_box.add(self.__color_image)
        self.__color_box.set_size_request(15, 15)
        r, g, b = drawing.cairo_to_gdk_color(self.__node.get_draw_info('color'))
        self.__color_box.modify_bg(gtk.STATE_NORMAL, gtk.gdk.Color(r, g, b))

        # title with the node ip and hostname
        self.__title = ""

        if self.__node.get_info('hostname') is not None:
            self.__title = self.__node.get_info('hostname') + ' - '

        self.__title += self.__node.get_info('ip')

        self.__title_label = HIGSectionLabel(self.__title)
        self.__title_label.modify_font(self.__title_font)

        # icon to collapse window
        self.__collapse_box = gtk.EventBox()
        self.__collapse_img = gtk.Image()
        self.__collapse_img.set_from_file(self.__icon.get_icon('collapse'))
        self.__collapse_box.add(self.__collapse_img)
        self.__collapse_box.connect('button_press_event', self.collapse_window)
        self.__collapse_box.add_events(gtk.gdk.BUTTON_PRESS_MASK)

        # icon to close window
        self.__close_box = gtk.EventBox()
        self.__close_img = gtk.Image()
        self.__close_img.set_from_file(self.__icon.get_icon('close'))
        self.__close_box.add(self.__close_img)
        self.__close_box.connect('button_press_event', self.close_window)
        self.__close_box.add_events(gtk.gdk.BUTTON_PRESS_MASK)

        # packing head elements
        self.__head._pack_noexpand_nofill(self.__color_box)
        self.__head._pack_expand_fill(self.__title_label)
        self.__head._pack_noexpand_nofill(self.__collapse_box)
        self.__head._pack_noexpand_nofill(self.__close_box)

        # packing all to content
        self.__content._pack_noexpand_nofill(self.__head)
        self.__content._pack_expand_fill(self.__notebook)

        # add context to window
        self.add(self.__content)


    def close_window(self, widget, event):
        """
        """
        self.__node.set_draw_info({'over':False})
        self.hide()
        self.__parent.queue_draw()

        return True


    def restore(self, x, y):
        """
        """
        self.move(x, y)
        self.show_all()

        self.__is_collapsed = False
        self.resize(DIMENSION_NORMAL[0], DIMENSION_NORMAL[1])
        self.__collapse_img.set_from_file(self.__icon.get_icon('collapse'))


    def collapse_window(self, widget, event):
        """
        """
        self.present()

        if self.__is_collapsed == False:

            self.__notebook.hide()
            self.__is_collapsed = True
            self.set_size_request(DIMENSION_SHADED[0], DIMENSION_SHADED[1])
            self.resize(DIMENSION_SHADED[0], DIMENSION_SHADED[1])
            self.__collapse_img.set_from_file(self.__icon.get_icon('expand'))

        else:

            self.__notebook.show()
            self.__is_collapsed = False
            self.set_size_request(DIMENSION_NORMAL[0], DIMENSION_NORMAL[1])
            self.resize(DIMENSION_NORMAL[0], DIMENSION_NORMAL[1])
            self.__collapse_img.set_from_file(self.__icon.get_icon('collapse'))

        return True


    def button_press(self, widget, event):
        """
        """
        self.present()
        self.__pressed = True
        self.__button_press_position = self.get_pointer()

        return True


    def button_release(self, widget, event):
        """
        """
        self.__pressed = False

        return True


    def enter_notify(self, widget, event):
        """
        """
        self.__node.set_draw_info({'over':True})
        self.__parent.queue_draw()


    def leave_notify(self, widget, event):
        """
        """
        self.set_keep_above(True)
        self.__node.set_draw_info({'over':False})


    def motion_notify(self, widget, event):
        """
        """
        self.__node.set_draw_info({'over':True})

        x, y, button_state = event.window.get_pointer()

        if button_state & gtk.gdk.BUTTON1_MASK and self.__pressed:

            xw, yw = event.window.get_root_origin()
            xd, yd = self.__button_press_position
            self.move(x + xw - xd, y + yw - yd)

        return True
    def __create_widgets(self):
        """
        """
        self.__vbox = HIGVBox()
        self.__vbox.set_border_width(6)

        self.__cell = gtk.CellRendererText()

        self.__general_frame = HIGExpanderRNet('General information')
        self.__sequences_frame = HIGExpanderRNet('Sequences')
        self.__os_frame = HIGExpanderRNet('Operating System')

        self.__sequences_frame._add(gtk.Label('No sequence information.'))
        self.__os_frame._add(gtk.Label('No OS information.'))

        # general information widgets
        self.__general = HIGTableRNet(3, 2)

        self.__address_label = HIGSectionLabel('Address:')
        self.__address_list = gtk.combo_box_entry_new_text()
        self.__address_list.child.set_editable(False)

        for address in self.__node.get_info('addresses'):

            params = address['addrtype'], address['addr']
            address_text = SYSTEM_ADDRESS_TEXT % params

            if address.get('vendor', None):
                address_text += " (%s)" % address['vendor']

            self.__address_list.append_text(address_text)

        self.__address_list.set_active(0)

        self.__general._attach_next(self.__address_label,
                                    yoptions=gtk.FILL,
                                    xoptions=gtk.FILL)
        self.__general._attach_next(self.__address_list, yoptions=gtk.FILL)

        if self.__node.get_info('hostnames') is not None:

            self.__hostname_label = HIGSectionLabel('Hostname:')
            self.__hostname_list = gtk.combo_box_entry_new_text()
            self.__hostname_list.child.set_editable(False)

            for hostname in self.__node.get_info('hostnames'):

                params = hostname['type'], hostname['name']
                self.__hostname_list.append_text(SYSTEM_ADDRESS_TEXT % params)

            self.__hostname_list.set_active(0)

            self.__general._attach_next(self.__hostname_label,
                                        yoptions=gtk.FILL,
                                        xoptions=gtk.FILL)
            self.__general._attach_next(self.__hostname_list,
                                        yoptions=gtk.FILL)

        if self.__node.get_info('uptime') is not None:

            self.__uptime_label = HIGSectionLabel('Last boot:')

            seconds = self.__node.get_info('uptime')['seconds']
            lastboot = self.__node.get_info('uptime')['lastboot']

            text = '%s (%s seconds).' % (lastboot, seconds)

            self.__uptime_value = HIGLabel(text)
            self.__uptime_value.set_selectable(True)
            self.__uptime_value.set_line_wrap(False)

            self.__general._attach_next(self.__uptime_label,
                                        yoptions=gtk.FILL,
                                        xoptions=gtk.FILL)
            self.__general._attach_next(self.__uptime_value,
                                        yoptions=gtk.FILL)

        self.__general_frame._add(self.__general)
        self.__general_frame.set_expanded(True)

        # sequences information widgets
        self.__sequences = HIGTableRNet(5, 3)

        sequences = self.__node.get_info('sequences')

        if len(sequences) > 0:

            self.__sequences.attach(HIGSectionLabel('Class'), 1, 2, 0, 1)
            self.__sequences.attach(HIGSectionLabel('Values'), 2, 3, 0, 1)

            self.__sequences.attach(HIGSectionLabel('TCP *'), 0, 1, 1, 2)
            self.__sequences.attach(HIGSectionLabel('IP ID'), 0, 1, 2, 3)
            self.__sequences.attach(HIGSectionLabel('TCP Timestamp'),
                                    0,
                                    1,
                                    3,
                                    4)

            # tcp sequence values
            tcp = sequences['tcp']

            tcp_class = HIGLabel(tcp.get('class', ''))
            tcp_class.set_selectable(True)

            self.__sequences.attach(tcp_class, 1, 2, 1, 2)

            tcp_values = gtk.combo_box_entry_new_text()

            for value in tcp['values']:
                tcp_values.append_text(value)

            tcp_values.set_active(0)

            self.__sequences.attach(tcp_values, 2, 3, 1, 2)

            tcp_note = HIGLabel()
            tcp_note.set_selectable(True)
            tcp_note.set_line_wrap(False)
            tcp_note.set_alignment(1.0, 0.5)
            if tcp['index']:
                tcp_note.set_markup(
                        TCP_SEQ_NOTE % (tcp['index'], tcp['difficulty']))

            self.__sequences.attach(tcp_note, 0, 3, 4, 5)

            # ip id sequence values
            ip_id = sequences['ip_id']

            ip_id_class = HIGLabel(ip_id['class'])
            ip_id_class.set_selectable(True)

            self.__sequences.attach(ip_id_class, 1, 2, 2, 3)

            ip_id_values = gtk.combo_box_entry_new_text()

            for value in ip_id['values']:
                ip_id_values.append_text(value)

            ip_id_values.set_active(0)

            self.__sequences.attach(ip_id_values, 2, 3, 2, 3)

            # tcp sequence values
            tcp_ts = sequences['tcp_ts']

            tcp_ts_class = HIGLabel(tcp_ts['class'])
            tcp_ts_class.set_selectable(True)

            self.__sequences.attach(tcp_ts_class, 1, 2, 3, 4)

            if tcp_ts.get('values', None) is not None:

                tcp_ts_values = gtk.combo_box_entry_new_text()

                for value in tcp_ts['values']:
                    tcp_ts_values.append_text(value)

                tcp_ts_values.set_active(0)

                self.__sequences.attach(tcp_ts_values, 2, 3, 3, 4)

            self.__sequences_frame._add(self.__sequences)

        # operating system information widgets
        self.__os = gtk.Notebook()
        # XXX Setting this custom positioning causes a hard gtk bug (verified
        # on Windows 7 at least, likely to happen under Vista too. Used
        # gtk 2.14.7 and gtk 2.12.9 both with pygtk 2.12.1).
        #self.__os.set_tab_pos(gtk.POS_LEFT)

        os = self.__node.get_info('os')

        if os is not None:

            if os.has_key('matches'):

                self.__match_scroll = HIGScrolledWindow()

                self.__match_store = gtk.ListStore(gobject.TYPE_INT,
                                                   gobject.TYPE_STRING,
                                                   gobject.TYPE_INT,
                                                   gobject.TYPE_BOOLEAN)

                self.__match_treeview = gtk.TreeView(self.__match_store)

                for os_match in os['matches']:
                    if 'accuracy' not in os_match:
                        # this may happen with older .usr
                        continue
                    self.__match_store.append([os_match['accuracy'],
                                               os_match['name'],
                                               os_match['db_line'],
                                               True])

                self.__match_column = list()

                for i in range(len(OSMATCH_HEADER)):

                    column = gtk.TreeViewColumn(OSMATCH_HEADER[i],
                                                self.__cell,
                                                text = i)

                    self.__match_column.append(column)

                    self.__match_column[i].set_reorderable(True)
                    self.__match_column[i].set_resizable(True)
                    self.__match_column[i].set_attributes(self.__cell,
                                                          text = i,
                                                          editable = 3)

                    self.__match_column[i].set_sort_column_id(i)
                    self.__match_treeview.append_column(self.__match_column[i])

                self.__match_scroll.add_with_viewport(self.__match_treeview)

                self.__os.append_page(self.__match_scroll, HIGLabel('Match'))

            if os.has_key('classes'):

                self.__class_scroll = HIGScrolledWindow()

                self.__class_store = gtk.ListStore(gobject.TYPE_INT,
                                                   gobject.TYPE_STRING,
                                                   gobject.TYPE_STRING,
                                                   gobject.TYPE_STRING,
                                                   gobject.TYPE_STRING,
                                                   gobject.TYPE_BOOLEAN)

                self.__class_treeview = gtk.TreeView(self.__class_store)

                for os_class in os['classes']:

                    os_gen = ''

                    if os_class.has_key('os_gen'):
                        os_gen = os_class['os_gen']

                    self.__class_store.append([os_class['accuracy'],
                                               os_class['vendor'],
                                               os_class['type'],
                                               os_class['os_family'],
                                               os_gen,
                                               True])

                self.__class_column = list()

                for i in range(len(OSCLASS_HEADER)):

                    column = gtk.TreeViewColumn(OSCLASS_HEADER[i],
                                                self.__cell,
                                                text = i)

                    self.__class_column.append(column)

                    self.__class_column[i].set_reorderable(True)
                    self.__class_column[i].set_resizable(True)
                    self.__class_column[i].set_attributes(self.__cell,
                                                          text = i,
                                                          editable = 5)

                    self.__class_column[i].set_sort_column_id(i)
                    self.__class_treeview.append_column(self.__class_column[i])

                self.__class_scroll.add_with_viewport(self.__class_treeview)

                self.__os.append_page(self.__class_scroll, HIGLabel('Class'))

            self.__fp_viewer = HIGTextEditor()
            self.__fp_viewer._modify_font(self.__font)
            self.__fp_viewer._set_editable(False)
            self.__fp_viewer._set_text(os['fingerprint'])

            self.__fp_ports = HIGHBox()
            self.__fp_label = HIGSectionLabel('Used ports:')

            self.__fp_ports_list = gtk.combo_box_entry_new_text()
            self.__fp_ports_list.child.set_editable(False)

            self.__fp_vbox = HIGVBox()

            if os.has_key('used_ports'):

                used_ports = os['used_ports']

                for port in used_ports:

                    params = port['id'], port['protocol'], port['state']
                    self.__fp_ports_list.append_text(USED_PORTS_TEXT % params)

                self.__fp_ports_list.set_active(0)

                self.__fp_ports._pack_noexpand_nofill(self.__fp_label)
                self.__fp_ports._pack_expand_fill(self.__fp_ports_list)

                self.__fp_vbox._pack_noexpand_nofill(self.__fp_ports)

            self.__os.append_page(self.__fp_viewer, HIGLabel('Fingerprint'))
            self.__fp_vbox._pack_expand_fill(self.__os)

            self.__os_frame._add(self.__fp_vbox)
            self.__os_frame.set_expanded(True)

        self.__vbox._pack_noexpand_nofill(self.__general_frame)
        self.__vbox._pack_expand_fill(self.__os_frame)
        self.__vbox._pack_noexpand_nofill(self.__sequences_frame)

        self.add_with_viewport(self.__vbox)
Beispiel #24
0
class NodeWindow(HIGWindow):
    """
    """
    def __init__(self, node, position, parent):
        """
        """
        HIGWindow.__init__(self, gtk.WINDOW_POPUP)
        self.set_decorated(False)
        self.set_keep_above(True)
        self.set_skip_taskbar_hint(True)
        self.move(position[0], position[1])
        self.set_size_request(DIMENSION_NORMAL[0], DIMENSION_NORMAL[1])

        self.__button_press_position = self.get_pointer()

        self.__is_compacted = True
        self.__is_collapsed = False

        self.__node = node
        self.__pressed = False
        self.__parent = parent

        self.connect('button_press_event', self.button_press)
        self.connect('button_release_event', self.button_release)
        self.connect('enter_notify_event', self.enter_notify)
        self.connect('leave_notify_event', self.leave_notify)
        self.connect('motion_notify_event', self.motion_notify)

        self.__title_font = pango.FontDescription('Monospace Bold')

        self.add_events(gtk.gdk.BUTTON_PRESS_MASK | gtk.gdk.BUTTON_RELEASE_MASK
                        | gtk.gdk.POINTER_MOTION_MASK | gtk.gdk.ENTER_NOTIFY
                        | gtk.gdk.LEAVE_NOTIFY
                        | gtk.gdk.POINTER_MOTION_HINT_MASK)

        self.__icon = Application()
        self.__create_widgets()

    def __create_widgets(self):
        """
        """
        self.__content = HIGVBox()
        self.__head = HIGHBox(spacing=2)

        self.__notebook = NodeNotebook(self.__node)

        # create head elements

        # icon with node's score color
        self.__color_box = gtk.EventBox()
        self.__color_image = gtk.Image()
        self.__color_image.set_from_file(self.__icon.get_icon('border'))
        self.__color_box.add(self.__color_image)
        self.__color_box.set_size_request(15, 15)
        r, g, b = drawing.cairo_to_gdk_color(
            self.__node.get_draw_info('color'))
        self.__color_box.modify_bg(gtk.STATE_NORMAL, gtk.gdk.Color(r, g, b))

        # title with the node ip and hostname
        self.__title = ""

        if self.__node.get_info('hostname') is not None:
            self.__title = self.__node.get_info('hostname') + ' - '

        self.__title += self.__node.get_info('ip')

        self.__title_label = HIGSectionLabel(self.__title)
        self.__title_label.modify_font(self.__title_font)

        # icon to collapse window
        self.__collapse_box = gtk.EventBox()
        self.__collapse_img = gtk.Image()
        self.__collapse_img.set_from_file(self.__icon.get_icon('collapse'))
        self.__collapse_box.add(self.__collapse_img)
        self.__collapse_box.connect('button_press_event', self.collapse_window)
        self.__collapse_box.add_events(gtk.gdk.BUTTON_PRESS_MASK)

        # icon to close window
        self.__close_box = gtk.EventBox()
        self.__close_img = gtk.Image()
        self.__close_img.set_from_file(self.__icon.get_icon('close'))
        self.__close_box.add(self.__close_img)
        self.__close_box.connect('button_press_event', self.close_window)
        self.__close_box.add_events(gtk.gdk.BUTTON_PRESS_MASK)

        # packing head elements
        self.__head._pack_noexpand_nofill(self.__color_box)
        self.__head._pack_expand_fill(self.__title_label)
        self.__head._pack_noexpand_nofill(self.__collapse_box)
        self.__head._pack_noexpand_nofill(self.__close_box)

        # packing all to content
        self.__content._pack_noexpand_nofill(self.__head)
        self.__content._pack_expand_fill(self.__notebook)

        # add context to window
        self.add(self.__content)

    def close_window(self, widget, event):
        """
        """
        self.__node.set_draw_info({'over': False})
        self.hide()
        self.__parent.queue_draw()

        return True

    def restore(self, x, y):
        """
        """
        self.move(x, y)
        self.show_all()

        self.__is_collapsed = False
        self.resize(DIMENSION_NORMAL[0], DIMENSION_NORMAL[1])
        self.__collapse_img.set_from_file(self.__icon.get_icon('collapse'))

    def collapse_window(self, widget, event):
        """
        """
        self.present()

        if self.__is_collapsed == False:

            self.__notebook.hide()
            self.__is_collapsed = True
            self.set_size_request(DIMENSION_SHADED[0], DIMENSION_SHADED[1])
            self.resize(DIMENSION_SHADED[0], DIMENSION_SHADED[1])
            self.__collapse_img.set_from_file(self.__icon.get_icon('expand'))

        else:

            self.__notebook.show()
            self.__is_collapsed = False
            self.set_size_request(DIMENSION_NORMAL[0], DIMENSION_NORMAL[1])
            self.resize(DIMENSION_NORMAL[0], DIMENSION_NORMAL[1])
            self.__collapse_img.set_from_file(self.__icon.get_icon('collapse'))

        return True

    def button_press(self, widget, event):
        """
        """
        self.present()
        self.__pressed = True
        self.__button_press_position = self.get_pointer()

        return True

    def button_release(self, widget, event):
        """
        """
        self.__pressed = False

        return True

    def enter_notify(self, widget, event):
        """
        """
        self.__node.set_draw_info({'over': True})
        self.__parent.queue_draw()

    def leave_notify(self, widget, event):
        """
        """
        self.set_keep_above(True)
        self.__node.set_draw_info({'over': False})

    def motion_notify(self, widget, event):
        """
        """
        self.__node.set_draw_info({'over': True})

        x, y, button_state = event.window.get_pointer()

        if button_state & gtk.gdk.BUTTON1_MASK and self.__pressed:

            xw, yw = event.window.get_root_origin()
            xd, yd = self.__button_press_position
            self.move(x + xw - xd, y + yw - yd)

        return True