def __do_layout(self):
        """
        Layout widgets in window.
        """
        main_vbox = HIGVBox()
        main_vbox.set_border_width(5)
        main_vbox.set_spacing(12)
        header_hbox = HIGHBox()
        schema_table = HIGTable()
        auth_table = HIGTable()
        btns_hbox = HIGHBox()

        header_hbox._pack_expand_fill(self.ttitle)
        header_hbox._pack_noexpand_nofill(self.umit_logo)

        # schema name
        schema_table.attach_label(self.schema_name_lbl, 0, 1, 0, 1)
        schema_table.attach_entry(self.schema_name, 1, 2, 0, 1)

        # smtp server
        schema_table.attach_label(self.smtp_server_lbl, 0, 1, 1, 2)
        schema_table.attach_entry(self.smtp_server, 1, 2, 1, 2)

        # smtp server port
        schema_table.attach_label(self.smtp_port_lbl, 0, 1, 2, 3)
        schema_table.attach_entry(self.smtp_port, 1, 2, 2, 3)

        # smtp mail from
        schema_table.attach_label(self.smtp_mailfrom_lbl, 0, 1, 3, 4)
        schema_table.attach_entry(self.smtp_mailfrom, 1, 2, 3, 4)

        # smtp user
        auth_table.attach_label(self.smtp_login_lbl, 0, 1, 0, 1)
        auth_table.attach_entry(self.smtp_login, 1, 2, 0, 1)

        # smtp passwd
        auth_table.attach_label(self.smtp_passwd_lbl, 0, 1, 1, 2)
        auth_table.attach_label(self.smtp_passwd, 1, 2, 1, 2)

        # bottom buttons
        btns_hbox.set_homogeneous(True)
        btns_hbox._pack_expand_fill(self.help)
        btns_hbox._pack_expand_fill(hig_box_space_holder())
        btns_hbox._pack_expand_fill(self.apply)
        btns_hbox._pack_expand_fill(self.cancel)
        btns_hbox._pack_expand_fill(self.ok)

        main_vbox._pack_noexpand_nofill(header_hbox)
        main_vbox._pack_noexpand_nofill(gtk.HSeparator())
        main_vbox._pack_noexpand_nofill(schema_table)
        main_vbox._pack_noexpand_nofill(gtk.HSeparator())
        main_vbox._pack_noexpand_nofill(self.smtp_need_auth)
        main_vbox._pack_noexpand_nofill(auth_table)
        main_vbox._pack_noexpand_nofill(gtk.HSeparator())
        main_vbox._pack_noexpand_nofill(self.smtp_encrypt_tls)
        main_vbox.pack_end(btns_hbox, False, False, 0)

        self.add(main_vbox)
예제 #2
0
    def __do_layout(self):
        """
        Layout widgets in window.
        """
        main_vbox = HIGVBox()
        main_vbox.set_border_width(5)
        main_vbox.set_spacing(12)
        header_hbox = HIGHBox()
        schema_table = HIGTable()
        auth_table = HIGTable()
        btns_hbox = HIGHBox()

        header_hbox._pack_expand_fill(self.ttitle)
        header_hbox._pack_noexpand_nofill(self.umit_logo)
        
        # schema name
        schema_table.attach_label(self.schema_name_lbl, 0, 1, 0, 1)
        schema_table.attach_entry(self.schema_name, 1, 2, 0, 1)
        
        # smtp server
        schema_table.attach_label(self.smtp_server_lbl, 0, 1, 1, 2)
        schema_table.attach_entry(self.smtp_server, 1, 2, 1, 2)

        # smtp server port
        schema_table.attach_label(self.smtp_port_lbl, 0, 1, 2, 3)
        schema_table.attach_entry(self.smtp_port, 1, 2, 2, 3)
        
        # smtp mail from
        schema_table.attach_label(self.smtp_mailfrom_lbl, 0, 1, 3, 4)
        schema_table.attach_entry(self.smtp_mailfrom, 1, 2, 3, 4)
        
        # smtp user
        auth_table.attach_label(self.smtp_login_lbl, 0, 1, 0, 1)
        auth_table.attach_entry(self.smtp_login, 1, 2, 0, 1)
        
        # smtp passwd
        auth_table.attach_label(self.smtp_passwd_lbl, 0, 1, 1, 2)
        auth_table.attach_label(self.smtp_passwd, 1, 2, 1, 2)
        
        # bottom buttons
        btns_hbox.set_homogeneous(True)
        btns_hbox._pack_expand_fill(self.help)
        btns_hbox._pack_expand_fill(hig_box_space_holder())
        btns_hbox._pack_expand_fill(self.apply)
        btns_hbox._pack_expand_fill(self.cancel)
        btns_hbox._pack_expand_fill(self.ok)
                
        main_vbox._pack_noexpand_nofill(header_hbox)
        main_vbox._pack_noexpand_nofill(gtk.HSeparator())
        main_vbox._pack_noexpand_nofill(schema_table)
        main_vbox._pack_noexpand_nofill(gtk.HSeparator())
        main_vbox._pack_noexpand_nofill(self.smtp_need_auth)
        main_vbox._pack_noexpand_nofill(auth_table)
        main_vbox._pack_noexpand_nofill(gtk.HSeparator())
        main_vbox._pack_noexpand_nofill(self.smtp_encrypt_tls)
        main_vbox.pack_end(btns_hbox, False, False, 0)
        
        self.add(main_vbox)
