Пример #1
0
    def _insert_menu(self):
        """Adds the menu entries for zooming."""
        manager = self._window.get_ui_manager()

        self._action_group = gtk.ActionGroup('ZoomPluginActions')

        action_submenu = gtk.Action('ZoomSubMenu', _('_Zoom'), _('_Zoom'),
                                    None)

        action_enlarge_font = gtk.Action('EnlargeFont', _('Zoom _In'),
                                         _('Zoom _In'), None)
        action_enlarge_font.connect('activate', self._enlarge_font)

        action_shrink_font = gtk.Action('ShrinkFont', _('Zoom _Out'),
                                        _('Zoom _Out'), None)
        action_shrink_font.connect('activate', self._shrink_font)

        action_reset_font = gtk.Action('OriginalSize', _('_Reset'),
                                       _('_Reset'), None)
        action_reset_font.connect('activate', self._reset_font)

        self._action_group.add_action(action_submenu)

        self._action_group.add_action_with_accel(
            action_enlarge_font, self.__class__._ENLARGE_ACCELERATORS[0])
        self._action_group.add_action_with_accel(
            action_shrink_font, self.__class__._SHRINK_ACCELERATORS[0])
        self._action_group.add_action_with_accel(
            action_reset_font, self.__class__._RESET_ACCELERATORS[0])

        manager.insert_action_group(self._action_group)

        self._ui_id = manager.add_ui_from_file(self.__class__._UI_FILE)
Пример #2
0
    def activate(self, totem_object):

        data = dict()
        manager = totem_object.get_ui_manager()

        data['action_group'] = gtk.ActionGroup('Python')

        action = gtk.Action('Python', 'Python', _('Python Console Menu'), None)
        data['action_group'].add_action(action)

        action = gtk.Action('PythonConsole', _('_Python Console'),
                            _("Show Totem's Python console"),
                            'gnome-mime-text-x-python')
        action.connect('activate', self.show_console, totem_object)
        data['action_group'].add_action(action)

        action = gtk.Action('PythonDebugger', _('Python Debugger'),
                            _("Enable remote Python debugging with rpdb2"),
                            None)
        if have_rpdb2:
            action.connect('activate', self.enable_debugging, totem_object)
        else:
            action.set_visible(False)
        data['action_group'].add_action(action)

        manager.insert_action_group(data['action_group'], 0)
        data['ui_id'] = manager.add_ui_from_string(ui_str)
        manager.ensure_update()

        totem_object.set_data('PythonConsolePluginInfo', data)
Пример #3
0
    def insert_menu_item(self, window):
        manager = self.window.get_ui_manager()
        
        self.action_group = gtk.ActionGroup("PythonPluginActions")
        
        # Create an action for the "Run in python" menu option
        # and set it to call the "run_document_in_python" function.
        self.run_in_python_action = gtk.Action(name="ToolRunInPython", label="Run Document in Python", tooltip="Run the current document through the Python interpreter", stock_id=gtk.STOCK_REFRESH)
        self.run_in_python_action.connect("activate", self.run_document_in_python)

        # Create an action to allow the user to clear the contents of the bottom panel.
        self.run_in_python_reset_action = gtk.Action(name="ToolRunInPython_Reset", label="Clear Run In Python output", tooltip="Clear the contents of the bottom panel", stock_id = None)
        self.run_in_python_reset_action.connect("activate", lambda unused_param: self.output_area.output_data.clear())
        
        # Add the action with Ctrl + F5 as its keyboard shortcut.
        self.action_group.add_action_with_accel(self.run_in_python_action, "<Ctrl>F5")
        self.action_group.add_action_with_accel(self.run_in_python_reset_action, "<Ctrl><Shift>F5")
        
        # Add the action group.
        manager.insert_action_group(self.action_group, -1)
        
        # Add the item to the "Tools" menu.
        self.ui_id = manager.add_ui_from_string(ui_string)
        
        # Get the bottom panel.
        panel = window.get_bottom_panel()
        
        # Create an output area object (HBox) where we'll store the Python interpreter's output.
        self.output_area = OutputArea(window)
        
        # Add the item to the panel.
        panel.add_item(self.output_area, "Output", gtk.Image())
