Пример #1
0
 def append_with_submenu(self, stock, signal=None):
     button = gtk.MenuToolButton(stock)
     self.insert(button, self.position)
     if signal:
         self.install_signal(signal)
         button.connect("clicked", self.clicked, signal)
     self.submenu = gtk.Menu()
     button.set_menu(self.submenu)
     self.position += 1
Пример #2
0
    def make_toolbar(self):
        
        toolbar = NavigationToolbar(self.canvas, self)

        next = 8

        toolitem = gtk.SeparatorToolItem()
        toolitem.show()
        toolbar.insert(toolitem, next); next+=1
        toolitem.set_expand(False)

        self.buttonFollowEvents = gtk.CheckButton ()
        self.buttonFollowEvents.set_label('Auto')
        self.buttonFollowEvents.show()
        self.buttonFollowEvents.set_active(True)

        toolitem = gtk.ToolItem()
        toolitem.show()
 	
	#Rewriting this for the new gtk tooltips available in pygtk 2.12 and up	
	#toolitem.set_tooltip(
        #   toolbar.tooltips,
        #   'Automatically update in response to selections in EEG', 'Private')
	toolitem.set_tooltip_text('Automatically update in response to selections in EEG')

        toolitem.add(self.buttonFollowEvents)
        toolbar.insert(toolitem, next); next +=1

        # XXX: only available in gtk 2.6
        menu = gtk.MenuToolButton(gtk.STOCK_EDIT)
        menu.show()
        context = self.make_context_menu()
        menu.set_menu(context)

        #menu.set_tooltip(
        #   toolbar.tooltips,
        #   'Set filter/detrend etc', 'Private')
	menu.set_tooltip_text('Set filter/detrend etc')

        toolbar.insert(menu, next); next+=1

        toolitem = gtk.SeparatorToolItem()
        toolitem.show()
        toolbar.insert(toolitem, next)
        toolitem.set_expand(False)


        return toolbar
Пример #3
0
 def _init_file_open(self):
     """Initialize file open menu item and toolbar button."""
     ph = self.ui.get_widget("/ToolBar/OpenFile")
     btn = gtk.MenuToolButton(gtk.STOCK_OPEN)
     btn.show()
     btn.connect('clicked', self.on_open_file)
     btn.set_menu(self._get_recent_menu())
     idx = self.toolbar.get_item_index(ph)
     self.toolbar.insert(btn, idx)
     ph = self.ui.get_widget('/MenuBar/File/RecentFiles')
     menu = self._get_recent_menu()
     menuitem = gtk.MenuItem(_(u'_Recent Files'))
     menuitem.show()
     menuitem.set_submenu(menu)
     file_menu = self.ui.get_widget('/MenuBar/File').get_submenu()
     for idx, child in enumerate(file_menu.get_children()):
         if child == ph:
             file_menu.insert(menuitem, idx)
             return
    def __create_widgets(self):
        """
        """
        self.__tools_menu = ToolsMenu(self.radialnet)

        self.__tools_button = gtk.MenuToolButton(gtk.STOCK_PREFERENCES)
        self.__tools_button.set_label(_("Tools"))
        self.__tools_button.set_is_important(True)
        self.__tools_button.set_menu(self.__tools_menu)
        self.__tools_button.connect('clicked', self.__tools_callback)

        self.__control = gtk.ToggleToolButton(gtk.STOCK_PROPERTIES)
        self.__control.set_label(_("Controls"))
        self.__control.set_is_important(True)
        self.__control.connect('clicked', self.__control_callback)
        self.__control.set_tooltip_text(_("Show control panel"))
        self.__control.set_active(False)

        self.__fisheye = gtk.ToggleToolButton(gtk.STOCK_ZOOM_FIT)
        self.__fisheye.set_label(_("Fisheye"))
        self.__fisheye.set_is_important(True)
        self.__fisheye.connect('clicked', self.__fisheye_callback)
        self.__fisheye.set_tooltip_text(_("Enable fisheye"))
        self.__fisheye.set_active(False)

        self.__fullscreen = gtk.ToggleToolButton(gtk.STOCK_FULLSCREEN)
        self.__fullscreen.set_label(_("Fullscreen"))
        self.__fullscreen.set_is_important(True)
        self.__fullscreen.connect('clicked', self.__fullscreen_callback)
        self.__fullscreen.set_tooltip_text(_("Toggle fullscreen"))

        self.__separator = gtk.SeparatorToolItem()
        self.__expander = gtk.SeparatorToolItem()
        self.__expander.set_expand(True)
        self.__expander.set_draw(False)

        self.insert(self.__tools_button, 0)
        self.insert(self.__expander, 1)
        self.insert(self.__control, 2)
        self.insert(self.__fisheye, 3)
        self.insert(self.__fullscreen, 4)

        gobject.timeout_add(REFRESH_RATE, self.__update)
Пример #5
0
	def init(self, context):
		BaseOutlineView.init(self, context)
		
		self._grouping = GROUP_NONE
		
		# add grouping controls to toolbar
		
		self._item_none = gtk.RadioMenuItem(None, "No Grouping")
		self._item_type = gtk.RadioMenuItem(self._item_none, "Group by Type")
		self._item_author = gtk.RadioMenuItem(self._item_none, "Group by Author")
		self._item_year = gtk.RadioMenuItem(self._item_none, "Group by Year")
		
		self._preferences = Preferences()
		
		grouping = self._preferences.get("BibtexOutlineGrouping", GROUP_NONE)
		if grouping == GROUP_NONE:
			self._item_none.set_active(True)
		elif grouping == GROUP_TYPE:
			self._item_type.set_active(True)
		elif grouping == GROUP_AUTHOR:
			self._item_author.set_active(True)
		elif grouping == GROUP_YEAR:
			self._item_year.set_active(True)
		
		self._handlers[self._item_none] = self._item_none.connect("toggled", self._on_grouping_toggled)
		self._handlers[self._item_type] = self._item_type.connect("toggled", self._on_grouping_toggled)
		self._handlers[self._item_author] = self._item_author.connect("toggled", self._on_grouping_toggled)
		self._handlers[self._item_year] = self._item_year.connect("toggled", self._on_grouping_toggled)

		menu = gtk.Menu()
		menu.add(self._item_none)
		menu.add(self._item_type)
		menu.add(self._item_author)
		menu.add(self._item_year)
		menu.show_all()

		tool_button = gtk.MenuToolButton(gtk.STOCK_SORT_DESCENDING)
		tool_button.set_menu(menu)
		tool_button.show()
		
		self._toolbar.insert(tool_button, -1)
Пример #6
0
    def _init_tool_actions(self):
        """
		 - Load defined Tools
		 - create and init ToolActions from them
		 - hook them in the window UI
		 - create a map from extensions to lists of ToolActions
		"""

        # add a MenuToolButton with the tools menu to the toolbar afterwards
        # FIXME: this is quite hacky
        menu = gtk.Menu()

        # this is used for enable/disable actions by name
        # None stands for every extension
        self._tool_action_extensions = {None: []}

        self._tool_action_group = gtk.ActionGroup("LaTeXPluginToolActions")

        items_ui = ""

        self._action_handlers = {}

        i = 1  # counting tool actions
        accel_counter = 1  # counting tool actions without custom accel
        for tool in self._preferences.tools:
            # hopefully unique action name
            name = "Tool%sAction" % i

            # update extension-tool mapping
            for extension in tool.extensions:
                try:
                    self._tool_action_extensions[extension].append(name)
                except KeyError:
                    # extension not yet mapped
                    self._tool_action_extensions[extension] = [name]

            # create action
            action = ToolAction(tool)
            gtk_action = gtk.Action(name, action.label, action.tooltip,
                                    action.stock_id)
            self._action_handlers[gtk_action] = gtk_action.connect(
                "activate", lambda gtk_action, action: action.activate(
                    self._window_context), action)

            if not tool.accelerator is None and len(tool.accelerator) > 0:
                # TODO: validate accelerator!
                self._tool_action_group.add_action_with_accel(
                    gtk_action, tool.accelerator)
            else:
                self._tool_action_group.add_action_with_accel(
                    gtk_action, "<Ctrl><Alt>%s" % accel_counter)
                accel_counter += 1

            # add to MenuToolBar menu
            # FIXME: GtkWarning: gtk_accel_label_set_accel_closure: assertion `gtk_accel_group_from_accel_closure (accel_closure) != NULL' failed
            menu.add(gtk_action.create_menu_item())

            # add UI definition
            items_ui += """<menuitem action="%s" />""" % name

            i += 1

        tool_ui = self._tool_ui_template.substitute({"items": items_ui})

        self._ui_manager.insert_action_group(self._tool_action_group, -1)
        self._tool_ui_id = self._ui_manager.add_ui_from_string(tool_ui)

        # add a MenuToolButton with the tools menu to the toolbar
        self._menu_tool_button = gtk.MenuToolButton(gtk.STOCK_CONVERT)
        self._menu_tool_button.set_menu(menu)
        self._menu_tool_button.show_all()
        self._toolbar.insert(self._menu_tool_button, -1)
