Beispiel #1
0
    def _add_menu_optional_actions(self, action_group, uimanager):
        if graphs.has_matplotlib:
            action = Gtk.Action(name='ToolsGraphMenu',
                                label='Create Graph',
                                tooltip=None,
                                stock_id=None)
            action_group.add_action(action)

            for graph_name in graphs.get_graphs():
                action_name = 'ToolsGraph' + graph_name
                action = Gtk.Action(name=action_name,
                                    label=graph_name,
                                    tooltip=graph_name,
                                    stock_id=None)
                action.connect('activate',
                               lambda _: self.show_campaign_graph(graph_name))
                action_group.add_action(action)

            merge_id = uimanager.new_merge_id()
            uimanager.add_ui(merge_id, '/MenuBar/ToolsMenu', 'ToolsGraphMenu',
                             'ToolsGraphMenu', Gtk.UIManagerItemType.MENU,
                             False)
            for graph_name in graphs.get_graphs():
                action_name = 'ToolsGraph' + graph_name
                uimanager.add_ui(merge_id, '/MenuBar/ToolsMenu/ToolsGraphMenu',
                                 action_name, action_name,
                                 Gtk.UIManagerItemType.MENUITEM, False)

        if sys.platform.startswith('linux'):
            action = Gtk.Action(name='ToolsSFTPClient',
                                label='SFTP Client',
                                tooltip='SFTP Client',
                                stock_id=None)
            action.connect('activate', lambda x: self.start_sftp_client())
            action_group.add_action(action)
            merge_id = uimanager.new_merge_id()
            uimanager.add_ui(merge_id, '/MenuBar/ToolsMenu', 'ToolsSFTPClient',
                             'ToolsSFTPClient', Gtk.UIManagerItemType.MENUITEM,
                             False)
Beispiel #2
0
    def add_choices_menu_actions(self, action_group):
        action_group.add_action(
            Gtk.Action("ChoicesMenu", "Choices", None, None))

        action_group.add_radio_actions(
            [("ChoiceOne", None, "One", None, None, 1),
             ("ChoiceTwo", None, "Two", None, None, 2)], 1,
            self.on_menu_choices_changed)

        three = Gtk.ToggleAction("ChoiceThree", "Three", None, None)
        three.connect("toggled", self.on_menu_choices_toggled)
        action_group.add_action(three)
        ad = Gtk.Action('DisabledAction', 'Disabled Action', None, None)
        ad.set_sensitive(False)
        action_group.add_action(ad)
        ia = Gtk.Action('InvisibleAction', 'Invisible Action', None, None)
        ia.set_visible(False)
        action_group.add_action(ia)
        ta = Gtk.Action('TooltipAction', 'Tooltip Action', 'A tooltip', None)
        action_group.add_action(ta)
        action_group.add_action(
            Gtk.Action('IconAction', 'Icon Action', None, None))
Beispiel #3
0
	def do_activate(self):
		self._totem = self.object
		totem_object = self.object
		
		data = dict()
		manager = totem_object.get_ui_manager()
		
		data['action_group'] = Gtk.ActionGroup('Python')
		
		action = Gtk.Action('Sleep', 'Sleep', _('System Shutdown Menu'), None)
		data['action_group'].add_action(action)
		
		action = Gtk.Action('SleepConfigure', _('_Configure'), _("Show Totem's Python console"), 'gnome-mime-text-x-python')
		action.connect('activate', self.show_config, totem_object)
		
		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.ShutdownPluginInfo = data
Beispiel #4
0
    def add_file_menu_actions(self, action_group):
        action_filemenu = Gtk.Action("FileMenu", "File", None, None)
        action_group.add_action(action_filemenu)

        action_filenewmenu = Gtk.Action("FileNew", None, None, Gtk.STOCK_NEW)
        action_group.add_action(action_filenewmenu)

        action_new = Gtk.Action("FileNewStandard", "_New", "Create a new file",
                                Gtk.STOCK_NEW)
        action_new.connect("activate", self.on_menu_file_new_generic)
        action_group.add_action_with_accel(action_new, None)

        action_group.add_actions([
            ("FileNewFoo", None, "New Foo", None, "Create new foo",
             self.on_menu_file_new_generic),
            ("FileNewGoo", None, "_New Goo", None, "Create new goo",
             self.on_menu_file_new_generic),
        ])

        action_filequit = Gtk.Action("FileQuit", None, None, Gtk.STOCK_QUIT)
        action_filequit.connect("activate", self.on_menu_file_quit)
        action_group.add_action(action_filequit)