Пример #4
0
    def create_detach_popup(self, event):
        if self.HAS_CONTROL_BOX and (self.HAS_CLOSE_BUTTON
                                     or self.HAS_DETACH_BUTTON):
            menu = gtk.Menu()
            if self.HAS_DETACH_BUTTON:
                act = gtk.Action(name='detach',
                                 label='Detach',
                                 tooltip='Detach this view',
                                 stock_id='gtk-up')

                def _det(_act):
                    self.__controlbar_clicked('detach')

                act.connect('activate', _det)
                mi = act.create_menu_item()
                menu.add(mi)
            if self.HAS_CLOSE_BUTTON:
                act = gtk.Action(name='close',
                                 label='Close',
                                 tooltip='Close this view',
                                 stock_id=gtk.STOCK_CLOSE)

                def _close(_act):
                    self.__controlbar_clicked('close')

                act.connect('activate', _close)
                mi = act.create_menu_item()
                menu.add(mi)
            menu.show_all()
            menu.popup(None, None, None, event.button, event.time)
Пример #5
0
 def __init__(self, patchname):
     title = _('gwsmhg: Patch "{0}" : {1}').format(
         patchname, utils.path_rel_home(os.getcwd()))
     dialogue.AmodalDialog.__init__(self,
                                    title=title,
                                    parent=dialogue.main_window,
                                    flags=gtk.DIALOG_DESTROY_WITH_PARENT)
     self.widget = Widget(patchname)
     self.vbox.pack_start(self.widget, expand=True, fill=True)
     self.refresh_action = gtk.Action('patch_view_refresh', _('_Refresh'),
                                      _('Refresh this patch in database.'),
                                      icons.STOCK_REFRESH_PATCH)
     self.refresh_action.connect('activate', self._refresh_acb)
     self.refresh_action.set_sensitive(
         ifce.PM.get_top_patch() == self.widget.patchname)
     refresh_button = gutils.ActionButton(self.refresh_action)
     self.action_area.pack_start(refresh_button)
     self._save_file = ifce.PM.get_patch_file_name(patchname)
     self.save_action = gtk.Action('patch_view_save', _('_Export'),
                                   _('Export patch to text file.'),
                                   gtk.STOCK_SAVE_AS)
     self.save_action.connect('activate', self._save_as_acb)
     save_button = gutils.ActionButton(self.save_action)
     self.action_area.pack_start(save_button)
     self.add_buttons(gtk.STOCK_CLOSE, gtk.RESPONSE_CLOSE)
     self.connect("response", self._close_cb)
     self.add_notification_cb(
         ws_event.PATCH_CHANGES | ws_event.FILE_CHANGES
         | ws_event.AUTO_UPDATE, self._update_display_cb)
     self.show_all()
Пример #6
0
    def __init__(self):
        self.config = tgcm.core.Config.Config(tgcm.country_support)
        self.device_dialer = tgcm.core.FreeDesktop.DeviceDialer()

        self.accelgroup = gtk.AccelGroup()
        self.menubar = gtk.MenuBar()
        self.main_actiongroup = gtk.ActionGroup('Tgcm')
        self.help_actiongroup = gtk.ActionGroup('Help')

        self.main_action = gtk.Action('Tgcm', self.config.get_app_name(), None,
                                      None)
        self.main_actiongroup.add_action(self.main_action)
        self.main_menuitem = self.main_action.create_menu_item()
        self.menubar.append(self.main_menuitem)

        self.help_action = gtk.Action('HelpGroup', None, None, gtk.STOCK_HELP)
        self.help_actiongroup.add_action(self.help_action)
        self.help_menuitem = self.help_action.create_menu_item()
        self.menubar.append(self.help_menuitem)

        self.main_menu = gtk.Menu()
        self.main_menuitem.set_submenu(self.main_menu)

        self.help_menu = gtk.Menu()
        self.help_menuitem.set_submenu(self.help_menu)