예제 #3
0
    def __do_layout(self):
        """
        Layout window widgets.
        """
        main_vbox = HIGVBox()
        main_vbox.set_border_width(5)
        main_vbox.set_spacing(12)
        header_hbox = HIGHBox()
        schedp_hbox = HIGHBox()
        cron_box = HIGVBox()
        cron_table = HIGTable(5, 2)
        btns_hbox = HIGHBox()

        header_hbox._pack_expand_fill(self.ttitle)
        header_hbox._pack_noexpand_nofill(self.umit_logo)

        schedp_hbox._pack_noexpand_nofill(self.schedp_name_lbl)
        schedp_hbox._pack_expand_fill(self.schedp_name)

        # cron format
        settings_align = gtk.Alignment(0.5, 0.5, 1, 1)
        settings_align.set_padding(6, 0, 12, 0)

        cron_table.attach(self.cron_minute_lbl, 0, 1, 0, 1)
        cron_table.attach(self.cron_minute, 1, 2, 0, 1)
        cron_table.attach(self.cron_hour_lbl, 0, 1, 1, 2)
        cron_table.attach(self.cron_hour, 1, 2, 1, 2)
        cron_table.attach(self.cron_day_lbl, 0, 1, 2, 3)
        cron_table.attach(self.cron_day, 1, 2, 2, 3)
        cron_table.attach(self.cron_month_lbl, 0, 1, 3, 4)
        cron_table.attach(self.cron_month, 1, 2, 3, 4)
        cron_table.attach(self.cron_weekday_lbl, 0, 1, 4, 5)
        cron_table.attach(self.cron_weekday, 1, 2, 4, 5)

        cron_box._pack_noexpand_nofill(cron_table)
        settings_align.add(cron_box)
        self.cron_frame.add(settings_align)

        # bottom buttons
        btns_hbox.set_homogeneous(True)
        btns_hbox._pack_expand_fill(self.help)
        btns_hbox._pack_expand_fill(hig_box_space_holder())
        btns_hbox._pack_expand_fill(self.apply)
        btns_hbox._pack_expand_fill(self.cancel)
        btns_hbox._pack_expand_fill(self.ok)

        main_vbox._pack_noexpand_nofill(header_hbox)
        main_vbox._pack_noexpand_nofill(gtk.HSeparator())
        main_vbox._pack_noexpand_nofill(schedp_hbox)
        main_vbox._pack_noexpand_nofill(self.cron_frame)
        main_vbox.pack_end(btns_hbox, False, False, 0)
        self.add(main_vbox)
    def __do_layout(self):
        """
        Layout window widgets.
        """
        main_vbox = HIGVBox()
        main_vbox.set_border_width(5)
        main_vbox.set_spacing(12)
        header_hbox = HIGHBox()
        schedp_hbox = HIGHBox()
        cron_box = HIGVBox()
        cron_table = HIGTable(5, 2)
        btns_hbox = HIGHBox()

        header_hbox._pack_expand_fill(self.ttitle)
        header_hbox._pack_noexpand_nofill(self.umit_logo)

        schedp_hbox._pack_noexpand_nofill(self.schedp_name_lbl)
        schedp_hbox._pack_expand_fill(self.schedp_name)

        # cron format
        settings_align = gtk.Alignment(0.5, 0.5, 1, 1)
        settings_align.set_padding(6, 0, 12, 0)

        cron_table.attach(self.cron_minute_lbl, 0, 1, 0, 1)
        cron_table.attach(self.cron_minute, 1, 2, 0, 1)
        cron_table.attach(self.cron_hour_lbl, 0, 1, 1, 2)
        cron_table.attach(self.cron_hour, 1, 2, 1, 2)
        cron_table.attach(self.cron_day_lbl, 0, 1, 2, 3)
        cron_table.attach(self.cron_day, 1, 2, 2, 3)
        cron_table.attach(self.cron_month_lbl, 0, 1, 3, 4)
        cron_table.attach(self.cron_month, 1, 2, 3, 4)
        cron_table.attach(self.cron_weekday_lbl, 0, 1, 4, 5)
        cron_table.attach(self.cron_weekday, 1, 2, 4, 5)

        cron_box._pack_noexpand_nofill(cron_table)
        settings_align.add(cron_box)
        self.cron_frame.add(settings_align)

        # bottom buttons
        btns_hbox.set_homogeneous(True)
        btns_hbox._pack_expand_fill(self.help)
        btns_hbox._pack_expand_fill(hig_box_space_holder())
        btns_hbox._pack_expand_fill(self.apply)
        btns_hbox._pack_expand_fill(self.cancel)
        btns_hbox._pack_expand_fill(self.ok)

        main_vbox._pack_noexpand_nofill(header_hbox)
        main_vbox._pack_noexpand_nofill(gtk.HSeparator())
        main_vbox._pack_noexpand_nofill(schedp_hbox)
        main_vbox._pack_noexpand_nofill(self.cron_frame)
        main_vbox.pack_end(btns_hbox, False, False, 0)
        self.add(main_vbox)
    def __do_layout(self):
        """
        Layout widgets in window.
        """

        def left_padding(widget):
            """
            Add left padding for a widget.
            """
            left_padding_align = gtk.Alignment(0.5, 0.5, 1, 1)
            left_padding_align.set_padding(0, 0, 12, 0)
            left_padding_align.add(widget)
            return left_padding_align


        main_vbox = HIGVBox()
        main_vbox.set_border_width(5)
        main_vbox.set_spacing(12)
        header_hbox = HIGHBox()
        profile_hbox = HIGHBox()
        hdivs_hbox = HIGHBox()
        arcdraw_vbox = HIGVBox()
        vdivs_vbox = HIGVBox()
        bgfill_vbox = HIGVBox()
        selectfill_vbox = HIGVBox()
        btns_hbox = HIGHBox()

        # header
        header_hbox._pack_expand_fill(self.ttitle)
        header_hbox._pack_noexpand_nofill(self.umit_logo)

        # profiles
        profile_hbox._pack_noexpand_nofill(self.graph_profile_lbl)
        profile_hbox._pack_noexpand_nofill(self.graph_profile)

        # horizontal divisors
        hdivs_hbox._pack_noexpand_nofill(self.hdivs_lbl)
        hdivs_hbox._pack_noexpand_nofill(self.hdivs)

        # arc drawing
        arcdraw_vbox._pack_noexpand_nofill(self.draw_arc_lbl)

        arcdraw_when = HIGHBox()
        arcdraw_when._pack_noexpand_nofill(self.draw_arc_onsel)
        arcdraw_when._pack_noexpand_nofill(self.draw_arc_always)

        arcdraw_where = HIGHBox()
        arcdraw_where._pack_noexpand_nofill(self.draw_arc_bounds)
        arcdraw_where._pack_noexpand_nofill(self.draw_arc_allpts)

        arcdraw_vbox._pack_noexpand_nofill(left_padding(arcdraw_when))
        arcdraw_vbox._pack_noexpand_nofill(left_padding(arcdraw_where))
        arcdraw_vbox._pack_noexpand_nofill(left_padding(self.balloons))

        # vertical divisors
        vdivs_vbox._pack_noexpand_nofill(self.draw_vertdiv)

        vdivs_kind = HIGHBox()
        vdivs_kind._pack_noexpand_nofill(self.draw_vertdiv_dash)
        vdivs_kind._pack_noexpand_nofill(self.draw_vertdiv_solid)

        vdivs_vbox._pack_noexpand_nofill(left_padding(vdivs_kind))

        # background fill
        bgfill_vbox._pack_noexpand_nofill(self.bg_gradient)

        bgfill_gtype = HIGHBox()
        bgfill_gtype._pack_noexpand_nofill(self.bg_gradient_vert)
        bgfill_gtype._pack_noexpand_nofill(self.bg_gradient_horiz)

        bgfill_vbox._pack_noexpand_nofill(left_padding(bgfill_gtype))

        # selection fill
        selectfill_vbox._pack_noexpand_nofill(self.selection_fill)

        selectfill_kind = HIGHBox()
        selectfill_kind._pack_noexpand_nofill(self.selection_fill_solid)
        selectfill_kind._pack_noexpand_nofill(self.selection_fill_gradient)

        selectfill_vbox._pack_noexpand_nofill(left_padding(selectfill_kind))

        # bottom buttons
        btns_hbox.set_homogeneous(True)
        btns_hbox._pack_expand_fill(self.help)
        btns_hbox._pack_expand_fill(hig_box_space_holder())
        btns_hbox._pack_expand_fill(self.apply)
        btns_hbox._pack_expand_fill(self.cancel)
        btns_hbox._pack_expand_fill(self.ok)


        main_vbox._pack_noexpand_nofill(header_hbox)
        main_vbox._pack_noexpand_nofill(gtk.HSeparator())
        main_vbox._pack_noexpand_nofill(profile_hbox)
        main_vbox._pack_noexpand_nofill(gtk.HSeparator())
        main_vbox._pack_noexpand_nofill(hdivs_hbox)
        main_vbox._pack_noexpand_nofill(gtk.HSeparator())
        main_vbox._pack_noexpand_nofill(arcdraw_vbox)
        main_vbox._pack_noexpand_nofill(gtk.HSeparator())
        main_vbox._pack_noexpand_nofill(vdivs_vbox)
        main_vbox._pack_noexpand_nofill(gtk.HSeparator())
        main_vbox._pack_noexpand_nofill(bgfill_vbox)
        main_vbox._pack_noexpand_nofill(gtk.HSeparator())
        main_vbox._pack_noexpand_nofill(selectfill_vbox)
        main_vbox.pack_end(btns_hbox, False, False, 0)
        main_vbox.pack_end(gtk.HSeparator(), False, False, 0)
        self.add(main_vbox)