Beispiel #5
0
    def do_activate(self):
        self.__action = Gtk.Action(
            name='SendTo',
            label=_('Send to...'),
            tooltip=_('Send files by mail, instant message...'),
            stock_id='')
        shell = self.object
        self.__action.connect('activate', self.send_to, shell)

        self.__action_group = Gtk.ActionGroup(name='SendToActionGroup')
        self.__action_group.add_action(self.__action)
        shell.get_ui_manager().insert_action_group(self.__action_group, -1)

        self.__ui_id = shell.get_ui_manager().add_ui_from_string(ui_definition)
Beispiel #6
0
    def create_menu_item(self):
        """
        Create a menu item in the "Tools" menu.
        """
        action = gtk.Action("RegexSearch", _("Regular expression..."),
                            _("Search using regular expressions"), None)
        action.connect("activate", self.on_open_regex_dialog)

        action_group = gtk.ActionGroup("RegexSearchActions")
        action_group.add_action_with_accel(action, "<control>r")

        manager = self._window.get_ui_manager()
        manager.insert_action_group(action_group, -1)
        manager.add_ui_from_string(ui_str)
Beispiel #7
0
 def _insert_menu(self):
     manager = self._window.get_ui_manager()
     self._action_group = Gtk.ActionGroup("FuzzyOpenPluginActions")
     fuzzyopen_action = Gtk.Action(name="FuzzyOpenAction",
                                   label="Fuzzy Open...\t",
                                   tooltip="Open file by autocomplete...",
                                   stock_id=Gtk.STOCK_JUMP_TO)
     fuzzyopen_action.connect("activate",
                              lambda a: self.on_fuzzyopen_action())
     self._action_group.add_action_with_accel(fuzzyopen_action,
                                              "<Ctrl><Shift>o")
     manager.insert_action_group(self._action_group)
     self._ui_id = manager.add_ui_from_string(ui_str)
     manager.ensure_update()
Beispiel #8
0
 def __init__(self, callbacks):
     super(ContextualMenu, self).__init__()
     for callback in callbacks:
         name = callback[0]
         label = self.menu_labels[name]
         action = Gtk.Action(name=name,
                             label=label,
                             tooltip=None,
                             stock_id=None)
         action.connect('activate', callback[1])
         menuitem = action.create_menu_item()
         menuitem.action_id = name
         self.append(menuitem)
     self.show_all()
Beispiel #9
0
    def do_activate(self):
        self.xplayer = self.object

        data = dict()
        manager = self.xplayer.get_ui_manager()

        data['action_group'] = Gtk.ActionGroup(name='Python')

        action = Gtk.Action(name='Python',
                            label='Python',
                            tooltip=_(u'Python Console Menu'),
                            stock_id=None)
        data['action_group'].add_action(action)

        action = Gtk.Action(name='PythonConsole',
                            label=_(u'_Python Console'),
                            tooltip=_(u"Show Xplayer's Python console"),
                            stock_id='gnome-mime-text-x-python')
        action.connect('activate', self._show_console)
        data['action_group'].add_action(action)

        action = Gtk.Action (name = 'PythonDebugger',
                             label = _(u'Python Debugger'),
                             tooltip = _(u"Enable remote Python debugging "\
                                          "with rpdb2"),
                             stock_id = None)
        if HAVE_RPDB2:
            action.connect('activate', self._enable_debugging)
        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()

        self.xplayer.PythonConsolePluginInfo = data