Пример #7
0
    def __create_crypt(self):
        root = gtk.Menu()

        action = gtk.Action(None, _('Encryption'), None,
                            gtk.STOCK_DIALOG_AUTHENTICATION)

        item = action.create_menu_item()
        item.set_submenu(root)

        self.menubar.append(item)

        lbls = ('MD5', 'SHA-1', 'SHA-256', 'ROT13')
        cbs = (self.__crypt_md5, self.__crypt_sha1, self.__crypt_sha256,
               self.__crypt_rot13)

        for lbl, cb in zip(lbls, cbs):
            action = gtk.Action(None, lbl, None,
                                gtk.STOCK_DIALOG_AUTHENTICATION)

            item = action.create_menu_item()
            action.connect('activate', cb)

            if lbl == "SHA-256":
                item.set_sensitive(SHA256_ENABLED)

            root.append(item)
    def activate(self, shell):
        data = dict()
        manager = shell.get_player().get_property('ui-manager')

        data['action_group'] = gtk.ActionGroup('PythonConsolePluginActions')

        action = gtk.Action('PythonConsole', _('_Python Console'),
                            _("Show Rhythmbox's python console"),
                            'gnome-mime-text-x-python')
        action.connect('activate', self.show_console, shell)
        data['action_group'].add_action(action)

        action = gtk.Action('PythonDebugger', _('Python Debugger'),
                            _("Enable remote python debugging with rpdb2"),
                            None)
        if have_rpdb2:
            action.connect('activate', self.enable_debugging, shell)
        else:
            action.set_visible(False)
        data['action_group'].add_action(action)

        manager.insert_action_group(data['action_group'], 0)
        data['ui_id'] = manager.add_ui_from_string(ui_str)
        manager.ensure_update()

        shell.set_data('PythonConsolePluginInfo', data)
Пример #9
0
    def activate(self, shell):
        self.shell = shell  # so the source can update the progress bar
        self.db = shell.get_property("db")

        self.entry_type = self.db.entry_register_type("MagnatuneEntryType")
        # allow changes which don't do anything
        self.entry_type.can_sync_metadata = True
        self.entry_type.sync_metadata = None

        theme = gtk.icon_theme_get_default()
        rb.append_plugin_source_path(theme, "/icons")

        width, height = gtk.icon_size_lookup(gtk.ICON_SIZE_LARGE_TOOLBAR)
        icon = rb.try_load_icon(theme, "magnatune", width, 0)

        group = rb.rb_source_group_get_by_name("stores")
        self.source = gobject.new(MagnatuneSource,
                                  shell=shell,
                                  entry_type=self.entry_type,
                                  source_group=group,
                                  icon=icon,
                                  plugin=self)

        shell.register_entry_type_for_source(self.source, self.entry_type)
        shell.append_source(self.source, None)  # Add the source to the list

        manager = shell.get_player().get_property('ui-manager')
        # Add the popup menu actions
        self.action_group = gtk.ActionGroup('MagnatunePluginActions')

        action = gtk.Action('MagnatuneDownloadAlbum', _('Download Album'),
                            _("Download this album from Magnatune"),
                            'gtk-save')
        action.connect(
            'activate', lambda a: self.shell.get_property("selected-source").
            download_album())
        self.action_group.add_action(action)
        action = gtk.Action('MagnatuneArtistInfo', _('Artist Information'),
                            _("Get information about this artist"), 'gtk-info')
        action.connect(
            'activate', lambda a: self.shell.get_property("selected-source").
            display_artist_info())
        self.action_group.add_action(action)
        action = gtk.Action('MagnatuneCancelDownload', _('Cancel Downloads'),
                            _("Stop downloading purchased albums"), 'gtk-stop')
        action.connect(
            'activate', lambda a: self.shell.get_property("selected-source").
            cancel_downloads())
        action.set_sensitive(False)
        self.action_group.add_action(action)

        manager.insert_action_group(self.action_group, 0)
        self.ui_id = manager.add_ui_from_string(popup_ui)

        self.pec_id = shell.get_player().connect('playing-song-changed',
                                                 self.playing_entry_changed)
        manager.ensure_update()
Пример #10
0
 def _create_actions(self):
     self._current = None
     self.add_widget(
         'dis_act',
         gtk.Action('Disable', 'Disable', 'Disable this breakpoint',
                    gtk.STOCK_NO))
     self.add_widget(
         'en_act',
         gtk.Action('Enable', 'Enable', 'Enable this breakpoint',
                    gtk.STOCK_YES))
def PyFileActionSubmenu(menu):
    action = gtk.Action("TMP:SubSubmenuitem1", "Subsubmenuitem 1", None, None)
    subitem = action.create_menu_item()
    menu.append(subitem)
    subitem.show()

    action = gtk.Action("TMP:SubSubmenuitem2", "Subsubmenuitem 2", None, None)
    subitem = action.create_menu_item()
    menu.append(subitem)
    subitem.show()