예제 #6
0
    def __do_layout(self):
        """
        Layout widgets in window.
        """
        main_vbox = HIGVBox()
        main_vbox.set_border_width(5)
        main_vbox.set_spacing(12)
        header_hbox = HIGHBox()
        schema_table = HIGTable()
        schedsn_hbox = HIGHBox()
        sett_table = HIGTable()
        btns_hbox = HIGHBox()

        header_hbox._pack_expand_fill(self.ttitle)
        header_hbox._pack_noexpand_nofill(self.umit_logo)

        # schema name
        schema_table.attach_label(self.schema_name_lbl, 0, 1, 0, 1)
        schema_table.attach_entry(self.schema_name, 1, 2, 0, 1)

        # target and scan profile
        schema_table.attach_label(self.scan_name_lbl, 0, 1, 1, 2)
        schema_table.attach_entry(self.scan_name, 1, 2, 1, 2)

        # scan command
        schema_table.attach_label(self.scan_command_lbl, 0, 1, 2, 3)
        schema_table.attach_label(self.scan_command, 1, 2, 2, 3)

        # scheduling profile
        schedsn_hbox._pack_expand_fill(self.sched_name)
        schedsn_hbox._pack_noexpand_nofill(self.sched_name_edit)

        schema_table.attach_label(self.sched_name_lbl, 0, 1, 3, 4)
        schema_table.attach_entry(schedsn_hbox, 1, 2, 3, 4)

        # settings frame
        settings_align = gtk.Alignment(0.5, 0.5, 1, 1)
        settings_align.set_padding(6, 0, 12, 0)
        schemasett_hbox = HIGVBox()

        # saveto
        sett_hbox = HIGHBox()
        sett_hbox._pack_expand_fill(self.setting_saveto_entry)
        sett_hbox._pack_noexpand_nofill(self.setting_saveto_browse)
        sett_table.attach_label(self.setting_saveto, 0, 1, 0, 1)
        sett_table.attach_entry(sett_hbox, 1, 2, 0, 1)

        # mailto, smtp
        sett_hbox = HIGHBox()
        sett_hbox._pack_expand_fill(self.setting_mailto_entry)
        sett_hbox._pack_noexpand_nofill(self.setting_smtp_lbl)
        sett_hbox._pack_expand_fill(self.setting_smtp)
        sett_table.attach_label(self.setting_mailto, 0, 1, 1, 2)
        sett_table.attach_entry(sett_hbox, 1, 2, 1, 2)
        schemasett_hbox._pack_noexpand_nofill(sett_table)

        # add to inventory
        sett_hbox = HIGHBox()
        sett_hbox._pack_noexpand_nofill(self.setting_addtoinv)
        schemasett_hbox._pack_noexpand_nofill(sett_hbox)

        # enabled/disabled
        sett_hbox = HIGHBox()
        sett_hbox._pack_noexpand_nofill(self.setting_enabled)
        schemasett_hbox._pack_noexpand_nofill(sett_hbox)
        settings_align.add(schemasett_hbox)

        self.schema_sett_frame.add(settings_align)

        # bottom buttons
        btns_hbox.set_homogeneous(True)
        btns_hbox._pack_expand_fill(self.help)
        btns_hbox._pack_expand_fill(hig_box_space_holder())
        btns_hbox._pack_expand_fill(self.apply)
        btns_hbox._pack_expand_fill(self.cancel)
        btns_hbox._pack_expand_fill(self.ok)

        main_vbox._pack_noexpand_nofill(header_hbox)
        main_vbox._pack_noexpand_nofill(gtk.HSeparator())
        main_vbox._pack_noexpand_nofill(schema_table)
        main_vbox._pack_noexpand_nofill(gtk.HSeparator())
        main_vbox._pack_noexpand_nofill(self.schema_sett_frame)
        main_vbox.pack_end(btns_hbox, False, False, 0)

        self.add(main_vbox)