Beispiel #10
0
    def __init__(self, structure, conditions, callbacks, action_group):
        """
        @param  structure: Menu structure
        @type   structure: list

        Note on "structure". The menu structure is defined in a list of tuples
        of two elements each.  The first element is a class - the MenuItem
        subclass that defines the menu interface (see below).

        The second element is either None (if there is no submenu) or a list of
        tuples if there is a submenu.  The submenus are generated recursively.
        FYI, this is a list of tuples so that we retain the desired menu item
        order (dicts do not retain order)

            Example:
            [
                (MenuClassOne, [
                    (MenuClassOneSubA,
                    (MenuClassOneSubB
                ]),
                (MenuClassTwo,
                (MenuClassThree
            ]

        """

        self.action_group = action_group

        for item_class in structure:

            item = item_class(conditions, callbacks)

            default_name = MenuItem.make_default_name(item.identifier)
            action = Gtk.Action(item.identifier, item.label, item.tooltip,
                                item.icon)

            if item.icon and hasattr(action, "set_icon_name"):
                action.set_icon_name(item.icon)

            if item.callback:
                if item.callback_args:
                    action.connect("activate", item.callback,
                                   item.callback_args)
                else:
                    action.connect("activate", item.callback)

            action.set_property("visible", item.show())
            setattr(action, "item", item)
            self.action_group.add_action(action)
Beispiel #11
0
    def build_menus(self):
        action_group = Gtk.ActionGroup("global_actions")

        # Create Import menu
        action_import_menu = Gtk.Action("ImportMenu", "Import", None, None)
        action_group.add_action(action_import_menu)

        action_import_opml = Gtk.Action("ImportOPML",
                                        "_Import OPML",
                                        "Import feeds from OPML file",
                                        Gtk.STOCK_FILE)
        action_import_opml.connect("activate", self.on_menu_import, "OPML")
        action_group.add_action(action_import_opml)

        action_import_file = Gtk.Action("ImportFeedFile",
                                        "_Import Feeds File",
                                        "Import feeds from file",
                                        Gtk.STOCK_FILE)
        action_import_file.connect("activate", self.on_menu_import, "FEEDS")
        action_group.add_action(action_import_file)

        # Create Export menu
        action_export_menu = Gtk.Action("ExportMenu", "Export", None, None)
        action_group.add_action(action_export_menu)

        action_export_file = Gtk.Action("ExportFeedFile",
                                        "_Export Feeds File",
                                        "Export feeds to file",
                                        Gtk.STOCK_FILE)
        action_export_file.connect("activate", self.on_menu_export_feeds)
        action_group.add_action(action_export_file)

        # Setup UI manager
        self.ui_manager.add_ui_from_string(UI_INFO)
        self.add_accel_group(self.ui_manager.get_accel_group())
        self.ui_manager.insert_action_group(action_group)
Beispiel #12
0
 def __init__(self, allApps, *args):
     guiplugins.ActionDialogGUI.__init__(self, allApps, *args)
     self.directAccel = None
     self.directAction = Gtk.Action("Approve", "_Approve",
                                    self.getDirectTooltip(), self.getStockId())
     self.directAction.connect("activate", self._respond)
     self.directAction.set_property("sensitive", False)
     self.addOption("v", "Version to approve", self.defaultVersionStr)
     self.addOption("old", "Version(s) to store previous results as")
     self.addSwitch("over", "Replace successfully compared files also", 0)
     if self.hasPerformance(allApps):
         self.addSwitch("ex", "Store", 1, ["Average performance", "Exact performance"])
     # Must do this in the constructor, so that "Approve" also takes account of them
     for option in list(self.optionGroup.options.values()):
         self.addValuesFromConfig(option)