Пример #7
0
    def __init__(self):
        """"""
        gtk.Window.__init__(self, gtk.WINDOW_TOPLEVEL)
        
        self.set_title(cons.APP_TITLE)
        self.set_size_request(MIN_WIDTH, MIN_HEIGHT)
        self.set_position(gtk.WIN_POS_CENTER)
        self.resize(600, 300)
        
        self.config = conf #config.py
        
        #app window position and size
        x, y, w, h = self.config.get_window_settings()
        if gtk.gdk.screen_width() <= w or gtk.gdk.screen_height() <= h:
            self.maximize()
        elif w >= MIN_WIDTH or h >= MIN_HEIGHT:
            self.resize(w, h)
        if x >= 0 and y >= 0:
            self.move(x, y)
        
        #widgets for tabs.
        self.downloads_list_gui = List(parent=self)
        self.downloads_list_gui.treeView.get_selection().connect("changed", self.on_selected)
        self.add_downloads_gui = AddDownloads(self.downloads_list_gui, parent=self)
        self.addons_gui = addons_gui.AddonsManager(self)
        self.preferences = Preferences(self.addons_gui.addons_list)
        self.log_gui = Log()

        self.vbox = gtk.VBox()
        self.add(self.vbox)

        #toolbar. button = ToolButton(icon, label), handler, sensitive.
        #add_download = gtk.ToolButton(gtk.ToolButton(gtk.STOCK_ADD), "Add Download"), self.add_links, True
        stop = (gtk.ToolButton(media.get_image(media.STOP, media.MEDIUM), None), _("Stop Download"), self.stop_download, False) #tuple
        start = (gtk.ToolButton(media.get_image(media.START, media.MEDIUM), None), _("Start Download"), self.start_download, False)
        accounts = (gtk.ToolButton(media.get_image(media.ACCOUNTS, media.MEDIUM), None), _("Accounts"), self.accounts_app, True)
        preferences = (gtk.MenuToolButton(media.get_image(media.PREFERENCES, media.MEDIUM), None), _("Preferences"), self.on_preferences, True)
        about = (gtk.ToolButton(media.get_image(media.ABOUT, media.MEDIUM), None), _("About"), self.about_dlg, True)
        self.stop = stop[WIDGET] #self.stop = gtk.ToolButton(gtk.ToolButton(gtk.STOCK_STOP), "Stop Download"). Para poder cambiar el set_sensitive
        self.start = start[WIDGET]
        self.Toolbar = Toolbar([start, stop, None, accounts, preferences, None, about]) #los botones se agregan al Toolbar en el orden de esta lista. None = separador
        self.vbox.pack_start(self.Toolbar, False)
        
        #menu
        config_preferences = (gtk.MenuItem(), _("Preferences"), self.on_preferences)
        config_about = (gtk.MenuItem(), _("About"), self.about_dlg)
        #addons-menu
        menu_items = [menu_item for menu_item in [addon.get_menu_item() for addon in self.addons_gui.addons_list] if menu_item is not None]
        menu_items.extend([None, config_preferences, config_about])
        menu = Menu(menu_items)
        preferences[WIDGET].set_menu(menu)
        
        #Sessions
        self.load_session()
        
        #tabs (notebooks)
        self.vbox2 = gtk.VBox()
        
        self.notebook = Notebook()
        self.notebook.set_tab_pos(gtk.POS_BOTTOM) #weird butg in gtk+ 2.24.10 on resizing to often (make the app crash).
        self.notebook.set_show_border(False)
        self.notebook.append_page(self.downloads_list_gui, gtk.Label(_("Downloads")))
        self.notebook.append_page(self.add_downloads_gui, gtk.Label(_("Add downloads")))
        [self.notebook.append_page(tab, gtk.Label(addon.name)) for tab, addon in [(addon.get_tab(), addon) for addon in self.addons_gui.addons_list] if tab is not None]
        self.notebook.append_page(self.log_gui, gtk.Label(_("Log")))
        self.notebook.connect("switch-page", self.on_tab_switch)
        
        self.vbox2.pack_start(self.notebook)
        self.vbox.pack_start(self.vbox2)
        
        #status bar
        self.status_bar = StatusBar(self.add_downloads_gui)
        #self.pack_start(self.status_bar, False, False, 0)
        self.vbox.pack_start(self.status_bar, False, False)
        
        #Quit Event
        events.connect(cons.EVENT_QUIT, self.on_close)
        
        #self.connect("destroy", self.on_close) #boton cerrar de la barra de arriba
        self.connect("delete-event", self.on_quit)
        
        self.show_all()
Пример #8
0
    def create_widgets(self):
        gtk.HPaned.__init__(self)

        self.create_spectralist()
        self.sl_add_action = gtk.Action("sl_add", None, _("Add spectra"),
                                        gtk.STOCK_ADD)
        self.sl_add_action.connect("activate", self.sl_add_button_cb)

        self.sl_remove_action = gtk.Action("sl_remove", None,
                                           _("Eliminate selected spectra"),
                                           gtk.STOCK_REMOVE)
        self.sl_remove_action.connect("activate", self.sl_remove_button_cb)
        self.sl_remove_action.set_sensitive(False)

        self.dil_paste_action = gtk.Action("dil_paste", None,
                                           _("Paste dilution data"),
                                           gtk.STOCK_PASTE)
        self.dil_paste_action.connect("activate", self._request_targets)
        self.dil_paste_action.set_sensitive(False)

        self.dil_reset_action = gtk.Action("dil_reset", None,
                                           _("Erase dilution data"),
                                           gtk.STOCK_CLEAR)
        self.dil_reset_action.connect("activate",
                                      self.reset_dilution_button_cb)

        self.show_preview_action = gtk.ToggleAction(
            "show_preview_action", _("Preview"),
            _("Show a plot of the selected spectrum"), gtk.STOCK_PRINT_PREVIEW)
        self.show_preview_action.connect("toggled",
                                         self._show_preview_toggle_cb)

        dil_menu = gtk.Menu()
        dil_menu.insert(self.dil_paste_action.create_menu_item(), -1)
        dil_menu.insert(self.dil_reset_action.create_menu_item(), -1)
        dil_toolmenu = gtk.MenuToolButton( \
                icon_widget = gtk.image_new_from_stock(gtk.STOCK_PASTE,
                                                       gtk.ICON_SIZE_SMALL_TOOLBAR),
                label=_("Dilution data"))
        dil_toolmenu.set_menu(dil_menu)
        dil_toolmenu.connect("clicked", self.dilution_menutoolbutton_cb)
        dil_toolmenu.set_tooltip(gtk.Tooltips(), _("Paste dilution factors"))
        dil_toolmenu.set_is_important(True)
        toolbar = gtk.Toolbar()
        toolbar.insert(self.sl_add_action.create_tool_item(), -1)
        toolbar.insert(self.sl_remove_action.create_tool_item(), -1)
        toolbar.insert(gtk.SeparatorToolItem(), -1)
        toolbar.insert(dil_toolmenu, -1)
        toolbar.insert(gtk.SeparatorToolItem(), -1)
        toolbar.insert(self.show_preview_action.create_tool_item(), -1)
        toolbar.set_style(gtk.TOOLBAR_BOTH_HORIZ)
        tv_vbox = gtk.VBox()
        tv_vbox.pack_start(toolbar, False, False, 4)
        tv_vbox.pack_start(self.spectra_scroll, True, True, 0)
        tv_frame = gtk.Frame(_("Spectra to be processed:"))
        tv_frame.add(tv_vbox)

        self.spectrum_panel = ShowSpectrumPanel()
        self.pack1(tv_frame, True, True)

        self.clipboard = gtk.clipboard_get(selection="CLIPBOARD")
