public override Gtk.MenuItem GetMenuItem () { Gtk.MenuItem it = new Gtk.MenuItem (label); Gtk.Menu submenu = new Gtk.Menu (); foreach (MenuNode node in ChildNodes) submenu.Insert (node.GetMenuItem (), -1); it.Submenu = submenu; return it; }
public Gtk.Menu GetSubmenu (object parent) { Gtk.Menu submenu = new Gtk.Menu (); foreach (MenuNode node in ChildNodes) submenu.Insert (node.GetMenuItem (parent), -1); return submenu; }
public Gtk.Menu GetSubmenu(object parent) { Gtk.Menu submenu = new Gtk.Menu(); foreach (MenuNode node in ChildNodes) { submenu.Insert(node.GetMenuItem(parent), -1); } return(submenu); }
public override Gtk.MenuItem GetMenuItem() { Gtk.MenuItem it = new Gtk.MenuItem(label); Gtk.Menu submenu = new Gtk.Menu(); foreach (MenuNode node in ChildNodes) { submenu.Insert(node.GetMenuItem(), -1); } it.Submenu = submenu; return(it); }
protected override void OnPressed() { base.OnPressed(); Gtk.Menu menu = new Gtk.Menu(); foreach (ComboItemSet iset in items) { if (iset.Count == 0) { continue; } if (menu.Children.Length > 0) { Gtk.SeparatorMenuItem sep = new Gtk.SeparatorMenuItem(); sep.Show(); menu.Insert(sep, -1); } Gtk.RadioMenuItem grp = new Gtk.RadioMenuItem(""); foreach (ComboItem ci in iset) { Gtk.RadioMenuItem mi = new Gtk.RadioMenuItem(grp, ci.Label.Replace("_", "__")); if (ci.Item == iset.CurrentItem || ci.Item.Equals(iset.CurrentItem)) { mi.Active = true; } ComboItemSet isetLocal = iset; ComboItem ciLocal = ci; mi.Activated += delegate { SelectItem(isetLocal, ciLocal); }; mi.ShowAll(); menu.Insert(mi, -1); } } menu.Popup(null, null, PositionFunc, 0, Gtk.Global.CurrentEventTime); }
public override Gtk.MenuItem GetMenuItem () { lock (this) { if (item == null || changed) { changed = false; item = new Gtk.MenuItem (_label != null ? Catalog.GetString (_label) : Id); Gtk.Menu submenu = new Gtk.Menu (); foreach (MenuNode node in ChildNodes) submenu.Insert (node.GetMenuItem (), -1); item.Submenu = submenu; } } return item; }
void OnSelectIcon(object s, Gtk.ButtonPressEventArgs args) { Gtk.Menu menu = new Gtk.Menu(); Gtk.CheckMenuItem item = new Gtk.CheckMenuItem(Catalog.GetString("Action")); item.DrawAsRadio = true; item.Active = (node.Action.Type == Stetic.Wrapper.Action.ActionType.Action); item.Activated += OnSetActionType; menu.Insert(item, -1); item = new Gtk.CheckMenuItem(Catalog.GetString("Radio Action")); item.DrawAsRadio = true; item.Active = (node.Action.Type == Stetic.Wrapper.Action.ActionType.Radio); item.Activated += OnSetRadioType; menu.Insert(item, -1); item = new Gtk.CheckMenuItem(Catalog.GetString("Toggle Action")); item.DrawAsRadio = true; item.Active = (node.Action.Type == Stetic.Wrapper.Action.ActionType.Toggle); item.Activated += OnSetToggleType; menu.Insert(item, -1); menu.Insert(new Gtk.SeparatorMenuItem(), -1); Gtk.MenuItem itIcons = new Gtk.MenuItem(Catalog.GetString("Select Icon")); menu.Insert(itIcons, -1); IconSelectorMenu menuIcons = new IconSelectorMenu(GetProject()); menuIcons.IconSelected += OnStockSelected; itIcons.Submenu = menuIcons; Gtk.MenuItem it = new Gtk.MenuItem(Catalog.GetString("Clear Icon")); it.Sensitive = (node.Action.GtkAction.StockId != null); it.Activated += OnClearIcon; menu.Insert(it, -1); menu.ShowAll(); uint but = args != null ? args.Event.Button : 1; menu.Popup(null, null, new Gtk.MenuPositionFunc(OnDropMenuPosition), but, Gtk.Global.CurrentEventTime); // Make sure we get the focus after closing the menu, so we can keep browsing buttons // using the keyboard. menu.Hidden += delegate(object sender, EventArgs a) { GrabFocus(); }; if (args != null) { args.RetVal = false; } }
public override Gtk.MenuItem GetMenuItem() { lock (this) { if (item == null || changed) { changed = false; item = new Gtk.MenuItem(_label != null ? Catalog.GetString(_label) : Id); Gtk.Menu submenu = new Gtk.Menu(); foreach (MenuNode node in ChildNodes) { submenu.Insert(node.GetMenuItem(), -1); } item.Submenu = submenu; } } return(item); }
/// <summary> /// Adds Gtk.Widget to Gtk.Menu. /// </summary> /// <param name="menu">Gtk.Menu object.</param> /// <param name="widget">Gtk.Widget object.</param> /// <param name="atEnd">Whether item will be added to begining or end of menu.</param> /// <param name="handler">Activated event handler.</param> public static Gtk.Widget AddWidget(this Gtk.Menu menu, Gtk.Widget widget, bool atEnd = true, System.EventHandler handler = null) { if (atEnd) { menu.Append(widget); } else { menu.Insert(widget, 0); } if (handler != null && widget is Gtk.MenuItem) { ((Gtk.MenuItem)widget).Activated += handler; } return(widget); }
void OnSelectIcon(object sender, Gtk.ButtonPressEventArgs e) { Gtk.Menu menu = new Gtk.Menu(); Gtk.CheckMenuItem item = new Gtk.CheckMenuItem(Catalog.GetString("Action")); item.DrawAsRadio = true; item.Active = (node.Action.Type == Stetic.Wrapper.Action.ActionType.Action); item.Activated += OnSetActionType; menu.Insert(item, -1); item = new Gtk.CheckMenuItem(Catalog.GetString("Radio Action")); item.DrawAsRadio = true; item.Active = (node.Action.Type == Stetic.Wrapper.Action.ActionType.Radio); item.Activated += OnSetRadioType; menu.Insert(item, -1); item = new Gtk.CheckMenuItem(Catalog.GetString("Toggle Action")); item.DrawAsRadio = true; item.Active = (node.Action.Type == Stetic.Wrapper.Action.ActionType.Toggle); item.Activated += OnSetToggleType; menu.Insert(item, -1); menu.Insert(new Gtk.SeparatorMenuItem(), -1); Gtk.MenuItem itIcons = new Gtk.MenuItem(Catalog.GetString("Select Icon")); menu.Insert(itIcons, -1); IconSelectorMenu menuIcons = new IconSelectorMenu(GetProject()); menuIcons.IconSelected += OnStockSelected; itIcons.Submenu = menuIcons; Gtk.MenuItem it = new Gtk.MenuItem(Catalog.GetString("Clear Icon")); it.Sensitive = (node.Action.GtkAction.StockId != null); it.Activated += OnClearIcon; menu.Insert(it, -1); menu.ShowAll(); menu.Popup(null, null, new Gtk.MenuPositionFunc(OnDropMenuPosition), 3, Gtk.Global.CurrentEventTime); e.RetVal = false; }
void Update(CommandInfo cmdInfo) { if (lastCmdInfo != null) { lastCmdInfo.CancelAsyncUpdate(); lastCmdInfo.Changed -= CommandInfoChanged; } lastCmdInfo = cmdInfo; lastCmdInfo.Changed += CommandInfoChanged; if (isArray && !isArrayItem) { this.Visible = false; Gtk.Menu menu = (Gtk.Menu)Parent; if (itemArray != null) { foreach (Gtk.MenuItem item in itemArray) { menu.Remove(item); } } itemArray = new ArrayList(); int i = Array.IndexOf(menu.Children, this); if (cmdInfo.ArrayInfo != null) { foreach (CommandInfo info in cmdInfo.ArrayInfo) { Gtk.MenuItem item; if (info.IsArraySeparator) { item = new Gtk.SeparatorMenuItem(); item.Show(); } else { item = CommandEntry.CreateMenuItem(commandManager, commandId, false); ICommandMenuItem mi = (ICommandMenuItem)item; mi.SetUpdateInfo(info, initialTarget); } menu.Insert(item, ++i); itemArray.Add(item); } } } else { Gtk.Widget child = Child; if (child == null) { return; } Gtk.Label accel_label = null; Gtk.Label label = null; if (!(child is Gtk.HBox)) { child = new Gtk.HBox(false, 0); accel_label = new Gtk.Label(""); accel_label.UseUnderline = false; accel_label.Xalign = 1.0f; accel_label.Show(); label = new Gtk.Label(""); label.UseUnderline = true; label.Xalign = 0.0f; label.Show(); ((Gtk.Box)child).PackStart(label); ((Gtk.Box)child).PackStart(accel_label); child.Show(); this.Remove(Child); this.Add(child); } else { accel_label = (Gtk.Label)((Gtk.Box)child).Children[1]; label = (Gtk.Label)((Gtk.Box)child).Children[0]; } if (cmdInfo.AccelKey != null) { accel_label.Text = " " + KeyBindingManager.BindingToDisplayLabel(cmdInfo.AccelKey, true); } else { accel_label.Text = String.Empty; } if (cmdInfo.UseMarkup) { label.Markup = overrideLabel ?? cmdInfo.Text; label.UseMarkup = true; } else { label.Text = overrideLabel ?? cmdInfo.Text; label.UseMarkup = false; } if (!string.IsNullOrEmpty(cmdInfo.Description) && label.TooltipText != cmdInfo.Description) { label.TooltipText = cmdInfo.Description; } label.UseUnderline = true; this.Sensitive = cmdInfo.Enabled; this.Visible = cmdInfo.Visible && (disabledVisible || cmdInfo.Enabled); if (!cmdInfo.Icon.IsNull && cmdInfo.Icon != lastIcon) { Image = new ImageView(cmdInfo.Icon, Gtk.IconSize.Menu); lastIcon = cmdInfo.Icon; } if (cmdInfo is CommandInfoSet) { CommandInfoSet ciset = (CommandInfoSet)cmdInfo; Gtk.Menu smenu = new Gtk.Menu(); Submenu = smenu; foreach (CommandInfo info in ciset.CommandInfos) { Gtk.MenuItem item; if (info.IsArraySeparator) { item = new Gtk.SeparatorMenuItem(); item.Show(); } else { item = CommandEntry.CreateMenuItem(commandManager, commandId, false); ICommandMenuItem mi = (ICommandMenuItem)item; mi.SetUpdateInfo(info, initialTarget); } smenu.Add(item); } } } }
void OnSelectIcon (object s, Gtk.ButtonPressEventArgs args) { Gtk.Menu menu = new Gtk.Menu (); Gtk.CheckMenuItem item = new Gtk.CheckMenuItem (Catalog.GetString ("Action")); item.DrawAsRadio = true; item.Active = (node.Action.Type == Stetic.Wrapper.Action.ActionType.Action); item.Activated += OnSetActionType; menu.Insert (item, -1); item = new Gtk.CheckMenuItem (Catalog.GetString ("Radio Action")); item.DrawAsRadio = true; item.Active = (node.Action.Type == Stetic.Wrapper.Action.ActionType.Radio); item.Activated += OnSetRadioType; menu.Insert (item, -1); item = new Gtk.CheckMenuItem (Catalog.GetString ("Toggle Action")); item.DrawAsRadio = true; item.Active = (node.Action.Type == Stetic.Wrapper.Action.ActionType.Toggle); item.Activated += OnSetToggleType; menu.Insert (item, -1); menu.Insert (new Gtk.SeparatorMenuItem (), -1); Gtk.MenuItem itIcons = new Gtk.MenuItem (Catalog.GetString ("Select Icon")); menu.Insert (itIcons, -1); IconSelectorMenu menuIcons = new IconSelectorMenu (GetProject ()); menuIcons.IconSelected += OnStockSelected; itIcons.Submenu = menuIcons; Gtk.MenuItem it = new Gtk.MenuItem (Catalog.GetString ("Clear Icon")); it.Sensitive = (node.Action.GtkAction.StockId != null); it.Activated += OnClearIcon; menu.Insert (it, -1); menu.ShowAll (); uint but = args != null ? args.Event.Button : 1; menu.Popup (null, null, new Gtk.MenuPositionFunc (OnDropMenuPosition), but, Gtk.Global.CurrentEventTime); // Make sure we get the focus after closing the menu, so we can keep browsing buttons // using the keyboard. menu.Hidden += delegate (object sender, EventArgs a) { GrabFocus (); }; if (args != null) args.RetVal = false; }
void OnSelectIcon (object sender, Gtk.ButtonPressEventArgs e) { Gtk.Menu menu = new Gtk.Menu (); Gtk.CheckMenuItem item = new Gtk.CheckMenuItem (Catalog.GetString ("Action")); item.DrawAsRadio = true; item.Active = (node.Action.Type == Stetic.Wrapper.Action.ActionType.Action); item.Activated += OnSetActionType; menu.Insert (item, -1); item = new Gtk.CheckMenuItem (Catalog.GetString ("Radio Action")); item.DrawAsRadio = true; item.Active = (node.Action.Type == Stetic.Wrapper.Action.ActionType.Radio); item.Activated += OnSetRadioType; menu.Insert (item, -1); item = new Gtk.CheckMenuItem (Catalog.GetString ("Toggle Action")); item.DrawAsRadio = true; item.Active = (node.Action.Type == Stetic.Wrapper.Action.ActionType.Toggle); item.Activated += OnSetToggleType; menu.Insert (item, -1); menu.Insert (new Gtk.SeparatorMenuItem (), -1); Gtk.MenuItem itIcons = new Gtk.MenuItem (Catalog.GetString ("Select Icon")); menu.Insert (itIcons, -1); IconSelectorMenu menuIcons = new IconSelectorMenu (GetProject ()); menuIcons.IconSelected += OnStockSelected; itIcons.Submenu = menuIcons; Gtk.MenuItem it = new Gtk.MenuItem (Catalog.GetString ("Clear Icon")); it.Sensitive = (node.Action.GtkAction.StockId != null); it.Activated += OnClearIcon; menu.Insert (it, -1); menu.ShowAll (); menu.Popup (null, null, new Gtk.MenuPositionFunc (OnDropMenuPosition), 3, Gtk.Global.CurrentEventTime); e.RetVal = false; }
public void AddRecentlyChangedNotes() { int min_size = (int)Preferences.Get(Preferences.MENU_NOTE_COUNT); int max_size = (int)Preferences.Get(Preferences.MENU_MAX_NOTE_COUNT); if (max_size < min_size) { max_size = min_size; } int list_size = 0; bool menuOpensUpward = tray.MenuOpensUpward(); NoteMenuItem item; // Remove the old dynamic items RemoveRecentlyChangedNotes(); // Assume menu opens downward, move common items to top of menu Gtk.MenuItem newNoteItem = Tomboy.ActionManager.GetWidget( "/TrayIconMenu/TrayNewNotePlaceholder/TrayNewNote") as Gtk.MenuItem; Gtk.MenuItem searchNotesItem = Tomboy.ActionManager.GetWidget( "/TrayIconMenu/ShowSearchAllNotes") as Gtk.MenuItem; tray_menu.ReorderChild(newNoteItem, 0); int insertion_point = 1; // If menu opens downward // Find all child widgets under the TrayNewNotePlaceholder // element. Make sure those added by add-ins are // properly accounted for and reordered. List <Gtk.Widget> newNotePlaceholderWidgets = new List <Gtk.Widget> (); IList <Gtk.Widget> allChildWidgets = Tomboy.ActionManager.GetPlaceholderChildren("/TrayIconMenu/TrayNewNotePlaceholder"); foreach (Gtk.Widget child in allChildWidgets) { if (child is Gtk.MenuItem && child != newNoteItem) { newNotePlaceholderWidgets.Add(child); tray_menu.ReorderChild(child, insertion_point); insertion_point++; } } tray_menu.ReorderChild(searchNotesItem, insertion_point); insertion_point++; DateTime days_ago = DateTime.Today.AddDays(-3); // Prevent template notes from appearing in the menu Tag template_tag = TagManager.GetOrCreateSystemTag(TagManager.TemplateNoteSystemTag); // List the most recently changed notes, any currently // opened notes, and any pinned notes... foreach (Note note in manager.Notes) { if (note.IsSpecial) { continue; } // Skip template notes if (note.ContainsTag(template_tag)) { continue; } bool show = false; // Test for note.IsPinned first so that all of the pinned notes // are guaranteed to be included regardless of the size of the // list. if (note.IsPinned) { show = true; } else if ((note.IsOpened && note.Window.IsMapped) || note.ChangeDate > days_ago || list_size < min_size) { if (list_size <= max_size) { show = true; } } if (show) { item = new NoteMenuItem(note, true); // Add this widget to the menu (+insertion_point to add after new+search+...) tray_menu.Insert(item, list_size + insertion_point); // Keep track of this item so we can remove it later recent_notes.Add(item); list_size++; } } Note start = manager.FindByUri(NoteManager.StartNoteUri); if (start != null) { item = new NoteMenuItem(start, false); if (menuOpensUpward) { tray_menu.Insert(item, list_size + insertion_point); } else { tray_menu.Insert(item, insertion_point); } recent_notes.Add(item); list_size++; bool enable_keybindings = (bool) Preferences.Get(Preferences.ENABLE_KEYBINDINGS); if (enable_keybindings) { GConfKeybindingToAccel.AddAccelerator( item, Preferences.KEYBINDING_OPEN_START_HERE); } } // FIXME: Rearrange this stuff to have less wasteful reordering if (menuOpensUpward) { // Relocate common items to bottom of menu insertion_point -= 1; tray_menu.ReorderChild(searchNotesItem, list_size + insertion_point); foreach (Gtk.Widget widget in newNotePlaceholderWidgets) { tray_menu.ReorderChild(widget, list_size + insertion_point); } tray_menu.ReorderChild(newNoteItem, list_size + insertion_point); insertion_point = list_size; } Gtk.SeparatorMenuItem separator = new Gtk.SeparatorMenuItem(); tray_menu.Insert(separator, insertion_point); recent_notes.Add(separator); }
public CueSheetsSource() : base(AddinManager.CurrentLocalizer.GetString("CueSheets"), AddinManager.CurrentLocalizer.GetString("CueSheets"), //"cuesheets", sort_order) //, //"hod-cuesheets-2013-01-06") { Hyena.Log.Information("CueSheetsSouce init"); DbConnection = ServiceManager.DbConnection; TM_Provider = DatabaseTrackInfo.Provider; _track_info_db = new CS_TrackInfoDb(DbConnection); _sheet = new CueSheet(); _sheets = new CueSheetCollection(); _view = new CueSheetsView(this); Properties.Set <ISourceContents> ("Nereid.SourceContents", _view); Properties.SetString("Icon.Name", "cueplay"); Hyena.Log.Information("CueSheets source has been instantiated."); Properties.Set <string> ("SearchEntryDescription", Catalog.GetString("Search albums and tracks")); try { Properties.SetString("GtkActionPath", "/CueSheetsPopup"); _actions = new CS_Actions(this); Hyena.Log.Information(_actions.ToString()); } catch (System.Exception ex) { Hyena.Log.Information(ex.ToString()); } InterfaceActionService action_service = ServiceManager.Get <InterfaceActionService> (); try { _track_search = new Gtk.CheckButton("Search Tracks"); _track_search.Clicked += delegate(object sender, EventArgs args) { this.DoFilter(); }; Gtk.Toolbar header_toolbar = (Gtk.Toolbar)action_service.UIManager.GetWidget("/HeaderToolbar"); int i, N, k; for (i = 0, k = -1, N = header_toolbar.NItems; i < N; i++) { Gtk.Widget w = header_toolbar.GetNthItem(i).Child; if (w != null) { if (w.GetType() == typeof(Banshee.Gui.Widgets.ConnectedVolumeButton)) { k = i; } } } if (k >= 0) { Hyena.Log.Information("Toolitem itm"); Gtk.ToolItem itm = new Gtk.ToolItem(); Hyena.Log.Information("Add cbk"); itm.Add(_track_search); Hyena.Log.Information("Insert cbk"); header_toolbar.Insert(itm, k); itm.Show(); } } catch (System.Exception ex) { Hyena.Log.Error(ex.ToString()); } Gtk.Menu viewMenu = (action_service.UIManager.GetWidget("/MainMenu/ViewMenu") as Gtk.MenuItem).Submenu as Gtk.Menu; _menuItem = new Gtk.MenuItem(Catalog.GetString("_Change Album View")); _menuItem.Activated += delegate { _view.ToggleGrid(); }; viewMenu.Insert(_menuItem, 2); _sep = new Gtk.SeparatorMenuItem(); viewMenu.Insert(_sep, 3); }
public void SetType(MenuItemType type) { string text = label.Text; Gtk.MenuItem newItem = null; switch (type) { case MenuItemType.Normal: if (!(item is Gtk.ImageMenuItem)) { newItem = new Gtk.ImageMenuItem(text); } break; case MenuItemType.CheckBox: if (item.GetType() != typeof(Gtk.CheckMenuItem)) { newItem = new Gtk.CheckMenuItem(text); } break; case MenuItemType.RadioButton: if (!(item is Gtk.RadioMenuItem)) { newItem = new Gtk.RadioMenuItem(text); } break; } if (newItem != null) { if ((newItem is Gtk.CheckMenuItem) && (item is Gtk.CheckMenuItem)) { ((Gtk.CheckMenuItem)item).Active = ((Gtk.CheckMenuItem)newItem).Active; } newItem.Sensitive = item.Sensitive; if (item.Parent != null) { Gtk.Menu m = (Gtk.Menu)item.Parent; int pos = Array.IndexOf(m.Children, item); m.Insert(newItem, pos); m.Remove(item); } newItem.ShowAll(); if (!item.Visible) { newItem.Hide(); } if (enabledEvents != null) { foreach (var ob in enabledEvents) { DisableEvent(ob); } } item = newItem; label = (Gtk.Label)item.Child; if (enabledEvents != null) { foreach (var ob in enabledEvents) { EnableEvent(ob); } } } }