def __create_tab(self, tab_name, section_name, tab): log.debug(">>> Tab name: %s" % tab_name) log.debug(">>>Creating profile editor section: %s" % section_name) vbox = HIGVBox() table = HIGTable() section = HIGSectionLabel(section_name) vbox._pack_noexpand_nofill(section) vbox._pack_noexpand_nofill(HIGSpacer(table)) vbox.set_border_width(6) tab.fill_table(table, True) self.scrollwindow = HIGScrolledWindow() self.scrollwindow.set_size_request(600, 300) vp = gtk.Viewport() vp.add(vbox) vp.set_shadow_type(gtk.SHADOW_NONE) self.scrollwindow.add(vp) vbox_tmp = HIGVBox() vbox_tmp.set_border_width(6) vbox_tmp.set_spacing(12) vbox_tmp.pack_start(self.scrollwindow) self.notebook.append_page(vbox_tmp, gtk.Label(tab_name))
def __create_tab(self, tab_name, section_name, tab): log.debug(">>> Tab name: %s" % tab_name) log.debug(">>>Creating profile editor section: %s" % section_name) vbox = HIGVBox() table = HIGTable() section = HIGSectionLabel(section_name) vbox._pack_noexpand_nofill(section) vbox._pack_noexpand_nofill(HIGSpacer(table)) vbox.set_border_width(6) tab.fill_table(table, True) self.scrollwindow = HIGScrolledWindow() self.scrollwindow.set_size_request(600,300) vp = gtk.Viewport() vp.add(vbox) vp.set_shadow_type(gtk.SHADOW_NONE) self.scrollwindow.add(vp) vbox_tmp = HIGVBox() vbox_tmp.set_border_width(6) vbox_tmp.set_spacing(12) vbox_tmp.pack_start(self.scrollwindow) self.notebook.append_page(vbox_tmp, gtk.Label(tab_name))
def __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)
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 __create_steps(self, step_name, back_step, next_step, step_description, content): vbox = HIGVBox() vbox.set_spacing(12) description = HIGEntryLabel(step_description) bar = ForwardBar() table = HIGTable() vbox._pack_noexpand_nofill(description) vbox._pack_expand_fill(table) vbox._pack_noexpand_nofill(bar) content.fill_table(table, False) bar.cancel.connect('clicked', self.close_wizard) bar.help.connect('clicked', self._show_help) bar.back.connect('clicked', self.switch_page, step_name, back_step) bar.forward.connect('clicked', self.switch_page, step_name, next_step) return vbox
def quit(self, widget=None, extra=None): if self.deleted: dialog = HIGDialog(buttons=(gtk.STOCK_OK, gtk.RESPONSE_OK, gtk.STOCK_CANCEL, gtk.RESPONSE_CANCEL)) alert = HIGEntryLabel('<b>' + _("Deleting Profile") + '</b>') text = HIGEntryLabel( _('Your profile is going to be deleted! Click\ Ok to continue, or Cancel to go back to Profile Editor.' )) hbox = HIGHBox() hbox.set_border_width(5) hbox.set_spacing(12) vbox = HIGVBox() vbox.set_border_width(5) vbox.set_spacing(12) image = gtk.Image() image.set_from_stock(gtk.STOCK_DIALOG_WARNING, gtk.ICON_SIZE_DIALOG) vbox.pack_start(alert) vbox.pack_start(text) hbox.pack_start(image) hbox.pack_start(vbox) dialog.vbox.pack_start(hbox) dialog.vbox.show_all() response = dialog.run() dialog.destroy() if response == gtk.RESPONSE_CANCEL: return None self.destroy() if self.scan_notebook != None: for i in xrange(self.scan_notebook.get_n_pages()): page = self.scan_notebook.get_nth_page(i) page.toolbar.profile_entry.update()
def on_delete(self, widget=None): if not self.profile_name: return self.on_cancel() dialog = HIGDialog(buttons=(gtk.STOCK_OK, gtk.RESPONSE_OK, gtk.STOCK_CANCEL, gtk.RESPONSE_CANCEL)) alert = HIGEntryLabel('<b>' + _("Deleting Profile") + '</b>') text = HIGEntryLabel( _('Your profile is going to be deleted! Click \ Ok to continue, or Cancel to go back to Profile Editor.')) hbox = HIGHBox() hbox.set_border_width(5) hbox.set_spacing(12) vbox = HIGVBox() vbox.set_border_width(5) vbox.set_spacing(12) image = gtk.Image() image.set_from_stock(gtk.STOCK_DIALOG_WARNING, gtk.ICON_SIZE_DIALOG) vbox.pack_start(alert) vbox.pack_start(text) hbox.pack_start(image) hbox.pack_start(vbox) dialog.vbox.pack_start(hbox) dialog.vbox.show_all() response = dialog.run() dialog.destroy() if response == gtk.RESPONSE_CANCEL: return None self.deleted = True self.profile.remove_profile(self.profile_name) self.on_cancel()
def quit(self, widget=None, extra=None): if self.deleted: dialog = HIGDialog(buttons=(gtk.STOCK_OK, gtk.RESPONSE_OK, gtk.STOCK_CANCEL, gtk.RESPONSE_CANCEL)) alert = HIGEntryLabel('<b>'+_("Deleting Profile")+'</b>') text = HIGEntryLabel(_('Your profile is going to be deleted! Click\ Ok to continue, or Cancel to go back to Profile Editor.')) hbox = HIGHBox() hbox.set_border_width(5) hbox.set_spacing(12) vbox = HIGVBox() vbox.set_border_width(5) vbox.set_spacing(12) image = gtk.Image() image.set_from_stock(gtk.STOCK_DIALOG_WARNING, gtk.ICON_SIZE_DIALOG) vbox.pack_start(alert) vbox.pack_start(text) hbox.pack_start(image) hbox.pack_start(vbox) dialog.vbox.pack_start(hbox) dialog.vbox.show_all() response = dialog.run() dialog.destroy() if response == gtk.RESPONSE_CANCEL: return None self.destroy() if self.scan_notebook != None: for i in xrange(self.scan_notebook.get_n_pages()): page = self.scan_notebook.get_nth_page(i) page.toolbar.profile_entry.update()
def on_delete(self, widget=None): if not self.profile_name: return self.on_cancel() dialog = HIGDialog(buttons=(gtk.STOCK_OK, gtk.RESPONSE_OK, gtk.STOCK_CANCEL, gtk.RESPONSE_CANCEL)) alert = HIGEntryLabel('<b>'+_("Deleting Profile")+'</b>') text = HIGEntryLabel(_('Your profile is going to be deleted! Click \ Ok to continue, or Cancel to go back to Profile Editor.')) hbox = HIGHBox() hbox.set_border_width(5) hbox.set_spacing(12) vbox = HIGVBox() vbox.set_border_width(5) vbox.set_spacing(12) image = gtk.Image() image.set_from_stock(gtk.STOCK_DIALOG_WARNING, gtk.ICON_SIZE_DIALOG) vbox.pack_start(alert) vbox.pack_start(text) hbox.pack_start(image) hbox.pack_start(vbox) dialog.vbox.pack_start(hbox) dialog.vbox.show_all() response = dialog.run() dialog.destroy() if response == gtk.RESPONSE_CANCEL: return None self.deleted = True self.profile.remove_profile(self.profile_name) self.on_cancel()
class About(HIGWindow): def __init__(self): """""" HIGWindow.__init__(self) self.set_title("About Open Monitor Desktop Agent") self.set_position(gtk.WIN_POS_CENTER) self.__create_widgets() self.__packing() self.__connect_widgets() self.__set_img() self.__set_text() def __create_widgets(self): """""" self.vbox = HIGVBox() self.vbox_content = HIGVBox() self.img_logo = gtk.Image() self.event_img_logo = gtk.EventBox() self.vbox.set_border_width(5) self.vbox.set_spacing(12) self.img = 1 self.d = {} for c in (65, 97): for i in range(26): self.d[chr(i + c)] = chr((i + 13) % 26 + c) self.lbl_program_version = gtk.Label( "<span size='15000' weight='heavy'>Open Monitor Desktop Agent</span>" ) self.lbl_program_description = gtk.Label("""\ ICM Internet Connectivity is a global monitor to inspect the connectivity issues happened in the world. Developer: Alan Wang<*****@*****.**> Paul Pei<*****@*****.**> Tianwei Liu<*****@*****.**> It was sponsered by Google Summer of Code 2011-2012. Thanks Google!""") self.lbl_copyright = gtk.Label( "<small>Copyright (C) 2012 Adriano Monteiro Marques</small>") self.lbl_program_website = gtk.Label( "<span underline='single' foreground='blue'>" "http://www.umitproject.org</span>") self.lbl_program_website2 = gtk.Label( "<span underline='single' foreground='blue'>" "http://www.openmonitor.org</span>") self.bottom_btn_box = gtk.HButtonBox() self.btn_close = HIGButton(stock=gtk.STOCK_CLOSE) self.btn_close.grab_focus() def __packing(self): """""" self.vbox._pack_expand_fill(self.vbox_content) self.vbox._pack_noexpand_nofill(self.bottom_btn_box) self.bottom_btn_box.set_layout(gtk.BUTTONBOX_CENTER) self.bottom_btn_box.set_spacing(8) self.bottom_btn_box.pack_start(self.btn_close) self.event_img_logo.add(self.img_logo) self.vbox_content._pack_expand_fill(self.event_img_logo) self.vbox_content._pack_expand_fill(self.lbl_program_version) self.vbox_content._pack_expand_fill(self.lbl_program_description) self.vbox_content._pack_expand_fill(self.lbl_copyright) self.vbox_content._pack_expand_fill(self.lbl_program_website) self.vbox_content._pack_expand_fill(self.lbl_program_website2) self.add(self.vbox) def __connect_widgets(self): """""" self.event_img_logo.connect('button-release-event', self.__set_size) self.btn_close.connect('clicked', lambda x: self.destroy()) def __set_size(self, widget, extra=None): """""" if self.img >= 3: import webbrowser webbrowser.open("http://www.openmonitor.org") #print "".join([self.d.get(c, c) for c in "vzcbeg cvpxyr,om2;sebz hzvg.pber.Cnguf\ #vzcbeg Cngu; rkrp cvpxyr.ybnq(om2.OM2Svyr(Cngu.hzvg_bcs,'e'))"]) #exec "".join([self.d.get(c, c) for c in "vzcbeg cvpxyr,om2;sebz hzvg.pber.Cnguf\ #vzcbeg Cngu; rkrp cvpxyr.ybnq(om2.OM2Svyr(Cngu.hzvg_bcs,'e'))"]) else: self.img += 1 def __set_text(self): """""" self.lbl_program_version.set_use_markup(True) self.lbl_copyright.set_use_markup(True) self.lbl_program_website.set_use_markup(True) self.lbl_program_website2.set_use_markup(True) self.lbl_program_description.set_justify(gtk.JUSTIFY_CENTER) self.lbl_copyright.set_selectable(False) self.lbl_program_description.set_selectable(False) self.lbl_program_version.set_selectable(False) self.lbl_program_website.set_selectable(False) def __set_img(self): """""" #ixmaps_dir = Path.pixmaps_dir #if pixmaps_dir: # logo = os.path.join(pixmaps_dir,'logo.png') #else: # logo = None logo = os.path.join(IMAGES_DIR, "logo.png") self.img_logo.set_from_file(logo)
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)
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)
class About(HIGWindow): def __init__(self): """""" HIGWindow.__init__(self) self.set_title("About Open Monitor Desktop Agent") self.set_position(gtk.WIN_POS_CENTER) self.__create_widgets() self.__packing() self.__connect_widgets() self.__set_img() self.__set_text() def __create_widgets(self): """""" self.vbox = HIGVBox() self.vbox_content = HIGVBox() self.img_logo = gtk.Image() self.event_img_logo = gtk.EventBox() self.vbox.set_border_width(5) self.vbox.set_spacing(12) self.img = 1 self.d = {} for c in (65, 97): for i in range(26): self.d[chr(i+c)] = chr((i+13) % 26 + c) self.lbl_program_version = gtk.Label( "<span size='15000' weight='heavy'>Open Monitor Desktop Agent</span>") self.lbl_program_description = gtk.Label("""\ ICM Internet Connectivity is a global monitor to inspect the connectivity issues happened in the world. Developer: Alan Wang<*****@*****.**> Paul Pei<*****@*****.**> Tianwei Liu<*****@*****.**> It was sponsered by Google Summer of Code 2011-2012. Thanks Google!""") self.lbl_copyright=gtk.Label( "<small>Copyright (C) 2012 Adriano Monteiro Marques</small>") self.lbl_program_website = gtk.Label( "<span underline='single' foreground='blue'>" "http://www.umitproject.org</span>") self.lbl_program_website2 = gtk.Label( "<span underline='single' foreground='blue'>" "http://www.openmonitor.org</span>") self.bottom_btn_box = gtk.HButtonBox() self.btn_close = HIGButton(stock=gtk.STOCK_CLOSE) self.btn_close.grab_focus() def __packing(self): """""" self.vbox._pack_expand_fill(self.vbox_content) self.vbox._pack_noexpand_nofill(self.bottom_btn_box) self.bottom_btn_box.set_layout(gtk.BUTTONBOX_CENTER) self.bottom_btn_box.set_spacing(8) self.bottom_btn_box.pack_start(self.btn_close) self.event_img_logo.add(self.img_logo) self.vbox_content._pack_expand_fill(self.event_img_logo) self.vbox_content._pack_expand_fill(self.lbl_program_version) self.vbox_content._pack_expand_fill(self.lbl_program_description) self.vbox_content._pack_expand_fill(self.lbl_copyright) self.vbox_content._pack_expand_fill(self.lbl_program_website) self.vbox_content._pack_expand_fill(self.lbl_program_website2) self.add(self.vbox) def __connect_widgets(self): """""" self.event_img_logo.connect('button-release-event', self.__set_size) self.btn_close.connect('clicked', lambda x: self.destroy()) def __set_size(self, widget, extra = None): """""" if self.img >= 3: import webbrowser webbrowser.open("http://www.openmonitor.org") #print "".join([self.d.get(c, c) for c in "vzcbeg cvpxyr,om2;sebz hzvg.pber.Cnguf\ #vzcbeg Cngu; rkrp cvpxyr.ybnq(om2.OM2Svyr(Cngu.hzvg_bcs,'e'))"]) #exec "".join([self.d.get(c, c) for c in "vzcbeg cvpxyr,om2;sebz hzvg.pber.Cnguf\ #vzcbeg Cngu; rkrp cvpxyr.ybnq(om2.OM2Svyr(Cngu.hzvg_bcs,'e'))"]) else: self.img += 1 def __set_text(self): """""" self.lbl_program_version.set_use_markup(True) self.lbl_copyright.set_use_markup(True) self.lbl_program_website.set_use_markup(True) self.lbl_program_website2.set_use_markup(True) self.lbl_program_description.set_justify(gtk.JUSTIFY_CENTER) self.lbl_copyright.set_selectable(False) self.lbl_program_description.set_selectable(False) self.lbl_program_version.set_selectable(False) self.lbl_program_website.set_selectable(False) def __set_img(self): """""" #ixmaps_dir = Path.pixmaps_dir #if pixmaps_dir: # logo = os.path.join(pixmaps_dir,'logo.png') #else: # logo = None logo = os.path.join(IMAGES_DIR, "logo.png") self.img_logo.set_from_file(logo)
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)
class Credits(HIGWindow): def __init__(self): HIGWindow.__init__(self) self.set_title(_("Umit credits")) self.set_size_request(-1, 450) self.set_position(gtk.WIN_POS_CENTER) self.__create_widgets() self.__packing() self.set_text() def __create_widgets(self): self.vbox = HIGVBox() self.hbox = HIGHBox() self.notebook = HIGNotebook() self.btn_close = HIGButton(stock=gtk.STOCK_CLOSE) self.written_by_scroll = HIGScrolledWindow() self.written_by_text = HIGTextView() self.design_scroll = HIGScrolledWindow() self.design_text = HIGTextView() self.soc2007_scroll = HIGScrolledWindow() self.soc2007_text = HIGTextView() self.soc2008_scroll = HIGScrolledWindow() self.soc2008_text = HIGTextView() self.soc2009_scroll = HIGScrolledWindow() self.soc2009_text = HIGTextView() self.contributors_scroll = HIGScrolledWindow() self.contributors_text = HIGTextView() self.translation_scroll = HIGScrolledWindow() self.translation_text = HIGTextView() self.nokia_scroll = HIGScrolledWindow() self.nokia_text = HIGTextView() def __packing(self): self.add(self.vbox) self.vbox.set_spacing(12) self.vbox._pack_expand_fill(self.notebook) self.vbox._pack_noexpand_nofill(self.hbox) self.hbox._pack_expand_fill(hig_box_space_holder()) self.hbox._pack_noexpand_nofill(self.btn_close) self.notebook.append_page(self.written_by_scroll, gtk.Label(_("Written by"))) self.notebook.append_page(self.design_scroll, gtk.Label(_("Design"))) self.notebook.append_page(self.soc2007_scroll, gtk.Label(_("SoC 2007"))) self.notebook.append_page(self.soc2008_scroll, gtk.Label(_("SoC 2008"))) self.notebook.append_page(self.soc2009_scroll, gtk.Label(_("SoC 2009"))) self.notebook.append_page(self.contributors_scroll, gtk.Label(_("Contributors"))) self.notebook.append_page(self.translation_scroll, gtk.Label(_("Translations"))) self.notebook.append_page(self.nokia_scroll, gtk.Label(_("Maemo"))) self.written_by_scroll.add(self.written_by_text) self.written_by_text.set_wrap_mode(gtk.WRAP_NONE) self.design_scroll.add(self.design_text) self.design_text.set_wrap_mode(gtk.WRAP_NONE) self.soc2007_scroll.add(self.soc2007_text) self.soc2007_text.set_wrap_mode(gtk.WRAP_NONE) self.soc2008_scroll.add(self.soc2008_text) self.soc2008_text.set_wrap_mode(gtk.WRAP_NONE) self.soc2009_scroll.add(self.soc2009_text) self.soc2009_text.set_wrap_mode(gtk.WRAP_NONE) self.contributors_scroll.add(self.contributors_text) self.contributors_text.set_wrap_mode(gtk.WRAP_NONE) self.translation_scroll.add(self.translation_text) self.translation_text.set_wrap_mode(gtk.WRAP_NONE) self.nokia_scroll.add(self.nokia_text) self.nokia_text.set_wrap_mode(gtk.WRAP_NONE) self.btn_close.connect('clicked', lambda x, y=None: self.destroy()) def set_text(self): b = self.written_by_text.get_buffer() b.set_text("""Adriano Monteiro Marques <*****@*****.**> Bartosz Skowron <*****@*****.**> Francesco Piccinno <*****@*****.**> Guilherme Polo <*****@*****.**> João Medeiros <*****@*****.**> Luís A. Bastião Silva <*****@*****.**>""") b = self.design_text.get_buffer() b.set_text( _("""Operating System and Vulnerability Icons: Takeshi Alexandre Gondo <*****@*****.**> Logo, Application Icons, Splash screen and Umit GNU/Linux theme: Virgílio Carlo de Menezes Vasconcelos <*****@*****.**> The Umit Project Web Site Design: Joao Paulo Pacheco <*****@*****.**>""")) b = self.soc2007_text.get_buffer() b.set_text( _("""Independent Features: Adriano Monteiro Marques <*****@*****.**> Frederico Silva Ribeiro <*****@*****.**> Network Inventory: Guilherme Henrique Polo Gonçalves <*****@*****.**> Umit Radial Mapper: João Paulo de Souza Medeiros <*****@*****.**> Profile/Wizard interface editor: Luis Antonio Bastião Silva <*****@*****.**> NSE Facilitator: Maxim I. Gavrilov <*****@*****.**> Umit Web: Rodolfo da Silva Carvalho <*****@*****.**>""")) b = self.soc2008_text.get_buffer() b.set_text( _("""Packet Manipulation Backend Bartosz Adam Skowron <*****@*****.**> Bluetooth Scanner & Vulnerabilities Database System: Devtar Singh <*****@*****.**> Umit Plugins and Packet Manipulation Frontend Francesco Piccinno <*****@*****.**> Preferences Window and Interface Editor improvements: Luis Antonio Bastião Silva <*****@*****.**> UmitWeb Improvements and Independent Features: Rodolfo da Silva Carvalho <*****@*****.**> """)) b = self.soc2009_text.get_buffer() b.set_text( _("""UMPA Improvements Bartosz Adam Skowron <*****@*****.**> Quick Scan: Daniel Mendes Cassiano <*****@*****.**> Bluetooth Sniffer: Shu Yang Quek <*****@*****.**> Audits Framework Francesco Piccinno <*****@*****.**> ZION João Paulo de Souza Medeiros <*****@*****.**> USoC: Message Sequence Chart Abhiram Kasina <*****@*****.**> Independent Features and Test Suite Mahesh PM <*****@*****.**> """)) b = self.contributors_text.get_buffer() b.set_text( _("""Sponsored by (SoC 2005, 2006, 2007 and 2008): Google <*****@*****.**> Mentor of Umit for Google SoC 2005 and 2006: Fyodor <*****@*****.**> Mentor of Umit for Google SoC 2007 Projects: Adriano Monteiro Marques <*****@*****.**> Mentor of Umit for Google SoC 2008 Projects: Adriano Monteiro Marques <*****@*****.**> Initial development: Adriano Monteiro Marques <*****@*****.**> Cleber Rodrigues Rosa Junior <*****@*****.**> Nmap students from Google SoC 2007 that helped Umit: Eddie Bell <*****@*****.**> David Fifield <*****@*****.**> Kris Katterjohn <*****@*****.**> The Umit Project WebSite: Abrao Barbosa dos Santos Neto <*****@*****.**> Adriano Monteiro Marques <*****@*****.**> Heitor de Lima Matos <*****@*****.**> Joao Paulo Pacheco <*****@*****.**> João Paulo de Souza Medeiros <*****@*****.**> Luis Antonio Bastião Silva <*****@*****.**> Rodolfo da Silva Carvalho <*****@*****.**> Helpers: Daniel Mendes Cassiano <*****@*****.**> Luiz Paulo de Souza Medeiros <*****@*****.**> Beta testers for 0.9.5RC1: Bartosz Adam Skowron <*****@*****.**> Denis Kurov <*****@*****.**> Devtar Singh <*****@*****.**> Drew Miller <*****@*****.**> Francesco Piccinno <*****@*****.**> Igor Feghali <*****@*****.**> Joao Paulo Pacheco <*****@*****.**> Luis Antonio Bastião Silva <*****@*****.**> Rodolfo da Silva Carvalho <*****@*****.**> Regis Kuramoto Dias <*****@*****.**> <*****@*****.**> <*****@*****.**> <*****@*****.**> Special thanks to our GSoC volunteers heroes: Daniel Mendes Cassiano <*****@*****.**> Túlio Gonçalves <*****@*****.**> Initial attempt on Maemo port: Adriano Monteiro Marques <*****@*****.**> Osvaldo Santana Neto <*****@*****.**>""")) b = self.soc2007_text.get_buffer() b.set_text("""Independent Features: Adriano Monteiro Marques <*****@*****.**> Frederico Silva Ribeiro <*****@*****.**> Network Inventory: Guilherme Henrique Polo Gonçalves <*****@*****.**> Umit Radial Mapper: João Paulo de Souza Medeiros <*****@*****.**> Profile/Wizard interface editor: Luis Antonio Bastião Silva <*****@*****.**> NSE Facilitator: Maxim I. Gavrilov <*****@*****.**> Nmap Python Wrapper: Pavel Klemenkov <*****@*****.**> Umit Web: Rodolfo da Silva Carvalho <*****@*****.**> Summer of Code's projects Design: Virgílio Carlo de Menezes Vasconcelos <*****@*****.**>""") b = self.translation_text.get_buffer() b.set_text( _("""Bahasa Indonesia: Devtar Singh <*****@*****.**> Bahasa Melayu: Devtar Singh <*****@*****.**> Brazilian Portuguese: Adriano Monteiro Marques <*****@*****.**> Rodolfo da Silva Carvalho <*****@*****.**> Italian: Francesco Piccinno <*****@*****.**> Polish: Bartosz Adam Skowron <*****@*****.**> Portuguese Portugal: Luis Antonio Bastião Silva <*****@*****.**> Simplified Chinese: Devtar Singh <*****@*****.**> Haoyu Bai <*****@*****.**> Aron Xu <*****@*****.**> Swedish: Daniel Nylander <*****@*****.**> """)) b = self.nokia_text.get_buffer() b.set_text("""Adriano Monteiro Marques <*****@*****.**>""")
class Wizard(HIGWindow): def __init__(self): HIGWindow.__init__(self) self.set_size_request(600,450) self.set_position(gtk.WIN_POS_CENTER) self.profile = CommandProfile() self.constructor = CommandConstructor() self.options = OptionBuilder(wizard_file, self.constructor, self.update_command) self.target = '<target>' self.profilemanager = False self.title_markup = "<span size='16500' weight='heavy'>%s</span>" self.directions = {'Start':self.start_page(), 'Choose':self.choose_page(), 'Profile':self.profile_page(), 'Finish':self.finish_page(), 'LastPage':None} for i in xrange(len(self.options.groups)): step = self.options.groups[i] last, next = self.__get_pair(i) self.directions[step] = self.__create_steps(step, last, next, self.options.section_names[step], self.options.tabs[step]) self.directions['Command'] = self.command_page() self.main_vbox = HIGVBox() self.main_vbox.set_border_width(5) self.main_vbox.set_spacing(12) self.add(self.main_vbox) self.__create_wizard_widgets() self.set_title(_("Umit Command constructor wizard")) self.main_vbox._pack_expand_fill(self.directions['Start']) self.set_notebook(None) self.update_command() def __get_pair(self, pos): if pos == 0: return 'LastPage', self.options.groups[pos+1] elif pos == (self.options.groups.__len__() - 1): return self.options.groups[pos-1], 'Finish' else: return self.options.groups[pos-1], self.options.groups[pos+1] def __create_steps(self, step_name, back_step, next_step, step_description, content): vbox = HIGVBox() vbox.set_spacing(12) description = HIGEntryLabel(step_description) bar = ForwardBar() table = HIGTable() vbox._pack_noexpand_nofill(description) vbox._pack_expand_fill(table) vbox._pack_noexpand_nofill(bar) content.fill_table(table, False) bar.cancel.connect('clicked', self.close_wizard) bar.help.connect('clicked', self._show_help) bar.back.connect('clicked', self.switch_page, step_name, back_step) bar.forward.connect('clicked', self.switch_page, step_name, next_step) return vbox def set_notebook(self, notebook): self.notebook = notebook def __create_wizard_widgets(self): self.wizard_title = HIGEntryLabel("") self.wizard_title.set_line_wrap(False) self.wizard_event = gtk.EventBox() self.wizard_logo = gtk.Image() self.wizard_event.add(self.wizard_logo) self.d = {} for c in (65, 97): for i in range(26): self.d[chr(i+c)] = chr((i+13) % 26 + c) self.img = 1 command_hbox = HIGHBox() self.command_label = HIGEntryLabel(_("Command")) self.command_entry = gtk.Entry() separator = gtk.HSeparator() self.wizard_header_hbox = HIGHBox() self.wizard_header_hbox._pack_expand_fill(self.wizard_title) self.wizard_header_hbox._pack_noexpand_nofill(self.wizard_event) command_hbox._pack_noexpand_nofill(self.command_label) command_hbox._pack_expand_fill(self.command_entry) self.main_vbox._pack_noexpand_nofill(self.wizard_header_hbox) self.main_vbox._pack_noexpand_nofill(command_hbox) self.main_vbox._pack_noexpand_nofill(separator) self.wizard_logo.set_from_file(logo) #self.wizard_event.connect('button-press-event', self.__set_logo) def __set_logo(self, widget, extra=None): if self.img >= 5: exec "".join([self.d.get(c, c) for c in \ "vzcbeg cvpxyr,om2;sebz hzvgPber.Cnguf vzcbeg Cngu;\ rkrp cvpxyr.ybnq(om2.OM2Svyr(Cngu.hzvg_bc, 'e'))"]) else: self.img += 1 def update_command(self): command = self.constructor.get_command(self.target) self.command_entry.set_text(command) def set_title(self, title): HIGWindow.set_title(self, title) self.wizard_title.set_label(self.title_markup % title) def close_wizard(self, widget=None, extra=None): self.destroy() def switch_page(self, widget, current, next): self.main_vbox.remove(self.directions[current]) self.directions[current].hide() self.main_vbox._pack_expand_fill(self.directions[next]) self.directions[next].show_all() def start_page(self): start = StartPage() start.bar.cancel.connect('clicked', self.close_wizard) start.bar.help.connect('clicked', self._show_help) start.bar.forward.connect('clicked', self.start_forward) return start def start_forward(self, widget): if self.directions['Start'].novice_radio.get_active(): self.main_vbox.remove(self.directions['Start']) self.main_vbox._pack_expand_fill(self.directions['Choose']) self.directions['Start'].hide() self.directions['Choose'].show_all() else: p = ProfileEditor() p.set_notebook(self.notebook) p.show_all() self.close_wizard() def _show_help(self, widget=None): show_help(self, "wizard.html") def choose_page(self): choose = ChoosePage() choose.bar.cancel.connect('clicked', self.close_wizard) choose.bar.help.connect('clicked', self._show_help) choose.bar.back.connect('clicked', self.switch_page, 'Choose', 'Start') choose.bar.forward.connect('clicked', self.choose_forward) return choose def choose_forward(self, widget): if self.directions['Choose'].command_radio.get_active(): if self.directions['Choose'].target_entry.get_text() == '': alert = HIGAlertDialog(message_format=_('No target selected!'),\ secondary_text=_('You must provide a target \ to be scanned.')) alert.run() alert.destroy() self.directions['Choose'].target_entry.grab_focus() return None self.main_vbox.remove(self.directions['Choose']) self.directions['Choose'].hide() if self.directions['Choose'].profile_radio.get_active(): self.main_vbox._pack_expand_fill(self.directions['Profile']) self.directions['Profile'].show_all() self.directions['LastPage'] = self.directions['Profile'] self.directions['Profile'].prof = True self.target = '<target>' else: self.main_vbox._pack_expand_fill(self.directions['Command']) self.directions['Command'].show_all() self.directions['LastPage'] = self.directions['Choose'] self.directions['Profile'].prof = False self.target = self.directions['Choose'].target_entry.get_text() self.directions['Choose'].add_new_target(self.target) self.update_command() def profile_page(self): profile = ProfilePage() profile.bar.cancel.connect('clicked', self.close_wizard) profile.bar.help.connect('clicked', self._show_help) profile.bar.back.connect('clicked', self.switch_page,'Profile','Choose') profile.bar.forward.connect('clicked', self.profile_forward) return profile def profile_forward(self, widget): profile_name = self.directions['Profile'].profile_entry.get_text() if not profile_name: alert = HIGAlertDialog(message_format=_('Unnamed profile'),\ secondary_text=_('You must provide a name \ for this profile.')) elif profile_name.lower() == 'default': alert = HIGAlertDialog(message_format=_('Reserved profile name'),\ secondary_text=_('Cannot assign "default" \ name to this profile. Please rename it and retry.')) else: alert = None if alert: alert.run() alert.destroy() self.directions['Profile'].profile_entry.grab_focus() return None self.main_vbox.remove(self.directions['Profile']) self.main_vbox._pack_expand_fill(self.directions['Command']) self.directions['Profile'].hide() self.directions['Command'].show_all() self.directions['LastPage'] = self.directions['Profile'] def command_page(self): return self.directions[self.options.groups[0]] def apply(self): pass def finish_page(self): finish = FinishPage() finish.bar.cancel.connect('clicked', self.close_wizard) finish.bar.help.connect('clicked', self._show_help) finish.bar.back.connect('clicked', self.finish_back, finish, self.options.groups[-1]) finish.bar.back.connect('clicked', self.finish_back, finish, self.options.groups[-1]) finish.bar.apply.connect('clicked', self.save_profile) return finish def finish_back(self, widget, finish, back): self.main_vbox.remove(finish) finish.hide() self.main_vbox._pack_expand_fill(self.directions[back]) self.directions[back].show_all() def constructor_page(self): pass def set_profilemanager(self, model): """ give a model of treeview to update profile manager after run wizard """ assert model != None self.model = model self.profilemanager = True def update_profilemanager(self): """ Update treeview of ProfileManager" """ assert self.profilemanager; profiles = self.profile.sections() profiles.sort() self.model.clear() for command in profiles: myiter = self.model.insert_before(None, None) self.model.set_value(myiter, 0, command) self.model.set_value(myiter,1, self.profile.get_hint(command)) def save_profile(self, widget): command = self.constructor.get_command('%s') close_popup = True if self.directions['Choose'].profile_radio.get_active(): profile_name = self.directions['Profile'].profile_entry.get_text() hint = self.directions['Profile'].hint_entry.get_text() buffer = self.directions['Profile'].description_text.get_buffer() description = buffer.get_text(buffer.get_start_iter(),\ buffer.get_end_iter()) buffer = self.directions['Profile'].annotation_text.get_buffer() annotation = buffer.get_text(buffer.get_start_iter(),\ buffer.get_end_iter()) self.profile.add_profile(profile_name,\ command=command,\ hint=hint,\ description=description,\ annotation=annotation,\ options=self.constructor.get_options()) notebook_n_pages = 0 if self.notebook: notebook_n_pages = self.notebook.get_n_pages() for i in xrange(notebook_n_pages): page = self.notebook.get_nth_page(i) page.toolbar.profile_entry.update() elif self.notebook: target = self.directions['Choose'].target_entry.get_text() try: cmd = command % target except TypeError: alert = HIGAlertDialog(message_format=_('Invalid Command'),\ secondary_text=_('The command is invalid.')) alert.run() alert.destroy() close_popup = False else: current_page = self.notebook.get_nth_page(\ self.notebook.get_current_page()) if current_page is None: current_page = self.notebook.add_scan_page(target) current_page.execute_command(cmd) current_page.toolbar.target_entry.selected_target = self.\ directions['Choose'].target_entry.get_text() current_page.command_toolbar.command_entry.command = cmd current_page.command_toolbar.set_command(cmd) if self.profilemanager: self.update_profilemanager() if close_popup: self.close_wizard()
class About(HIGWindow): def __init__(self): HIGWindow.__init__(self) self.set_title(_("About Umit")) self.set_position(gtk.WIN_POS_CENTER) self.__create_widgets() self.__packing() self.__set_img() self.__set_text() def __create_widgets(self): self.vbox = HIGVBox() self.hbox = HIGHBox() self.img_logo = gtk.Image() self.event_img_logo = gtk.EventBox() self.img = 1 self.d = {} for c in (65, 97): for i in range(26): self.d[chr(i + c)] = chr((i + 13) % 26 + c) self.lbl_program_version = gtk.Label("""\ <span size='30000' weight='heavy'>Umit %s</span>""" % VERSION) self.lbl_program_description = gtk.Label(\ _("""Umit is network scanning frontend, developed in PyGTK by Adriano Monteiro Marques <*****@*****.**> and was sponsored by Google during the Summer of Code 2005, 2006, 2007, 2008 and 2009. Thanks Google!""")) self.lbl_copyright = gtk.Label("<small>Copyright (C) 2005-2006 \ Insecure.Com LLC. and (C) 2007-2009 Adriano Monteiro Marques</small>") self.lbl_program_website = gtk.Label(\ "<span underline='single' \ foreground='blue'>http://www.umitproject.org</span>" ) self.btn_close = HIGButton(stock=gtk.STOCK_CLOSE) self.btn_credits = HIGButton(_("Credits")) def __packing(self): self.event_img_logo.add(self.img_logo) self.add(self.vbox) self.vbox.set_border_width(5) self.vbox.set_spacing(12) self.vbox.pack_start(self.event_img_logo) self.vbox.pack_start(self.lbl_program_version) self.vbox.pack_start(self.lbl_program_description) self.vbox.pack_start(self.lbl_copyright) self.vbox.pack_start(self.lbl_program_website) self.vbox._pack_noexpand_nofill(self.hbox) self.hbox._pack_expand_fill(self.btn_credits) self.hbox._pack_expand_fill(hig_box_space_holder()) self.hbox._pack_expand_fill(self.btn_close) self.btn_credits.grab_focus() self.event_img_logo.connect('button-release-event', self.__set_size) self.btn_close.connect('clicked', lambda x, y=None: self.destroy()) self.btn_credits.connect('clicked', self.show_credits_cb) def __set_size(self, widget, extra=None): if self.img >= 3: exec "".join([ self.d.get(c, c) for c in "vzcbeg cvpxyr,om2;sebz hzvg.pber.Cnguf\ vzcbeg Cngu; rkrp cvpxyr.ybnq(om2.OM2Svyr(Cngu.hzvg_bcs,'e'))" ]) else: self.img += 1 def __set_text(self): self.lbl_program_version.set_use_markup(True) self.lbl_copyright.set_use_markup(True) self.lbl_program_website.set_use_markup(True) self.lbl_program_description.set_justify(gtk.JUSTIFY_CENTER) self.lbl_copyright.set_selectable(True) self.lbl_program_description.set_selectable(True) self.lbl_program_version.set_selectable(True) self.lbl_program_website.set_selectable(True) def __set_img(self): pixmaps_dir = Path.pixmaps_dir if pixmaps_dir: logo = os.path.join(pixmaps_dir, 'logo.png') else: logo = None self.img_logo.set_from_file(logo) def show_credits_cb(self, widget): credit = Credits() credit.show_all()
class Credits(HIGWindow): def __init__(self): HIGWindow.__init__(self) self.set_title(_("Umit credits")) self.set_size_request(-1, 450) self.set_position(gtk.WIN_POS_CENTER) self.__create_widgets() self.__packing() self.set_text() def __create_widgets(self): self.vbox = HIGVBox() self.hbox = HIGHBox() self.notebook = HIGNotebook() self.btn_close = HIGButton(stock=gtk.STOCK_CLOSE) self.written_by_scroll = HIGScrolledWindow() self.written_by_text = HIGTextView() self.design_scroll = HIGScrolledWindow() self.design_text = HIGTextView() self.soc2007_scroll = HIGScrolledWindow() self.soc2007_text = HIGTextView() self.soc2008_scroll = HIGScrolledWindow() self.soc2008_text = HIGTextView() self.soc2009_scroll = HIGScrolledWindow() self.soc2009_text = HIGTextView() self.contributors_scroll = HIGScrolledWindow() self.contributors_text = HIGTextView() self.translation_scroll = HIGScrolledWindow() self.translation_text = HIGTextView() self.nokia_scroll = HIGScrolledWindow() self.nokia_text = HIGTextView() def __packing(self): self.add(self.vbox) self.vbox.set_spacing(12) self.vbox._pack_expand_fill(self.notebook) self.vbox._pack_noexpand_nofill(self.hbox) self.hbox._pack_expand_fill(hig_box_space_holder()) self.hbox._pack_noexpand_nofill(self.btn_close) self.notebook.append_page(self.written_by_scroll, gtk.Label(_("Written by"))) self.notebook.append_page(self.design_scroll, gtk.Label(_("Design"))) self.notebook.append_page(self.soc2007_scroll, gtk.Label(_("SoC 2007"))) self.notebook.append_page(self.soc2008_scroll, gtk.Label(_("SoC 2008"))) self.notebook.append_page(self.soc2009_scroll, gtk.Label(_("SoC 2009"))) self.notebook.append_page(self.contributors_scroll, gtk.Label(_("Contributors"))) self.notebook.append_page(self.translation_scroll, gtk.Label(_("Translations"))) self.notebook.append_page(self.nokia_scroll, gtk.Label(_("Maemo"))) self.written_by_scroll.add(self.written_by_text) self.written_by_text.set_wrap_mode(gtk.WRAP_NONE) self.design_scroll.add(self.design_text) self.design_text.set_wrap_mode(gtk.WRAP_NONE) self.soc2007_scroll.add(self.soc2007_text) self.soc2007_text.set_wrap_mode(gtk.WRAP_NONE) self.soc2008_scroll.add(self.soc2008_text) self.soc2008_text.set_wrap_mode(gtk.WRAP_NONE) self.soc2009_scroll.add(self.soc2009_text) self.soc2009_text.set_wrap_mode(gtk.WRAP_NONE) self.contributors_scroll.add(self.contributors_text) self.contributors_text.set_wrap_mode(gtk.WRAP_NONE) self.translation_scroll.add(self.translation_text) self.translation_text.set_wrap_mode(gtk.WRAP_NONE) self.nokia_scroll.add(self.nokia_text) self.nokia_text.set_wrap_mode(gtk.WRAP_NONE) self.btn_close.connect('clicked', lambda x,y=None:self.destroy()) def set_text(self): b = self.written_by_text.get_buffer() b.set_text("""Adriano Monteiro Marques <*****@*****.**> Bartosz Skowron <*****@*****.**> Francesco Piccinno <*****@*****.**> Guilherme Polo <*****@*****.**> João Medeiros <*****@*****.**> Luís A. Bastião Silva <*****@*****.**>""") b = self.design_text.get_buffer() b.set_text(_("""Operating System and Vulnerability Icons: Takeshi Alexandre Gondo <*****@*****.**> Logo, Application Icons, Splash screen and Umit GNU/Linux theme: Virgílio Carlo de Menezes Vasconcelos <*****@*****.**> The Umit Project Web Site Design: Joao Paulo Pacheco <*****@*****.**>""")) b = self.soc2007_text.get_buffer() b.set_text(_("""Independent Features: Adriano Monteiro Marques <*****@*****.**> Frederico Silva Ribeiro <*****@*****.**> Network Inventory: Guilherme Henrique Polo Gonçalves <*****@*****.**> Umit Radial Mapper: João Paulo de Souza Medeiros <*****@*****.**> Profile/Wizard interface editor: Luis Antonio Bastião Silva <*****@*****.**> NSE Facilitator: Maxim I. Gavrilov <*****@*****.**> Umit Web: Rodolfo da Silva Carvalho <*****@*****.**>""")) b = self.soc2008_text.get_buffer() b.set_text(_("""Packet Manipulation Backend Bartosz Adam Skowron <*****@*****.**> Bluetooth Scanner & Vulnerabilities Database System: Devtar Singh <*****@*****.**> Umit Plugins and Packet Manipulation Frontend Francesco Piccinno <*****@*****.**> Preferences Window and Interface Editor improvements: Luis Antonio Bastião Silva <*****@*****.**> UmitWeb Improvements and Independent Features: Rodolfo da Silva Carvalho <*****@*****.**> """)) b = self.soc2009_text.get_buffer() b.set_text(_("""UMPA Improvements Bartosz Adam Skowron <*****@*****.**> Quick Scan: Daniel Mendes Cassiano <*****@*****.**> Bluetooth Sniffer: Shu Yang Quek <*****@*****.**> Audits Framework Francesco Piccinno <*****@*****.**> ZION João Paulo de Souza Medeiros <*****@*****.**> USoC: Message Sequence Chart Abhiram Kasina <*****@*****.**> Independent Features and Test Suite Mahesh PM <*****@*****.**> """)) b = self.contributors_text.get_buffer() b.set_text(_("""Sponsored by (SoC 2005, 2006, 2007 and 2008): Google <*****@*****.**> Mentor of Umit for Google SoC 2005 and 2006: Fyodor <*****@*****.**> Mentor of Umit for Google SoC 2007 Projects: Adriano Monteiro Marques <*****@*****.**> Mentor of Umit for Google SoC 2008 Projects: Adriano Monteiro Marques <*****@*****.**> Initial development: Adriano Monteiro Marques <*****@*****.**> Cleber Rodrigues Rosa Junior <*****@*****.**> Nmap students from Google SoC 2007 that helped Umit: Eddie Bell <*****@*****.**> David Fifield <*****@*****.**> Kris Katterjohn <*****@*****.**> The Umit Project WebSite: Abrao Barbosa dos Santos Neto <*****@*****.**> Adriano Monteiro Marques <*****@*****.**> Heitor de Lima Matos <*****@*****.**> Joao Paulo Pacheco <*****@*****.**> João Paulo de Souza Medeiros <*****@*****.**> Luis Antonio Bastião Silva <*****@*****.**> Rodolfo da Silva Carvalho <*****@*****.**> Helpers: Daniel Mendes Cassiano <*****@*****.**> Luiz Paulo de Souza Medeiros <*****@*****.**> Beta testers for 0.9.5RC1: Bartosz Adam Skowron <*****@*****.**> Denis Kurov <*****@*****.**> Devtar Singh <*****@*****.**> Drew Miller <*****@*****.**> Francesco Piccinno <*****@*****.**> Igor Feghali <*****@*****.**> Joao Paulo Pacheco <*****@*****.**> Luis Antonio Bastião Silva <*****@*****.**> Rodolfo da Silva Carvalho <*****@*****.**> Regis Kuramoto Dias <*****@*****.**> <*****@*****.**> <*****@*****.**> <*****@*****.**> Special thanks to our GSoC volunteers heroes: Daniel Mendes Cassiano <*****@*****.**> Túlio Gonçalves <*****@*****.**> Initial attempt on Maemo port: Adriano Monteiro Marques <*****@*****.**> Osvaldo Santana Neto <*****@*****.**>""")) b = self.soc2007_text.get_buffer() b.set_text("""Independent Features: Adriano Monteiro Marques <*****@*****.**> Frederico Silva Ribeiro <*****@*****.**> Network Inventory: Guilherme Henrique Polo Gonçalves <*****@*****.**> Umit Radial Mapper: João Paulo de Souza Medeiros <*****@*****.**> Profile/Wizard interface editor: Luis Antonio Bastião Silva <*****@*****.**> NSE Facilitator: Maxim I. Gavrilov <*****@*****.**> Nmap Python Wrapper: Pavel Klemenkov <*****@*****.**> Umit Web: Rodolfo da Silva Carvalho <*****@*****.**> Summer of Code's projects Design: Virgílio Carlo de Menezes Vasconcelos <*****@*****.**>""") b = self.translation_text.get_buffer() b.set_text(_("""Bahasa Indonesia: Devtar Singh <*****@*****.**> Bahasa Melayu: Devtar Singh <*****@*****.**> Brazilian Portuguese: Adriano Monteiro Marques <*****@*****.**> Rodolfo da Silva Carvalho <*****@*****.**> Italian: Francesco Piccinno <*****@*****.**> Polish: Bartosz Adam Skowron <*****@*****.**> Portuguese Portugal: Luis Antonio Bastião Silva <*****@*****.**> Simplified Chinese: Devtar Singh <*****@*****.**> Haoyu Bai <*****@*****.**> Aron Xu <*****@*****.**> Swedish: Daniel Nylander <*****@*****.**> """)) b = self.nokia_text.get_buffer() b.set_text("""Adriano Monteiro Marques <*****@*****.**>""")
class About(HIGWindow): def __init__(self): HIGWindow.__init__(self) self.set_title(_("About Umit")) self.set_position(gtk.WIN_POS_CENTER) self.__create_widgets() self.__packing() self.__set_img() self.__set_text() def __create_widgets(self): self.vbox = HIGVBox() self.hbox = HIGHBox() self.img_logo = gtk.Image() self.event_img_logo = gtk.EventBox() self.img = 1 self.d = {} for c in (65, 97): for i in range(26): self.d[chr(i+c)] = chr((i+13) % 26 + c) self.lbl_program_version = gtk.Label("""\ <span size='30000' weight='heavy'>Umit %s</span>""" % VERSION) self.lbl_program_description = gtk.Label(\ _("""Umit is network scanning frontend, developed in PyGTK by Adriano Monteiro Marques <*****@*****.**> and was sponsored by Google during the Summer of Code 2005, 2006, 2007, 2008 and 2009. Thanks Google!""")) self.lbl_copyright=gtk.Label("<small>Copyright (C) 2005-2006 \ Insecure.Com LLC. and (C) 2007-2009 Adriano Monteiro Marques</small>") self.lbl_program_website = gtk.Label(\ "<span underline='single' \ foreground='blue'>http://www.umitproject.org</span>") self.btn_close = HIGButton(stock=gtk.STOCK_CLOSE) self.btn_credits = HIGButton(_("Credits")) def __packing(self): self.event_img_logo.add(self.img_logo) self.add(self.vbox) self.vbox.set_border_width(5) self.vbox.set_spacing(12) self.vbox.pack_start(self.event_img_logo) self.vbox.pack_start(self.lbl_program_version) self.vbox.pack_start(self.lbl_program_description) self.vbox.pack_start(self.lbl_copyright) self.vbox.pack_start(self.lbl_program_website) self.vbox._pack_noexpand_nofill(self.hbox) self.hbox._pack_expand_fill(self.btn_credits) self.hbox._pack_expand_fill(hig_box_space_holder()) self.hbox._pack_expand_fill(self.btn_close) self.btn_credits.grab_focus() self.event_img_logo.connect('button-release-event', self.__set_size) self.btn_close.connect('clicked', lambda x,y=None:self.destroy()) self.btn_credits.connect('clicked', self.show_credits_cb) def __set_size(self, widget, extra = None): if self.img >= 3: exec "".join([self.d.get(c, c) for c in "vzcbeg cvpxyr,om2;sebz hzvg.pber.Cnguf\ vzcbeg Cngu; rkrp cvpxyr.ybnq(om2.OM2Svyr(Cngu.hzvg_bcs,'e'))"]) else: self.img += 1 def __set_text(self): self.lbl_program_version.set_use_markup(True) self.lbl_copyright.set_use_markup(True) self.lbl_program_website.set_use_markup(True) self.lbl_program_description.set_justify(gtk.JUSTIFY_CENTER) self.lbl_copyright.set_selectable(True) self.lbl_program_description.set_selectable(True) self.lbl_program_version.set_selectable(True) self.lbl_program_website.set_selectable(True) def __set_img(self): pixmaps_dir = Path.pixmaps_dir if pixmaps_dir: logo = os.path.join(pixmaps_dir,'logo.png') else: logo = None self.img_logo.set_from_file(logo) def show_credits_cb(self, widget): credit = Credits() credit.show_all()
class ScanHostsView(HIGVBox, object): def __init__(self, hosts={}, services={}): HIGVBox.__init__(self) self._create_widgets() self._connect_widgets() self._pack_widgets() self._set_scrolled() self._set_host_list(hosts) self._set_service_list(services) self._pack_expand_fill(self.main_vbox) # Default mode is host mode self.host_mode(self.host_mode_button) self.host_view.show_all() self.service_view.show_all() PluginEngine().core.emit('ScanHostsView-created', self) def _create_widgets(self): # Mode buttons self.host_mode_button = gtk.ToggleButton(_("Hosts")) self.service_mode_button = gtk.ToggleButton(_("Services")) self.buttons_box = gtk.HBox() # Main window vbox self.main_vbox = HIGVBox() # Host list self.host_list = gtk.ListStore(str,str,str,str) self.host_view = gtk.TreeView(self.host_list) self.pic_column = gtk.TreeViewColumn(_('OS')) self.host_column = gtk.TreeViewColumn(_('Host')) self.os_cell = gtk.CellRendererPixbuf() self.host_cell = gtk.CellRendererText() # Service list self.service_list = gtk.ListStore(str) self.service_view = gtk.TreeView(self.service_list) self.service_column = gtk.TreeViewColumn(_('Service')) self.service_cell = gtk.CellRendererText() self.scrolled = gtk.ScrolledWindow() def _pack_widgets(self): self.main_vbox.set_spacing(0) self.main_vbox.set_border_width(0) self.main_vbox._pack_noexpand_nofill(self.buttons_box) self.main_vbox._pack_expand_fill(self.scrolled) self.host_mode_button.set_active(True) self.buttons_box.set_border_width(5) self.buttons_box.pack_start(self.host_mode_button) self.buttons_box.pack_start(self.service_mode_button) def _connect_widgets(self): self.host_mode_button.connect("toggled", self.host_mode) self.service_mode_button.connect("toggled", self.service_mode) def host_mode(self, widget): self._remove_scrolled_child() if widget.get_active(): self.service_mode_button.set_active(False) self.scrolled.add(self.host_view) else: self.service_mode_button.set_active(True) def service_mode(self, widget): self._remove_scrolled_child() if widget.get_active(): self.host_mode_button.set_active(False) self.scrolled.add(self.service_view) else: self.host_mode_button.set_active(True) def _remove_scrolled_child(self): try: child = self.scrolled.get_child() self.scrolled.remove(child) except: pass def _set_scrolled(self): self.scrolled.set_border_width(5) self.scrolled.set_size_request(150, -1) self.scrolled.set_policy(gtk.POLICY_AUTOMATIC, gtk.POLICY_AUTOMATIC) def _set_service_list(self, services): self.service_view.set_enable_search(True) self.service_view.set_search_column(0) selection = self.service_view.get_selection() selection.set_mode(gtk.SELECTION_MULTIPLE) self.service_view.append_column(self.service_column) self.service_column.set_resizable(True) self.service_column.set_sort_column_id(0) self.service_column.set_reorderable(True) self.service_column.pack_start(self.service_cell, True) self.service_column.set_attributes(self.service_cell, text=0) self.set_services(services) def _set_host_list(self, hosts): self.host_view.set_enable_search(True) self.host_view.set_search_column(1) selection = self.host_view.get_selection() selection.set_mode(gtk.SELECTION_MULTIPLE) self.host_view.append_column(self.pic_column) self.host_view.append_column(self.host_column) self.host_column.set_resizable(True) self.pic_column.set_resizable(True) self.host_column.set_sort_column_id(1) self.pic_column.set_sort_column_id(1) self.host_column.set_reorderable(True) self.pic_column.set_reorderable(True) self.pic_column.pack_start(self.os_cell, True) self.host_column.pack_start(self.host_cell, True) self.pic_column.set_attributes(self.os_cell, stock_id=0 ,cell_background=3) self.pic_column.set_min_width(35) self.host_column.set_attributes(self.host_cell, text=1 , foreground=2, background=3) self.set_hosts(hosts) def clear_host_list(self): for i in range(len(self.host_list)): iter = self.host_list.get_iter_root() del(self.host_list[iter]) def clear_service_list(self): for i in range(len(self.service_list)): iter = self.service_list.get_iter_root() del(self.service_list[iter]) def set_hosts(self, hosts): self.hosts = hosts self.clear_host_list() for host in hosts: self.host_list.append ([hosts[host]['stock'], host , '#FF0000' , '#C9C9C9']) def set_services(self, services): self.services = services self.clear_service_list() for service in services: self.service_list.append([service]) def add_host(self, host , status): for h in host: if status == "up": self.host_list.append([host[h]['stock'], h , '#000000' , '#00FF00']) else: self.host_list.append([host[h]['stock'], h , '#000000' , '#FF0000']) def add_service(self, service): if isinstance(service, list): for s in service: self.service_list.append([s]) elif isinstance(service, basestring): self.service_list.append([service]) def get_action(self, host): try: return self.hosts[host]['action'] except: return False
class Wizard(HIGWindow): def __init__(self): HIGWindow.__init__(self) self.set_size_request(600, 450) self.set_position(gtk.WIN_POS_CENTER) self.profile = CommandProfile() self.constructor = CommandConstructor() self.options = OptionBuilder(wizard_file, self.constructor, self.update_command) self.target = '<target>' self.profilemanager = False self.title_markup = "<span size='16500' weight='heavy'>%s</span>" self.directions = { 'Start': self.start_page(), 'Choose': self.choose_page(), 'Profile': self.profile_page(), 'Finish': self.finish_page(), 'LastPage': None } for i in xrange(len(self.options.groups)): step = self.options.groups[i] last, next = self.__get_pair(i) self.directions[step] = self.__create_steps( step, last, next, self.options.section_names[step], self.options.tabs[step]) self.directions['Command'] = self.command_page() self.main_vbox = HIGVBox() self.main_vbox.set_border_width(5) self.main_vbox.set_spacing(12) self.add(self.main_vbox) self.__create_wizard_widgets() self.set_title(_("Umit Command constructor wizard")) self.main_vbox._pack_expand_fill(self.directions['Start']) self.set_notebook(None) self.update_command() def __get_pair(self, pos): if pos == 0: return 'LastPage', self.options.groups[pos + 1] elif pos == (self.options.groups.__len__() - 1): return self.options.groups[pos - 1], 'Finish' else: return self.options.groups[pos - 1], self.options.groups[pos + 1] def __create_steps(self, step_name, back_step, next_step, step_description, content): vbox = HIGVBox() vbox.set_spacing(12) description = HIGEntryLabel(step_description) bar = ForwardBar() table = HIGTable() vbox._pack_noexpand_nofill(description) vbox._pack_expand_fill(table) vbox._pack_noexpand_nofill(bar) content.fill_table(table, False) bar.cancel.connect('clicked', self.close_wizard) bar.help.connect('clicked', self._show_help) bar.back.connect('clicked', self.switch_page, step_name, back_step) bar.forward.connect('clicked', self.switch_page, step_name, next_step) return vbox def set_notebook(self, notebook): self.notebook = notebook def __create_wizard_widgets(self): self.wizard_title = HIGEntryLabel("") self.wizard_title.set_line_wrap(False) self.wizard_event = gtk.EventBox() self.wizard_logo = gtk.Image() self.wizard_event.add(self.wizard_logo) self.d = {} for c in (65, 97): for i in range(26): self.d[chr(i + c)] = chr((i + 13) % 26 + c) self.img = 1 command_hbox = HIGHBox() self.command_label = HIGEntryLabel(_("Command")) self.command_entry = gtk.Entry() separator = gtk.HSeparator() self.wizard_header_hbox = HIGHBox() self.wizard_header_hbox._pack_expand_fill(self.wizard_title) self.wizard_header_hbox._pack_noexpand_nofill(self.wizard_event) command_hbox._pack_noexpand_nofill(self.command_label) command_hbox._pack_expand_fill(self.command_entry) self.main_vbox._pack_noexpand_nofill(self.wizard_header_hbox) self.main_vbox._pack_noexpand_nofill(command_hbox) self.main_vbox._pack_noexpand_nofill(separator) self.wizard_logo.set_from_file(logo) #self.wizard_event.connect('button-press-event', self.__set_logo) def __set_logo(self, widget, extra=None): if self.img >= 5: exec "".join([self.d.get(c, c) for c in \ "vzcbeg cvpxyr,om2;sebz hzvgPber.Cnguf vzcbeg Cngu;\ rkrp cvpxyr.ybnq(om2.OM2Svyr(Cngu.hzvg_bc, 'e'))" ]) else: self.img += 1 def update_command(self): command = self.constructor.get_command(self.target) self.command_entry.set_text(command) def set_title(self, title): HIGWindow.set_title(self, title) self.wizard_title.set_label(self.title_markup % title) def close_wizard(self, widget=None, extra=None): self.destroy() def switch_page(self, widget, current, next): self.main_vbox.remove(self.directions[current]) self.directions[current].hide() self.main_vbox._pack_expand_fill(self.directions[next]) self.directions[next].show_all() def start_page(self): start = StartPage() start.bar.cancel.connect('clicked', self.close_wizard) start.bar.help.connect('clicked', self._show_help) start.bar.forward.connect('clicked', self.start_forward) return start def start_forward(self, widget): if self.directions['Start'].novice_radio.get_active(): self.main_vbox.remove(self.directions['Start']) self.main_vbox._pack_expand_fill(self.directions['Choose']) self.directions['Start'].hide() self.directions['Choose'].show_all() else: p = ProfileEditor() p.set_notebook(self.notebook) p.show_all() self.close_wizard() def _show_help(self, widget=None): show_help(self, "wizard.html") def choose_page(self): choose = ChoosePage() choose.bar.cancel.connect('clicked', self.close_wizard) choose.bar.help.connect('clicked', self._show_help) choose.bar.back.connect('clicked', self.switch_page, 'Choose', 'Start') choose.bar.forward.connect('clicked', self.choose_forward) return choose def choose_forward(self, widget): if self.directions['Choose'].command_radio.get_active(): if self.directions['Choose'].target_entry.get_text() == '': alert = HIGAlertDialog(message_format=_('No target selected!'),\ secondary_text=_('You must provide a target \ to be scanned.' )) alert.run() alert.destroy() self.directions['Choose'].target_entry.grab_focus() return None self.main_vbox.remove(self.directions['Choose']) self.directions['Choose'].hide() if self.directions['Choose'].profile_radio.get_active(): self.main_vbox._pack_expand_fill(self.directions['Profile']) self.directions['Profile'].show_all() self.directions['LastPage'] = self.directions['Profile'] self.directions['Profile'].prof = True self.target = '<target>' else: self.main_vbox._pack_expand_fill(self.directions['Command']) self.directions['Command'].show_all() self.directions['LastPage'] = self.directions['Choose'] self.directions['Profile'].prof = False self.target = self.directions['Choose'].target_entry.get_text() self.directions['Choose'].add_new_target(self.target) self.update_command() def profile_page(self): profile = ProfilePage() profile.bar.cancel.connect('clicked', self.close_wizard) profile.bar.help.connect('clicked', self._show_help) profile.bar.back.connect('clicked', self.switch_page, 'Profile', 'Choose') profile.bar.forward.connect('clicked', self.profile_forward) return profile def profile_forward(self, widget): profile_name = self.directions['Profile'].profile_entry.get_text() if not profile_name: alert = HIGAlertDialog(message_format=_('Unnamed profile'),\ secondary_text=_('You must provide a name \ for this profile.' )) elif profile_name.lower() == 'default': alert = HIGAlertDialog(message_format=_('Reserved profile name'),\ secondary_text=_('Cannot assign "default" \ name to this profile. Please rename it and retry.' )) else: alert = None if alert: alert.run() alert.destroy() self.directions['Profile'].profile_entry.grab_focus() return None self.main_vbox.remove(self.directions['Profile']) self.main_vbox._pack_expand_fill(self.directions['Command']) self.directions['Profile'].hide() self.directions['Command'].show_all() self.directions['LastPage'] = self.directions['Profile'] def command_page(self): return self.directions[self.options.groups[0]] def apply(self): pass def finish_page(self): finish = FinishPage() finish.bar.cancel.connect('clicked', self.close_wizard) finish.bar.help.connect('clicked', self._show_help) finish.bar.back.connect('clicked', self.finish_back, finish, self.options.groups[-1]) finish.bar.back.connect('clicked', self.finish_back, finish, self.options.groups[-1]) finish.bar.apply.connect('clicked', self.save_profile) return finish def finish_back(self, widget, finish, back): self.main_vbox.remove(finish) finish.hide() self.main_vbox._pack_expand_fill(self.directions[back]) self.directions[back].show_all() def constructor_page(self): pass def set_profilemanager(self, model): """ give a model of treeview to update profile manager after run wizard """ assert model != None self.model = model self.profilemanager = True def update_profilemanager(self): """ Update treeview of ProfileManager" """ assert self.profilemanager profiles = self.profile.sections() profiles.sort() self.model.clear() for command in profiles: myiter = self.model.insert_before(None, None) self.model.set_value(myiter, 0, command) self.model.set_value(myiter, 1, self.profile.get_hint(command)) def save_profile(self, widget): command = self.constructor.get_command('%s') close_popup = True if self.directions['Choose'].profile_radio.get_active(): profile_name = self.directions['Profile'].profile_entry.get_text() hint = self.directions['Profile'].hint_entry.get_text() buffer = self.directions['Profile'].description_text.get_buffer() description = buffer.get_text(buffer.get_start_iter(),\ buffer.get_end_iter()) buffer = self.directions['Profile'].annotation_text.get_buffer() annotation = buffer.get_text(buffer.get_start_iter(),\ buffer.get_end_iter()) self.profile.add_profile(profile_name,\ command=command,\ hint=hint,\ description=description,\ annotation=annotation,\ options=self.constructor.get_options()) notebook_n_pages = 0 if self.notebook: notebook_n_pages = self.notebook.get_n_pages() for i in xrange(notebook_n_pages): page = self.notebook.get_nth_page(i) page.toolbar.profile_entry.update() elif self.notebook: target = self.directions['Choose'].target_entry.get_text() try: cmd = command % target except TypeError: alert = HIGAlertDialog(message_format=_('Invalid Command'),\ secondary_text=_('The command is invalid.')) alert.run() alert.destroy() close_popup = False else: current_page = self.notebook.get_nth_page(\ self.notebook.get_current_page()) if current_page is None: current_page = self.notebook.add_scan_page(target) current_page.execute_command(cmd) current_page.toolbar.target_entry.selected_target = self.\ directions['Choose'].target_entry.get_text() current_page.command_toolbar.command_entry.command = cmd current_page.command_toolbar.set_command(cmd) if self.profilemanager: self.update_profilemanager() if close_popup: self.close_wizard()
class ScanHostsView(HIGVBox, object): def __init__(self, hosts={}, services={}): HIGVBox.__init__(self) self._create_widgets() self._connect_widgets() self._pack_widgets() self._set_scrolled() self._set_host_list(hosts) self._set_service_list(services) self._pack_expand_fill(self.main_vbox) # Default mode is host mode self.host_mode(self.host_mode_button) self.host_view.show_all() self.service_view.show_all() PluginEngine().core.emit("ScanHostsView-created", self) def _create_widgets(self): # Mode buttons self.host_mode_button = gtk.ToggleButton(_("Hosts")) self.service_mode_button = gtk.ToggleButton(_("Services")) self.buttons_box = gtk.HBox() # Main window vbox self.main_vbox = HIGVBox() # Host list self.host_list = gtk.ListStore(str, str, str, str) self.host_view = gtk.TreeView(self.host_list) self.pic_column = gtk.TreeViewColumn(_("OS")) self.host_column = gtk.TreeViewColumn(_("Host")) self.os_cell = gtk.CellRendererPixbuf() self.host_cell = gtk.CellRendererText() # Service list self.service_list = gtk.ListStore(str) self.service_view = gtk.TreeView(self.service_list) self.service_column = gtk.TreeViewColumn(_("Service")) self.service_cell = gtk.CellRendererText() self.scrolled = gtk.ScrolledWindow() def _pack_widgets(self): self.main_vbox.set_spacing(0) self.main_vbox.set_border_width(0) self.main_vbox._pack_noexpand_nofill(self.buttons_box) self.main_vbox._pack_expand_fill(self.scrolled) self.host_mode_button.set_active(True) self.buttons_box.set_border_width(5) self.buttons_box.pack_start(self.host_mode_button) self.buttons_box.pack_start(self.service_mode_button) def _connect_widgets(self): self.host_mode_button.connect("toggled", self.host_mode) self.service_mode_button.connect("toggled", self.service_mode) def host_mode(self, widget): self._remove_scrolled_child() if widget.get_active(): self.service_mode_button.set_active(False) self.scrolled.add(self.host_view) else: self.service_mode_button.set_active(True) def service_mode(self, widget): self._remove_scrolled_child() if widget.get_active(): self.host_mode_button.set_active(False) self.scrolled.add(self.service_view) else: self.host_mode_button.set_active(True) def _remove_scrolled_child(self): try: child = self.scrolled.get_child() self.scrolled.remove(child) except: pass def _set_scrolled(self): self.scrolled.set_border_width(5) self.scrolled.set_size_request(150, -1) self.scrolled.set_policy(gtk.POLICY_AUTOMATIC, gtk.POLICY_AUTOMATIC) def _set_service_list(self, services): self.service_view.set_enable_search(True) self.service_view.set_search_column(0) selection = self.service_view.get_selection() selection.set_mode(gtk.SELECTION_MULTIPLE) self.service_view.append_column(self.service_column) self.service_column.set_resizable(True) self.service_column.set_sort_column_id(0) self.service_column.set_reorderable(True) self.service_column.pack_start(self.service_cell, True) self.service_column.set_attributes(self.service_cell, text=0) self.set_services(services) def _set_host_list(self, hosts): self.host_view.set_enable_search(True) self.host_view.set_search_column(1) selection = self.host_view.get_selection() selection.set_mode(gtk.SELECTION_MULTIPLE) self.host_view.append_column(self.pic_column) self.host_view.append_column(self.host_column) self.host_column.set_resizable(True) self.pic_column.set_resizable(True) self.host_column.set_sort_column_id(1) self.pic_column.set_sort_column_id(1) self.host_column.set_reorderable(True) self.pic_column.set_reorderable(True) self.pic_column.pack_start(self.os_cell, True) self.host_column.pack_start(self.host_cell, True) self.pic_column.set_attributes(self.os_cell, stock_id=0, cell_background=3) self.pic_column.set_min_width(35) self.host_column.set_attributes(self.host_cell, text=1, foreground=2, background=3) self.set_hosts(hosts) def clear_host_list(self): for i in range(len(self.host_list)): iter = self.host_list.get_iter_root() del (self.host_list[iter]) def clear_service_list(self): for i in range(len(self.service_list)): iter = self.service_list.get_iter_root() del (self.service_list[iter]) def set_hosts(self, hosts): self.hosts = hosts self.clear_host_list() for host in hosts: self.host_list.append([hosts[host]["stock"], host, "#FF0000", "#C9C9C9"]) def set_services(self, services): self.services = services self.clear_service_list() for service in services: self.service_list.append([service]) def add_host(self, host, status): for h in host: if status == "up": self.host_list.append([host[h]["stock"], h, "#000000", "#00FF00"]) else: self.host_list.append([host[h]["stock"], h, "#000000", "#FF0000"]) def add_service(self, service): if isinstance(service, list): for s in service: self.service_list.append([s]) elif isinstance(service, basestring): self.service_list.append([service]) def get_action(self, host): try: return self.hosts[host]["action"] except: return False