Пример #9
0
    def refresh(self, vm):
        '''
        Полная перерисовка кнопок на драйв-панели
        '''
        for child in self.get_children():
            self.remove(child)
        uris = []
        # рут и хоум
        b = gtk.ToolButton(gtk.STOCK_HARDDISK)
        b.set_label('/')
        b.set_tooltip_text('/')
        b.connect('clicked', self.clicked, Drive('/', '/'))
        self.insert(b, self.get_n_items())

        b = gtk.ToolButton(gtk.STOCK_HOME)
        b.set_label('~')
        b.set_tooltip_text(os.path.expanduser('~'))
        b.connect('clicked', self.clicked,
                  Drive('Home', os.path.expanduser('~')))
        self.insert(b, self.get_n_items())

        # volumes
        volumes = vm.get_volumes()
        for volume in volumes:
            mount = volume.get_mount()
            if mount:
                uri = mount.get_root().get_uri()
                uris.append(uri)
            else:
                uri = None
            image = gtk.Image()
            image.set_from_gicon(volume.get_icon(), gtk.ICON_SIZE_MENU)
            if volume.get_mount() and (volume.get_mount().can_eject()
                                       or volume.get_mount().can_unmount()):
                b = gtk.MenuToolButton(image, volume.get_name())
                b.set_menu(self.create_menu(volume.get_mount()))
            else:
                b = gtk.ToolButton(image, volume.get_name())
            b.set_tooltip_text(volume.get_mount().get_root().get_path(
            ) if volume.get_mount() else volume.get_name())
            b.set_is_important(True)
            b.connect('clicked', self.clicked, volume)
            self.insert(b, self.get_n_items())

        #mounts
        mounts = vm.get_mounts()
        for mount in mounts:
            if mount.get_root().get_uri() not in uris:
                image = gtk.Image()
                image.set_from_gicon(mount.get_icon(), gtk.ICON_SIZE_MENU)
                if mount.can_eject() or mount.can_unmount():
                    b = gtk.MenuToolButton(image, mount.get_name())
                    b.set_menu(self.create_menu(mount))
                else:
                    b = gtk.ToolButton(image, mount.get_name())
                b.set_tooltip_text(mount.get_root().get_path())
                b.set_is_important(True)
                b.connect('clicked', self.clicked, mount)
                self.insert(b, self.get_n_items())

        self.show_all()
Пример #10
0
    def build_toolbar(self):
        self.set_orientation(gtk.ORIENTATION_HORIZONTAL)
        self.set_style(gtk.TOOLBAR_ICONS)

        new_button = gtk.ToolButton(gtk.STOCK_NEW)
        new_button.connect('clicked', self.gshell.new_terminal)
        new_button.set_tooltip(gtk.Tooltips(), 'New')
        self.insert(new_button, -1)

        open_button = gtk.ToolButton(gtk.STOCK_OPEN)
        open_button.connect('clicked', self.gshell.menu_open)
        open_button.set_tooltip(gtk.Tooltips(), 'Open')
        self.insert(open_button, -1)

        self.insert(gtk.SeparatorToolItem(), -1)

        self.reconnect_button = gtk.ToolButton(gtk.STOCK_CONNECT)
        self.reconnect_button.connect('clicked',
                                      self.gshell.menu_reconnect_tab)
        self.reconnect_button.set_tooltip(gtk.Tooltips(), 'Connect')
        self.insert(self.reconnect_button, -1)

        self.disconnect_button = gtk.ToolButton(gtk.STOCK_DISCONNECT)
        self.disconnect_button.connect('clicked',
                                       self.gshell.menu_disconnect_tab)
        self.disconnect_button.set_tooltip(gtk.Tooltips(), 'Disconnect')
        self.insert(self.disconnect_button, -1)

        self.insert(gtk.SeparatorToolItem(), -1)

        self.copy_button = gtk.ToolButton(gtk.STOCK_COPY)
        self.copy_button.connect('clicked', self.gshell.menu_copy)
        self.copy_button.set_tooltip(gtk.Tooltips(), 'Copy')
        self.insert(self.copy_button, -1)

        self.paste_button = gtk.ToolButton(gtk.STOCK_PASTE)
        self.paste_button.connect('clicked', self.gshell.menu_paste)
        self.paste_button.set_tooltip(gtk.Tooltips(), 'Paste')
        self.insert(self.paste_button, -1)

        self.search_button = gtk.ToolButton(gtk.STOCK_FIND)
        self.search_button.set_tooltip(gtk.Tooltips(), "Search")
        self.search_button.connect('clicked', self.gshell.menu_search)
        self.insert(self.search_button, -1)

        self.insert(gtk.SeparatorToolItem(), -1)

        self.zoom_in_button = gtk.ToolButton(gtk.STOCK_ZOOM_IN)
        self.zoom_in_button.set_tooltip(gtk.Tooltips(), "Zoom In")
        self.zoom_in_button.connect('clicked', self.gshell.menu_zoom_tab,
                                    'zoom_in')
        self.insert(self.zoom_in_button, -1)

        self.zoom_out_button = gtk.ToolButton(gtk.STOCK_ZOOM_OUT)
        self.zoom_out_button.set_tooltip(gtk.Tooltips(), "Zoom Out")
        self.zoom_out_button.connect('clicked', self.gshell.menu_zoom_tab,
                                     'zoom_out')
        self.insert(self.zoom_out_button, -1)

        self.zoom_orig_button = gtk.ToolButton(gtk.STOCK_ZOOM_100)
        self.zoom_orig_button.set_tooltip(gtk.Tooltips(), "Zoom Default")
        self.zoom_orig_button.connect('clicked', self.gshell.menu_zoom_tab,
                                      'zoom_orig')
        self.insert(self.zoom_orig_button, -1)

        self.insert(gtk.SeparatorToolItem(), -1)

        broadcast_image_file = self.gshell.config.broadcast_images['blue']
        broadcast_image = gtk.gdk.pixbuf_new_from_file_at_size(
            broadcast_image_file, 18, 18)
        image = gtk.Image()
        image.set_from_pixbuf(broadcast_image)
        broadcast_button = gtk.MenuToolButton(image, 'Broadcast')
        broadcast_button.connect('clicked', self.gshell.menu_broadcast,
                                 'current')
        menu_broadcast = gtk.Menu()
        menu_broadcast_all = gtk.MenuItem('Broadcast Enable All')
        menu_broadcast_all.connect('activate', self.gshell.menu_broadcast,
                                   'enable')
        menu_broadcast.append(menu_broadcast_all)
        menu_broadcast_none = gtk.MenuItem('Broadcast Disable All')
        menu_broadcast_none.connect('activate', self.gshell.menu_broadcast,
                                    'disable')
        menu_broadcast.append(menu_broadcast_none)
        menu_broadcast_select = gtk.MenuItem('Broadcast ...')
        menu_broadcast_select.connect('activate', self.gshell.menu_broadcast,
                                      'choise')
        menu_broadcast.append(menu_broadcast_select)
        menu_broadcast.show_all()
        broadcast_button.set_menu(menu_broadcast)
        self.insert(broadcast_button, -1)

        self.insert(gtk.SeparatorToolItem(), -1)

        self.copy_password_button = gtk.ToolButton(gtk.STOCK_DND_MULTIPLE)
        self.copy_password_button.set_tooltip(gtk.Tooltips(), "Copy password")
        self.copy_password_button.connect('clicked',
                                          self.gshell.menu_copy_password,
                                          'zoom_orig')
        self.insert(self.copy_password_button, -1)

        self.insert(gtk.SeparatorToolItem(), -1)