예제 #7
0
    def __do_layout(self):
        """
        Layout widgets.
        """
        main_vbox = HIGVBox()
        main_vbox.set_border_width(5)
        main_vbox.set_spacing(12)
        header_hbox = HIGHBox()
        invname_hbox = HIGHBox()
        scan_hbox = HIGHBox()
        scanadv_hbox = HIGHBox()
        scantarget_hbox = HIGHBox()
        sched_box = HIGHBox()
        btns_hbox = HIGHBox()

        # header
        header_hbox._pack_expand_fill(self.ttitle)
        header_hbox._pack_noexpand_nofill(self.umit_logo)
        # inventory's name
        invname_hbox._pack_noexpand_nofill(self.invname_lbl)
        invname_hbox._pack_expand_fill(self.invname)
        invname_hbox._pack_noexpand_nofill(self.invname_inuse)
        invname_hbox._pack_noexpand_nofill(self.invenabled)
        # scan command
        scan_hbox._pack_noexpand_nofill(self.scandefault)
        scan_hbox._pack_noexpand_nofill(self.scandefault_tip)
        scanadv_hbox._pack_expand_fill(self.scanadv)

        adv_box = HIGVBox()
        scanadv_align = gtk.Alignment(0.5, 0.5, 1, 1)
        scanadv_align.set_padding(6, 0, 12, 0)
        scanname_box = HIGHBox()
        scanname_box._pack_noexpand_nofill(self.scan_name_lbl)
        scanname_box._pack_expand_fill(self.scan_name)
        scanname_box._pack_noexpand_nofill(self.cmd_wizard)
        adv_box.add(scanname_box)
        scancmd_box = HIGHBox()
        scancmd_box._pack_noexpand_nofill(self.scan_command_lbl)
        scancmd_box._pack_expand_fill(self.scan_command)
        adv_box.add(scancmd_box)

        scanadv_align.add(adv_box)
        self.scanadv.add(scanadv_align)
        # scan target
        scantarget_hbox._pack_noexpand_nofill(self.scantarget_lbl)
        scantarget_hbox._pack_expand_fill(self.scantarget)
        scantarget_hbox._pack_noexpand_nofill(self.scantarget_discovery)
        # scheduling profiles
        sched_box._pack_noexpand_nofill(self.sched_name_lbl)
        sched_box._pack_expand_fill(self.sched_name)
        sched_box._pack_noexpand_nofill(self.sched_name_edit)
        # bottom buttons
        btns_hbox.set_homogeneous(True)
        btns_hbox._pack_expand_fill(self.help)
        btns_hbox._pack_expand_fill(hig_box_space_holder())
        btns_hbox._pack_expand_fill(self.cancel)
        btns_hbox._pack_expand_fill(self.ok)

        main_vbox._pack_noexpand_nofill(header_hbox)
        main_vbox._pack_noexpand_nofill(gtk.HSeparator())
        main_vbox._pack_noexpand_nofill(invname_hbox)
        main_vbox._pack_noexpand_nofill(scan_hbox)
        main_vbox._pack_noexpand_nofill(scanadv_hbox)
        main_vbox._pack_noexpand_nofill(scantarget_hbox)

        if self.loaded_command and self.edit_mode:
            view_cmd_box = HIGHBox()
            view_cmd_box._pack_noexpand_nofill(gtk.Label(_("Command")))
            # XXX Why don't reuse scan_command?
            self.cmd_entry = gtk.Entry()
            self.cmd_entry.set_text(self.loaded_command)
            view_cmd_box._pack_expand_fill(self.cmd_entry)
            img_info = gtk.Image()
            img_info.set_from_stock(gtk.STOCK_INFO, gtk.ICON_SIZE_MENU)
            eb = gtk.EventBox()
            eb.add(img_info)
            self.tooltips.set_tip(eb, _("Changes in command won't be saved!"))
            view_cmd_box.pack_end(eb, False, False, 0)
            main_vbox._pack_noexpand_nofill(view_cmd_box)

        main_vbox._pack_noexpand_nofill(sched_box)
        main_vbox.pack_end(btns_hbox, False, False, 0)
        main_vbox.pack_end(gtk.HSeparator(), False, False, 0)

        self.add(main_vbox)