Пример #12
0
	def _insert_menu( self ):
		manager = self._window.get_ui_manager()
		self._action_group = gtk.ActionGroup( "SnapOpenPluginActions" )
		snapopen_menu_action = gtk.Action( name="SnapOpenMenuAction", label="Snap", tooltip="Snap tools", stock_id=None )
		self._action_group.add_action( snapopen_menu_action )
		snapopen_action = gtk.Action( name="SnapOpenAction", label="Snap Open...\t", tooltip="Open file by autocomplete...", stock_id=gtk.STOCK_JUMP_TO )
		snapopen_action.connect( "activate", lambda a: self.on_snapopen_action() )
		self._action_group.add_action_with_accel( snapopen_action, "<Ctrl><Alt>o" )
		manager.insert_action_group( self._action_group, 0 )
		self._ui_id = manager.new_merge_id()
		manager.add_ui_from_string( ui_str )
		manager.ensure_update()
Пример #13
0
    def _make_station_menu(self, station, port):
        xml = """
<ui>
  <popup name="menu">
    <menuitem action="ping"/>
    <menuitem action="conntest"/>
    <menuitem action="reqpos"/>
    <menuitem action="sendfile"/>
    <menuitem action="version"/>
    <menuitem action="mcheck"/>
    <menuitem action="qrz"/>
    <separator/>
    <menuitem action="remove"/>
    <menuitem action="reset"/>
    <separator/>
    <menuitem action="clearall"/>
    <menuitem action="pingall"/>
    <menuitem action="reqposall"/>
  </popup>
</ui>
"""
        ag = gtk.ActionGroup("menu")
        actions = [("ping", _("Ping"), None),
                   ("conntest", _("Test Connectivity"), None),
                   ("reqpos", _("Request Position"), None),
                   ("sendfile", _("Send file"), None),
                   ("remove", _("Remove"), gtk.STOCK_DELETE),
                   ("reset", _("Reset"), gtk.STOCK_JUMP_TO),
                   ("version", _("Get version"), gtk.STOCK_ABOUT),
                   ("mcheck", _("Request mail check"), None),
                   ("qrz", _("Check on Qrz.com"), None)]

        for action, label, stock in actions:
            a = gtk.Action(action, label, None, stock)
            a.connect("activate", self._mh, station, port)
            a.set_sensitive(station is not None)
            ag.add_action(a)

        actions = [("clearall", _("Clear All"), gtk.STOCK_CLEAR),
                   ("pingall", _("Ping All Stations"), None),
                   ("reqposall", _("Request all positions"), None)]
        for action, label, stock in actions:
            a = gtk.Action(action, label, None, stock)
            a.connect("activate", self._mh, station, port)
            ag.add_action(a)

        uim = gtk.UIManager()
        uim.insert_action_group(ag, 0)
        uim.add_ui_from_string(xml)

        return uim.get_widget("/menu")
Пример #14
0
    def activate(self, shell):
        self.db = shell.get_property("db")

        self.entry_type = self.db.entry_register_type("JamendoEntryType")
        # allow changes which don't do anything
        self.entry_type.can_sync_metadata = True
        self.entry_type.sync_metadata = None

        theme = gtk.icon_theme_get_default()
        rb.append_plugin_source_path(theme, "/icons/")

        width, height = gtk.icon_size_lookup(gtk.ICON_SIZE_LARGE_TOOLBAR)
        icon = rb.try_load_icon(theme, "jamendo", width, 0)

        group = rb.rb_source_group_get_by_name("stores")
        self.source = gobject.new(JamendoSource,
                                  shell=shell,
                                  entry_type=self.entry_type,
                                  plugin=self,
                                  icon=icon,
                                  source_group=group)
        shell.register_entry_type_for_source(self.source, self.entry_type)
        shell.append_source(self.source, None)  # Add the source to the list

        # Add button
        manager = shell.get_player().get_property('ui-manager')
        action = gtk.Action('JamendoDownloadAlbum', _('_Download Album'),
                            _("Download this album using BitTorrent"),
                            'gtk-save')
        action.connect(
            'activate',
            lambda a: shell.get_property("selected-source").download_album())
        self.action_group = gtk.ActionGroup('JamendoPluginActions')
        self.action_group.add_action(action)

        # Add Button for Donate
        action = gtk.Action('JamendoDonateArtist', _('_Donate to Artist'),
                            _("Donate Money to this Artist"), 'gtk-jump-to')
        action.connect(
            'activate',
            lambda a: shell.get_property("selected-source").launch_donate())
        self.action_group.add_action(action)

        manager.insert_action_group(self.action_group, 0)
        self.ui_id = manager.add_ui_from_string(popup_ui)
        manager.ensure_update()

        self.pec_id = shell.get_player().connect('playing-song-changed',
                                                 self.playing_entry_changed)