Пример #11
0
    def __init__(self, main):
        super(Toolbar, self).__init__(False, 1)

        self.main = main
        self.toolbox = self

        self.main_tb = gtk.Toolbar()
        self.main_tb.set_style(gtk.TOOLBAR_ICONS)

        # New KB button
        self.new_tb = gtk.ToolButton(gtk.STOCK_NEW)
        self.new_tb.set_tooltip_text('Create new KB')
        self.new_tb.connect("clicked", self._miau)
        self.main_tb.insert(self.new_tb, 0)
        self.new_tb.set_sensitive(False)

        # Load KB button
        self.load_tb = gtk.MenuToolButton(gtk.STOCK_OPEN)
        self.load_tb.set_tooltip_text('Load KB')
        self.load_tb.connect("clicked", self.load_kb)
        self.main_tb.insert(self.load_tb, 1)

        # Rcent files menu
        self.manager = gtk.recent_manager_get_default()
        self.recent_menu = gtk.RecentChooserMenu(self.manager)
        filter = gtk.RecentFilter()
        filter.add_pattern("*.kb")
        self.recent_menu.add_filter(filter)
        self.load_tb.set_menu(self.recent_menu)
        self.load_tb.set_arrow_tooltip_text('Recent opened KB')
        self.recent_menu.connect('item-activated', self.recent_kb)

        # Save KB button
        self.save_tb = gtk.ToolButton(gtk.STOCK_SAVE)
        self.save_tb.set_tooltip_text('Save current KB')
        self.save_tb.connect("clicked", self.save_kb)
        self.main_tb.insert(self.save_tb, 2)

        # Import button
        self.import_tb = gtk.ToolButton(gtk.STOCK_CONVERT)
        self.import_tb.set_tooltip_text('Import Nmap/CSV file')
        self.import_tb.connect("clicked", self.import_scan)
        self.main_tb.insert(self.import_tb, 3)

        # Editor button
        self.edit_tb = gtk.ToolButton(gtk.STOCK_EDIT)
        self.edit_tb.set_tooltip_text('Open editor')
        self.edit_tb.connect("clicked", self.load_editor)
        self.main_tb.insert(self.edit_tb, 4)

        # Separator
        self.sep = gtk.SeparatorToolItem()
        self.main_tb.insert(self.sep, 5)

        # Proxy button
        self.proxy_tb = gtk.ToolButton(gtk.STOCK_CONNECT)
        self.proxy_tb.set_tooltip_text('Start TCP proxy')
        self.proxy_tb.connect("clicked", self._miau)
        self.proxy_tb.set_sensitive(False)
        self.main_tb.insert(self.proxy_tb, 6)

        # Web server button
        self.wserver_tb = gtk.ToolButton(gtk.STOCK_CONVERT)
        self.wserver_tb.set_tooltip_text('Run web server')
        self.wserver_tb.connect("clicked", self._miau)
        self.wserver_tb.set_sensitive(False)
        self.main_tb.insert(self.wserver_tb, 7)

        # Sniffer button
        self.sniffer_tb = gtk.ToolButton(gtk.STOCK_NETWORK)
        self.sniffer_tb.set_tooltip_text('Open network sniffer')
        self.sniffer_tb.connect("clicked", self.run_sniffer)
        self.main_tb.insert(self.sniffer_tb, 8)

        # Separator
        self.sep = gtk.SeparatorToolItem()
        self.main_tb.insert(self.sep, 9)

        # Scapy button
        self.scapy_tb = gtk.ToolButton(gtk.STOCK_MEDIA_PLAY)
        self.scapy_tb.set_tooltip_text('Start Scapy')
        self.scapy_tb.connect("clicked", self.show_term)
        self.main_tb.insert(self.scapy_tb, 10)

        self.scapy_logo = gtk.Image()
        self.scapy_logo.set_from_file('lib' + os.sep + 'ui' + os.sep + 'data' +
                                      os.sep + 'python-icon.png')
        self.scapy_tb.set_icon_widget(self.scapy_logo)

        # Separator
        self.sep = gtk.SeparatorToolItem()
        self.main_tb.insert(self.sep, 11)

        # Add target button
        self.add_tb = gtk.ToolButton(gtk.STOCK_ADD)
        self.add_tb.set_tooltip_text('Add a new target')
        self.add_tb.connect("clicked", self.add_target)
        self.main_tb.insert(self.add_tb, 12)

        # Preferences button
        self.prefs_tb = gtk.ToolButton(gtk.STOCK_PREFERENCES)
        self.prefs_tb.set_tooltip_text('Open preferences dialog')
        self.prefs_tb.connect("clicked", self.show_pref)
        self.main_tb.insert(self.prefs_tb, 13)

        # Log  button
        self.log_tb = gtk.ToggleToolButton(gtk.STOCK_LEAVE_FULLSCREEN)
        self.log_tb.set_tooltip_text('Show/Hide Log panel')
        self.log_tb.connect("toggled", self.show_log)
        self.main_tb.insert(self.log_tb, 14)

        # KB button
        self.kb_tb = gtk.ToggleToolButton(gtk.STOCK_LEAVE_FULLSCREEN)
        self.kb_tb.set_tooltip_text('Show/Hide KB panel')
        self.kb_tb.connect("toggled", self.show_kb)
        self.main_tb.insert(self.kb_tb, 15)

        # Separator
        self.sep = gtk.SeparatorToolItem()
        self.main_tb.insert(self.sep, 16)

        # Report button
        self.report_tb = gtk.ToolButton(gtk.STOCK_INDEX)
        self.report_tb.set_tooltip_text('Show KB report')
        self.report_tb.connect("clicked", self.report)
        self.main_tb.insert(self.report_tb, 17)

        # Exit button
        self.exit_tb = gtk.ToolButton(gtk.STOCK_QUIT)
        self.exit_tb.connect("clicked", self._bye)
        self.exit_tb.set_tooltip_text('Have a nice day ;-)')
        self.main_tb.insert(self.exit_tb, 18)

        # Separator
        self.sep = gtk.SeparatorToolItem()
        self.sep.set_expand(True)
        self.sep.set_draw(False)
        self.main_tb.insert(self.sep, 19)

        # About button
        self.about_tb = gtk.ToolButton(gtk.STOCK_ABOUT)
        self.about_tb.connect("clicked", self.create_about_dialog)
        self.about_tb.set_tooltip_text('About Inguma')
        self.main_tb.insert(self.about_tb, 20)

        # Throbber
        self.throbber = throbber.Throbber()
        self.throbber_tb = gtk.ToolItem()
        self.throbber_tb.add(self.throbber)
        self.main_tb.insert(self.throbber_tb, 21)

        self.toolbox.pack_start(self.main_tb, True, True)

        self.show_all()