예제 #8
0
class DiffWindow(gtk.Window):
    def __init__(self, scans):
        """scans in the format: {"scan_title":parsed_scan}
        """
        gtk.Window.__init__(self)
        self.set_title(_("Compare Results"))
        self.scans = scans

        self.umit_conf = UmitConf()
        self.colors = Colors()
        
        # Diff views
        self.text_view = DiffText(self.colors, self.umit_conf.colored_diff)
        self.compare_view = DiffTree(self.colors)

        self._create_widgets()
        self._pack_widgets()
        self._connect_widgets()


        # Settings
        if self.umit_conf.diff_mode == "text":
            self.text_mode.set_active(True)
        else:
            self.compare_mode.set_active(True)
        self.check_color.set_active(self.umit_conf.colored_diff)

        # Initial Size Request
        self.initial_size = self.size_request()

    def _show_help(self, action):
        show_help(self, "index.html")
        
    def _create_widgets(self):
        self.main_vbox = HIGVBox()
        self.hbox_mode = HIGHBox()
        self.hbox_settings = HIGHBox()
        self.hbox_buttons = HIGHBox()
        self.hbox_result = HIGHBox()
        self.btn_open_browser = HIGButton(_("Open in Browser"),
                                          stock=gtk.STOCK_EXECUTE)
        self.btn_help = HIGButton(stock=gtk.STOCK_HELP)
        self.btn_close = HIGButton(stock=gtk.STOCK_CLOSE)
        self.check_color = gtk.CheckButton(_("Enable colored diffies"))
        self.btn_legend = HIGButton(_("Color Descriptions"),
                                    stock=gtk.STOCK_SELECT_COLOR)
        self.text_mode = gtk.ToggleButton(_("Text Mode"))
        self.compare_mode = gtk.ToggleButton(_("Compare Mode"))
        self.vpaned = gtk.VPaned()
        self.hpaned = gtk.HPaned()
        self.scan_chooser1 = ScanChooser(self.scans, "1")
        self.scan_chooser2 = ScanChooser(self.scans, "2")
        self.scan_buffer1 = self.scan_chooser1.get_buffer()
        self.scan_buffer2 = self.scan_chooser2.get_buffer()

    def _pack_widgets(self):
        self.main_vbox.set_border_width(6)
        
        self.vpaned.pack1(self.hpaned, True, False)
        self.vpaned.pack2(self.hbox_result)
        self.hpaned.pack1(self.scan_chooser1, True, False)
        self.hpaned.pack2(self.scan_chooser2, True, False)

        self.hbox_buttons._pack_expand_fill(self.btn_help)
        self.hbox_buttons._pack_expand_fill(self.btn_legend)
        self.hbox_buttons._pack_expand_fill(self.btn_open_browser)
        self.hbox_buttons._pack_expand_fill(self.btn_close)
        self.hbox_buttons.set_homogeneous(True)

        self.hbox_mode.set_homogeneous(True)
        self.hbox_mode.pack_start(self.text_mode)
        self.hbox_mode.pack_start(self.compare_mode)
        self.hbox_settings._pack_noexpand_nofill(self.hbox_mode)
        self.hbox_settings._pack_expand_fill(self.check_color)

        self.main_vbox._pack_expand_fill(self.vpaned)
        self.main_vbox._pack_noexpand_nofill(self.hbox_settings)
        self.main_vbox._pack_noexpand_nofill(self.hbox_buttons)

        self.add(self.main_vbox)

    def _connect_widgets(self):
        self.connect("delete-event", self.close)
        self.btn_legend.connect("clicked", self.show_legend_window)
        self.btn_help.connect("clicked", self._show_help)
        self.btn_close.connect("clicked", self.close)
        self.btn_open_browser.connect("clicked", self.open_browser)
        self.check_color.connect("toggled", self._set_color)
        self.text_mode.connect("clicked", self._change_to_text)
        self.compare_mode.connect("clicked", self._change_to_compare)
        self.scan_chooser1.exp_scan.connect('activate', self.resize_vpane)
        self.scan_chooser2.exp_scan.connect('activate', self.resize_vpane)
        self.scan_buffer1.connect('changed', self.text_changed)
        self.scan_buffer2.connect('changed', self.text_changed)

    def open_browser(self, widget):
        text1=self.scan_buffer1.get_text(self.scan_buffer1.get_start_iter(),\
                                self.scan_buffer1.get_end_iter())
        text2=self.scan_buffer2.get_text(self.scan_buffer2.get_start_iter(),\
                                self.scan_buffer2.get_end_iter())

        if not text1 or not text2:
            alert = HIGAlertDialog(
                    message_format='<b>'+_('Select Scan')+'</b>',
                    secondary_text=_("You must select two different scans to \
generate diff."))
            alert.run()
            alert.destroy()
            return False
        
        text1 = text1.split('\n')
        text2 = text2.split('\n')
        
        self.temp_view = mktemp('.html')
        
        text1 = [text+'\n' for text in text1]
        text2 = [text+'\n' for text in text2]
        
        if use_html:
            diff = DiffHtml(text1, text2)
            diff = diff.generate()

            file_desc = open(self.temp_view, 'w')
            file_desc.write(''.join(diff))

            # Closing file to avoid problems with file descriptors
            file_desc.close()
        else:
            diff = Diff(text1, text2)
            diff = diff.generate ()
            diff.insert(0, '''<pre>(This diff is been shown in pure text \
because you dont have Python 2.4 or higher.)\n''')
            diff.append('</pre>')

            file_desc = open(self.temp_view, 'w')
            file_desc.writelines(diff)

            # Closing file to avoid problems with file descriptors
            file_desc.close()
        
        webbrowser.open("file://" + self.temp_view, autoraise=1)

    def show_legend_window(self, widget):
        legend_window = DiffLegendWindow(self.colors)
        legend_window.run()
        legend_window.destroy()
        self.text_changed(None)

    def text_changed (self, widget):
        text1 = self.scan_buffer1.get_text(self.scan_buffer1.get_start_iter(),\
                                           self.scan_buffer1.get_end_iter())
        text2 = self.scan_buffer2.get_text(self.scan_buffer2.get_start_iter(),\
                                           self.scan_buffer2.get_end_iter())

        if text1 != '' and text2 != '':
            if self.compare_mode.get_active():
                self.compare_view.make_diff(self.scan_chooser1.parsed_scan,
                                            self.scan_chooser2.parsed_scan)
                self.compare_view.activate_color(self.check_color.get_active())
            else:
                self.text1 = text1.split ('\n')
                self.text2 = text2.split ('\n')
            
                self.diff = Diff(self.text1, self.text2)
                self.text_view.txt_diff_result.get_buffer().set_text\
                               ('\n'.join(self.diff.generate_without_banner()))
                self.text_view.activate_color(self.check_color.get_active())
                self.text_view._text_changed(None)

    def resize_vpane(self, widget):
        exp1 = not widget.get_expanded()
        if widget == self.scan_chooser1.exp_scan:
            exp2 = self.scan_chooser2.exp_scan.get_expanded()
        else:
            exp2 = self.scan_chooser1.exp_scan.get_expanded()

        if not exp1 and not exp2:
            self.vpaned.compute_position(-1, 0, 500)
            self.size_allocate(gtk.gdk.Rectangle(width=self.initial_size[0],
                                                 height=self.initial_size[1]))
            self.queue_resize()

    def _change_to_text(self, widget):
        if not widget.get_active():
            return

        self.umit_conf.diff_mode = "text"

        children = self.hbox_result.get_children()
        if children:
            self.hbox_result.remove(children[0])
            self.compare_view.hide()
        
        self.hbox_result._pack_expand_fill(self.text_view)
        self.text_view.show_all()
        
        self.compare_mode.set_active(False)
        self.text_changed(None)

    def _change_to_compare(self, widget):
        if not widget.get_active():
            return

        self.umit_conf.diff_mode = "compare"

        children = self.hbox_result.get_children()
        if children:
            self.hbox_result.remove(children[0])
            self.text_view.hide()
        
        self.hbox_result._pack_expand_fill(self.compare_view)
        self.compare_view.show_all()
        
        self.text_mode.set_active(False)
        self.text_changed(None)

    def _set_color(self, widget):
        activate = widget.get_active()
        self.umit_conf.colored_diff = activate
        self.compare_view.activate_color(activate)
        self.text_view.activate_color(activate)

    def close(self, widget=None, extra=None):
        self.destroy()
