# it under the terms of the GNU General Public License as published by # the Free Software Foundation; either version 2 of the License, or # (at your option) any later version. # # This program is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU General Public License for more details. # # You should have received a copy of the GNU General Public License # along with this program; if not, write to the Free Software # Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA # # In addition, as a special exception, the copyright holders give # permission to link the code of portions of this program with the OpenSSL # library. # # You must obey the GNU General Public License in all respects for all of # the code used other than OpenSSL. If you modify file(s) with this # exception, you may extend this exception to your version of the file(s), # but you are not obligated to do so. If you do not wish to do so, delete # this exception statement from your version. If you delete this exception # statement from all source files in the program, then also delete it here. from miro.plat.utils import appstore_edition if appstore_edition(): AUTOUPDATE = False else: AUTOUPDATE = True
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 appstore_edition(): miroMenuItems += [ menus.MenuItem(_("Check _Version"), "AppStoreCheckVersion") ] else: 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) # 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