Пример #12
0
    def __init__(self,
                 debug_flag=None,
                 inapplet=False,
                 manual_poscorrect=False):
        self.debug_flag = debug_flag
        self.inapplet = inapplet
        self.manual_poscorrect = manual_poscorrect

        self.__loadIcon__()
        self.__loadGlade__()

        self.editor = None
        self.schedule = None

        self.noevents = False

        # Common string representation for the different output modes
        self.output_strings = [
            _("Default behaviour"),
            _("Suppress output"),
            _("X application"),
            _("X application: suppress output"),
        ]

        #start the backend where all the user configuration is stored
        self.backend = data.ConfigBackend(self, "gconf")
        self.template = template.Template(self, self.backend)

        ##configure the window
        self.widget = self.xml.get_widget("mainWindow")

        self.widget.connect("delete_event", self.__quit__)
        self.widget.connect("destroy_event", self.__quit__)

        self.widget.set_icon(self.iconPixbuf)

        #load state
        (x, y, h, w) = self.backend.get_window_state()
        if (x and y):
            self.widget.move(x, y)
        if (h and w):
            self.widget.resize(h, w)

        self.widget.set_resizable(True)

        ##

        ##configure statusbar
        self.statusbar = self.xml.get_widget("statusbar")

        self.statusbarUser = self.statusbar.get_context_id("user")
        ##

        ##configure the toolbar
        self.toolbar = self.xml.get_widget("toolbar")
        self.add_button = gtk.MenuToolButton(gtk.STOCK_NEW)

        self.add_button_menu = gtk.Menu()
        self.add_button_menu_add_crontab = gtk.MenuItem()
        self.add_button_menu_add_at = gtk.MenuItem()
        self.add_button_menu_add_template = gtk.MenuItem()

        self.recurrenthbox = gtk.HBox()
        icon = gtk.Image()
        icon.set_from_pixbuf(self.iconcrontab)
        label = gtk.Label(_("Recurrent task"))
        icon.set_alignment(0, 0.5)
        label.set_justify(gtk.JUSTIFY_LEFT)
        label.set_alignment(0, 0.5)
        self.recurrenthbox.pack_start(icon, False, False, 2)
        self.recurrenthbox.pack_start(label, True, True, 2)
        self.add_button_menu_add_crontab.add(self.recurrenthbox)

        self.onetimehbox = gtk.HBox()
        icon = gtk.Image()
        icon.set_from_pixbuf(self.iconat)
        label = gtk.Label(_("One-time task"))
        icon.set_alignment(0, 0.5)
        label.set_justify(gtk.JUSTIFY_LEFT)
        label.set_alignment(0, 0.5)
        self.onetimehbox.pack_start(icon, False, False, 2)
        self.onetimehbox.pack_start(label, True, True, 2)
        self.add_button_menu_add_at.add(self.onetimehbox)

        self.templatehbox = gtk.HBox()
        icon = gtk.Image()
        icon.set_from_pixbuf(self.icontemplate)
        label = gtk.Label(_("From template"))
        icon.set_alignment(0, 0.5)
        label.set_justify(gtk.JUSTIFY_LEFT)
        label.set_alignment(0, 0.5)
        self.templatehbox.pack_start(icon, False, False, 2)
        self.templatehbox.pack_start(label, True, True, 2)
        self.add_button_menu_add_template.add(self.templatehbox)

        self.add_button_menu.append(self.add_button_menu_add_crontab)
        self.add_button_menu.append(self.add_button_menu_add_at)
        self.add_button_menu.append(self.add_button_menu_add_template)

        self.add_button.set_menu(self.add_button_menu)

        self.toolbar.insert(self.add_button, 0)
        self.add_button.set_is_important(True)
        tip = gtk.Tooltips()
        tip.enable()

        self.add_button.set_tooltip(tip, _("Add a new task"), tip_private=None)
        self.add_button.show_all()
        self.add_button_menu.show_all()
        self.add_button_menu_add_crontab.show_all()
        self.add_button_menu_add_at.show_all()

        self.add_button.connect("clicked", self.on_add_button_clicked)
        self.add_button_menu_add_crontab.connect("activate",
                                                 self.on_add_crontab_task)
        self.add_button_menu_add_at.connect("activate", self.on_add_at_task)
        self.add_button_menu_add_template.connect("activate",
                                                  self.on_add_from_template)

        self.prop_button = self.xml.get_widget("prop_button")
        self.del_button = self.xml.get_widget("del_button")
        self.run_button = self.xml.get_widget("run_button")
        self.help_button = self.xml.get_widget("help_button")
        self.btnSetUser = self.xml.get_widget("btnSetUser")
        self.btnExit = self.xml.get_widget("btnExit")
        self.about_button = self.xml.get_widget("about_button")
        self.edit_mode_button = self.xml.get_widget("edit_mode_button")
        self.button_template = self.xml.get_widget("button_m_template")

        icon = gtk.Image()
        icon.set_from_pixbuf(self.normalicontemplate)
        self.button_template.set_icon_widget(icon)
        icon.show()

        self.prop_button.set_sensitive(False)
        self.del_button.set_sensitive(False)
        self.run_button.set_sensitive(False)

        self.xml.signal_connect("on_prop_button_clicked",
                                self.on_prop_button_clicked)
        self.xml.signal_connect("on_del_button_clicked",
                                self.on_del_button_clicked)
        self.xml.signal_connect("on_help_button_clicked",
                                self.on_help_button_clicked)
        self.xml.signal_connect("on_btnSetUser_clicked",
                                self.on_btnSetUser_clicked)
        self.xml.signal_connect("on_about_menu_activate",
                                self.on_about_menu_activate)
        self.xml.signal_connect("on_edit_mode_button_clicked",
                                self.on_advanced_menu_activate)
        self.xml.signal_connect("on_btnExit_clicked", self.__quit__)
        self.xml.signal_connect("on_mainWindow_delete_event", self.__quit__)
        self.xml.signal_connect("on_run_button_clicked",
                                self.on_run_button_clicked)

        self.xml.signal_connect("on_button_m_template_clicked",
                                self.on_template_manager_button)

        ##inittializing the treeview and treemodel
        ## somethins not rite here..:
        ## [0 Title, 1 Frequency, 2 Command, 3 Crontab record, 4 ID, 5 Time, 6 Icon, 7 scheduled instance, 8 icon path, 9 date, 10 class_id, 11 user, 12 time, 13 type, 14 crontab/at, 15 advanced time string]
        ##for at this would be like:

        # ["untitled", "12:50 2004-06-25", "preview", "script", "job_id", "12:50", icon, at instance, icon_path, "2004-06-25", "a", "drzap", "at"]

        ##for crontab it would be:

        # ["untitled", "every hour", "ls /", "0 * * * * ls / # untitled", "5", "0 * * * *", icon, crontab instance,icon_path, 1(job_id), "", "", "crontab"]
        self.treemodel = gtk.ListStore(
            gobject.TYPE_STRING, gobject.TYPE_STRING, gobject.TYPE_STRING,
            gobject.TYPE_STRING, gobject.TYPE_INT, gobject.TYPE_STRING,
            gtk.gdk.Pixbuf, gobject.TYPE_PYOBJECT, gobject.TYPE_STRING,
            gobject.TYPE_STRING, gobject.TYPE_STRING, gobject.TYPE_STRING,
            gobject.TYPE_STRING, gobject.TYPE_STRING, gobject.TYPE_STRING,
            gobject.TYPE_INT, gobject.TYPE_STRING)

        self.treeview = self.xml.get_widget("treeview")

        self.xml.signal_connect("on_treeview_button_press_event",
                                self.on_treeview_button_press_event)
        self.xml.signal_connect("on_treeview_key_press_event",
                                self.on_treeview_key_pressed)

        self.treeview.set_model(self.treemodel)
        self.treeview.get_selection().connect("changed",
                                              self.on_TreeViewSelectRow)

        #enable or disable advanced depending on user config
        self.noevents = True
        if self.backend.get_advanced_option():
            self.switchView("advanced")
            self.edit_mode_button.set_active(True)
        else:
            self.switchView("simple")
            self.edit_mode_button.set_active(False)
        self.noevents = False

        self.__initUser__()

        ##create crontab
        self.crontab = crontab.Crontab(self.root, self.user, self.uid,
                                       self.gid, self.user_home_dir)
        self.crontab_editor = crontabEditor.CrontabEditor(
            self, self.backend, self.crontab, self.template)
        ##

        ##create at
        self.at = at.At(self.root, self.user, self.uid, self.gid,
                        self.user_home_dir, self.manual_poscorrect)
        self.at_editor = atEditor.AtEditor(self, self.backend, self.at,
                                           self.template)
        ##

        #set user window
        self.setuserWindow = setuserWindow.SetuserWindow(self)

        #set add window
        self.addWindow = addWindow.AddWindow(self)

        # template windows
        self.template_chooser = template_chooser.TemplateChooser(
            self, self.template)
        self.template_manager = template_manager.TemplateManager(
            self, self.template)

        self.schedule_reload()

        self.timeout_handler_id = gobject.timeout_add(9000,
                                                      self.update_schedule)

        # temporary files to be deleted
        self.temp_files = []

        if inapplet == False:
            gtk.main()
Пример #13
0
    def __setup_toolbar(self):
    
        toolbar_buttons = [
            ('decodeandcut', 'decodeandcut.png', "Dekodieren und Schneiden", Action.DECODEANDCUT),
            ('decode', 'decode.png', 'Dekodieren', Action.DECODE),
            ('delete', 'bin.png', "In den Müll verschieben", Action.DELETE),
            ('archive', 'archive.png', "Archivieren", Action.ARCHIVE),
            ('cut', 'cut.png', "Schneiden", Action.CUT),          
            ('restore', 'restore.png', "Wiederherstellen", Action.RESTORE),
            ('rename', 'rename.png', "Umbenennen", Action.RENAME),
            ('new_folder', 'new_folder.png', "Neuer Ordner", Action.NEW_FOLDER),            
            ('real_delete', 'delete.png', "Löschen", Action.REAL_DELETE),
            ('plan_add', 'film_add.png', "Hinzufügen", Action.PLAN_ADD),
            ('plan_remove', 'film_delete.png', "Löschen", Action.PLAN_REMOVE),
            ('plan_edit', 'film_edit.png', "Bearbeiten", Action.PLAN_EDIT),
            ('plan_search', 'film_search.png', "Auf Mirror suchen", Action.PLAN_SEARCH),
            ('download_add', 'add_download.png', "Download hinzufügen", Action.DOWNLOAD_ADD),
            ('download_add_link', 'add_download.png', "Link hinzufügen", Action.DOWNLOAD_ADD_LINK),
            ('download_start', 'download_start.png', "Start", Action.DOWNLOAD_START),
            ('download_stop', 'download_stop.png', "Stop", Action.DOWNLOAD_STOP),
            ('download_remove', 'delete.png', "Löschen", Action.DOWNLOAD_REMOVE),
            ]
        
        self.__toolbar_buttons = {}
        for key, image_name, text, action in toolbar_buttons:
            image = gtk.image_new_from_file(path.get_image_path(image_name))
            image.show()
            
            if key == "cut" or key == "decodeandcut":
                self.__toolbar_buttons[key] = gtk.MenuToolButton(image, text)
                self.__toolbar_buttons[key].set_menu(self.__get_cut_menu(action))
            else:
                self.__toolbar_buttons[key] = gtk.ToolButton(image, text)

            self.__toolbar_buttons[key].connect("clicked", self._on_toolbutton_clicked, action)              
            self.__toolbar_buttons[key].show()
             
        self.__sets_of_toolbars = {
            Section.PLANNING :   [ 'plan_add', 'plan_edit', 'plan_remove', 'plan_search'],
            Section.DOWNLOAD:    [ 'download_add_link', 'download_start', 'download_stop', 'download_remove' ],
            Section.OTRKEY :     [ 'decodeandcut', 'decode', 'delete', 'real_delete' ],
            Section.VIDEO_UNCUT: [ 'cut', 'delete', 'real_delete', 'archive'  ],
            Section.VIDEO_CUT:   [ 'archive', 'delete', 'real_delete', 'cut', 'rename' ],
            Section.ARCHIVE:     [ 'delete', 'real_delete', 'rename', 'new_folder' ],
            Section.TRASH:       [ 'real_delete', 'restore' ]
        }           

        # create sets of toolbuttons          
        for section, button_names in self.__sets_of_toolbars.iteritems():
            toolbar_buttons = []
            for button_name in button_names:
                toolbar_buttons.append(self.__toolbar_buttons[button_name])
                
            self.__sets_of_toolbars[section] = toolbar_buttons
   
        # toolbar_search
        self.search_tool_item = EntrySearchToolItem("Durchsuchen")
        self.builder.get_object('toolbar_search').insert(self.search_tool_item, -1)
        
        self.search_tool_item.connect('search', lambda w, search: self.do_search(search))
        self.search_tool_item.connect('clear', self.on_search_clear)        