Beispiel #13
0
def get_test_window_availablepane():
    # needed because available pane will try to get it
    vm = get_test_gtk3_viewmanager()
    assert vm is not None
    db = get_test_db()
    cache = get_test_pkg_info()
    icons = get_test_gtk3_icon_cache()
    backend = get_test_install_backend()
    distro = softwarecenter.distro.get_distro()

    manager = appmanager.get_appmanager()
    if manager is None:
        # create global AppManager instance
        manager = appmanager.ApplicationManager(db, backend, icons)

    navhistory_back_action = Gtk.Action("navhistory_back_action", "Back",
                                        "Back", None)
    navhistory_forward_action = Gtk.Action("navhistory_forward_action",
                                           "Forward", "Forward", None)

    zl = "softwarecenter.backend.zeitgeist_logger.ZeitgeistLogger"
    patch(zl + ".log_install_event").start().return_value = False
    patch(zl + ".log_uninstall_event").start().return_value = False
    patch("softwarecenter.utils.is_unity_running").start().return_value = False

    w = availablepane.AvailablePane(cache, db, distro, icons,
                                    navhistory_back_action,
                                    navhistory_forward_action)
    w.init_view()
    w.show()

    win = get_test_window(child=w, width=800, height=600)
    # this is used later in tests
    win.set_data("pane", w)
    win.set_data("vm", vm)
    return win
    def add_choices_menu_actions(self, action_group):
        action_group.add_action(Gtk.Action(name="ChoicesMenu", label="Choices"))

        action_group.add_radio_actions(
            [
                ("ChoiceOne", None, "One", None, None, 1),
                ("ChoiceTwo", None, "Two", None, None, 2),
            ],
            1,
            self.on_menu_choices_changed,
        )

        three = Gtk.ToggleAction(name="ChoiceThree", label="Three")
        three.connect("toggled", self.on_menu_choices_toggled)
        action_group.add_action(three)
Beispiel #15
0
    def do_activate(self):
        shell = self.object
        print "Activating Random Album Plugin"
        action = Gtk.Action('RandomAlbum', _('Random Album'),
                            _('Play a Random Album'), "")
        action.connect('activate', self.random_album, shell)
        action_group = Gtk.ActionGroup('RandomAlbumActionGroup')
        action_group.add_action_with_accel(action, "<alt>R")

        ui_manager = shell.props.ui_manager
        ui_manager.insert_action_group(action_group)
        self.ui_id = ui_manager.add_ui_from_string(random_album_menu_item)

        self.settings = Gio.Settings(
            'org.gnome.rhythmbox.plugins.randomalbumplayer')
Beispiel #16
0
    def add_edit_menu_actions(self, action_group):
        ''' Command项目的菜单设定。 '''
        action_command_menu = Gtk.Action("MenuEdit", "Edit", None, None)
        action_group.add_action(action_command_menu)

        action_edit_execute = Gtk.Action("ItemExecute", None, None, Gtk.STOCK_EXECUTE)
        action_edit_execute.connect("activate", self.on_menu_edit_execute)
        action_group.add_action_with_accel(action_edit_execute, "<control>Return")
        self.action_edit_execute = action_edit_execute
        
        action_edit_keep = Gtk.Action("ItemKeep", "Keep", None, Gtk.STOCK_SAVE)
        action_edit_keep.connect("activate", self.on_menu_edit_keep)
        action_group.add_action_with_accel(action_edit_keep, "<control>k")
        self.action_edit_keep = action_edit_keep
        
        action_edit_undo = Gtk.Action("ItemUndo", None, None, Gtk.STOCK_UNDO)
        action_edit_undo.connect("activate", self.on_menu_edit_undo)
        action_group.add_action_with_accel(action_edit_undo, "<control>Left")
        self.action_edit_undo = action_edit_undo
        
        action_edit_restore = Gtk.Action("ItemRestore", "Restore", None, Gtk.STOCK_GOTO_FIRST)
        action_edit_restore.connect("activate", self.on_menu_edit_restore)
        action_group.add_action_with_accel(action_edit_restore, "<control>Home")
        self.action_edit_store = action_edit_restore