Пример #15
0
    def __on_button_press(self, tree, event):
        self.last_pos = (event.x, event.y)

        if event.button != 3:
            return

        selected = self.get_selected_ips()

        if not selected:
            return

        info_str = len(selected) == 1 and \
                 selected[0] or _('%d IP') % len(selected)

        session = ServiceBus().call('pm.sessions', 'get_current_session')

        if session.session_name == 'AUDIT' and \
           session.get_current_page_name() == 'TARGETS':
            sensitive = True
        else:
            sensitive = False

        menu = gtk.Menu()

        act = gtk.Action('target1-add',
                         _("Add '%s' to target1") % info_str, None,
                         gtk.STOCK_ADD)
        act.connect('activate', lambda a, (s, ip): \
                    s.target_page.target1_tree.append(ip), (session, selected))

        item = act.create_menu_item()
        item.set_sensitive(sensitive)
        menu.append(item)

        act = gtk.Action('target2-add',
                         _("Add '%s' to target2") % info_str, None,
                         gtk.STOCK_ADD)
        act.connect('activate', lambda a, (s, ip): \
                    s.target_page.target2_tree.append(ip), (session, selected))

        item = act.create_menu_item()
        item.set_sensitive(sensitive)
        menu.append(item)

        menu.show_all()
        menu.popup(None, None, None, event.button, event.time)

        return True
Пример #16
0
    def cb_popup(self, t, menu):
        if not t.get_selection():
            menu.get_children()[0].set_sensitive(False)
        x, y = t.window_to_buffer_coords(*t.get_pointer())
        i = t.get_iter_at_location(x, y)
        if i.has_tag(self.it) or i.has_tag(self.pt):
            e = i.copy()
            if i.has_tag(self.it):
                i.get_tag_start(self.it)
                e.get_tag_end(self.it)
                string = i.get_text(e)
                filename, ln, empty = string.split(':')
            elif i.has_tag(self.pt):
                i.get_tag_start(self.pt)
                e.get_tag_end(self.pt)
                string = i.get_text(e)
                filename, ln = pre.search(string).groups()

            menu.add(gtk.SeparatorMenuItem())
            a = gtk.Action('goto-line', 'Goto line', 'Goto the line',
                           gtk.STOCK_OK)
            mi = a.create_menu_item()
            menu.add(mi)
            menu.show_all()
            a.connect('activate', self.act_gotoline, filename, int(ln) - 1)
Пример #17
0
 def createAg(self):
     ag = gtk.ActionGroup("a")
     for name in (ACTION_FIND_FORWARD, ACTION_FIND_BACKWARD):
         ag.add_action(gtk.Action(name, None, None, "gtk-open"))
     ag.add_action(
         gtk.ToggleAction(ACTION_FIND_TOGGLE, None, None, "gtk-open"))
     return ag
Пример #18
0
    def build_popup_menu(self):

        # TEST
        manager = self.window.get_ui_manager()

        if (self.ui_popup_id):
            manager.remove_ui(self.ui_popup_id)
            self.ui_popup_id = None

            self.action_group.remove_action(self.popup_action)

        self.ui_popup_id = manager.new_merge_id()

        action_name = "splitview_popup_submenu"
        path = "/NotebookPopup/NotebookPupupOps_1"

        manager.add_ui(merge_id=self.ui_popup_id,
                       path=path,
                       name=action_name,
                       action=action_name,
                       type=gtk.UI_MANAGER_MENU,
                       top=False)

        self.popup_action = gtk.Action(
            name=action_name,
            label="Quick Splitview",
            tooltip="Choose another document to view...",
            stock_id=None)
        self.popup_action.set_visible(True)

        self.action_group.add_action(self.popup_action)
Пример #19
0
 def test_linker(self):
     buff = gtk.TextBuffer()
     act = gtk.Action("Fop", "", None, None)
     l = sensitive.SaveLinker(buff, act)
     ref = weakref.ref(l)
     l = None
     assert ref() is None
