public RadioAction AddDocument (Document doc) { RadioAction action = new RadioAction (doc.Guid.ToString (), doc.Filename, string.Empty, null, 0); // Tie these all together as a radio group if (OpenWindows.Count > 0) action.Group = OpenWindows[0].Group; action.Active = true; action.Activated += (o, e) => { if ((o as Gtk.ToggleAction).Active) PintaCore.Workspace.SetActiveDocumentInternal (doc); }; OpenWindows.Add (action); CheckMenuItem menuitem; // We only assign accelerators up to Alt-9 if (OpenWindows.Count < 10) menuitem = action.CreateAcceleratedMenuItem (IntegerToNumKey (OpenWindows.Count), Gdk.ModifierType.Mod1Mask); else menuitem = (CheckMenuItem)action.CreateMenuItem (); action_menu_items.Add (action, menuitem); window_menu.Add (menuitem); doc.Renamed += (o, e) => { UpdateMenuLabel (action, o as Document); }; doc.IsDirtyChanged += (o, e) => { UpdateMenuLabel (action, o as Document); }; return action; }
public Menu BuildBookmarkMenu() { Menu bookmarkMenu = new Menu(); string[] bookmarks = m_App.CacheStore.GetBookmarkLists(); int count = 0; RadioAction noList = new RadioAction("None", Catalog.GetString("None"), null, null, count); noList.Active = true; noList.Toggled += HandleNoListToggled; bookmarkMenu.Append(noList.CreateMenuItem()); foreach(string bookmark in bookmarks) { RadioAction action = new RadioAction(bookmark, bookmark, null, null, count); action.Group = noList.Group; if (bookmark == m_App.CacheStore.ActiveBookmarkList) action.Active = true; action.Toggled += HandleActionToggled; bookmarkMenu.Append(action.CreateMenuItem()); } return bookmarkMenu; }
#pragma warning disable 219 public void UpdateBookmarkList(List<string> items) { Menu bookmarksSub = new Menu(); Menu addAllSub = new Menu(); Menu addSelSub = new Menu(); CacheStore store = Engine.getInstance().Store; int count = 0; GLib.SList grp = new GLib.SList(IntPtr.Zero); RadioAction noList = new RadioAction("None", Catalog.GetString("None"), null, null, count); noList.Active = true; noList.Toggled += HandleNoListToggled; bookmarksSub.Append(noList.CreateMenuItem()); bookmarksSub.Append(new MenuItem()); foreach (string str in items) { RadioAction action = new RadioAction(str, str, null, null, count); action.Group = noList.Group; action.Toggled += HandleActionToggled; bookmarksSub.Append(action.CreateMenuItem()); MenuItem bookmarkAll = new MenuItem(str); if (store.BookmarkList == str) bookmarkAll.Sensitive = false; bookmarkAll.Activated += HandleBookmarkAllActivated; addAllSub.Append(bookmarkAll); MenuItem bookmarkSel = new MenuItem(str); if (store.BookmarkList == str) bookmarkSel.Sensitive = false; bookmarkSel.Activated += HandleBookmarkSelActivated; addSelSub.Append(bookmarkSel); if (str == store.BookmarkList) action.Active = true; count++; } if (items.Count != 0) { bmrkLists.Submenu = bookmarksSub; bmrkLists.Sensitive = true; addVisibleCaches.Submenu = addAllSub; addVisibleCaches.Sensitive = true; addCacheTo.Submenu = addSelSub; addCacheTo.Sensitive = true; } else { bmrkLists.Sensitive = false; bmrkLists.Submenu = null; addVisibleCaches.Submenu = null; addVisibleCaches.Sensitive = false; addCacheTo.Submenu = null; addCacheTo.Sensitive = false; } bmrkLists.ShowAll(); addVisibleCaches.ShowAll(); addCacheTo.ShowAll(); }