Exemplo n.º 1
0
    def _setup_ui_manager(self):
        self.menu_structure = menus.get_menu()

        # make modifications to the menu structure here

        # on linux, we don't have a CheckVersion option because
        # we update with the package system.
        this_platform = app.config.get(prefs.APP_PLATFORM)
        if this_platform == 'linux':
            file_menu = self.menu_structure.get("FileMenu")
            file_menu.remove("CheckVersion")

        # If the renderer supports it, create a the subtitle encodings menu
        try:
            app.video_renderer.setup_subtitle_encoding_menu(
                self.menu_structure)
        except AttributeError:
            pass

        # generate action groups after making all modifications
        mag = menus.generate_action_groups(self.menu_structure)
        self.menu_action_groups = mag

        self.ui_manager = gtk.UIManager()
        self.make_actions()

        outstream = StringIO.StringIO()
        outstream.write('<ui><menubar name="MiroMenu">')
        for mem in self.menu_structure.menuitems:
            self._add_menu(mem, outstream)
        outstream.write('</menubar>')

        for mem in self.menu_structure:
            if ((not isinstance(mem, menus.MenuItem) or
                 len(mem.shortcuts) <= 1)):
                continue
            for shortcut in mem.shortcuts[1:]:
                outstream.write('<accelerator action="%s%i" />' % \
                                (mem.action, id(shortcut)))
        outstream.write('</ui>')
        self.ui_manager.add_ui_from_string(outstream.getvalue())
Exemplo n.º 2
0
    def _setup_ui_manager(self):
        self.menu_structure = menus.get_menu()

        # make modifications to the menu structure here

        # on linux, we don't have a CheckVersion option because
        # we update with the package system.
        this_platform = app.config.get(prefs.APP_PLATFORM)
        if this_platform == 'linux':
            file_menu = self.menu_structure.get("FileMenu")
            file_menu.remove("CheckVersion")

        # If the renderer supports it, create a the subtitle encodings menu
        try:
            app.video_renderer.setup_subtitle_encoding_menu(
                self.menu_structure)
        except AttributeError:
            pass

        # generate action groups after making all modifications
        mag = menus.generate_action_groups(self.menu_structure)
        self.menu_action_groups = mag

        self.ui_manager = gtk.UIManager()
        self.make_actions()

        outstream = StringIO.StringIO()
        outstream.write('<ui><menubar name="MiroMenu">')
        for mem in self.menu_structure.menuitems:
            self._add_menu(mem, outstream)
        outstream.write('</menubar>')

        for mem in self.menu_structure:
            if ((not isinstance(mem, menus.MenuItem)
                 or len(mem.shortcuts) <= 1)):
                continue
            for shortcut in mem.shortcuts[1:]:
                outstream.write('<accelerator action="%s%i" />' % \
                                (mem.action, id(shortcut)))
        outstream.write('</ui>')
        self.ui_manager.add_ui_from_string(outstream.getvalue())
