protected override MenuList OnGetMenuItems () { MenuList list = new MenuList (); list[MenuListContainer.Actions].Add (new MenuItem (Catalog.GetString ("_Open"), Icon, (o, a) => Open ())); if (Mnt.CanEject () || Mnt.CanUnmount) list[MenuListContainer.Actions].Add (new MenuItem (Mnt.CanEject () ? Catalog.GetString ("_Eject") : Catalog.GetString ("_Unmount"), "media-eject", (o, a) => UnMount ())); return list; }
public MenuList Combine (MenuList other) { MenuList result = new MenuList (); foreach (KeyValuePair<MenuListContainer, List<MenuItem>> kvp in list) { result[kvp.Key].AddRange (kvp.Value); } foreach (KeyValuePair<MenuListContainer, List<MenuItem>> kvp in other.list) { result[kvp.Key].AddRange (kvp.Value); } // copy other first so any conflicts are resolved with this copy winning foreach (KeyValuePair<MenuListContainer, string> kvp in other.titles) { result.SetContainerTitle (kvp.Key, kvp.Value); } foreach (KeyValuePair<MenuListContainer, string> kvp in titles) { result.SetContainerTitle (kvp.Key, kvp.Value); } return result; }
public void SetItems(MenuList items) { if (Container.Child != null) { foreach (Gtk.Widget widget in (Container.Child as VBox).Children) { if (widget is MenuItemWidget) { (widget as MenuItemWidget).SelectedChanged -= HandleSelectedChanged; } widget.Dispose(); widget.Destroy(); } Container.Remove(Container.Child); } VBox vbox = new VBox(); Container.Add(vbox); Cairo.Color textColor; if (IsLight) { textColor = new Cairo.Color(0.1, 0.1, 0.1); } else { textColor = new Cairo.Color(1, 1, 1); } bool hasIcon = false; foreach (MenuItem item in items.DisplayItems) { if (item.ShowIcons) { hasIcon = true; break; } } bool first = true; int width = 1; foreach (MenuItem item in items.DisplayItems) { if (item is SeparatorMenuItem) { SeparatorWidget widget = new SeparatorWidget((item as SeparatorMenuItem).Title); widget.TextColor = textColor; if (first) { widget.DrawLine = false; } first = false; vbox.PackStart(widget); } else { MenuItemWidget menuItem = new MenuItemWidget(item); menuItem.SelectedChanged += HandleSelectedChanged; menuItem.TextColor = textColor; menuItem.MenuShowingIcons = hasIcon; first = false; vbox.PackStart(menuItem, false, false, 0); width = Math.Max(width, menuItem.RequestedWidth); } } vbox.SetSizeRequest(width, -1); Container.ShowAll(); }
protected override MenuList OnGetMenuItems () { // intentionally dont inherit MenuList list = new MenuList (); list.SetContainerTitle (MenuListContainer.CustomOne, Catalog.GetString ("Restore Files")); FileEnumerator enumerator = OwnedFile.EnumerateChildren ("standard::type,standard::name", FileQueryInfoFlags.NofollowSymlinks, null); List<File> files = new List<File> (); if (enumerator != null) { FileInfo info; while ((info = enumerator.NextFile ()) != null) { files.Add (OwnedFile.GetChild (info.Name)); info.Dispose (); } if (info != null) info.Dispose (); enumerator.Close (null); enumerator.Dispose (); } /* FIXME - this code should work, but GetFiles() currently uses .net IO instead of GIO when this starts working, the enumeration block above can go away too foreach (File _f in OwnedFile.GetFiles ().OrderByDescending (f => f.QueryInfo<string> ("trash::deletion-date")).Take (5)) { */ foreach (File _f in files.OrderByDescending (f => f.QueryInfo<string> ("trash::deletion-date")).Take (5)) { File f = _f; MenuItem item = new IconMenuItem (f.Basename, f.Icon (), (o, a) => RestoreFile (f)); item.Mnemonic = null; list[MenuListContainer.CustomOne].Add (item); } list[MenuListContainer.CustomTwo].Add ( new MenuItem (Catalog.GetString ("_Open Trash"), Icon, (o, a) => OpenTrash ())); list[MenuListContainer.CustomTwo].Add ( new MenuItem (Catalog.GetString ("Empty _Trash"), "gtk-clear", (o, a) => EmptyTrash (), !TrashFull)); return list; }
public void SetItems (MenuList items) { if (Container.Child != null) { foreach (Gtk.Widget widget in (Container.Child as VBox).Children) { if (widget is MenuItemWidget) (widget as MenuItemWidget).SelectedChanged -= HandleSelectedChanged; widget.Dispose (); widget.Destroy (); } Container.Remove (Container.Child); } VBox vbox = new VBox (); Container.Add (vbox); Cairo.Color textColor; if (IsLight) { textColor = new Cairo.Color (0.1, 0.1, 0.1); } else { textColor = new Cairo.Color (1, 1, 1); } bool hasIcon = false; foreach (MenuItem item in items.DisplayItems) { if (item.ShowIcons) { hasIcon = true; break; } } bool first = true; int width = 1; foreach (MenuItem item in items.DisplayItems) { if (item is SeparatorMenuItem) { SeparatorWidget widget = new SeparatorWidget ((item as SeparatorMenuItem).Title); widget.TextColor = textColor; if (first) widget.DrawLine = false; first = false; vbox.PackStart (widget); } else { MenuItemWidget menuItem = new MenuItemWidget (item); menuItem.SelectedChanged += HandleSelectedChanged; menuItem.TextColor = textColor; menuItem.MenuShowingIcons = hasIcon; first = false; vbox.PackStart (menuItem, false, false, 0); width = Math.Max (width, menuItem.RequestedWidth); } } vbox.SetSizeRequest (width, -1); Container.ShowAll (); }
protected override MenuList OnGetMenuItems () { MenuList list = new MenuList (); Desks.ForEach (d => { Desk desk = d; list[MenuListContainer.Actions].Add (new Docky.Menus.MenuItem (desk.Name, (desk.IsActive ? "desktop" : ""), (o, a) => desk.Activate ())); }); return list; }
protected override MenuList OnGetMenuItems () { MenuList list = new MenuList (); if (ShowSettings) list[MenuListContainer.Actions].Add (new MenuItem (Catalog.GetString ("_Settings"), PrefsIcon, (o, a) => ConfigurationWindow.Instance.Show ())); list[MenuListContainer.Actions].Add (new MenuItem (Catalog.GetString ("_About"), AboutIcon, (o, a) => Docky.ShowAbout ())); list[MenuListContainer.Actions].Add (new MenuItem (Catalog.GetString ("_Help"), HelpIcon, (o, a) => DockServices.System.Open ("http://wiki.go-docky.com"))); if (ShowQuit) list[MenuListContainer.Actions].Add (new MenuItem (Catalog.GetString ("_Quit Docky"), CloseIcon, (o, a) => Docky.Quit ())); return list; }