public static void BuildMenu(MenuShell menu, ActionModelNode node) { if (node.PathSegment != null) { MenuItem menuItem; if (node.Action != null) { // this is a leaf node (terminal menu item) menuItem = new ActiveMenuItem((IClickAction)node.Action); } else { // this menu item has a sub menu string menuText = node.PathSegment.LocalizedText.Replace('&', '_'); menuItem = new MenuItem(menuText); menuItem.Submenu = new Menu(); } menu.Append(menuItem); menu = (MenuShell)menuItem.Submenu; } foreach (ActionModelNode child in node.ChildNodes) { BuildMenu(menu, child); } }
/// <summary> /// Populates the specified shell with sub-menus. /// </summary> /// <param name="shell">The shell.</param> public void Populate( ActionManager manager, MenuShell shell) { // Create a new submenu for ourselves. var menu = new Menu(); var menuItem = new MenuItem(Label); menuItem.Submenu = menu; menuItem.RightJustified = RightAligned; // If we have a group name, add it to the list. if (!String.IsNullOrEmpty(GroupName)) { ActionSet group = manager.GetOrCreateGroup(GroupName); group.Add(menuItem); } // Attach our menu to the shell. shell.Append(menuItem); // Go through all of our elements and add them to our menu. foreach (ILayoutListItem item in this) { // Go through and populate the menu itself. item.Populate(manager, menu); } }
/// <summary> /// Populates the specified shell with sub-menus. /// </summary> /// <param name="manager"></param> /// <param name="shell">The shell.</param> public void Populate( ActionManager manager, MenuShell shell) { // Get the action associated with this. Action action = manager.GetAction(ActionName); MenuItem menuItem; if (action == null) { // Create a placeholder menu item. menuItem = new MenuItem("<Unknown Action: " + ActionName + ">"); menuItem.Sensitive = false; // Add it to the errors. manager.Messages.Add( new SeverityMessage( Severity.Error, "Could not find action " + ActionName + " to add to menu.")); } else { // Create a menu item from this action. menuItem = new ActionMenuItem(manager, action); } // Add the resulting menu item to the list. shell.Add(menuItem); }
/// <summary> /// Populates the specified shell with sub-menus. /// </summary> /// <param name="manager">The manager.</param> /// <param name="shell">The shell.</param> public void Populate( ActionManager manager, MenuShell shell) { var separator = new MenuItem(); shell.Add(separator); }
public MenuItemCollection(MenuShell menu, MenuItem parent = null, MenuItemWrapper parentWrapper = null) { this.menu = menu; this.parent = parent; this.parentWrapper = parentWrapper; if (menu != null) { menu.Shown += menu_Shown; } }
private void BindMenuBar() { UIManager ui = interface_action_service.UIManager; // retreive and hide the gtk menu MenuShell menu = (MenuShell)ui.GetWidget("/MainMenu"); menu.Hide(); // bind menu IgeMacMenu.MenuBar = menu; }
public override void InitializeIdle() { ActionGroup mainMenuActionGroup = new ActionGroup("Main"); mainMenuActionGroup.Add(new ActionEntry [] { new ActionEntry("FileMenuAction", null, Catalog.GetString("_File"), null, null, null), new ActionEntry("WindowMenuAction", null, Catalog.GetString("_Window"), null, null, null) }); UIManager uiManager = Application.Instance.UIManager; uiManager.AddUiFromString(osxMenuXml); uiManager.InsertActionGroup(mainMenuActionGroup, 1); // This totally doesn't work...is my lib too old? IgeMacDock dock = new IgeMacDock(); dock.Clicked += delegate(object sender, EventArgs args) { TaskWindow.ShowWindow(); }; dock.QuitActivate += delegate(object sender, EventArgs args) { Application.Instance.Quit(); }; MenuShell mainMenu = uiManager.GetWidget("/MainMenu") as MenuShell; mainMenu.Show(); IgeMacMenu.MenuBar = mainMenu; MenuItem about_item = uiManager.GetWidget("/TrayIconMenu/AboutAction") as MenuItem; MenuItem prefs_item = uiManager.GetWidget("/TrayIconMenu/PreferencesAction") as MenuItem; MenuItem quit_item = uiManager.GetWidget("/TrayIconMenu/QuitAction") as MenuItem; IgeMacMenuGroup about_group = IgeMacMenu.AddAppMenuGroup(); IgeMacMenuGroup prefs_group = IgeMacMenu.AddAppMenuGroup(); about_group.AddMenuItem(about_item, null); prefs_group.AddMenuItem(prefs_item, null); IgeMacMenu.QuitMenuItem = quit_item; // Hide StatusIcon Application.Instance.Tray.Visible = false; }
private void ConfigureOsxMainMenu() { var osx_app = new GtkOsxApplication(); // remove the "Quit" item as this is auto-added by gtk-mac-integration to the AppMenu var quit_item = ((MenuItem)interface_action_service.UIManager.GetWidget("/MainMenu/MediaMenu/Quit")); if (quit_item != null) { quit_item.Hide(); } MenuShell shell = (MenuShell)interface_action_service.UIManager.GetWidget("/MainMenu"); if (shell != null) { osx_app.SetMenu(shell); } // place the "about" and "preferences" menu items into the OS X application menu // as every OS X app uses this convention var about_item = interface_action_service.UIManager.GetWidget("/MainMenu/HelpMenu/About") as MenuItem; if (about_item != null) { osx_app.InsertIntoAppMenu(about_item, 0); } // place a separator between the About and the Preferences dialog var separator = new SeparatorMenuItem(); osx_app.InsertIntoAppMenu(separator, 1); var preferences_item = interface_action_service.UIManager.GetWidget("/MainMenu/EditMenu/Preferences") as MenuItem; if (preferences_item != null) { osx_app.InsertIntoAppMenu(preferences_item, 2); } // remove unnecessary separator as we have moved the preferences item var preferences_seperator = interface_action_service.UIManager.GetWidget("/MainMenu/EditMenu/PreferencesSeparator") as SeparatorMenuItem; if (preferences_seperator != null) { preferences_seperator.Destroy(); } // actually performs the menu binding osx_app.Ready(); }
public CheckMenuItem AddCheck(string label, EventHandler toggled) { CheckMenuItem item = new CheckMenuItem(label); item.Toggled += toggled; if (stack.Count > 0) { MenuShell parent = stack.Peek(); parent.Append(item); } return(item); }
public MenuItem Add(string label, EventHandler activated) { MenuItem item = new MenuItem(label); item.Activated += activated; if (stack.Count > 0) { MenuShell parent = stack.Peek(); parent.Append(item); } return(item); }
private void EnsureMenu() { if (parent.Submenu != null) { return; } if (parent == null) { return; } menu = new Menu(); parent.Submenu = menu; }
async void Save_Clicked(object sender, EventArgs e) { if (Item.Text == "usuario") { // await Navigation.PushAsync(new NavigationPage(new MenuShell())); MenuShell oso = new MenuShell(); Application.Current.MainPage = oso; // await (App.Current.MainPage as Xamarin.Forms.Shell).GoToAsync("app://com.companyname/_Shell/shell_item/about", true); } else { } }
public MainMenu() { InterfaceActionService interface_service = ServiceManager.Get <InterfaceActionService> (); MenuShell menu = (MenuShell)interface_service.UIManager.GetWidget("/MainMenu"); ((PlaybackRepeatActions)interface_service.FindActionGroup("PlaybackRepeat")).AttachSubmenu( "/MainMenu/PlaybackMenu/RepeatMenu"); ((PlaybackShuffleActions)interface_service.FindActionGroup("PlaybackShuffle")).AttachSubmenu( "/MainMenu/PlaybackMenu/ShuffleMenu"); menu.Show(); PackStart(menu, true, true, 0); }
public Menu StartMenu(string title) { Menu menu = new Menu(); if ((stack.Count > 0) && (title != null)) { MenuShell parent = stack.Peek(); MenuItem item = new MenuItem(title); item.Submenu = menu; parent.Append(item); } stack.Push(menu); return(menu); }
// Takes the Gtk.MenuShell and sets it as OS X application menu public void SetMenu(MenuShell shell) { gtkosx_application_set_menu_bar(theApp, shell.Handle); }
public void Separate() { MenuShell parent = stack.Peek(); parent.Append(new SeparatorMenuItem()); }