Exemplo n.º 3
0
def populate_menu():
    short_appname = app.config.get(prefs.SHORT_APP_NAME)

    menubar = menus.get_menu()

    # Application menu
    miroMenuItems = [
        extract_menu_item(menubar, "About"),
        menus.Separator(),
        extract_menu_item(menubar, "Donate")
    ]

    if not appstore_edition():
        miroMenuItems += [
            extract_menu_item(menubar, "CheckVersion")
        ]

    miroMenuItems += [
        menus.Separator(),
        extract_menu_item(menubar, "EditPreferences"),
        menus.Separator(),
        menus.Menu(_("Services"), "ServicesMenu", []),
        menus.Separator(),
        menus.MenuItem(_("Hide %(appname)s", {"appname": short_appname}),
                       "HideMiro", menus.Shortcut("h", MOD)),
        menus.MenuItem(_("Hide Others"), "HideOthers", 
                       menus.Shortcut("h", MOD, ALT)),
        menus.MenuItem(_("Show All"), "ShowAll"),
        menus.Separator(),
        extract_menu_item(menubar, "Quit")
    ]
    miroMenu = menus.Menu(short_appname, "Miro", miroMenuItems)
    miroMenu.get("EditPreferences").label = _("Preferences...")
    miroMenu.get("EditPreferences").shortcuts = (menus.Shortcut(",", MOD),)
    miroMenu.get("Quit").label = _("Quit %(appname)s", 
                                   {"appname": short_appname})

    # File menu
    closeWinItem = menus.MenuItem(_("Close Window"), "CloseWindow", 
                                  menus.Shortcut("w", MOD))
    menubar.get("FileMenu").append(closeWinItem)

    # Edit menu
    editMenuItems = [
        menus.MenuItem(_("Cut"), "Cut", menus.Shortcut("x", MOD)),
        menus.MenuItem(_("Copy"), "Copy", menus.Shortcut("c", MOD)),
        menus.MenuItem(_("Paste"), "Paste", menus.Shortcut("v", MOD)),
        menus.MenuItem(_("Delete"), "Delete"),
        menus.Separator(),
        menus.MenuItem(_("Select All"), "SelectAll", menus.Shortcut("a", MOD))
    ]
    editMenu = menus.Menu(_("Edit"), "Edit", editMenuItems)
    menubar.insert(1, editMenu)

    # Playback menu
    presentMenuItems = [
        menus.MenuItem(_("Present Half Size"), "PresentHalfSize", 
                       menus.Shortcut("0", MOD),
                       groups=["PlayingVideo", "PlayableVideosSelected"]),
        menus.MenuItem(_("Present Actual Size"), "PresentActualSize", 
                       menus.Shortcut("1", MOD),
                       groups=["PlayingVideo", "PlayableVideosSelected"]),
        menus.MenuItem(_("Present Double Size"), "PresentDoubleSize", 
                       menus.Shortcut("2", MOD),
                       groups=["PlayingVideo", "PlayableVideosSelected"]),
    ]
    playback_menu = menubar.get("PlaybackMenu")
    subtitlesMenu = playback_menu.get("SubtitlesMenu")
    audioMenu = playback_menu.get("AudioTrackMenu")
    playback_menu.remove("SubtitlesMenu")
    playback_menu.remove("AudioTrackMenu")
    presentMenu = menus.Menu(_("Present Video"), "Present", presentMenuItems)
    playback_menu.append(presentMenu)
    playback_menu.append(audioMenu)
    playback_menu.append(subtitlesMenu)
    fullscreen_menu_item = playback_menu.get("Fullscreen")
    fullscreen_menu_item.shortcuts = [ menus.Shortcut("f", MOD)]

    # Window menu
    windowMenuItems = [
        menus.MenuItem(_("Zoom"), "Zoom"),
        menus.MenuItem(_("Minimize"), "Minimize", menus.Shortcut("m", MOD)),
        menus.Separator(),
        menus.MenuItem(_("Main Window"), "ShowMain", 
                       menus.Shortcut("M", MOD, SHIFT)),
        menus.Separator(),
        menus.MenuItem(_("Bring All to Front"), "BringAllToFront"),
    ]
    windowMenu = menus.Menu(_("Window"), "Window", windowMenuItems)
    menubar.insert(6, windowMenu)

    # Help Menu
    helpItem = menubar.get("Help")
    helpItem.label = _("%(appname)s Help", {"appname": short_appname})
    helpItem.shortcuts = (menus.Shortcut("?", MOD),)

    # Now populate the main menu bar
    main_menu = NSApp().mainMenu()
    # XXX: should be using the tag to prevent interface and locale breakages
    appMenu = main_menu.itemAtIndex_(0).submenu()
    populate_single_menu(appMenu, miroMenu)
    servicesMenuItem = appMenu.itemWithTitle_(_("Services"))
    NSApp().setServicesMenu_(servicesMenuItem)

    for menu in menubar.menuitems:
        nsmenu = NSMenu.alloc().init()
        nsmenu.setTitle_(menu.label.replace("_", ""))
        populate_single_menu(nsmenu, menu)
        nsmenuitem = make_menu_item(menu)
        nsmenuitem.setSubmenu_(nsmenu)
        main_menu.addItem_(nsmenuitem)

    # we do this to get groups correct
    menubar.insert(0, miroMenu)

    menus.osx_menu_structure = menubar
    menus.osx_action_groups = menus.generate_action_groups(menubar)
    
    # Keep the updated structure around
    global _menu_structure
    _menu_structure = menubar