Beispiel #17
0
    def merge(self):
        action_group = self.action_group = Gtk.ActionGroup(
            "GeditLineEndingStylePluginActions")
        action_group.set_translation_domain("gedit-line-ending-style-plugin")
        _ = lambda s: gettext.dgettext("gedit-line-ending-style-plugin", s)

        window = self.window
        statusbar = window.get_statusbar()
        sb_combo = self.sb_combo = GeditStatusComboBox.new(None)

        entries = [
            ("GeditLineEndingStylePluginStatusComboToLFItem", "Unix/Linux",
             "Switch to Unix/Linux-style line endings (LF)",
             Gedit.DocumentNewlineType.LF, "LF"),
            ("GeditLineEndingStylePluginStatusComboToCRItem", "Mac OS Classic",
             "Switch to Mac OS Classic-style line endings (CR)",
             Gedit.DocumentNewlineType.CR, "CR"),
            ("GeditLineEndingStylePluginStatusComboToCRLFItem", "Windows",
             "Switch to Windows-style line endings (CRLF)",
             Gedit.DocumentNewlineType.CR_LF, "CRLF")
        ]
        for entry in entries:
            action = Gtk.Action(entry[0], _(entry[1]), _(entry[2]), None)
            action_group.add_action(action)
            item = action.create_menu_item()
            item.set_data(LineEndingStylePluginUI.ITEM_VALUE_KEY, entry[3])
            activate_handler_id = item.connect("activate",
                                               self.__activate_item)
            item.set_data(LineEndingStylePluginUI.ITEM_ACTIVATE_HANDLER_ID_KEY,
                          activate_handler_id)
            sb_combo.add_item(item, _(entry[4]))

        sb_combo.show_all()
        statusbar.pack_end(sb_combo, False, True, 0)

        doc = window.get_active_document()
        if doc:
            self.__update_state_per_document(doc)

        self.tab_added_handler_id = window.connect("tab-added",
                                                   self.__tab_added)
        self.active_tab_changed_handler_id = window.connect(
            "active-tab-changed", self.__active_tab_changed)
        self.tab_removed_handler_id = window.connect("tab-removed",
                                                     self.__tab_removed)

        for doc in window.get_documents():
            self.__connect_document(doc)
Beispiel #18
0
    def do_activate(self):
        shell = self.object
        self.action = Gtk.Action(
            'OpenFolder', _('Open Containing Folder'),
            _('Open the folder that contains the selected song.'),
            'rb-open-folder')
        self.activate_id = self.action.connect('activate', self.open_folder,
                                               shell)

        self.action_group = Gtk.ActionGroup('OpenFolderPluginActions')
        self.action_group.add_action(self.action)

        uim = shell.get_ui_manager()
        uim.insert_action_group(self.action_group, 0)
        self.ui_id = uim.add_ui_from_string(ui_str)
        uim.ensure_update()
Beispiel #19
0
    def _create_application_actions(self):
        def callback(action, name):
            self.switch_application(name)

        self.application_actions = {}
        actions = []
        for app in self.get_available_applications():
            action = Gtk.Action(app.name, app.fullname, app.description, app.icon)
            action.connect('activate', callback, app.name)
            actions.append(action)
            self.application_actions[app.name] = action

        # By default, the menu comes with an 'Empty' item that we must hide
        self.HomeToolItem.get_proxies()[0].get_menu().get_children()[-1].hide()
        self.HomeToolItem.add_actions(self.uimanager, actions,
                                      add_separator=False)
Beispiel #20
0
    def _insert_menu(self):
        # Get the GtkUIManager
        manager = self._window.get_ui_manager()

        self._menubar_menu = GeditMenu(self, self.vcs_client, self.base_dir, [self._get_document_path()])
        self._menu_action = gtk.Action( name="RabbitVCSMenu", label="RabbitVCS", tooltip="Excellent Version Control for Linux", stock_id=None )
        
        self._action_group = gtk.ActionGroup("RabbitVCSActions")
        self._action_group = self._menubar_menu.get_action_group(self._action_group)
        self._action_group.add_action( self._menu_action )

        # Insert the action group
        manager.insert_action_group(self._action_group, 0)

        # Merge the UI
        self._ui_id = manager.add_ui_from_string(ui_str)