Пример #20
0
    def __init__(self):
        self._ui = None
        self.default_store = get_default_store()
        self._printer_verified = False
        # Delay printer creation until we are accessing pos or till app. Other
        # applications should still be accessible without a printer
        self._printer = None

        SaleStatusChangedEvent.connect(self._on_SaleStatusChanged)
        ECFIsLastSaleEvent.connect(self._on_ECFIsLastSale)
        TillOpenEvent.connect(self._on_TillOpen)
        TillCloseEvent.connect(self._on_TillClose)
        TillAddCashEvent.connect(self._on_TillAddCash)
        TillAddTillEntryEvent.connect(self._on_AddTillEntry)
        TillRemoveCashEvent.connect(self._on_TillRemoveCash)
        StartApplicationEvent.connect(self._on_StartApplicationEvent)
        StopApplicationEvent.connect(self._on_StopApplicationEvent)
        CouponCreatedEvent.connect(self._on_CouponCreatedEvent)
        GerencialReportPrintEvent.connect(self._on_GerencialReportPrintEvent)
        GerencialReportCancelEvent.connect(self._on_GerencialReportCancelEvent)
        CheckECFStateEvent.connect(self._on_CheckECFStateEvent)
        HasPendingReduceZ.connect(self._on_HasPendingReduceZ)
        HasOpenCouponEvent.connect(self._on_HasOpenCouponEvent)

        self._till_summarize_action = gtk.Action('Summary', _('Summary'), None,
                                                 None)
        self._till_summarize_action.connect('activate',
                                            self._on_TillSummary__activate)

        add_bindings([
            ('plugin.ecf.read_memory', '<Primary>F9'),
            ('plugin.ecf.summarize', '<Primary>F11'),
        ])
Пример #21
0
    def _make_session_menu(self, sid, event):
        xml = """
<ui>
  <popup name="menu">
    <menuitem action="stop"/>
    <menuitem action="cancel"/>
    <menuitem action="restart"/>
  </popup>
</ui>
"""
        ag = gtk.ActionGroup("menu")

        actions = [("stop", _("Stop"), not event.is_final()),
                   ("cancel", _("Cancel"), not event.is_final()),
                   ("restart", _("Restart"), event.get_restart_info())]
        for action, label, sensitive in actions:
            a = gtk.Action(action, label, None, None)
            a.connect("activate", self._mh_xfer, event)
            a.set_sensitive(bool(sensitive))
            ag.add_action(a)

        uim = gtk.UIManager()
        uim.insert_action_group(ag, 0)
        uim.add_ui_from_string(xml)

        return uim.get_widget("/menu")
    def start(self, reader):
        self.reader = reader

        self.icon = None
        self.wnd_pos = (0, 0)

        self.menu = gtk.Menu()
        self.menu.show()

        action = gtk.Action(None, '_Quit', 'Quit from UMIT', gtk.STOCK_QUIT)
        action.connect('activate', self.__on_quit)

        item = action.create_menu_item()
        item.show()

        self.menu.append(item)

        self.type = self.notifier = None

        # Force to use win32 module
        if WIN32_PRESENT:
            self.set_type(TrayPlugin.TYPE_WINDOWS)
        else:
            self.set_type(tray_prefs.parser['notifications']['type'].value)
            tray_prefs.parser['notifications']['type'].value = self.type

            logo = os.path.join(Path.icons_dir, 'umit_16.ico')
            log.debug('Creating status icon with %s as logo' % logo)

            self.icon = gtk.status_icon_new_from_file(logo)
            tray_prefs.change_cb = self.set_type

        self.icon.connect('popup-menu', self.__on_right_click)
        self.icon.connect('activate', self.__on_activate)
Пример #23
0
    def build_menus(self, accelerators):
        menu_entries = (
            ('ConnectAction', gtk.STOCK_CONNECT, None, 'app.connect()',
             self.main_menu),
            ('DisconnectAction', gtk.STOCK_DISCONNECT, None,
             'app.disconnect()', self.main_menu),
            ('AnAction', None, _('Available networks'), 'app.networks()',
             self.main_menu),
            ('QuitAction', gtk.STOCK_QUIT, None, 'window.close()',
             self.main_menu),
            ('HelpAction', gtk.STOCK_HELP, None, 'app.help()', self.help_menu),
        )

        for entry_id, stock_id, name, oper_id, menu in menu_entries:

            action = gtk.Action(entry_id, name, None, stock_id)
            action.connect('activate', self.menu_callback, oper_id)

            accelerator = None
            if (oper_id in accelerators) and ('window.close' not in oper_id):
                accelerator = accelerators[oper_id]
            self.main_actiongroup.add_action_with_accel(action, accelerator)
            action.set_accel_group(self.accelgroup)
            action.connect_accelerator()
            menu_item = action.create_menu_item()
            menu.append(menu_item)

            if entry_id == 'ConnectAction':
                self.connect_menuitem = menu_item
            elif entry_id == 'DisconnectAction':
                self.disconnect_menuitem = menu_item

        self.device_dialer.connect('connected', self._on_connected)
        self.device_dialer.connect('disconnected', self._on_disconnected)