Пример #14
0
    def __init__(self, core, main):
        super(TopButtons,self).__init__(False, 1)

        self.main = main

        self.uicore = core
        self.toolbox = self
        self.dependency_check = self.main.dependency_check

        self.img_path = os.path.dirname(__file__) + os.sep + 'data' + os.sep
        self.options_dict = {'Hexadecimal':'x', 'String':'s', 'String no case':'i', 'Regexp':'r', 'Unicode':'u', 'Unicode no case':'U'}

        self.main_tb = gtk.Toolbar()
        self.main_tb.set_style(gtk.TOOLBAR_ICONS)

        # New file button
        self.new_tb = gtk.MenuToolButton(gtk.STOCK_NEW)
        self.new_tb.set_label("New")
        self.new_tb.set_tooltip_text('Open new file')
        self.new_tb.connect("clicked", self.new_file)
        self.main_tb.insert(self.new_tb, 0)

        # Rcent files menu
        self.manager = gtk.recent_manager_get_default()
        self.recent_menu = gtk.RecentChooserMenu(self.manager)
        self.new_tb.set_menu(self.recent_menu)
        self.new_tb.set_arrow_tooltip_text('Recent opened files')
        self.recent_menu.connect('item-activated', self.recent_kb)

        # Separator
        self.sep = gtk.SeparatorToolItem()
        self.main_tb.insert(self.sep, 1)

        # PDF Streams search
        self.streams_tb = gtk.ToolButton(gtk.STOCK_INDEX)
        self.streams_tb.set_tooltip_text('Find PDF streams')
        self.streams_tb.connect("clicked", self.search_pdfstreams)
        self.streams_tb.set_sensitive(False)
        self.main_tb.insert(self.streams_tb, 2)
        # Separator
        self.sep = gtk.SeparatorToolItem()
        self.main_tb.insert(self.sep, 3)

        # URL related buttons

        i = gtk.Image()
        pixbuf = gtk.gdk.pixbuf_new_from_file(self.img_path + 'response-headers.png')
        scaled_buf = pixbuf.scale_simple(24,24,gtk.gdk.INTERP_BILINEAR)
        i.set_from_pixbuf(scaled_buf)
        self.urls = gtk.MenuToolButton(i, 'URL')
        #self.urls.set_icon_widget(i)
        self.urls.set_tooltip_text('URL plugins')
        self.urls_menu = gtk.Menu()

        i = gtk.Image()
        pixbuf = gtk.gdk.pixbuf_new_from_file(self.img_path + 'response-headers.png')
        scaled_buf = pixbuf.scale_simple(16,16,gtk.gdk.INTERP_BILINEAR)
        i.set_from_pixbuf(scaled_buf)
        item = gtk.ImageMenuItem('Search for URL')
        item.set_image(i)
        item.connect("activate", self.show_urls)
        self.urls_menu.append(item)

        i = gtk.Image()
        pixbuf = gtk.gdk.pixbuf_new_from_file(self.img_path + 'response-body.png')
        scaled_buf = pixbuf.scale_simple(16,16,gtk.gdk.INTERP_BILINEAR)
        i.set_from_pixbuf(scaled_buf)
        item = gtk.ImageMenuItem('Check URL')
        item.set_image(i)
        item.connect("activate", self.check_urls)
        self.urls_menu.append(item)

        i = gtk.Image()
        pixbuf = gtk.gdk.pixbuf_new_from_file(self.img_path + 'request-body.png')
        scaled_buf = pixbuf.scale_simple(16,16,gtk.gdk.INTERP_BILINEAR)
        i.set_from_pixbuf(scaled_buf)
        item = gtk.ImageMenuItem('Check bad URL')
        item.set_image(i)
        item.connect("activate", self.check_bad_urls)
        self.urls_menu.append(item)

        self.urls_menu.show_all()

        self.urls.set_menu(self.urls_menu)
        self.urls_menu.show_all()
        self.main_tb.insert(self.urls, 4)

        # Separator
        self.sep = gtk.SeparatorToolItem()
        self.main_tb.insert(self.sep, 5)

        # Visualizatin buttons
        self.visbin_tb = gtk.ToolButton(gtk.STOCK_ZOOM_FIT)
        self.visbin_tb.connect("clicked", self.execute, 'binvi')
        self.visbin_tb.set_tooltip_text('Visualize binary')
        self.visbin_tb.set_sensitive(False)
        self.main_tb.insert(self.visbin_tb, 6)
        # Separator
        self.sep = gtk.SeparatorToolItem()
        self.main_tb.insert(self.sep, 7)

        # Binary analysis buttons
        self.vtotal_tb = gtk.ToolButton(gtk.STOCK_CONNECT)
        self.vtotal_tb.connect("clicked", self.send_to_virustotal)
        self.vtotal_tb.set_tooltip_text('Send to VirusTotal')
        self.vtotal_tb.set_sensitive(False)
        self.main_tb.insert(self.vtotal_tb, 8)

        self.threat_tb = gtk.ToolButton(gtk.STOCK_JUMP_TO)
        self.threat_tb.connect("clicked", self.execute, 'threat')
        self.threat_tb.set_tooltip_text('Search in Threat Expert')
        self.threat_tb.set_sensitive(False)
        self.main_tb.insert(self.threat_tb, 9)

        self.shellcode_tb = gtk.ToolButton(gtk.STOCK_FIND)
        self.shellcode_tb.connect("clicked", self.search_shellcode)
        self.shellcode_tb.set_tooltip_text('Search for Shellcode')
        self.shellcode_tb.set_sensitive(False)
        self.main_tb.insert(self.shellcode_tb, 10)

        # not yet working properly
        self.antivm_tb = gtk.ToolButton(gtk.STOCK_FIND_AND_REPLACE)
        self.antivm_tb.connect("clicked", self.search_antivm)
        self.antivm_tb.set_tooltip_text('Search for antivm tricks')
        self.antivm_tb.set_sensitive(False)
        self.main_tb.insert(self.antivm_tb, 11)

        self.packed_tb = gtk.ToolButton(gtk.STOCK_CONVERT)
        self.packed_tb.connect("clicked", self.check_packer)
        self.packed_tb.set_tooltip_text('Check if the PE file is packed')
        self.packed_tb.set_sensitive(False)
        self.main_tb.insert(self.packed_tb, 12)

        # Separator
        self.sep = gtk.SeparatorToolItem()
        self.main_tb.insert(self.sep, 13)

        # Search components
        self.search_combo_tb = gtk.ToolItem()
        self.search_combo_align = gtk.Alignment(yalign=0.5)
        store = gtk.ListStore(gtk.gdk.Pixbuf, str)
        self.search_combo = gtk.ComboBox(store)
        rendererText = gtk.CellRendererText()
        rendererPix = gtk.CellRendererPixbuf()
        self.search_combo.pack_start(rendererPix, False)
        self.search_combo.pack_start(rendererText, True)
        self.search_combo.add_attribute(rendererPix, 'pixbuf', 0)
        self.search_combo.add_attribute(rendererText, 'text', 1)

        options = {
            'String':gtk.gdk.pixbuf_new_from_file(os.path.dirname(__file__) + os.sep + 'data' + os.sep + 'icon_string_16.png'),
            'String no case':gtk.gdk.pixbuf_new_from_file(os.path.dirname(__file__) + os.sep + 'data' + os.sep + 'icon_string_no_case_16.png'),
            'Hexadecimal':gtk.gdk.pixbuf_new_from_file(os.path.dirname(__file__) + os.sep + 'data' + os.sep + 'icon_hexadecimal_16.png'),
            'Regexp':gtk.gdk.pixbuf_new_from_file(os.path.dirname(__file__) + os.sep + 'data' + os.sep + 'icon_regexp_16.png')
        }

        for option in options.keys():
            store.append([options[option], option])
        self.search_combo.set_active(0)
        self.search_combo_align.add(self.search_combo)
        self.search_combo_tb.add(self.search_combo_align)
        self.main_tb.insert(self.search_combo_tb, 14)

        # Separator
        self.sep = gtk.SeparatorToolItem()
        self.sep.set_draw(False)
        self.main_tb.insert(self.sep, 15)

        self.search_entry_tb = gtk.ToolItem()
        self.search_entry = gtk.Entry(100)
        self.search_entry.set_text('Text to search')
        self.search_entry.set_icon_from_stock(1, gtk.STOCK_FIND)
        self.search_entry.set_icon_tooltip_text(1, 'Search')
        self.search_entry.connect("activate", self.search)
        self.search_entry.connect("icon-press", self.search)
        self.search_entry.connect('focus-in-event', self._clean, 'in')
        self.search_entry.connect('focus-out-event', self._clean, 'out')
        self.search_entry_tb.add(self.search_entry)
        self.main_tb.insert(self.search_entry_tb, 16)

        # Separator
        self.sep = gtk.SeparatorToolItem()
        self.main_tb.insert(self.sep, 17)

        # Cheatsheet button
        self.cheatsheet_tb = gtk.ToolButton(gtk.STOCK_JUSTIFY_FILL)
        self.cheatsheet_tb.set_tooltip_text('Show assembler reference sheet')
        self.cheatsheet_tb.connect("clicked", self.create_cheatsheet_dialog)
        self.main_tb.insert(self.cheatsheet_tb, 18)

        # Separator
        self.sep = gtk.SeparatorToolItem()
        self.sep.set_expand(True)
        self.sep.set_draw(False)
        self.main_tb.insert(self.sep, 19)

        # Exit button
        self.exit_tb = gtk.ToolButton(gtk.STOCK_QUIT)
        self.exit_tb.set_label('Quit')
        self.exit_tb.connect("clicked", self.main.quit)
        self.exit_tb.set_tooltip_text('Have a nice day ;-)')
        self.main_tb.insert(self.exit_tb, 20)

        # Throbber
        self.throbber = throbber.Throbber()
        self.throbber_tb = gtk.ToolItem()
        self.throbber_tb.add(self.throbber)
        self.main_tb.insert(self.throbber_tb, 21)

        self.toolbox.pack_start(self.main_tb, True, True)


        self.show_all()