Beispiel #21
0
    def add_menuitem(self, entry):
        """Add a menu item to the current menu

        Params:
            entry (tuple): tuple containing name, label and callback

        Returns:
            Gtk.MenuItem
        """
        name, label, callback = entry
        action = Gtk.Action(name=name, label=label)
        action.connect("activate", callback)

        menu_item = action.create_menu_item()
        menu_item.action_id = name
        self.append(menu_item)
        return menu_item
Beispiel #22
0
    def do_activate(self):
        self._action = Gtk.Action('InstallPlugins', 'Install Plugins',
                                  'Easily discover and install plugins', None)
        self._action.connect("activate", self._run)

        self._actiongroup = Gtk.ActionGroup("InstallPlugins")
        self._actiongroup.add_action(self._action)

        self._ui_manager = self.shell.get_property("ui-manager")
        self._ui_manager.insert_action_group(self._actiongroup)
        self._ui_manager.add_ui_from_string("""<ui>
                        <menubar name='MainwindowMenubar'>
                          <menu action='ToolsMenu'>
                            <menuitem action='InstallPlugins'/>
                          </menu>
                        </menubar>
                     </ui>""")
Beispiel #23
0
	def menuArchivo(self, action_group):
		'''
		Pestaña 'Archivo'
		:param action_group:
		:return:
		'''
		action_group.add_actions(
			[
				("archivo", None, "Archivo"),
				("cargarImagen", None, 'Cargar', '<control>N', None, self.cargaImagen),
				("guardarASCII", None, 'Guardar ASCII', "<control>G", None, self.guardar),
			]
		)

		action_filequit = Gtk.Action(name="FileQuit", stock_id=Gtk.STOCK_QUIT)
		action_filequit.connect("activate", self.cerrarVentana)
		action_group.add_action(action_filequit)
Beispiel #24
0
    def add_about(self):
        group = Gtk.ActionGroup(name="xapp-status-applet-group")
        group.set_translation_domain("xapp")

        about_action = Gtk.Action(name="ShowAbout",
                                  icon_name="info",
                                  label=_("About"),
                                  visible=True)

        about_action.connect("activate", self.show_about)
        group.add_action(about_action)

        xml = '\
            <menuitem name="ShowDesktopAboutItem" action="ShowAbout"/> \
        '

        self.applet.setup_menu(xml, group)