Пример #24
0
 def add_macro(self, config_name, modulename, classname, methodname,
               help, image_path, run_macro):
     """Add a macro to the macro menu."""
     macro_address = '/TopMenuBar/Metadata'
     macro_menu = self.uimanager.get_widget(macro_address).get_submenu()
     if methodname == rose.macro.VALIDATE_METHOD:
         all_v_item = self.uimanager.get_widget(macro_address + "/All V")
         all_v_item.set_sensitive(True)
     config_menu_name = config_name.replace('/', ':').replace('_', '__')
     config_label_name = config_name.split('/')[-1].replace('_', '__')
     label = rose.config_editor.TOP_MENU_METADATA_MACRO_CONFIG.format(
         config_label_name)
     config_address = macro_address + '/' + config_menu_name
     config_item = self.uimanager.get_widget(config_address)
     if config_item is None:
         actiongroup = self.uimanager.get_action_groups()[0]
         if actiongroup.get_action(config_menu_name) is None:
             actiongroup.add_action(gtk.Action(config_menu_name,
                                               label,
                                               None, None))
         new_ui = """<ui><menubar name="TopMenuBar">
                     <menu action="Metadata">
                     <menuitem action="{0}"/></menu></menubar>
                     </ui>""".format(config_menu_name)
         self.macro_ids.append(self.uimanager.add_ui_from_string(new_ui))
         config_item = self.uimanager.get_widget(config_address)
         if image_path is not None:
             image = gtk.image_new_from_file(image_path)
             config_item.set_image(image)
     if config_item.get_submenu() is None:
         config_item.set_submenu(gtk.Menu())
     macro_fullname = ".".join([modulename, classname, methodname])
     macro_fullname = macro_fullname.replace("_", "__")
     if methodname == rose.macro.VALIDATE_METHOD:
         stock_id = gtk.STOCK_DIALOG_QUESTION
     else:
         stock_id = gtk.STOCK_CONVERT
     macro_item = gtk.ImageMenuItem(stock_id=stock_id)
     macro_item.set_label(macro_fullname)
     macro_item.set_tooltip_text(help)
     macro_item.show()
     macro_item._run_data = [config_name, modulename, classname,
                             methodname]
     macro_item.connect("activate",
                        lambda i: run_macro(*i._run_data))
     config_item.get_submenu().append(macro_item)
     if (methodname == rose.macro.VALIDATE_METHOD):
         for item in config_item.get_submenu().get_children():
             if hasattr(item, "_rose_all_validators"):
                 return False
         all_item = gtk.ImageMenuItem(gtk.STOCK_DIALOG_QUESTION)
         all_item._rose_all_validators = True
         all_item.set_label(rose.config_editor.MACRO_MENU_ALL_VALIDATORS)
         all_item.set_tooltip_text(
             rose.config_editor.MACRO_MENU_ALL_VALIDATORS_TIP)
         all_item.show()
         all_item._run_data = [config_name, None, None, methodname]
         all_item.connect("activate",
                          lambda i: run_macro(*i._run_data))
         config_item.get_submenu().prepend(all_item)
    def activate(self, shell):
        self.shell = shell
        self.db = shell.props.db
        self.library = self.shell.props.library_source
        self.player = shell.props.shell_player
        data = dict()
        ui_manager = shell.get_ui_manager()

        icon_file_name = self.find_file("echo_logo_64a.png")
        iconsource = gtk.IconSource()
        iconsource.set_filename(icon_file_name)
        iconset = gtk.IconSet()
        iconset.add_source(iconsource)
        iconfactory = gtk.IconFactory()
        iconfactory.add("genius_icon", iconset)
        iconfactory.add_default()

        data['action_group'] = gtk.ActionGroup('GeniusPluginActions')

        action = gtk.Action('MakeGeniusPlaylist',
                            _('Echo Nest Recommender Playlist'),
                            _("Make an Echo Nest Recommender playlist"),
                            "genius_icon")
        action.connect('activate', self.make_playlist, shell)
        data['action_group'].add_action(action)

        ui_manager.insert_action_group(data['action_group'], 0)
        data['ui_id'] = ui_manager.add_ui_from_string(ui_toolbar_button)
        ui_manager.ensure_update()

        shell.set_data('GeniusPluginInfo', data)