예제 #9
0
class DiffWindow(gtk.Window):
    def __init__(self, scans):
        """scans in the format: {"scan_title":parsed_scan}
        """
        gtk.Window.__init__(self)
        self.set_title(_("Compare Results"))
        self.scans = scans

        self.umit_conf = UmitConf()
        self.colors = Colors()

        # Diff views
        self.text_view = DiffText(self.colors, self.umit_conf.colored_diff)
        self.compare_view = DiffTree(self.colors)

        self._create_widgets()
        self._pack_widgets()
        self._connect_widgets()

        # Settings
        if self.umit_conf.diff_mode == "text":
            self.text_mode.set_active(True)
        else:
            self.compare_mode.set_active(True)
        self.check_color.set_active(self.umit_conf.colored_diff)

        # Initial Size Request
        self.initial_size = self.size_request()

    def _show_help(self, action):
        show_help(self, "index.html")

    def _create_widgets(self):
        self.main_vbox = HIGVBox()
        self.hbox_mode = HIGHBox()
        self.hbox_settings = HIGHBox()
        self.hbox_buttons = HIGHBox()
        self.hbox_result = HIGHBox()
        self.btn_open_browser = HIGButton(_("Open in Browser"),
                                          stock=gtk.STOCK_EXECUTE)
        self.btn_help = HIGButton(stock=gtk.STOCK_HELP)
        self.btn_close = HIGButton(stock=gtk.STOCK_CLOSE)
        self.check_color = gtk.CheckButton(_("Enable colored diffies"))
        self.btn_legend = HIGButton(_("Color Descriptions"),
                                    stock=gtk.STOCK_SELECT_COLOR)
        self.text_mode = gtk.ToggleButton(_("Text Mode"))
        self.compare_mode = gtk.ToggleButton(_("Compare Mode"))
        self.vpaned = gtk.VPaned()
        self.hpaned = gtk.HPaned()
        self.scan_chooser1 = ScanChooser(self.scans, "1")
        self.scan_chooser2 = ScanChooser(self.scans, "2")
        self.scan_buffer1 = self.scan_chooser1.get_buffer()
        self.scan_buffer2 = self.scan_chooser2.get_buffer()

    def _pack_widgets(self):
        self.main_vbox.set_border_width(6)

        self.vpaned.pack1(self.hpaned, True, False)
        self.vpaned.pack2(self.hbox_result)
        self.hpaned.pack1(self.scan_chooser1, True, False)
        self.hpaned.pack2(self.scan_chooser2, True, False)

        self.hbox_buttons._pack_expand_fill(self.btn_help)
        self.hbox_buttons._pack_expand_fill(self.btn_legend)
        self.hbox_buttons._pack_expand_fill(self.btn_open_browser)
        self.hbox_buttons._pack_expand_fill(self.btn_close)
        self.hbox_buttons.set_homogeneous(True)

        self.hbox_mode.set_homogeneous(True)
        self.hbox_mode.pack_start(self.text_mode)
        self.hbox_mode.pack_start(self.compare_mode)
        self.hbox_settings._pack_noexpand_nofill(self.hbox_mode)
        self.hbox_settings._pack_expand_fill(self.check_color)

        self.main_vbox._pack_expand_fill(self.vpaned)
        self.main_vbox._pack_noexpand_nofill(self.hbox_settings)
        self.main_vbox._pack_noexpand_nofill(self.hbox_buttons)

        self.add(self.main_vbox)

    def _connect_widgets(self):
        self.connect("delete-event", self.close)
        self.btn_legend.connect("clicked", self.show_legend_window)
        self.btn_help.connect("clicked", self._show_help)
        self.btn_close.connect("clicked", self.close)
        self.btn_open_browser.connect("clicked", self.open_browser)
        self.check_color.connect("toggled", self._set_color)
        self.text_mode.connect("clicked", self._change_to_text)
        self.compare_mode.connect("clicked", self._change_to_compare)
        self.scan_chooser1.exp_scan.connect('activate', self.resize_vpane)
        self.scan_chooser2.exp_scan.connect('activate', self.resize_vpane)
        self.scan_buffer1.connect('changed', self.text_changed)
        self.scan_buffer2.connect('changed', self.text_changed)

    def open_browser(self, widget):
        text1=self.scan_buffer1.get_text(self.scan_buffer1.get_start_iter(),\
                                self.scan_buffer1.get_end_iter())
        text2=self.scan_buffer2.get_text(self.scan_buffer2.get_start_iter(),\
                                self.scan_buffer2.get_end_iter())

        if not text1 or not text2:
            alert = HIGAlertDialog(
                message_format='<b>' + _('Select Scan') + '</b>',
                secondary_text=_("You must select two different scans to \
generate diff."))
            alert.run()
            alert.destroy()
            return False

        text1 = text1.split('\n')
        text2 = text2.split('\n')

        self.temp_view = mktemp('.html')

        text1 = [text + '\n' for text in text1]
        text2 = [text + '\n' for text in text2]

        if use_html:
            diff = DiffHtml(text1, text2)
            diff = diff.generate()

            file_desc = open(self.temp_view, 'w')
            file_desc.write(''.join(diff))

            # Closing file to avoid problems with file descriptors
            file_desc.close()
        else:
            diff = Diff(text1, text2)
            diff = diff.generate()
            diff.insert(
                0, '''<pre>(This diff is been shown in pure text \
because you dont have Python 2.4 or higher.)\n''')
            diff.append('</pre>')

            file_desc = open(self.temp_view, 'w')
            file_desc.writelines(diff)

            # Closing file to avoid problems with file descriptors
            file_desc.close()

        webbrowser.open("file://" + self.temp_view, autoraise=1)

    def show_legend_window(self, widget):
        legend_window = DiffLegendWindow(self.colors)
        legend_window.run()
        legend_window.destroy()
        self.text_changed(None)

    def text_changed(self, widget):
        text1 = self.scan_buffer1.get_text(self.scan_buffer1.get_start_iter(),\
                                           self.scan_buffer1.get_end_iter())
        text2 = self.scan_buffer2.get_text(self.scan_buffer2.get_start_iter(),\
                                           self.scan_buffer2.get_end_iter())

        if text1 != '' and text2 != '':
            if self.compare_mode.get_active():
                self.compare_view.make_diff(self.scan_chooser1.parsed_scan,
                                            self.scan_chooser2.parsed_scan)
                self.compare_view.activate_color(self.check_color.get_active())
            else:
                self.text1 = text1.split('\n')
                self.text2 = text2.split('\n')

                self.diff = Diff(self.text1, self.text2)
                self.text_view.txt_diff_result.get_buffer().set_text\
                               ('\n'.join(self.diff.generate_without_banner()))
                self.text_view.activate_color(self.check_color.get_active())
                self.text_view._text_changed(None)

    def resize_vpane(self, widget):
        exp1 = not widget.get_expanded()
        if widget == self.scan_chooser1.exp_scan:
            exp2 = self.scan_chooser2.exp_scan.get_expanded()
        else:
            exp2 = self.scan_chooser1.exp_scan.get_expanded()

        if not exp1 and not exp2:
            self.vpaned.compute_position(-1, 0, 500)
            self.size_allocate(
                gtk.gdk.Rectangle(width=self.initial_size[0],
                                  height=self.initial_size[1]))
            self.queue_resize()

    def _change_to_text(self, widget):
        if not widget.get_active():
            return

        self.umit_conf.diff_mode = "text"

        children = self.hbox_result.get_children()
        if children:
            self.hbox_result.remove(children[0])
            self.compare_view.hide()

        self.hbox_result._pack_expand_fill(self.text_view)
        self.text_view.show_all()

        self.compare_mode.set_active(False)
        self.text_changed(None)

    def _change_to_compare(self, widget):
        if not widget.get_active():
            return

        self.umit_conf.diff_mode = "compare"

        children = self.hbox_result.get_children()
        if children:
            self.hbox_result.remove(children[0])
            self.text_view.hide()

        self.hbox_result._pack_expand_fill(self.compare_view)
        self.compare_view.show_all()

        self.text_mode.set_active(False)
        self.text_changed(None)

    def _set_color(self, widget):
        activate = widget.get_active()
        self.umit_conf.colored_diff = activate
        self.compare_view.activate_color(activate)
        self.text_view.activate_color(activate)

    def close(self, widget=None, extra=None):
        self.destroy()