Beispiel #25
0
 def __init__(self, allApps, dynamic, *args):
     guiplugins.ActionTabGUI.__init__(self, allApps)
     AllTestsHandler.__init__(self)
     self.dynamic = dynamic
     self.filterAccel = None
     self.filterAction = Gtk.Action("Filter", "Filter",
                                    self.getFilterTooltip(), self.getStockId())
     self.filterAction.connect("activate", self.filterTests)
     self.selectDiag = logging.getLogger("Select Tests")
     self.addOption("vs", "Tests for version", description="Select tests for a specific version.",
                    possibleValues=self.getPossibleVersions(allApps))
     self.selectionGroup = plugins.OptionGroup(self.getTabTitle())
     self.selectionGroup.addSwitch("select_in_collapsed_suites", "Select in collapsed suites",
                                   0, description="Select in currently collapsed suites as well?")
     currSelectDesc = ["Unselect all currently selected tests before applying the new selection criteria.",
                       "Apply the new selection criteria only to the currently selected tests, to obtain a subselection.",
                       "Keep the currently selected tests even if they do not match the new criteria, and extend the selection with all other tests which meet the new criteria.",
                       "After applying the new selection criteria to all tests, unselect the currently selected tests, to exclude them from the new selection."]
     self.selectionGroup.addSwitch("current_selection", options=["Discard", "Refine", "Extend", "Exclude"],
                                   description=currSelectDesc)
     self.filteringGroup = plugins.OptionGroup("Filtering")
     currFilterDesc = ["Show all tests which match the criteria, and hide all those that do not.",
                       "Hide all tests which do not match the criteria. Do not show any tests that aren't already shown.",
                       "Show all tests which match the criteria. Do not hide any tests that are currently shown."]
     self.filteringGroup.addSwitch("current_filtering", options=[
                                   "Discard", "Refine", "Extend"], description=currFilterDesc)
     excludeKeys = set(self.optionGroup.keys())  # remember these so we don't try and save them to selections
     self.addApplicationOptions(allApps, self.optionGroup)
     appNames = set([app.name for app in allApps])
     if len(appNames) > 1:
         self.addOption("app", "App names containing",
                        description="Select tests for which the application name matches the entered text. The text can be a regular expression.")
     if self.hasPerformance(allApps, "performance"):
         self.optionGroup.moveToEnd(["r"])
         self.addOption("fastest", "Only fastest tests", 0,
                        description="Select the given number of tests which match the other selected criteria and have the fastest runtimes")
         self.addOption("slowest", "Only slowest tests", 0,
                        description="Select the given number of tests which match the other selected criteria and have the longest runtimes")
     self.optionGroup.moveToEnd(["grep", "grepfile"])
     if self.dynamic:
         self.addSwitch("std", options=["Use test-files from current run", "Use stored test-files"], description=["When searching using 'test-files containing', look in the results of tests in the current run",
                                                                                                                  "When searching using 'test-files containing', look in the stored results, i.e. the same search as would be done in the static GUI"])
     self.appKeys = set(self.optionGroup.keys())
     self.appKeys.difference_update(excludeKeys)
    def build_menus(self):
        action_group = Gtk.ActionGroup("global_actions")

        # Create Import menu
        action_import_menu = Gtk.Action("ImportMenu", _("Import"), None, None)
        action_group.add_action(action_import_menu)

        action_import_opml = Gtk.Action("ImportOPML", _("_Import OPML"),
                                        _("Import feeds from OPML file"),
                                        Gtk.STOCK_FILE)
        action_import_opml.connect("activate", self.on_menu_import, "OPML")
        action_group.add_action(action_import_opml)

        action_import_file = Gtk.Action("ImportFeedFile",
                                        _("_Import Feeds File"),
                                        _("Import feeds from file"),
                                        Gtk.STOCK_FILE)
        action_import_file.connect("activate", self.on_menu_import, "FEEDS")
        action_group.add_action(action_import_file)

        # Create Export menu
        action_export_menu = Gtk.Action("ExportMenu", _("Export"), None, None)
        action_group.add_action(action_export_menu)

        action_export_file = Gtk.Action("ExportFeedFile",
                                        _("_Export Feeds File"),
                                        _("Export feeds to file"),
                                        Gtk.STOCK_FILE)
        action_export_file.connect("activate", self.on_menu_export_feeds)
        action_group.add_action(action_export_file)

        # Create Option menu
        action_option_menu = Gtk.Action("OptionMenu", _("Options"), None, None)
        action_group.add_action(action_option_menu)

        action_toggle_hidden = Gtk.Action("ShowHideFields",
                                          _("_Toggle Hidden Fields"),
                                          _("Show or Hide hidden fields"),
                                          Gtk.STOCK_FILE)
        action_toggle_hidden.connect("activate", self.on_menu_toggle_hidden)
        action_group.add_action(action_toggle_hidden)

        # Setup UI manager
        self.ui_manager.add_ui_from_string(UI_INFO)
        self.add_accel_group(self.ui_manager.get_accel_group())
        self.ui_manager.insert_action_group(action_group)