Exemplo n.º 4
0
def populate_menu():
    short_appname = app.config.get(prefs.SHORT_APP_NAME)

    menubar = menus.get_menu()

    # Application menu
    miroMenuItems = [
        extract_menu_item(menubar, "About"),
        menus.Separator(),
        extract_menu_item(menubar, "Donate")
    ]

    if not appstore_edition():
        miroMenuItems += [
            extract_menu_item(menubar, "CheckVersion")
        ]

    miroMenuItems += [
        menus.Separator(),
        extract_menu_item(menubar, "EditPreferences"),
        menus.Separator(),
        menus.Menu(_("Services"), "ServicesMenu", []),
        menus.Separator(),
        menus.MenuItem(_("Hide %(appname)s", {"appname": short_appname}),
                       "HideMiro", menus.Shortcut("h", MOD)),
        menus.MenuItem(_("Hide Others"), "HideOthers", 
                       menus.Shortcut("h", MOD, ALT)),
        menus.MenuItem(_("Show All"), "ShowAll"),
        menus.Separator(),
        extract_menu_item(menubar, "Quit")
    ]
    miroMenu = menus.Menu(short_appname, "Miro", miroMenuItems)
    miroMenu.get("EditPreferences").label = _("Preferences...")
    miroMenu.get("EditPreferences").shortcuts = (menus.Shortcut(",", MOD),)
    miroMenu.get("Quit").label = _("Quit %(appname)s", 
                                   {"appname": short_appname})

    # File menu
    closeWinItem = menus.MenuItem(_("Close Window"), "CloseWindow", 
                                  menus.Shortcut("w", MOD))
    menubar.get("FileMenu").append(closeWinItem)

    # Edit menu
    editMenuItems = [
        menus.MenuItem(_("Cut"), "Cut", menus.Shortcut("x", MOD)),
        menus.MenuItem(_("Copy"), "Copy", menus.Shortcut("c", MOD)),
        menus.MenuItem(_("Paste"), "Paste", menus.Shortcut("v", MOD)),
        menus.MenuItem(_("Delete"), "Delete"),
        menus.Separator(),
        menus.MenuItem(_("Select All"), "SelectAll", menus.Shortcut("a", MOD))
    ]
    editMenu = menus.Menu(_("Edit"), "Edit", editMenuItems)
    menubar.insert(1, editMenu)

    # Playback menu
    presentMenuItems = [
        menus.MenuItem(_("Present Half Size"), "PresentHalfSize", 
                       menus.Shortcut("0", MOD),
                       groups=["PlayingVideo", "PlayableVideosSelected"]),
        menus.MenuItem(_("Present Actual Size"), "PresentActualSize", 
                       menus.Shortcut("1", MOD),
                       groups=["PlayingVideo", "PlayableVideosSelected"]),
        menus.MenuItem(_("Present Double Size"), "PresentDoubleSize", 
                       menus.Shortcut("2", MOD),
                       groups=["PlayingVideo", "PlayableVideosSelected"]),
    ]
    playback_menu = menubar.get("PlaybackMenu")
    subtitlesMenu = playback_menu.get("SubtitlesMenu")
    playback_menu.remove("SubtitlesMenu")
    presentMenu = menus.Menu(_("Present Video"), "Present", presentMenuItems)
    playback_menu.append(presentMenu)
    playback_menu.append(subtitlesMenu)
    fullscreen_menu_item = playback_menu.get("Fullscreen")
    fullscreen_menu_item.shortcuts = [ menus.Shortcut("f", MOD)]

    # Window menu
    windowMenuItems = [
        menus.MenuItem(_("Zoom"), "Zoom"),
        menus.MenuItem(_("Minimize"), "Minimize", menus.Shortcut("m", MOD)),
        menus.Separator(),
        menus.MenuItem(_("Main Window"), "ShowMain", 
                       menus.Shortcut("M", MOD, SHIFT)),
        menus.Separator(),
        menus.MenuItem(_("Bring All to Front"), "BringAllToFront"),
    ]
    windowMenu = menus.Menu(_("Window"), "Window", windowMenuItems)
    menubar.insert(6, windowMenu)

    # Help Menu
    helpItem = menubar.get("Help")
    helpItem.label = _("%(appname)s Help", {"appname": short_appname})
    helpItem.shortcuts = (menus.Shortcut("?", MOD),)

    # Now populate the main menu bar
    main_menu = NSApp().mainMenu()
    # XXX: should be using the tag to prevent interface and locale breakages
    appMenu = main_menu.itemAtIndex_(0).submenu()
    populate_single_menu(appMenu, miroMenu)
    servicesMenuItem = appMenu.itemWithTitle_(_("Services"))
    NSApp().setServicesMenu_(servicesMenuItem)

    for menu in menubar.menuitems:
        nsmenu = NSMenu.alloc().init()
        nsmenu.setTitle_(menu.label.replace("_", ""))
        populate_single_menu(nsmenu, menu)
        nsmenuitem = make_menu_item(menu)
        nsmenuitem.setSubmenu_(nsmenu)
        main_menu.addItem_(nsmenuitem)

    # we do this to get groups correct
    menubar.insert(0, miroMenu)

    menus.osx_menu_structure = menubar
    menus.osx_action_groups = menus.generate_action_groups(menubar)
    
    # Keep the updated structure around
    global _menu_structure
    _menu_structure = menubar