예제 #10
0
    def __do_layout(self):
        """
        Layout widgets.
        """
        main_vbox = HIGVBox()
        main_vbox.set_border_width(5)
        main_vbox.set_spacing(12)
        header_hbox = HIGHBox()
        invname_hbox = HIGHBox()
        scan_hbox = HIGHBox()
        scanadv_hbox = HIGHBox()
        scantarget_hbox = HIGHBox()
        sched_box = HIGHBox()
        btns_hbox = HIGHBox()

        # header
        header_hbox._pack_expand_fill(self.ttitle)
        header_hbox._pack_noexpand_nofill(self.umit_logo)
        # inventory's name
        invname_hbox._pack_noexpand_nofill(self.invname_lbl)
        invname_hbox._pack_expand_fill(self.invname)
        invname_hbox._pack_noexpand_nofill(self.invname_inuse)
        invname_hbox._pack_noexpand_nofill(self.invenabled)
        # scan command
        scan_hbox._pack_noexpand_nofill(self.scandefault)
        scan_hbox._pack_noexpand_nofill(self.scandefault_tip)
        scanadv_hbox._pack_expand_fill(self.scanadv)

        adv_box = HIGVBox()
        scanadv_align = gtk.Alignment(0.5, 0.5, 1, 1)
        scanadv_align.set_padding(6, 0, 12, 0)
        scanname_box = HIGHBox()
        scanname_box._pack_noexpand_nofill(self.scan_name_lbl)
        scanname_box._pack_expand_fill(self.scan_name)
        scanname_box._pack_noexpand_nofill(self.cmd_wizard)
        adv_box.add(scanname_box)
        scancmd_box = HIGHBox()
        scancmd_box._pack_noexpand_nofill(self.scan_command_lbl)
        scancmd_box._pack_expand_fill(self.scan_command)
        adv_box.add(scancmd_box)

        scanadv_align.add(adv_box)
        self.scanadv.add(scanadv_align)
        # scan target
        scantarget_hbox._pack_noexpand_nofill(self.scantarget_lbl)
        scantarget_hbox._pack_expand_fill(self.scantarget)
        scantarget_hbox._pack_noexpand_nofill(self.scantarget_discovery)
        # scheduling profiles
        sched_box._pack_noexpand_nofill(self.sched_name_lbl)
        sched_box._pack_expand_fill(self.sched_name)
        sched_box._pack_noexpand_nofill(self.sched_name_edit)
        # bottom buttons
        btns_hbox.set_homogeneous(True)
        btns_hbox._pack_expand_fill(self.help)
        btns_hbox._pack_expand_fill(hig_box_space_holder())
        btns_hbox._pack_expand_fill(self.cancel)
        btns_hbox._pack_expand_fill(self.ok)


        main_vbox._pack_noexpand_nofill(header_hbox)
        main_vbox._pack_noexpand_nofill(gtk.HSeparator())
        main_vbox._pack_noexpand_nofill(invname_hbox)
        main_vbox._pack_noexpand_nofill(scan_hbox)
        main_vbox._pack_noexpand_nofill(scanadv_hbox)
        main_vbox._pack_noexpand_nofill(scantarget_hbox)
        
        if self.loaded_command and self.edit_mode:
            view_cmd_box = HIGHBox()
            view_cmd_box._pack_noexpand_nofill(gtk.Label(_("Command")))
            # XXX Why don't reuse scan_command?
            self.cmd_entry = gtk.Entry()
            self.cmd_entry.set_text(self.loaded_command)
            view_cmd_box._pack_expand_fill(self.cmd_entry)
            img_info = gtk.Image()
            img_info.set_from_stock(gtk.STOCK_INFO, gtk.ICON_SIZE_MENU)
            eb = gtk.EventBox()
            eb.add(img_info)
            self.tooltips.set_tip(eb, _("Changes in command won't be saved!"))
            view_cmd_box.pack_end(eb, False, False, 0)
            main_vbox._pack_noexpand_nofill(view_cmd_box)

        main_vbox._pack_noexpand_nofill(sched_box)
        main_vbox.pack_end(btns_hbox, False, False, 0)
        main_vbox.pack_end(gtk.HSeparator(), False, False, 0)

        self.add(main_vbox)
    def __do_layout(self):
        """
        Layout widgets in window.
        """
        main_vbox = HIGVBox()
        main_vbox.set_border_width(5)
        main_vbox.set_spacing(12)
        header_hbox = HIGHBox()
        schema_table = HIGTable()
        schedsn_hbox = HIGHBox()
        sett_table = HIGTable()
        btns_hbox = HIGHBox()

        header_hbox._pack_expand_fill(self.ttitle)
        header_hbox._pack_noexpand_nofill(self.umit_logo)

        # schema name
        schema_table.attach_label(self.schema_name_lbl, 0, 1, 0, 1)
        schema_table.attach_entry(self.schema_name, 1, 2, 0, 1)

        # target and scan profile
        schema_table.attach_label(self.scan_name_lbl, 0, 1, 1, 2)
        schema_table.attach_entry(self.scan_name, 1, 2, 1, 2)

        # scan command
        schema_table.attach_label(self.scan_command_lbl, 0, 1, 2, 3)
        schema_table.attach_label(self.scan_command, 1, 2, 2, 3)

        # scheduling profile
        schedsn_hbox._pack_expand_fill(self.sched_name)
        schedsn_hbox._pack_noexpand_nofill(self.sched_name_edit)

        schema_table.attach_label(self.sched_name_lbl, 0, 1, 3, 4)
        schema_table.attach_entry(schedsn_hbox, 1, 2, 3, 4)

        # settings frame
        settings_align = gtk.Alignment(0.5, 0.5, 1, 1)
        settings_align.set_padding(6, 0, 12, 0)
        schemasett_hbox = HIGVBox()

        # saveto
        sett_hbox = HIGHBox()
        sett_hbox._pack_expand_fill(self.setting_saveto_entry)
        sett_hbox._pack_noexpand_nofill(self.setting_saveto_browse)
        sett_table.attach_label(self.setting_saveto, 0, 1, 0, 1)
        sett_table.attach_entry(sett_hbox, 1, 2, 0, 1)

        # mailto, smtp
        sett_hbox = HIGHBox()
        sett_hbox._pack_expand_fill(self.setting_mailto_entry)
        sett_hbox._pack_noexpand_nofill(self.setting_smtp_lbl)
        sett_hbox._pack_expand_fill(self.setting_smtp)
        sett_table.attach_label(self.setting_mailto, 0, 1, 1, 2)
        sett_table.attach_entry(sett_hbox, 1, 2, 1, 2)
        schemasett_hbox._pack_noexpand_nofill(sett_table)

        # add to inventory
        sett_hbox = HIGHBox()
        sett_hbox._pack_noexpand_nofill(self.setting_addtoinv)
        schemasett_hbox._pack_noexpand_nofill(sett_hbox)

        # enabled/disabled
        sett_hbox = HIGHBox()
        sett_hbox._pack_noexpand_nofill(self.setting_enabled)
        schemasett_hbox._pack_noexpand_nofill(sett_hbox)
        settings_align.add(schemasett_hbox)

        self.schema_sett_frame.add(settings_align)

        # bottom buttons
        btns_hbox.set_homogeneous(True)
        btns_hbox._pack_expand_fill(self.help)
        btns_hbox._pack_expand_fill(hig_box_space_holder())
        btns_hbox._pack_expand_fill(self.apply)
        btns_hbox._pack_expand_fill(self.cancel)
        btns_hbox._pack_expand_fill(self.ok)

        main_vbox._pack_noexpand_nofill(header_hbox)
        main_vbox._pack_noexpand_nofill(gtk.HSeparator())
        main_vbox._pack_noexpand_nofill(schema_table)
        main_vbox._pack_noexpand_nofill(gtk.HSeparator())
        main_vbox._pack_noexpand_nofill(self.schema_sett_frame)
        main_vbox.pack_end(btns_hbox, False, False, 0)

        self.add(main_vbox)
    def __layout(self):
        """
        Layout widgets
        """
        main_vbox = HIGVBox()
        main_vbox.set_border_width(5)
        main_vbox.set_spacing(12)
        main_hpaned = gtk.HPaned()
        btns_hbox = HIGHBox()
        left_box = HIGVBox()
        right_box = gtk.VBox()

        header_hbox = HIGHBox()
        hostdetect_hbox = HIGHBox()
        targetl_hbox = HIGHBox()
        targetv_hbox = HIGHBox()
        targetr_hbox = HIGHBox()

        # header
        header_hbox._pack_expand_fill(self.ttitle)
        header_hbox._pack_noexpand_nofill(self.umit_logo)
        # network list
        netframe = HIGFrame(_("Network list"))
        settings_align = gtk.Alignment(0.5, 0.5, 1, 1)
        settings_align.set_padding(6, 0, 12, 0)
        nbox = HIGVBox()
        entry = gtk.Entry()
        entry.set_text(_("Sample 192.168.254.0/24"))
        nbox._pack_noexpand_nofill(entry)
        addnw_hbox = HIGHBox()
        addnw_hbox._pack_noexpand_nofill(self.addnetworks)
        nbox.pack_end(addnw_hbox, False, False, 0)
        self.networks_box = nbox
        settings_align.add(nbox)
        netframe.add(settings_align)
        # detection
        hostdetect_hbox._pack_noexpand_nofill(self.netdetect_btn)
        hostdetect_hbox._pack_noexpand_nofill(self.hostdetect_btn)

        # target list
        targetl_hbox._pack_noexpand_nofill(self.target_lbl)
        targetv_hbox._pack_expand_fill(self.tview)
        targetr_hbox.pack_end(self.target_remove, False, False, 0)

        # bottom buttons
        btns_hbox.set_homogeneous(True)
        btns_hbox._pack_expand_fill(self.help)
        btns_hbox._pack_expand_fill(hig_box_space_holder())
        btns_hbox._pack_expand_fill(self.cancel)
        btns_hbox._pack_expand_fill(self.apply)
        # change apply button stock text
        lbl = self.apply.get_children()[0].get_children()[0].get_children()[1]
        lbl.set_text(_("Use target list"))

        left_box._pack_noexpand_nofill(netframe)
        left_box.pack_end(hostdetect_hbox, False, False, 0)
        right_box.pack_start(targetl_hbox, False, False, 0)
        right_box.pack_start(targetv_hbox, True, True, 6)
        right_box.pack_start(targetr_hbox, False, False, 0)

        left_align = gtk.Alignment(0.5, 0.5, 1, 1)
        left_align.set_padding(0, 0, 0, 6)
        left_align.add(left_box)
        right_align = gtk.Alignment(0.5, 0.5, 1, 1)
        right_align.set_padding(0, 0, 6, 0)
        right_align.add(right_box)

        main_hpaned.add1(left_align)
        main_hpaned.add2(right_align)

        main_vbox._pack_noexpand_nofill(header_hbox)
        main_vbox._pack_noexpand_nofill(gtk.HSeparator())
        main_vbox._pack_expand_fill(main_hpaned)
        main_vbox.pack_end(btns_hbox, False, False, 0)

        self.add(main_vbox)