Пример #15
0
    def __init__(self, ing):
        super(TopButtons,self).__init__(False, 1)

        self.ing = ing
        #self.main = self.ing.bokken

        self.toolbox = self

        self.img_path = 'lib' + os.sep + 'ui' + os.sep + 'bokken' + os.sep + 'data' + os.sep
        self.options_dict = {'Hexadecimal':'x', 'String':'s', 'String no case':'i', 'Regexp':'r', 'Unicode':'u', 'Unicode no case':'U'}

        self.main_tb = gtk.Toolbar()
        self.main_tb.set_style(gtk.TOOLBAR_ICONS)

        # New file button
        self.new_tb = gtk.MenuToolButton(gtk.STOCK_NEW)
        self.new_tb.set_tooltip_text('Open new file')
        self.new_tb.connect("clicked", self.new_file)
        self.main_tb.insert(self.new_tb, 0)

        # Rcent files menu
        self.manager = gtk.recent_manager_get_default()
        self.recent_menu = gtk.RecentChooserMenu(self.manager)
        self.new_tb.set_menu(self.recent_menu)
        self.new_tb.set_arrow_tooltip_text('Recent opened files')
        self.recent_menu.connect('item-activated', self.recent_kb)

        # Separator
        self.sep = gtk.SeparatorToolItem()
        self.main_tb.insert(self.sep, 1)

        # PDF Streams search
        self.streams_tb = gtk.ToolButton(gtk.STOCK_INDEX)
        self.streams_tb.set_tooltip_text('Find PDF streams')
        self.streams_tb.connect("clicked", self.search_pdfstreams)
        self.streams_tb.set_sensitive(False)
        self.main_tb.insert(self.streams_tb, 2)
        # Separator
        self.sep = gtk.SeparatorToolItem()
        self.main_tb.insert(self.sep, 3)

        # URL related buttons
        self.url_tb = gtk.ToolButton()
        i = gtk.Image()
        pixbuf = gtk.gdk.pixbuf_new_from_file(self.img_path + 'response-headers.png')
        scaled_buf = pixbuf.scale_simple(24,24,gtk.gdk.INTERP_BILINEAR)
        i.set_from_pixbuf(scaled_buf)
        self.url_tb.set_icon_widget(i)
        self.url_tb.set_tooltip_text('URL')
        self.url_tb.connect("clicked", self.show_urls)
        self.url_tb.set_sensitive(False)
        self.main_tb.insert(self.url_tb, 4)

        self.check_url_tb = gtk.ToolButton()
        i = gtk.Image()
        pixbuf = gtk.gdk.pixbuf_new_from_file(self.img_path  + 'response-body.png')
        scaled_buf = pixbuf.scale_simple(24,24,gtk.gdk.INTERP_BILINEAR)
        i.set_from_pixbuf(scaled_buf)
        self.check_url_tb.set_icon_widget(i)
        self.check_url_tb.set_tooltip_text('Check URL')
        self.check_url_tb.connect("clicked", self.check_urls)
        self.check_url_tb.set_sensitive(False)
        self.main_tb.insert(self.check_url_tb, 5)

        self.bad_url_tb = gtk.ToolButton()
        i = gtk.Image()
        pixbuf = gtk.gdk.pixbuf_new_from_file(self.img_path  + 'request-body.png')
        scaled_buf = pixbuf.scale_simple(24,24,gtk.gdk.INTERP_BILINEAR)
        i.set_from_pixbuf(scaled_buf)
        self.bad_url_tb.set_icon_widget(i)
        self.bad_url_tb.set_tooltip_text('Check bad URL')
        self.bad_url_tb.connect("clicked", self.check_bad_urls)
        self.bad_url_tb.set_sensitive(False)
        self.main_tb.insert(self.bad_url_tb, 6)
        # Separator
        self.sep = gtk.SeparatorToolItem()
        self.main_tb.insert(self.sep, 7)

        # Visualizatin buttons
        self.visbin_tb = gtk.ToolButton(gtk.STOCK_ZOOM_FIT)
        self.visbin_tb.connect("clicked", self.execute, 'binvi')
        self.visbin_tb.set_tooltip_text('Visualize binary')
        self.visbin_tb.set_sensitive(False)
        self.main_tb.insert(self.visbin_tb, 8)
        # Separator
        self.sep = gtk.SeparatorToolItem()
        self.main_tb.insert(self.sep, 9)

        # Binary analysis buttons
        self.vtotal_tb = gtk.ToolButton(gtk.STOCK_CONNECT)
        self.vtotal_tb.connect("clicked", self.send_to_virustotal)
        self.vtotal_tb.set_tooltip_text('Send to VirusTotal')
        self.vtotal_tb.set_sensitive(False)
        self.main_tb.insert(self.vtotal_tb, 10)

        self.threat_tb = gtk.ToolButton(gtk.STOCK_JUMP_TO)
        self.threat_tb.connect("clicked", self.execute, 'threat')
        self.threat_tb.set_tooltip_text('Search in Threat Expert')
        self.threat_tb.set_sensitive(False)
        self.main_tb.insert(self.threat_tb, 11)

        self.shellcode_tb = gtk.ToolButton(gtk.STOCK_FIND)
        self.shellcode_tb.connect("clicked", self.search_shellcode)
        self.shellcode_tb.set_tooltip_text('Search for Shellcode')
        self.shellcode_tb.set_sensitive(False)
        self.main_tb.insert(self.shellcode_tb, 12)

        # not yet working properly
        self.antivm_tb = gtk.ToolButton(gtk.STOCK_FIND_AND_REPLACE)
        self.antivm_tb.connect("clicked", self.search_antivm)
        self.antivm_tb.set_tooltip_text('Search for antivm tricks')
        self.antivm_tb.set_sensitive(False)
        self.main_tb.insert(self.antivm_tb, 13)

        self.packed_tb = gtk.ToolButton(gtk.STOCK_CONVERT)
        self.packed_tb.connect("clicked", self.check_packer)
        self.packed_tb.set_tooltip_text('Check if the PE file is packed')
        self.packed_tb.set_sensitive(False)
        self.main_tb.insert(self.packed_tb, 14)

        # Separator
        self.sep = gtk.SeparatorToolItem()
        self.main_tb.insert(self.sep, 15)

        # Search components
        self.search_tb = gtk.ToolItem()
        self.search_label = gtk.Label('  Search:  ')
        self.search_tb.add(self.search_label)
        self.main_tb.insert(self.search_tb, 16)

        self.search_combo_tb = gtk.ToolItem()
        self.search_combo = gtk.combo_box_new_text()

        options = ['Hexadecimal', 'String', 'String no case', 'Regexp', 'Unicode', 'Unicode no case']
        for option in options:
            self.search_combo.append_text(option)
        self.search_combo_tb.add(self.search_combo)
        self.main_tb.insert(self.search_combo_tb, 17)

        # Separator
        self.sep = gtk.SeparatorToolItem()
        self.sep.set_draw(False)
        self.main_tb.insert(self.sep, 18)

        self.search_entry_tb = gtk.ToolItem()
        self.search_entry = gtk.Entry(100)
        self.search_entry_tb.add(self.search_entry)
        self.main_tb.insert(self.search_entry_tb, 19)

        self.search_tb = gtk.ToolButton(gtk.STOCK_FIND)
        self.search_tb.connect("clicked", self.search)
        self.search_tb.set_tooltip_text('Search')
        self.search_tb.set_sensitive(False)
        self.main_tb.insert(self.search_tb, 20)

        # Separator
        self.sep = gtk.SeparatorToolItem()
        self.main_tb.insert(self.sep, 21)

        # Exit button
        self.exit_tb = gtk.ToolButton(gtk.STOCK_QUIT)
        self.exit_tb.connect("clicked", self._bye)
        self.exit_tb.set_tooltip_text('Have a nice day ;-)')
        self.main_tb.insert(self.exit_tb, 22)

        # Separator
        self.sep = gtk.SeparatorToolItem()
        self.sep.set_expand(True)
        self.sep.set_draw(False)
        self.main_tb.insert(self.sep, 23)

        # About button
        self.about_tb = gtk.ToolButton(gtk.STOCK_ABOUT)
        self.about_tb.connect("clicked", self.create_about_dialog)
        self.about_tb.set_tooltip_text('About Bokken')
        self.main_tb.insert(self.about_tb, 24)

        # Throbber
        self.throbber = throbber.Throbber()
        self.throbber_tb = gtk.ToolItem()
        self.throbber_tb.add(self.throbber)
        self.main_tb.insert(self.throbber_tb, 25)

        self.toolbox.pack_start(self.main_tb, True, True)


        self.show_all()