Пример #26
0
    def os_append_menu(self):
        """
        """

        self.os_action_group = gtk.ActionGroup('OpenSubtitles')

        self.action = gtk.Action(
            'opensubtitles', _('_Download Movie Subtitles...'),
            _("Download movie subtitles from OpenSubtitles"), '')

        self.os_action_group.add_action(self.action)

        self.manager.insert_action_group(self.os_action_group, 0)

        self.menu_id = self.manager.new_merge_id()
        self.manager.add_ui(
            self.menu_id,
            '/tmw-menubar/view/subtitles/subtitle-download-placeholder',
            'opensubtitles', 'opensubtitles', gtk.UI_MANAGER_MENUITEM, False)
        self.action.set_visible(True)

        self.manager.ensure_update()

        self.action.connect('activate', self.os_show_dialog, self.totem)

        self.action.set_sensitive(self.totem.is_playing()
                                  and self.os_check_allowed_scheme()
                                  and not self.os_check_is_audio())
    def __init__(self):
        gtk.VBox.__init__(self, False, 2)

        self.entry = FilterEntry()
        self.tree = AuditOutputTree()

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

        action = gtk.Action('save', _('Save log'),
                            _('Save log to file'), gtk.STOCK_SAVE)
        action.connect('activate', self.tree.on_save_log)

        item = action.create_tool_item()
        self.toolbar.insert(item, -1)

        item = gtk.ToolItem()
        item.add(self.entry)
        item.set_expand(True)

        self.toolbar.insert(item, -1)

        self.pack_start(self.toolbar, False, False)
        self.pack_end(self.tree)

        self.entry.get_entry().connect('changed', self.__on_filter)
Пример #28
0
    def __on_button_press(self, widget, evt, typo):
        if evt.button != 3:
            return

        menu = gtk.Menu()

        # OK show a popup to copy and paste
        # cut/copy/paste/delete

        txts = (_('Cu_t'), _('_Copy'), _('_Paste'), _('Copy from _both'))
        icons = (gtk.STOCK_CUT, gtk.STOCK_COPY, gtk.STOCK_PASTE,
                 gtk.STOCK_COPY)
        cbcs = (self.__on_cut, self.__on_copy, self.__on_paste,
                self.__on_bcopy)

        clipboard_sel = gtk.clipboard_get().wait_for_text() and True or False

        idx = 0

        for txt, icon, cbc in zip(txts, icons, cbcs):
            action = gtk.Action(None, txt, None, icon)
            action.connect('activate', cbc, typo)

            item = action.create_menu_item()

            if not clipboard_sel and idx == 2:
                item.set_sensitive(False)

            menu.append(item)

            idx += 1

        menu.popup(None, None, None, evt.button, evt.time, None)
        menu.show_all()
Пример #29
0
def get_gtk_actiongroup(obj):
    '''Return a C{gtk.ActionGroup} for an object using L{Action}
	objects as attributes.

	Defines the attribute C{obj.actiongroup} if it does not yet exist.

	This method can only be used when gtk is available
	'''
    import gtk

    if hasattr(obj, 'actiongroup') \
    and obj.actiongroup is not None:
        return obj.actiongroup

    obj.actiongroup = gtk.ActionGroup(obj.__class__.__name__)

    for name, action in inspect.getmembers(obj.__class__,
                                           lambda m: isinstance(m, Action)):
        if isinstance(action, ToggleAction):
            gaction = gtk.ToggleAction(*action._attr)
        else:
            gaction = gtk.Action(*action._attr)

        action.connect_actionable(obj, gaction)
        obj.actiongroup.add_action_with_accel(gaction, action._accel)

    return obj.actiongroup
Пример #30
0
    def update_history (self, history):
        ''' fill the " Previous Documents " menu with the specified list of documents '''

        if self.recents:
            for mid in self.recents_mid:
                self.uim.remove_ui (mid)
                
            self.uim.remove_action_group (self.recents)

        self.recents_mid = []
        self.recents = gtk.ActionGroup ('Recent')

        self.uim.insert_action_group (self.recents, 1)

        for item in history:
            # Display name in the menu
            quoted   = string.replace (item [0], '_', '__')
        
            mid = self.uim.new_merge_id ()

            self.recents_mid.append (mid)
            
            action = gtk.Action (str (mid), quoted, None, None)
            self.recents.add_action (action)

            action.connect ('activate', self._history_open_cb, item)
        
            self.uim.add_ui (mid, '/Menubar/File/Recent', str (mid),
                             str (mid), gtk.UI_MANAGER_MENUITEM, False)

        return