Beispiel #27
0
def add_menu_actions(window, actiongroup) -> None:
    """Add actions to application menu."""
    actionfilemenu = Gtk.Action("FileMenu", language.MT_("File"), None, None)
    actiongroup.add_action(actionfilemenu)
    actionfilemenusave = Gtk.Action("save", language.MT_('Save'), None, Gtk.STOCK_SAVE)
    actionfilemenusave.connect("activate", save_tlp_config, window)
    actiongroup.add_action(actionfilemenusave)
    actionfilemenuquit = Gtk.Action("quit", language.MT_('Quit'), None, Gtk.STOCK_QUIT)
    actionfilemenuquit.connect("activate", quit_tlp_config, window)
    actiongroup.add_action(actionfilemenuquit)

    actionlanguagemenu = Gtk.Action("LanguageMenu", language.MT_("Language"), None, None)
    actiongroup.add_action(actionlanguagemenu)

    zhlanguagesubmenu = Gtk.Action("zhSubMenu", "zh", None, None)
    actiongroup.add_action(zhlanguagesubmenu)

    actionhelpmenu = Gtk.Action("HelpMenu", language.MT_("Help"), None, None)
    actiongroup.add_action(actionhelpmenu)

    aboutdialogmenu = Gtk.Action("AboutDialog", language.MT_("About"), None, Gtk.STOCK_INFO)
    actiongroup.add_action(aboutdialogmenu)
    aboutdialogmenu.connect('activate', show_about_dialog)

    langdir = Path(settings.langdir)
    for langobject in langdir.iterdir():
        if langobject.is_dir():
            locale = langobject.name

            if locale == settings.userconfig.language:
                actionlang = Gtk.Action(locale, locale, None, Gtk.STOCK_APPLY)
            else:
                actionlang = Gtk.Action(locale, locale, None, None)

            actionlang.connect("activate", switch_language, locale, window)
            actiongroup.add_action(actionlang)
Beispiel #28
0
    def menuArchivo(self, action_group):
        '''
		Pestaña 'Archivo'
		:param action_group:
		:return:
		'''
        action_group.add_actions([
            ("archivo", None, "Archivo"),
            ("cargarInicio", None, 'Cargar', '<control>N', None,
             self.cargaEstado),
            ("guardarSimulacion", None, 'Guardar Estado', "<control>G", None,
             self.guardarEstado),
            ("random", None, 'Configuracion Random', "<control>R", None,
             self.random),
        ])

        action_filequit = Gtk.Action(name="FileQuit", stock_id=Gtk.STOCK_QUIT)
        action_filequit.connect("activate", self.cerrarVentana)
        action_group.add_action(action_filequit)
Beispiel #29
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

        self._setup_params()
        self._setup_events()

        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'),
        ])
Beispiel #30
0
    def add_command_group_menu_actions(self, action_group):
        ''' Command Group项目的菜单设定。 '''
        action_command_menu = Gtk.Action("CommandGroupMenu", "CommandGroup",
                                         None, None)
        action_group.add_action(action_command_menu)

        action_command_group_new = Gtk.Action("CommandGroupNew", None,
                                              "Create a command group",
                                              Gtk.STOCK_NEW)
        action_command_group_new.connect("activate",
                                         self.on_menu_command_group_new)
        action_group.add_action_with_accel(action_command_group_new,
                                           "<control>N")
        self.action_command_group_new = action_command_group_new

        action_command_group_open = Gtk.Action("CommandGroupOpen", None,
                                               "Open a command group",
                                               Gtk.STOCK_OPEN)
        action_command_group_open.connect("activate",
                                          self.on_menu_command_group_open)
        action_group.add_action_with_accel(action_command_group_open,
                                           "<control>O")
        self.action_command_group_open = action_command_group_open

        action_command_group_close = Gtk.Action("CommandGroupClose", None,
                                                "Close current command group",
                                                Gtk.STOCK_CLOSE)
        action_command_group_close.connect("activate",
                                           self.on_menu_command_group_close)
        action_group.add_action_with_accel(action_command_group_close,
                                           "<control>W")
        self.action_command_group_close = action_command_group_close

        action_command_group_save = Gtk.Action("CommandGroupSave", None,
                                               "Save current command group",
                                               Gtk.STOCK_SAVE)
        action_command_group_save.connect("activate",
                                          self.on_menu_command_group_save)
        action_group.add_action_with_accel(action_command_group_save,
                                           "<control>S")
        self.action_command_group_save = action_command_group_save

        action_command_group_delete = Gtk.Action(
            "CommandGroupDelete", None, "Delete current command group",
            Gtk.STOCK_DELETE)
        action_command_group_delete.connect("activate",
                                            self.on_menu_command_group_delete)
        action_group.add_action(action_command_group_delete)
        self.action_command_group_delete = action_command_group_delete