protected virtual void OnPopulatePopup(object sender, Gtk.PopulatePopupArgs e) { Trace.Call(sender, e); if (!_AtLinkTag) { return; } Gtk.Menu popup = e.Menu; // remove all items foreach (Gtk.Widget children in popup.Children) { popup.Remove(children); } Gtk.ImageMenuItem open_item = new Gtk.ImageMenuItem(Gtk.Stock.Open, null); open_item.Activated += delegate { if (_ActiveLink != null) { OpenLink(_ActiveLink); } }; popup.Append(open_item); Gtk.ImageMenuItem copy_item = new Gtk.ImageMenuItem(Gtk.Stock.Copy, null); copy_item.Activated += delegate { Gdk.Atom clipboardAtom = Gdk.Atom.Intern("CLIPBOARD", false); Gtk.Clipboard clipboard = Gtk.Clipboard.Get(clipboardAtom); clipboard.Text = _ActiveLink.ToString(); }; popup.Append(copy_item); popup.ShowAll(); }
void UpdateMenu() { // // Clear out the old list // foreach (Gtk.MenuItem old_item in menu.Children) { menu.Remove(old_item); } // // Build a new list // foreach (BacklinkMenuItem item in GetBacklinkMenuItems()) { item.ShowAll(); menu.Append(item); } // If nothing was found, add in a "dummy" item if (menu.Children.Length == 0) { Gtk.MenuItem blank_item = new Gtk.MenuItem(Catalog.GetString("(none)")); blank_item.Sensitive = false; blank_item.ShowAll(); menu.Append(blank_item); } submenu_built = true; }
bool SetMenuItemsIdle() { idle_source = 0; if (menu != null) { foreach (Gtk.Widget widget in menu.Children) { menu.Remove(widget); widget.Destroy(); } } menu = new Gtk.Menu(); foreach (Gtk.MenuItem item in CurrentMenuItems()) { menu.Append(item); item.Show(); } menu.Show(); //if (indicator.Menu == null) indicator.Menu = menu; return(false); }
void RemoveRecentlyChangedNotes() { foreach (Gtk.Widget item in recent_notes) { tray_menu.Remove(item); } recent_notes.Clear(); }
public override void RemoveMenu (MenuItem item) { if (Control.Submenu == null) return; Gtk.Menu menu = (Gtk.Menu)Control.Submenu; menu.Remove ((Gtk.Widget)item.ControlObject); if (menu.Children.Length == 0) { Control.Submenu = null; } }
private void RemoveMenuItems(Gtk.Menu menu) { #if MAC menu.HideAll(); #endif foreach (Gtk.MenuItem child in menu.Children) { menu.Remove(child); } }
protected virtual void OnTabMenuShown(object sender, EventArgs e) { Trace.Call(sender, e); foreach (var child in _TabMenu.Children) { _TabMenu.Remove(child); } var closeItem = new Gtk.ImageMenuItem(Gtk.Stock.Close, null); closeItem.Activated += OnTabMenuCloseActivated; _TabMenu.Append(closeItem); _TabMenu.ShowAll(); }
void UpdateMenu() { // // Clear out the old list // foreach (Gtk.MenuItem oldItem in menu.Children) { menu.Remove(oldItem); } // // Build a new menu // // Add the "New Notebook..." Gtk.ImageMenuItem newNotebookMenuItem = new Gtk.ImageMenuItem(Catalog.GetString("_New notebook...")); newNotebookMenuItem.Image = new Gtk.Image(NewNotebookIcon); newNotebookMenuItem.Activated += OnNewNotebookMenuItem; newNotebookMenuItem.Show(); menu.Append(newNotebookMenuItem); // Add the "(no notebook)" item at the top of the list NotebookMenuItem noNotebookMenuItem = new NotebookMenuItem(Note, null); noNotebookMenuItem.ShowAll(); menu.Append(noNotebookMenuItem); // Add in all the real notebooks List <NotebookMenuItem> notebookMenuItems = GetNotebookMenuItems(); if (notebookMenuItems.Count > 0) { Gtk.SeparatorMenuItem separator = new Gtk.SeparatorMenuItem(); separator.ShowAll(); menu.Append(separator); foreach (NotebookMenuItem item in GetNotebookMenuItems()) { item.ShowAll(); menu.Append(item); } } }
private void HandleChildRemoved(Wrappers.Node source, Wrappers.Wrapper child) { if (!d_map.ContainsKey(child)) { return; } Gtk.Menu sub = d_map[child].Menu; sub.Remove(d_map[child].Item); if (d_recursive && child is Wrappers.Node) { Wrappers.Node grp = (Wrappers.Node)child; grp.ChildAdded -= HandleChildAdded; grp.ChildRemoved -= HandleChildRemoved; } RemoveFromMap(child); }
/// <summary> /// Initializes the menu. /// </summary> /// <param name="menu">The menu whose items are to be set.</param> /// <param name="addShortcuts">If <c>true</c>, add menu item shortcuts to the items.</param> private static void InitializeAvailableDevicesMenu(Gtk.Menu menu, bool addShortcuts) { var items = menu.Children; for (var i = 0; i < items.Length; ++i) { var menuItem = items[i] as Gtk.MenuItem; if (menuItem != null) { // Remove any existing accelerators if (addShortcuts) { var key = Gdk.Key.Key_0 + i + 1; var modifiers = Gdk.ModifierType.ControlMask; var acceleratorKey = new Gtk.AccelKey(key, modifiers, Gtk.AccelFlags.Visible); SetActiveDeviceCommand.RemoveAccelerator(menuItem, acceleratorKey); } menu.Remove(menuItem); } } var ports = DeviceConnectionViewModel.GetAvailableConnections(Group.Context as LtoFlashViewModel); var shortcutNumber = 0; foreach (var port in ports) { ++shortcutNumber; var menuItem = SetActiveDeviceCommand.CreateMenuItem(menu, ConnectToDeviceSubmenuCommand, Gtk.StockItem.Zero, null, null); menuItem.SetName(port.Name); menuItem.NativeMenuItem.Sensitive = SetActiveDeviceCommand.CanExecute(port); if (addShortcuts && (shortcutNumber < 10)) { var key = Gdk.Key.Key_0 + shortcutNumber; var modifiers = Gdk.ModifierType.ControlMask; var acceleratorKey = new Gtk.AccelKey(key, modifiers, Gtk.AccelFlags.Visible); SetActiveDeviceCommand.AddAccelerator(menuItem, acceleratorKey); } menuItem.SetValue(IFakeDependencyObjectHelpers.DataContextPropertyName, port); } }
protected virtual void Populate(Gtk.Menu menu) { foreach (var w in menu.Children.ToArray()) { menu.Remove(w); } foreach (var child in Children) { var wGtk = child.ToGtk() as Gtk.Widget; var image = wGtk; var ti = wGtk as Gtk.ToolItem; if (ti != null && ti.Child is Gtk.EventBox) { ((Gtk.EventBox)ti.Child).VisibleWindow = false; } var but = wGtk as Gtk.ToolButton; if (but != null) { image = but.IconWidget; } var item = new Gtk.ImageMenuItem("") { Image = image, TooltipText = wGtk.TooltipText }; item.Show(); menu.Add(item); var b = child as IGtkToolbarItemBackend; if (b != null) { item.ButtonPressEvent += (s, e) => b.Click(s, e); } item.ModifyBg(Gtk.StateType.Prelight, Notifycolor); } }
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); } } } }
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); } } } }
/// <summary> /// Creates menu based on Clipboard history content. /// </summary> public Gtk.Menu RebuildMenu() { Item item; bool at_end = !Settings.Instance[Settings.Keys.UI.ReverseOrder].AsBoolean(); bool keyboard = Settings.Instance[Settings.Keys.Core.KeyboardClipboard].AsBoolean(); bool mouse = Settings.Instance[Settings.Keys.Core.MouseClipboard].AsBoolean(); bool synchronize = Settings.Instance[Settings.Keys.Core.SynchronizeClipboards].AsBoolean(); if (this.menu != null) { foreach (Gtk.Widget w in this.menu.Children) { menu.Remove(w); if (w is Gtk.MenuItem) { ((Gtk.MenuItem)w).Submenu = null; } w.Destroy(); w.Dispose(); } this.menu.Destroy(); this.menu.Dispose(); } this.menu = new Gtk.Menu(); if (synchronize) { item = Clipboard.Instance.KeyboardItem; if (item != null) { this.menu.AddMenuItem(UnicodeCharacters.Scissors + " " + item.Label, at_end, this.OnPreviewItemActivated); } else { this.menu.AddMenuItem(UnicodeCharacters.Scissors, at_end, sensitive: false); } } else { if (keyboard) { item = Clipboard.Instance.KeyboardItem; if (item != null) { this.menu.AddMenuItem(UnicodeCharacters.Keyboard + " " + item.Label, at_end, this.OnPreviewItemActivated); } else { this.menu.AddMenuItem(UnicodeCharacters.Keyboard, at_end, sensitive: false); } } if (mouse) { item = Clipboard.Instance.MouseItem; if (item != null) { this.menu.AddMenuItem(UnicodeCharacters.Cursor + " " + item.Label, at_end, this.OnPreviewItemActivated); } else { this.menu.AddMenuItem(UnicodeCharacters.Cursor, at_end, sensitive: false); } } } if (Clipboard.Instance.Items.Count > 0) { bool separator_added = false; foreach (Item i in Clipboard.Instance.Items) { if (((synchronize || keyboard) && i == Clipboard.Instance.KeyboardItem) || (mouse && i == Clipboard.Instance.MouseItem)) { continue; } if (!separator_added) { separator_added = true; this.menu.AddWidget(new Gtk.SeparatorMenuItem(), at_end); } this.menu.AddMenuItem(i.Label, at_end, this.OnItemActivated); } } this.menu.AddWidget(new Gtk.SeparatorMenuItem()); this.menu.AddMenuItem(Catalog.GetString("_Clear clipboard"), true, (s, e) => Clipboard.Instance.Clear(), true); if (Settings.Instance[Settings.Keys.UI.ShowEditClipboard].AsBoolean()) { this.menu.AddMenuItem(Catalog.GetString("_Edit current content"), true, (s, e) => { if (this.EditContentWindow == null) { this.EditContentWindow = new EditContentWindow(this); this.EditContentWindow.ShowAll(); } else { this.EditContentWindow.Present(); } }, true); } this.menu.AddWidget(new Gtk.SeparatorMenuItem()); List <Gtk.MenuItem> plugin_menuitems = new List <Gtk.MenuItem>(); foreach (IPlugin plugin in this.Plugins) { Gtk.MenuItem mi = plugin.MenuItem; if (mi != null) { plugin_menuitems.Add(mi); } } if (plugin_menuitems.Count() > 0) { foreach (Gtk.MenuItem mi in plugin_menuitems) { this.menu.AddWidget(mi); } this.menu.AddWidget(new Gtk.SeparatorMenuItem()); } this.menu.AddMenuItem(Catalog.GetString("_Preferences"), true, (s, e) => { if (this.PreferencesWindow == null) { this.PreferencesWindow = new PreferencesWindow(this); this.PreferencesWindow.ShowAll(); } else { this.PreferencesWindow.Present(); } }, true); if (Settings.Instance[Settings.Keys.UI.ShowAbout].AsBoolean()) { this.menu.AddMenuItem(Catalog.GetString("_About"), true, (s, e) => AboutWindow.Show(), true); } if (Settings.Instance[Settings.Keys.UI.ShowQuit].AsBoolean()) { this.menu.AddMenuItem(Catalog.GetString("_Quit"), true, (s, e) => Syscall.kill(Syscall.getpid(), Signum.SIGTERM), true); } this.menu.ShowAll(); this.OnMenuRebuilt(this, this.menu); return(this.menu); }