Пример #16
0
    def __init__(self):
        # display weight measurements by default
        self.datasetdata = parameters.user.measurements

        # create the window
        self.window = gtk.Window(gtk.WINDOW_TOPLEVEL)
        self.window.set_title('Pondus')
        self.window.set_default_size(
                            parameters.config['window.width'],
                            parameters.config['window.height'])
        gtk.window_set_default_icon_from_file(parameters.logo_path)

        # build the content
        mainbox = gtk.VBox()
        self.window.add(mainbox)

        # register icons
        guiutil.register_icons()

        # set up UIManager
        uimanager = gtk.UIManager()
        accelgroup = uimanager.get_accel_group()
        self.window.add_accel_group(accelgroup)
        action_group = gtk.ActionGroup('pondus_actions')
        action_group.add_actions([
            ('add', gtk.STOCK_ADD, None, '<Control>a',
                _('Add dataset'), self.add_dialog),
            ('edit', gtk.STOCK_EDIT, None, '<Control>e',
                _('Edit selected dataset'), self.edit_dialog),
            ('remove', gtk.STOCK_REMOVE, None, '<Control>d',
                _('Delete selected dataset'), self.remove_dialog),
            ('plot', 'pondus_plot', _('Plot'), '<Control>p',
                _('Matplotlib not available!'), self.plot_dialog),
            ('preferences', gtk.STOCK_PREFERENCES, None, None,
                _('Preferences'), self.preferences_dialog),
            ('quit', gtk.STOCK_QUIT, None, '<Control>q',
                _('Quit'), self.destroy)])
        self.editaction = action_group.get_action('edit')
        self.removeaction = action_group.get_action('remove')
        self.plotaction = action_group.get_action('plot')
        prefaction = action_group.get_action('preferences')
        uimanager.insert_action_group(action_group, 0)

        ui = """
        <ui>
        <toolbar name='Toolbar'>
            <toolitem action='add'/>
            <toolitem action='edit'/>
            <toolitem action='remove'/>
            <toolitem action='plot'/>
            <toolitem action='quit'/>
        </toolbar>
        </ui>"""
        uimanager.add_ui_from_string(ui)

        prefbutton = gtk.MenuToolButton(gtk.STOCK_PREFERENCES)
        prefaction.connect_proxy(prefbutton)
        prefmenu = gtk.Menu()
        csv_import_item = gtk.MenuItem(_('CSV Import'))
        csv_export_item = gtk.MenuItem(_('CSV Export'))
        csv_import_item.show()
        csv_export_item.show()
        prefmenu.append(csv_import_item)
        prefmenu.append(csv_export_item)
        prefbutton.set_menu(prefmenu)

        toolbar = uimanager.get_widget('/Toolbar')
        toolbar.set_style(gtk.TOOLBAR_ICONS)
        toolbar.insert(prefbutton, -1)
        for action in action_group.list_actions():
            action.connect_accelerator()
        mainbox.pack_start(toolbar, False, True)

        # hide quit action
        action_group.get_action('quit').set_visible(False)
        self.editaction.set_visible(False)
        uimanager.get_widget('/Toolbar/edit').set_no_show_all(True)
        uimanager.get_widget('/Toolbar/quit').set_no_show_all(True)

        self.plotbutton = uimanager.get_widget('/Toolbar/plot')

        # add list displaying the datasets
        self.contentbox = gtk.VBox(spacing=5)
        datawindow = gtk.ScrolledWindow()
        datawindow.set_policy(gtk.POLICY_AUTOMATIC, gtk.POLICY_AUTOMATIC)
        datawindow.set_shadow_type(gtk.SHADOW_IN)
        self.datalist = gtk.ListStore(int, str, str, str)
        self.display_data(self.datasetdata)
        self.dataview = gtk.TreeView(self.datalist)
        self.add_column(_('Date'), 1)
        self.add_column(_('Weight'), 2)
        self.datalist.set_sort_func(2, guiutil.sort_function_weight, None)
        self.datalist.set_sort_column_id(1, gtk.SORT_DESCENDING)
        self.dataview.set_rules_hint(True)
        self.dataview.set_tooltip_column(3)
        datawindow.add(self.dataview)
        self.contentbox.pack_start(datawindow)

        # measurement or plan selector
        self.modeselector = gtk.combo_box_new_text()
        self.modeselector.append_text(_('Weight Measurements'))
        self.modeselector.append_text(_('Weight Planner'))
        self.modeselector.set_active(0)
        mainbox.pack_start(self.contentbox)

        # get treeselection and deactivate actions if no selection
        self.treeselection = self.dataview.get_selection()
        self.set_selection_active(self.treeselection)
        self.set_plot_action_active()
        self.check_modeselector()

        # connect the signals
        csv_import_item.connect('activate', self.csv_dialog_import)
        csv_export_item.connect('activate', self.csv_dialog_export)
        self.dataview.add_events(gtk.gdk.BUTTON_PRESS_MASK)
        self.treeselection.connect('changed', self.set_selection_active)
        self.dataview.connect('button-press-event', self.button_pressed)
        self.dataview.connect('key-press-event', self.on_key_press)
        self.modeselector.connect('changed', self.update_mode)
        self.window.connect('destroy', self.destroy)

        # display window with content
        self.window.show_all()