예제 #13
0
    def __layout(self):
        """
        Layout widgets
        """
        main_vbox = HIGVBox()
        main_vbox.set_border_width(5)
        main_vbox.set_spacing(12)
        main_hpaned = gtk.HPaned()
        btns_hbox = HIGHBox()
        left_box = HIGVBox()
        right_box = gtk.VBox()

        header_hbox = HIGHBox()
        hostdetect_hbox = HIGHBox()
        targetl_hbox = HIGHBox()
        targetv_hbox = HIGHBox()
        targetr_hbox = HIGHBox()

        # header
        header_hbox._pack_expand_fill(self.ttitle)
        header_hbox._pack_noexpand_nofill(self.umit_logo)
        # network list
        netframe = HIGFrame(_("Network list"))
        settings_align = gtk.Alignment(0.5, 0.5, 1, 1)
        settings_align.set_padding(6, 0, 12, 0)
        nbox = HIGVBox()
        entry = gtk.Entry()
        entry.set_text(_("Sample 192.168.254.0/24"))
        nbox._pack_noexpand_nofill(entry)
        addnw_hbox = HIGHBox()
        addnw_hbox._pack_noexpand_nofill(self.addnetworks)
        nbox.pack_end(addnw_hbox, False, False, 0)
        self.networks_box = nbox
        settings_align.add(nbox)
        netframe.add(settings_align)
        # detection
        hostdetect_hbox._pack_noexpand_nofill(self.netdetect_btn)
        hostdetect_hbox._pack_noexpand_nofill(self.hostdetect_btn)

        # target list
        targetl_hbox._pack_noexpand_nofill(self.target_lbl)
        targetv_hbox._pack_expand_fill(self.tview)
        targetr_hbox.pack_end(self.target_remove, False, False, 0)

        # bottom buttons
        btns_hbox.set_homogeneous(True)
        btns_hbox._pack_expand_fill(self.help)
        btns_hbox._pack_expand_fill(hig_box_space_holder())
        btns_hbox._pack_expand_fill(self.cancel)
        btns_hbox._pack_expand_fill(self.apply)
        # change apply button stock text
        lbl = self.apply.get_children()[0].get_children()[0].get_children()[1]
        lbl.set_text(_("Use target list"))


        left_box._pack_noexpand_nofill(netframe)
        left_box.pack_end(hostdetect_hbox, False, False, 0)
        right_box.pack_start(targetl_hbox, False, False, 0)
        right_box.pack_start(targetv_hbox, True, True, 6)
        right_box.pack_start(targetr_hbox, False, False, 0)

        left_align = gtk.Alignment(0.5, 0.5, 1, 1)
        left_align.set_padding(0, 0, 0, 6)
        left_align.add(left_box)
        right_align = gtk.Alignment(0.5, 0.5, 1, 1)
        right_align.set_padding(0, 0, 6, 0)
        right_align.add(right_box)

        main_hpaned.add1(left_align)
        main_hpaned.add2(right_align)

        main_vbox._pack_noexpand_nofill(header_hbox)
        main_vbox._pack_noexpand_nofill(gtk.HSeparator())
        main_vbox._pack_expand_fill(main_hpaned)
        main_vbox.pack_end(btns_hbox, False, False, 0)

        self.add(main_vbox)