void PopupQuickFixMenu(Gdk.EventButton evt) { Gtk.Menu menu = new Gtk.Menu(); Dictionary <Gtk.MenuItem, ContextAction> fixTable = new Dictionary <Gtk.MenuItem, ContextAction> (); int mnemonic = 1; foreach (ContextAction fix in fixes) { var escapedLabel = fix.GetMenuText(document, loc).Replace("_", "__"); var label = (mnemonic <= 10) ? "_" + (mnemonic++ % 10).ToString() + " " + escapedLabel : " " + escapedLabel; Gtk.MenuItem menuItem = new Gtk.MenuItem(label); fixTable [menuItem] = fix; menuItem.Activated += delegate(object sender, EventArgs e) { // ensure that the Ast is recent. document.UpdateParseDocument(); var runFix = fixTable [(Gtk.MenuItem)sender]; runFix.Run(document, loc); document.Editor.Document.CommitUpdateAll(); menu.Destroy(); }; menu.Add(menuItem); } menu.ShowAll(); menu.SelectFirst(true); menuPushed = true; menu.Destroyed += delegate { menuPushed = false; QueueDraw(); }; GtkWorkarounds.ShowContextMenu(menu, this, evt, Allocation); }
void HandleClicked(object sender, Gtk.ButtonPressEventArgs e) { if (e.Event.Button != 1) { return; } Gtk.Menu menu = CreateMenu(); if (menu != null) { isOpen = true; //make sure the button looks depressed Gtk.ReliefStyle oldRelief = Widget.Relief; Widget.Relief = Gtk.ReliefStyle.Normal; //clean up after the menu's done menu.Hidden += delegate { Widget.Relief = oldRelief; isOpen = false; ((Gtk.Widget)Widget).State = Gtk.StateType.Normal; //FIXME: for some reason the menu's children don't get activated if we destroy //directly here, so use a timeout to delay it GLib.Timeout.Add(100, delegate { //menu.Destroy (); return(false); }); }; menu.Popup(null, null, PositionFunc, 1, Gtk.Global.CurrentEventTime); } }
void OnDropMenuPosition(Gtk.Menu menu, out int x, out int y, out bool pushIn) { this.ParentWindow.GetOrigin(out x, out y); x += this.Allocation.X; y += this.Allocation.Y + this.Allocation.Height; pushIn = true; }
protected virtual void OnMessageTextViewPopulatePopup(object sender, Gtk.PopulatePopupArgs e) { Trace.Call(sender, e); if (OutputMessageTextView.IsAtUrlTag) { return; } if (Frontend.MainWindow.ShowMenuBar) { return; } Gtk.Menu popup = e.Menu; popup.Prepend(new Gtk.SeparatorMenuItem()); var item = new Gtk.CheckMenuItem(_("Show _Menubar")); item.Active = Frontend.MainWindow.ShowMenuBar; item.Activated += delegate { try { Frontend.MainWindow.ShowMenuBar = true; } catch (Exception ex) { Frontend.ShowException(ex); } }; popup.Prepend(item); popup.ShowAll(); }
protected void SetupUi() { var box = new Gtk.VBox(); var menu = new Gtk.MenuBar(); var fileMenu = new Gtk.Menu(); var file = new Gtk.MenuItem("File"); file.Submenu = fileMenu; menu.Append(file); var save = new Gtk.MenuItem("Save"); save.Activated += OnSaveMenuActivated; var load = new Gtk.MenuItem("Load"); load.Activated += OnLoadMenuActivated; var exit = new Gtk.MenuItem("Exit"); exit.Activated += (sender, e) => Gtk.Application.Quit(); fileMenu.Append(save); fileMenu.Append(load); fileMenu.Append(exit); box.PackStart(menu, false, false, 0); nb = new Gtk.Notebook(); nb.ShowTabs = false; nb.AppendPage(SetupOverviewPage(), new Gtk.Label("Overview")); nb.AppendPage(SetupNewNotePage(), new Gtk.Label("New")); box.PackStart(nb, true, true, 2); Add(box); }
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(); }
public void Activate(Gdk.EventButton eb, Literal literal, Gtk.Menu popupMenu, bool isPopup) { /*MenuItem attach_item = new MenuItem (Catalog.GetString ("Find With")); * TagMenu attach_menu = new TagMenu (attach_item, App.Instance.Database.Tags); * attach_menu.TagSelected += literal.HandleAttachTagCommand; * attach_item.ShowAll (); * popup_menu.Append (attach_item);*/ if (literal.IsNegated) { GtkUtil.MakeMenuItem(popupMenu, Strings.IncludePhotosTaggedTagName(literal.Tag.Name), new EventHandler(literal.HandleToggleNegatedCommand), true); } else { GtkUtil.MakeMenuItem(popupMenu, Strings.ExcludePhotosTaggedTagName(literal.Tag.Name), new EventHandler(literal.HandleToggleNegatedCommand), true); } GtkUtil.MakeMenuItem(popupMenu, Strings.RemoveFromSearch, "gtk-remove", new EventHandler(literal.HandleRemoveCommand), true); if (isPopup) { if (eb != null) { popupMenu.Popup(null, null, null, eb.Button, eb.Time); } else { popupMenu.Popup(null, null, null, 0, Gtk.Global.CurrentEventTime); } } }
private void PopulateAlbums() { Gtk.Menu menu = new Gtk.Menu(); if (gallery.Version == GalleryVersion.Version1) { Gtk.MenuItem top_item = new Gtk.MenuItem(Catalog.GetString("(TopLevel)")); menu.Append(top_item); } foreach (Album album in gallery.Albums) { System.Text.StringBuilder label_builder = new System.Text.StringBuilder(); for (int i = 0; i < album.Parents.Count; i++) { label_builder.Append(" "); } label_builder.Append(album.Title); album_optionmenu.AppendText(label_builder.ToString()); } album_optionmenu.Sensitive = true; menu.ShowAll(); }
/// <summary> /// Creates menu from actions list. /// </summary> private void BuildMenu() { if (this.submenu != null) { foreach (Gtk.Widget w in this.submenu.Children) { this.submenu.Remove(w); w.Destroy(); w.Dispose(); } this.submenu.Destroy(); this.submenu.Dispose(); } Action action; Gtk.MenuItem mi; this.submenu = new Gtk.Menu(); foreach (object[] o in this.list) { action = ((Action)o[0]); string content = action.Content; mi = new Gtk.MenuItem(action.Label); this.submenu.Append(mi); mi.Activated += (s, e) => ExecuteCommand(content, Clipboard.Instance.Items.FirstOrDefault(i => i.IsText)); mi.ButtonReleaseEvent += (s, e) => ExecuteCommand(content, Clipboard.Instance.Items.FirstOrDefault(i => i.IsText)); } }
private void PopulateAlbums() { Gtk.Menu menu = new Gtk.Menu(); if (gallery.Version == GalleryVersion.Version1) { Gtk.MenuItem top_item = new Gtk.MenuItem(Catalog.GetString("(TopLevel)")); menu.Append(top_item); } foreach (Album album in gallery.Albums) { System.Text.StringBuilder label_builder = new System.Text.StringBuilder(); for (int i = 0; i < album.Parents.Count; i++) { label_builder.Append(" "); } label_builder.Append(album.Title); Gtk.MenuItem item = new Gtk.MenuItem(label_builder.ToString()); ((Gtk.Label)item.Child).UseUnderline = false; menu.Append(item); AlbumPermission create_sub = album.Perms & AlbumPermission.CreateSubAlbum; if (create_sub == 0) { item.Sensitive = false; } } album_optionmenu.Sensitive = true; menu.ShowAll(); album_optionmenu.Menu = menu; }
protected override void OnClicked() { base.OnClicked(); if (creator != null) { Gtk.Menu menu = creator(this); if (menu != null) { isOpen = true; //make sure the button looks depressed Gtk.ReliefStyle oldRelief = this.Relief; this.Relief = Gtk.ReliefStyle.Normal; //clean up after the menu's done menu.Hidden += delegate { this.Relief = oldRelief; isOpen = false; this.State = Gtk.StateType.Normal; //FIXME: for some reason the menu's children don't get activated if we destroy //directly here, so use a timeout to delay it GLib.Timeout.Add(100, delegate { //menu.Destroy (); return(false); }); }; menu.Popup(null, null, PositionFunc, 0, Gtk.Global.CurrentEventTime); } } }
private void OnMenuRebuilt(object sender, Gtk.Menu menu) { foreach (ITray tray in this.Trays) { tray.OnMenuRebuilt(sender, menu); } }
void OnIconMarginButtonPress(object s, MarginMouseEventArgs args) { if (args.Button == 3) { editor.Caret.Line = args.LineNumber; editor.Caret.Column = 1; Gtk.Menu popupMenu = (Gtk.Menu)MainClass.MainWindow.ActionUiManager.GetWidget("/iconMarginPopup"); if (popupMenu != null) { popupMenu.ShowAll(); popupMenu.Popup(); } } else if (args.Button == 1) { if (!string.IsNullOrEmpty(FileName)) { if (args.LineSegment != null) { //DebuggingService.Breakpoints.Toggle (this.Document.FileName, args.LineNumber + 1); //AddBreakpoints(args.LineSegment); } } } }
private void BuildMenu() { var menuBar = new Gtk.MenuBar(); var miFile = new Gtk.MenuItem("File"); var mFile = new Gtk.Menu(); var miHelp = new Gtk.MenuItem("Help"); var mHelp = new Gtk.Menu(); var miView = new Gtk.MenuItem("View"); var mView = new Gtk.Menu(); miFile.Submenu = mFile; mFile.Append(this.actQuit.CreateMenuItem()); miHelp.Submenu = mHelp; mHelp.Append(this.actAbout.CreateMenuItem()); miView.Submenu = mView; mView.Append(this.actViewBoxes.CreateMenuItem()); mView.Append(this.actViewFrames.CreateMenuItem()); mView.Append(this.actViewNotebook.CreateMenuItem()); mView.Append(this.actViewDrawing.CreateMenuItem()); menuBar.Append(miFile); menuBar.Append(miView); menuBar.Append(miHelp); this.vbMain.PackStart(menuBar, false, false, 5); }
private void AddTemplate(Gtk.Menu menu, Wrappers.Wrapper template) { if (!(d_filter == null || d_filter(template) || (template is Wrappers.Node && d_recursive))) { return; } string lbl = template.FullId.Replace("_", "__"); Gtk.MenuItem item = new Gtk.MenuItem(lbl); item.Show(); item.Activated += delegate { if (item.Submenu == null) { Activated(this, template); } }; menu.Append(item); d_map[template] = new MenuInfo(item, menu); if (d_recursive && template is Wrappers.Node) { Gtk.Menu sub = new Gtk.Menu(); item.Submenu = sub; Traverse((Wrappers.Node)template, sub); } template.WrappedObject.AddNotification("id", HandleIdChanged); }
public static Gtk.MenuItem MakeMenuItem(Gtk.Menu menu, string l, EventHandler e, bool enabled) { Gtk.MenuItem i; Gtk.StockItem item = Gtk.StockItem.Zero; if (Gtk.StockManager.Lookup(l, ref item)) { i = new Gtk.ImageMenuItem(l, new Gtk.AccelGroup()); } else { i = new Gtk.MenuItem(l); } if (e != null) { i.Activated += e; } i.Sensitive = enabled; menu.Append(i); i.Show(); return(i); }
public static void PopupMenu(Gtk.Menu menu, Gdk.EventButton ev, Gtk.MenuPositionFunc mpf) { menu.Deactivated += DeactivateMenu; try { menu.Popup(null, null, mpf, (ev == null) ? 0 : ev.Button, (ev == null) ? Gtk.Global.CurrentEventTime : ev.Time); } catch { Logger.Debug("Menu popup failed with custom MenuPositionFunc; trying again without"); menu.Popup(null, null, null, (ev == null) ? 0 : ev.Button, (ev == null) ? Gtk.Global.CurrentEventTime : ev.Time); } // Highlight the parent if (menu.AttachWidget != null) { menu.AttachWidget.State = Gtk.StateType.Selected; } #if WIN32 BringToForeground(); #endif }
public static Gtk.Menu GetSubmenu(Tag [] tags) { Tag single_tag = null; if (tags != null && tags.Length == 1) single_tag = tags[0]; if (LogicWidget.Root == null || LogicWidget.Root.SubTerms.Count == 0) { return null; } else { var m = new Gtk.Menu (); Gtk.MenuItem all_item = GtkUtil.MakeMenuItem (m, Catalog.GetString ("All"), new EventHandler (App.Instance.Organizer.HandleRequireTag)); GtkUtil.MakeMenuSeparator (m); int sensitive_items = 0; foreach (Term term in LogicWidget.Root.SubTerms) { var term_parts = new List<string> (); bool contains_tag = AppendTerm (term_parts, term, single_tag); string name = "_" + String.Join (", ", term_parts.ToArray ()); Gtk.MenuItem item = GtkUtil.MakeMenuItem (m, name, new EventHandler (App.Instance.Organizer.HandleAddTagToTerm)); item.Sensitive = !contains_tag; if (!contains_tag) sensitive_items++; } if (sensitive_items == 0) all_item.Sensitive = false; return m; } }
/// <summary> /// Loads tray plugin. /// </summary> /// <param name="menu">Menu reference.</param> /// <param name="rebuildMenuFunc">Rebuild menu function.</param> public void Load(Gtk.Menu menu, MenuFunc rebuildMenuFunc) { this.RebuildMenu = rebuildMenuFunc; this.indicator = new ApplicationIndicator("glippy", EnvironmentVariables.PanelIcon, Category.Other); this.indicator.Status = Status.Active; this.indicator.Menu = menu; }
private void _OnOutputMessageTextViewPopulatePopup(object o, Gtk.PopulatePopupArgs args) { if (OutputMessageTextView.IsAtUrlTag) { return; } Gtk.Menu popup = args.Menu; popup.Append(new Gtk.SeparatorMenuItem()); Gtk.ImageMenuItem whois_item = new Gtk.ImageMenuItem(_("Whois")); whois_item.Activated += _OnMenuWhoisItemActivated; popup.Append(whois_item); Gtk.ImageMenuItem ctcp_item = new Gtk.ImageMenuItem(_("CTCP")); Gtk.Menu ctcp_menu_item = new CtcpMenu(_IrcProtocolManager, Frontend.MainWindow.ChatViewManager, PersonModel); ctcp_item.Submenu = ctcp_menu_item; popup.Append(ctcp_item); Gtk.ImageMenuItem invite_to_item = new Gtk.ImageMenuItem(_("Invite to")); Gtk.Menu invite_to_menu_item = new InviteToMenu(_IrcProtocolManager, Frontend.MainWindow.ChatViewManager, PersonModel); invite_to_item.Submenu = invite_to_menu_item; popup.Append(invite_to_item); popup.ShowAll(); }
private void BuildMenu() { var menuBar = new Gtk.MenuBar(); var miFile = new Gtk.MenuItem( "File" ); var mFile = new Gtk.Menu(); var miHelp = new Gtk.MenuItem( "Help" ); var mHelp = new Gtk.Menu(); var miView = new Gtk.MenuItem( "View" ); var mView = new Gtk.Menu(); miFile.Submenu = mFile; mFile.Append( this.actQuit.CreateMenuItem() ); miHelp.Submenu = mHelp; mHelp.Append( this.actAbout.CreateMenuItem() ); miView.Submenu = mView; mView.Append( this.actViewBoxes.CreateMenuItem() ); mView.Append( this.actViewFrames.CreateMenuItem() ); mView.Append( this.actViewNotebook.CreateMenuItem() ); mView.Append( this.actViewDrawing.CreateMenuItem() ); menuBar.Append( miFile ); menuBar.Append( miView ); menuBar.Append( miHelp ); this.vbMain.PackStart( menuBar, false, false, 5 ); }
public static void MakeMenuSeparator(Gtk.Menu menu) { var i = new Gtk.SeparatorMenuItem(); menu.Append(i); i.Show(); }
protected virtual void ShowDropDown() { if (HasChildren) { PopupMenu = new Gtk.Menu(); PopupMenu.Hidden += (s, o) => HideDropDown(); PopupMenu.SelectionDone += (s, e) => { var i = 0; }; Populate(PopupMenu); PopupMenu.ShowAll(); PopupMenu.Popup(null, null, delegate(Gtk.Menu menu, out int x, out int y, out bool push_in) { var all = ContentWidget.Allocation; var loc = GtkBackendHelper.ConvertToScreenCoordinates(ContentWidget, new Xwt.Point(0, all.Height)); x = (int)loc.X; y = (int)loc.Y; push_in = true; }, 0, Gtk.Global.CurrentEventTime); PopupMenu.WidthRequest = this.Widget.Allocation.Width; } }
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); }
public GlobalKeybinder (Gtk.AccelGroup accel_group) { this.accel_group = accel_group; fake_menu = new Gtk.Menu (); fake_menu.AccelGroup = accel_group; }
static void GetMenuPosition(Gtk.Menu menu, out int x, out int y, out bool push_in) { if (menu.AttachWidget == null || menu.AttachWidget.GdkWindow == null) { // Prevent null exception in weird cases x = 0; y = 0; push_in = true; return; } menu.AttachWidget.GdkWindow.GetOrigin(out x, out y); x += menu.AttachWidget.Allocation.X; Gtk.Requisition menu_req = menu.SizeRequest(); if (y + menu_req.Height >= menu.AttachWidget.Screen.Height) { y -= menu_req.Height; } else { y += menu.AttachWidget.Allocation.Height; } push_in = true; }
void ShowMenu() { Gtk.Menu menu = CreateMenu(); if (menu != null) { isOpen = true; //make sure the button looks depressed Gtk.ReliefStyle oldRelief = Widget.Relief; Widget.Relief = Gtk.ReliefStyle.Normal; Widget.SetStateActive(); //clean up after the menu's done menu.Hidden += delegate { Widget.Relief = oldRelief; isOpen = false; Widget.SetStateNormal(); //FIXME: for some reason the menu's children don't get activated if we destroy //directly here, so use a timeout to delay it GLib.Timeout.Add(100, delegate { //menu.Destroy (); return(false); }); }; menu.Popup(null, null, PositionFunc, 1, Gtk.Global.CurrentEventTime); } }
public GlobalKeybinder(Gtk.AccelGroup accel_group) { this.accel_group = accel_group; fake_menu = new Gtk.Menu(); fake_menu.AccelGroup = accel_group; }
public override void OnNoteOpened() { if (menu == null) { menu = new Gtk.Menu(); menu.ShowAll(); } if (toolButton == null) { InitializeToolButton(); // Disable the notebook button if this note is a template note Tag templateTag = TagManager.GetOrCreateSystemTag(TagManager.TemplateNoteSystemTag); if (Note.ContainsTag(templateTag) == true) { toolButton.Sensitive = false; // Also prevent notebook templates from being deleted if (NotebookManager.GetNotebookFromNote(Note) != null) { Note.Window.DeleteButton.Sensitive = false; } } } }
public static Gtk.AccelGroup MenuGetAccelGroup(Gtk.Menu menu) { IntPtr raw_ret = gnome_popup_menu_get_accel_group(menu == null ? IntPtr.Zero : menu.Handle); Gtk.AccelGroup ret = GLib.Object.GetObject(raw_ret) as Gtk.AccelGroup; return(ret); }
/// <summary> /// Initalize Gtk and DBus stuff /// </summary> private void GtkDBusInit() { /* setup StatusIcon */ statusIcon = new Gtk.StatusIcon(); statusIcon.IconName = "keepass2-locked"; #if DEBUG statusIcon.File = Path.GetFullPath("Resources/icons/hicolor/16x16/apps/keepass2-locked.png"); #endif statusIcon.Tooltip = PwDefs.ProductName; statusIconMenu = new Gtk.Menu(); var trayContextMenu = pluginHost.MainWindow.TrayContextMenu; // make copy of item list to prevent list changed exception when iterating var menuItems = new System.Windows.Forms.ToolStripItem[trayContextMenu.Items.Count]; trayContextMenu.Items.CopyTo(menuItems, 0); trayContextMenu.ItemAdded += (sender, e) => DBusBackgroundWorker.InvokeGtkThread (() => ConvertAndAddMenuItem(e.Item, statusIconMenu)); foreach (System.Windows.Forms.ToolStripItem item in menuItems) { ConvertAndAddMenuItem(item, statusIconMenu); } statusIcon.PopupMenu += OnPopupMenu; statusIcon.Activate += (sender, e) => { DBusBackgroundWorker.InvokeWinformsThread (() => pluginHost.MainWindow.EnsureVisibleForegroundWindow(true, true)); }; }
void IMenuItemContainer.ShowContextMenu(ActionItem aitem) { ActionMenuItem menuItem = aitem as ActionMenuItem; Gtk.Menu m = new Gtk.Menu(); Gtk.MenuItem item = new Gtk.ImageMenuItem(Gtk.Stock.Cut, null); m.Add(item); item.Activated += delegate(object s, EventArgs a) { Cut(menuItem); }; item.Visible = false; // No copy & paste for now item = new Gtk.ImageMenuItem(Gtk.Stock.Copy, null); m.Add(item); item.Activated += delegate(object s, EventArgs a) { Copy(menuItem); }; item.Visible = false; // No copy & paste for now item = new Gtk.ImageMenuItem(Gtk.Stock.Paste, null); m.Add(item); item.Activated += delegate(object s, EventArgs a) { Paste(menuItem); }; item.Visible = false; // No copy & paste for now item = new Gtk.ImageMenuItem(Gtk.Stock.Delete, null); m.Add(item); item.Activated += delegate(object s, EventArgs a) { Delete(menuItem); }; m.ShowAll(); m.Popup(); }
public SearchEntry() { WidthRequest = 300; Gtk.Menu searchMenu = Menu; Gtk.RadioMenuItem searchMenuItemAll = new Gtk.RadioMenuItem("All"); Gtk.RadioMenuItem searchMenuItemAuthor = new Gtk.RadioMenuItem(searchMenuItemAll, "Author"); Gtk.RadioMenuItem searchMenuItemTitle = new Gtk.RadioMenuItem(searchMenuItemAll, "Title"); Gtk.RadioMenuItem searchMenuItemArticle = new Gtk.RadioMenuItem(searchMenuItemAll, "Article"); searchMenuItemAll.Data.Add("searchField", BibtexSearchField.All); searchMenuItemAuthor.Data.Add("searchField", BibtexSearchField.Author); searchMenuItemTitle.Data.Add("searchField", BibtexSearchField.Title); searchMenuItemArticle.Data.Add("searchField", BibtexSearchField.Article); searchMenu.Add(searchMenuItemAll); searchMenu.Add(searchMenuItemAuthor); searchMenu.Add(searchMenuItemTitle); searchMenu.Add(searchMenuItemArticle); searchMenuItemAll.Activated += OnSearchEntryChanged; searchMenuItemAuthor.Activated += OnSearchEntryChanged; searchMenuItemTitle.Activated += OnSearchEntryChanged; searchMenuItemArticle.Activated += OnSearchEntryChanged; Changed += OnSearchEntryChanged; Show(); }
public void ShowContextMenu(ActionItem aitem) { ActionToolItem menuItem = aitem as ActionToolItem; Gtk.Menu m = new Gtk.Menu(); Gtk.MenuItem item = new Gtk.MenuItem(Catalog.GetString("Insert Before")); m.Add(item); item.Activated += delegate(object s, EventArgs a) { InsertActionAt(menuItem, false, false); }; item = new Gtk.MenuItem(Catalog.GetString("Insert After")); m.Add(item); item.Activated += delegate(object s, EventArgs a) { InsertActionAt(menuItem, true, false); }; item = new Gtk.MenuItem(Catalog.GetString("Insert Separator Before")); m.Add(item); item.Activated += delegate(object s, EventArgs a) { InsertActionAt(menuItem, false, true); }; item = new Gtk.MenuItem(Catalog.GetString("Insert Separator After")); m.Add(item); item.Activated += delegate(object s, EventArgs a) { InsertActionAt(menuItem, true, true); }; m.Add(new Gtk.SeparatorMenuItem()); item = new Gtk.ImageMenuItem(Gtk.Stock.Cut, null); m.Add(item); item.Activated += delegate(object s, EventArgs a) { menuItem.Cut(); }; item = new Gtk.ImageMenuItem(Gtk.Stock.Copy, null); m.Add(item); item.Activated += delegate(object s, EventArgs a) { menuItem.Copy(); }; item = new Gtk.ImageMenuItem(Gtk.Stock.Paste, null); m.Add(item); item.Activated += delegate(object s, EventArgs a) { Paste(menuItem); }; item = new Gtk.ImageMenuItem(Gtk.Stock.Delete, null); m.Add(item); item.Activated += delegate(object s, EventArgs a) { menuItem.Delete(); }; m.ShowAll(); m.Popup(); }
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; }
public override void Wrap (object obj, bool initialized) { Gtk.OptionMenu omenu = (Gtk.OptionMenu)obj; if (omenu.Menu == null) { Gtk.Menu menu = new Gtk.Menu (); menu.Show (); omenu.Menu = menu; } base.Wrap (obj, initialized); }
public MenuToolButton (Gtk.Menu menu, string icon): base (icon) { this.menu = menu; Child.ButtonPressEvent += new Gtk.ButtonPressEventHandler (OnButtonPress); if (string.IsNullOrEmpty (icon)) { this.Expand = false; this.Homogeneous = false; this.IconWidget = new Gtk.Arrow (Gtk.ArrowType.Down, Gtk.ShadowType.None); } }
public override void OnNoteOpened () { menu = new Gtk.Menu (); menu.Hidden += OnMenuHidden; menu.ShowAll (); menu_item = new Gtk.ImageMenuItem ( Catalog.GetString ("What links here?")); menu_item.Image = new Gtk.Image (Gtk.Stock.JumpTo, Gtk.IconSize.Menu); menu_item.Submenu = menu; menu_item.Activated += OnMenuItemActivated; menu_item.Show (); AddPluginMenuItem (menu_item); }
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; }
public SearchEntry() { this.placeholderText = null; this.presets = null; this.presetsChanged = false; this.popup = null; this.ShowClearIcon = true; this.SetIconFromStock(Icon.Stock_Find.Name, EntryIconPosition.Primary); this.KeyPressEvent += OnKeyPressEvent; this.Changed += OnChanged; this.IconPress += OnIconPressEvent; this.Shown += OnShown; this.FocusInEvent += OnFocusInEvent; this.FocusOutEvent += OnFocusOutEvent; }
protected override void Run (RefactoringOptions options) { Gtk.Menu menu = new Gtk.Menu (); bool resolveDirect; List<string> namespaces = GetResolveableNamespaces (options, out resolveDirect); foreach (string ns in namespaces) { // remove used namespaces for conflict resolving. if (options.Document.CompilationUnit.IsNamespaceUsedAt (ns, options.ResolveResult.ResolvedExpression.Region.Start)) continue; Gtk.MenuItem menuItem = new Gtk.MenuItem (string.Format (GettextCatalog.GetString ("Add using '{0}'"), ns)); CurrentRefactoryOperationsHandler.ResolveNameOperation resolveNameOperation = new CurrentRefactoryOperationsHandler.ResolveNameOperation (options.Dom, options.Document, options.ResolveResult, ns); menuItem.Activated += delegate { resolveNameOperation.AddImport (); }; menu.Add (menuItem); } if (resolveDirect) { foreach (string ns in namespaces) { Gtk.MenuItem menuItem = new Gtk.MenuItem (string.Format (GettextCatalog.GetString ("Add '{0}'"), ns)); CurrentRefactoryOperationsHandler.ResolveNameOperation resolveNameOperation = new CurrentRefactoryOperationsHandler.ResolveNameOperation (options.Dom, options.Document, options.ResolveResult, ns); menuItem.Activated += delegate { resolveNameOperation.ResolveName (); }; menu.Add (menuItem); } } if (menu.Children != null && menu.Children.Length > 0) { menu.ShowAll (); ICompletionWidget widget = options.Document.GetContent<ICompletionWidget> (); CodeCompletionContext codeCompletionContext = widget.CreateCodeCompletionContext (options.GetTextEditorData ().Caret.Offset); menu.Popup (null, null, delegate (Gtk.Menu menu2, out int x, out int y, out bool pushIn) { x = codeCompletionContext.TriggerXCoord; y = codeCompletionContext.TriggerYCoord; pushIn = false; }, 0, Gtk.Global.CurrentEventTime); menu.SelectFirst (true); } }
public void PopupQuickFixMenu () { Gtk.Menu menu = new Gtk.Menu (); Dictionary<Gtk.MenuItem, ContextAction> fixTable = new Dictionary<Gtk.MenuItem, ContextAction> (); int mnemonic = 1; foreach (ContextAction fix in fixes) { var escapedLabel = fix.GetMenuText (document, loc).Replace ("_", "__"); var label = (mnemonic <= 10) ? "_" + (mnemonic++ % 10).ToString () + " " + escapedLabel : " " + escapedLabel; Gtk.MenuItem menuItem = new Gtk.MenuItem (label); fixTable [menuItem] = fix; menuItem.Activated += delegate(object sender, EventArgs e) { // ensure that the Ast is recent. document.UpdateParseDocument (); var runFix = fixTable [(Gtk.MenuItem)sender]; runFix.Run (document, loc); document.Editor.Document.CommitUpdateAll (); menu.Destroy (); }; menu.Add (menuItem); } menu.ShowAll (); int dx, dy; this.ParentWindow.GetOrigin (out dx, out dy); dx += ((TextEditorContainer.EditorContainerChild)(this.document.Editor.Parent.Parent as TextEditorContainer) [this]).X; dy += ((TextEditorContainer.EditorContainerChild)(this.document.Editor.Parent.Parent as TextEditorContainer) [this]).Y - (int)document.Editor.VAdjustment.Value; menu.Popup (null, null, delegate (Gtk.Menu menu2, out int x, out int y, out bool pushIn) { x = dx; y = dy + Allocation.Height; pushIn = false; menuPushed = true; QueueDraw (); }, 0, Gtk.Global.CurrentEventTime); menu.SelectFirst (true); menu.Destroyed += delegate { menuPushed = false; QueueDraw (); }; }
protected override bool OnPopupMenu() { Gtk.Menu mnu=new Gtk.Menu(); Gtk.ImageMenuItem play=new Gtk.ImageMenuItem(Gtk.Stock.MediaPlay,null); play.Activated+=delegate(object sender,EventArgs a) { _view.PlayAlbum((CS_AlbumInfo) this.Model[Selection.FirstIndex]); }; Gtk.ImageMenuItem edit=new Gtk.ImageMenuItem(Gtk.Stock.Edit,null); edit.Activated+=delegate(object sender,EventArgs a) { _view.EditSheet(((CS_AlbumInfo) this.Model[Selection.FirstIndex]).getSheet ()); }; Gtk.ImageMenuItem show_file=new Gtk.ImageMenuItem("Show in filesystem"); show_file.Image=new Gtk.Image(Gtk.Stock.Directory,Gtk.IconSize.Menu); show_file.Activated+=delegate(object sender, EventArgs a) { _view.OpenContainingFolder((CS_AlbumInfo) this.Model[Selection.FirstIndex]); }; mnu.Append (play); mnu.Append (new Gtk.SeparatorMenuItem()); mnu.Append (edit); mnu.Append (show_file); CueSheet s=((CS_AlbumInfo) this.Model[Selection.FirstIndex]).getSheet (); if (Mp3Split.DllPresent()) { if (Mp3Split.IsSupported(s.musicFileName ())) { Gtk.ImageMenuItem split=new Gtk.ImageMenuItem("Split & Write to location"); split.Image=new Gtk.Image(Gtk.Stock.Convert,Gtk.IconSize.Menu); split.Activated+=delegate(object sender,EventArgs a) { _view.MusicFileToDevice(((CS_AlbumInfo) this.Model[Selection.FirstIndex]).getSheet ()); }; mnu.Append (split); } } mnu.ShowAll (); mnu.Popup(); return false; }
public void Step1_SetWidget(Gtk.Widget widget) { // Add right-click context menu to control. var menu = new Gtk.Menu(); var resetMenuItem = new Gtk.MenuItem("Reset Camera Offset"); resetMenuItem.Activated += delegate(object sender, EventArgs e) { SetCameraOffset(0, 0); }; menu.Add(resetMenuItem); // Handle mouse move events. widget.MotionNotifyEvent += delegate(object o, Gtk.MotionNotifyEventArgs args) { if (!m_enabled) return; if (!m_mouseDown) return; double x = args.Event.X; double y = args.Event.Y; double dx = x - m_mouseDownX; double dy = y - m_mouseDownY; SetCameraOffset(m_offsetDownX + dx, m_offsetDownY + dy); }; widget.ButtonPressEvent += delegate(object o, Gtk.ButtonPressEventArgs args) { if (m_enablePopupMenu && (args.Event.Button & 2) == 2) { menu.ShowAll(); menu.Popup(); return; } m_mouseDown = true; m_mouseDownX = args.Event.X; m_mouseDownY = args.Event.Y; m_offsetDownX = m_offsetX; m_offsetDownY = m_offsetY; }; widget.ButtonReleaseEvent += delegate(object o, Gtk.ButtonReleaseEventArgs args) { m_mouseDown = false; }; }
public override void OnNoteOpened () { menu = new Gtk.Menu (); menu.Hidden += OnMenuHidden; menu.ShowAll (); Gtk.Image tasqueImage = new Gtk.Image (TasqueIcon); tasqueImage.Show (); menuToolButton = new Gtk.MenuToolButton (tasqueImage, Catalog.GetString ("Tasque")); menuToolButton.Menu = menu; menuToolButton.Clicked += OnMenuToolButtonClicked; menuToolButton.ShowMenu += OnMenuItemActivated; menuToolButton.Sensitive = false; menuToolButton.Show (); AddToolItem (menuToolButton, -1); // Sensitize the Task button on text selection markSetTimeout = new InterruptableTimeout(); markSetTimeout.Timeout += UpdateTaskButtonSensitivity; Note.Buffer.MarkSet += OnSelectionMarkSet; }
protected override void OnDestroyed() { if (menu != null) { menu.Destroy (); menu = null; } base.OnDestroyed (); }
internal void ShowDockPopupMenu (uint time) { Gtk.Menu menu = new Gtk.Menu (); // Hide menuitem if ((Behavior & DockItemBehavior.CantClose) == 0) { Gtk.MenuItem mitem = new Gtk.MenuItem (Catalog.GetString("Hide")); mitem.Activated += delegate { Visible = false; }; menu.Append (mitem); } Gtk.MenuItem citem; // Auto Hide menuitem if ((Behavior & DockItemBehavior.CantAutoHide) == 0 && Status != DockItemStatus.AutoHide) { citem = new Gtk.MenuItem (Catalog.GetString("Minimize")); citem.Activated += delegate { Status = DockItemStatus.AutoHide; }; menu.Append (citem); } if (Status != DockItemStatus.Dockable) { // Dockable menuitem citem = new Gtk.MenuItem (Catalog.GetString("Dock")); citem.Activated += delegate { Status = DockItemStatus.Dockable; }; menu.Append (citem); } // Floating menuitem if ((Behavior & DockItemBehavior.NeverFloating) == 0 && Status != DockItemStatus.Floating) { citem = new Gtk.MenuItem (Catalog.GetString("Undock")); citem.Activated += delegate { Status = DockItemStatus.Floating; }; menu.Append (citem); } if (menu.Children.Length == 0) { menu.Destroy (); return; } ShowingContextMemu = true; menu.ShowAll (); menu.Hidden += (o,e) => { ShowingContextMemu = false; }; menu.Popup (null, null, null, 3, time); }
void Update (CommandInfo cmdInfo) { lastCmdInfo = cmdInfo; 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; } label.UseUnderline = true; this.Sensitive = cmdInfo.Enabled; this.Visible = cmdInfo.Visible && (disabledVisible || cmdInfo.Enabled); if (!cmdInfo.Icon.IsNull && cmdInfo.Icon != lastIcon) { Image = new Gtk.Image (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 GroupChatView(GroupChatModel groupChat) : base(groupChat) { Trace.Call(groupChat); _GroupChatModel = groupChat; // person list Participants = new List<PersonModel>(); _OutputHPaned = new Gtk.HPaned(); Gtk.TreeView tv = new Gtk.TreeView(); _PersonTreeView = tv; Gtk.ScrolledWindow sw = new Gtk.ScrolledWindow(); PersonScrolledWindow = sw; sw.ShadowType = Gtk.ShadowType.None; sw.HscrollbarPolicy = Gtk.PolicyType.Never; //tv.CanFocus = false; tv.BorderWidth = 0; tv.Selection.Mode = Gtk.SelectionMode.Multiple; sw.Add(tv); Gtk.TreeViewColumn column; var cellr = new Gtk.CellRendererText() { Ellipsize = Pango.EllipsizeMode.End }; IdentityNameCellRenderer = cellr; column = new Gtk.TreeViewColumn(String.Empty, cellr); column.SortColumnId = 0; column.Spacing = 0; column.SortIndicator = false; column.Expand = true; column.Sizing = Gtk.TreeViewColumnSizing.Autosize; // FIXME: this callback leaks memory column.SetCellDataFunc(cellr, new Gtk.TreeCellDataFunc(RenderPersonIdentityName)); tv.AppendColumn(column); _IdentityNameColumn = column; Gtk.ListStore liststore = new Gtk.ListStore(typeof(PersonModel)); liststore.SetSortColumnId(0, Gtk.SortType.Ascending); liststore.SetSortFunc(0, new Gtk.TreeIterCompareFunc(SortPersonListStore)); _PersonListStore = liststore; tv.Model = liststore; tv.SearchColumn = 0; tv.SearchEqualFunc = (model, col, key, iter) => { var person = (PersonModel) model.GetValue(iter, col); // Ladies and gentlemen welcome to C // 0 means it matched but 0 as bool is false. So if it matches // we have to return false. Still not clear? true is false and // false is true, weirdo! If you think this is retarded, // yes it is. return !person.IdentityName.StartsWith(key, StringComparison.InvariantCultureIgnoreCase); }; tv.EnableSearch = true; tv.HeadersVisible = false; tv.RowActivated += new Gtk.RowActivatedHandler(OnPersonsRowActivated); tv.FocusOutEvent += OnPersonTreeViewFocusOutEvent; // popup menu _PersonMenu = new Gtk.Menu(); // don't loose the focus else we lose the selection too! // see OnPersonTreeViewFocusOutEvent() _PersonMenu.TakeFocus = false; _PersonMenu.Shown += OnPersonMenuShown; _PersonTreeView.ButtonPressEvent += _OnPersonTreeViewButtonPressEvent; _PersonTreeView.KeyPressEvent += OnPersonTreeViewKeyPressEvent; // frame needed for events when selecting something in the treeview _PersonTreeViewFrame = new Gtk.Frame() { ShadowType = Gtk.ShadowType.In }; _PersonTreeViewFrame.ButtonReleaseEvent += new Gtk.ButtonReleaseEventHandler(_OnUserListButtonReleaseEvent); _PersonTreeViewFrame.Add(sw); // topic // don't worry, ApplyConfig() will add us to the OutputVBox! _OutputVBox = new Gtk.VBox() { Spacing = 1 }; _TopicTextView = new MessageTextView(); _TopicTextView.Editable = false; _TopicTextView.WrapMode = Gtk.WrapMode.WordChar; _TopicScrolledWindow = new Gtk.ScrolledWindow(); _TopicScrolledWindow.ShadowType = Gtk.ShadowType.In; _TopicScrolledWindow.HscrollbarPolicy = Gtk.PolicyType.Never; _TopicScrolledWindow.Add(_TopicTextView); // make sure the topic is invisible and remains by default and // visible when a topic gets set _TopicScrolledWindow.ShowAll(); _TopicScrolledWindow.Visible = false; _TopicScrolledWindow.NoShowAll = true; _TopicScrolledWindow.SizeRequested += delegate(object o, Gtk.SizeRequestedArgs args) { // predict and set useful topic heigth int lineWidth, lineHeight; using (var layout = _TopicTextView.CreatePangoLayout("Test Topic")) { layout.GetPixelSize(out lineWidth, out lineHeight); } var lineSpacing = _TopicTextView.PixelsAboveLines + _TopicTextView.PixelsBelowLines; var it = _TopicTextView.Buffer.StartIter; int newLines = 1; // move to end of next visual line while (_TopicTextView.ForwardDisplayLineEnd(ref it)) { newLines++; // calling ForwardDisplayLineEnd repeatedly stays on the same position // therefor we move one cursor position further it.ForwardCursorPosition(); } newLines = Math.Min(newLines, 3); var bestSize = new Gtk.Requisition() { Height = ((lineHeight + lineSpacing) * newLines) + 4 }; args.Requisition = bestSize; }; Add(_OutputHPaned); //ApplyConfig(Frontend.UserConfig); ShowAll(); }
void PopupQuickFixMenu (Gdk.EventButton evt) { var menu = new Gtk.Menu (); var caretOffset = document.Editor.Caret.Offset; Gtk.Menu fixMenu = menu; DomRegion region; var resolveResult = document.GetLanguageItem (caretOffset, out region); if (resolveResult != null) { var possibleNamespaces = MonoDevelop.Refactoring.ResolveCommandHandler.GetPossibleNamespaces (document, resolveResult); bool addUsing = !(resolveResult is AmbiguousTypeResolveResult); if (addUsing) { foreach (string ns_ in possibleNamespaces) { string ns = ns_; var menuItem = new Gtk.MenuItem (GettextCatalog.GetString ("Import Namespace {0}", ns)); menuItem.Activated += delegate { new MonoDevelop.Refactoring.ResolveCommandHandler.AddImport (document, resolveResult, ns, true).Run (); }; menu.Add (menuItem); } } bool resolveDirect = !(resolveResult is UnknownMemberResolveResult); if (resolveDirect) { foreach (string ns in possibleNamespaces) { var menuItem = new Gtk.MenuItem (GettextCatalog.GetString ("Use {0}", ns + "." + document.Editor.GetTextBetween (region.Begin, region.End))); menuItem.Activated += delegate { new MonoDevelop.Refactoring.ResolveCommandHandler.AddImport (document, resolveResult, ns, false).Run (); }; menu.Add (menuItem); } } if (menu.Children.Any () && fixes.Any ()) { fixMenu = new Gtk.Menu (); var menuItem = new Gtk.MenuItem (GettextCatalog.GetString ("Quick Fixes")); menuItem.Submenu = fixMenu; menu.Add (menuItem); } } PopulateFixes (fixMenu); menu.ShowAll (); menu.SelectFirst (true); menuPushed = true; menu.Destroyed += delegate { menuPushed = false; }; var container = (TextEditorContainer)document.Editor.Parent.Parent; var child = (TextEditorContainer.EditorContainerChild)container [this]; GtkWorkarounds.ShowContextMenu (menu, document.Editor.Parent, null, new Gdk.Rectangle (child.X, child.Y + Allocation.Height - (int)document.Editor.VAdjustment.Value, 0, 0)); }
public ChatView(ChatModel chat) { Trace.Call(chat); _ChatModel = chat; IsAutoScrolling = true; MessageTextView tv = new MessageTextView(); _EndMark = tv.Buffer.CreateMark("end", tv.Buffer.EndIter, false); tv.ShowTimestamps = true; tv.ShowMarkerline = true; tv.Editable = false; tv.CursorVisible = true; tv.WrapMode = Gtk.WrapMode.Char; tv.MessageAdded += OnMessageTextViewMessageAdded; tv.MessageHighlighted += OnMessageTextViewMessageHighlighted; tv.PopulatePopup += OnMessageTextViewPopulatePopup; tv.SizeRequested += delegate { AutoScroll(); }; tv.PersonClicked += OnMessageTextViewPersonClicked; _OutputMessageTextView = tv; Gtk.ScrolledWindow sw = new Gtk.ScrolledWindow(); _OutputScrolledWindow = sw; //sw.HscrollbarPolicy = Gtk.PolicyType.Never; sw.HscrollbarPolicy = Gtk.PolicyType.Automatic; sw.VscrollbarPolicy = Gtk.PolicyType.Always; sw.ShadowType = Gtk.ShadowType.In; sw.Vadjustment.ValueChanged += OnVadjustmentValueChanged; sw.Add(_OutputMessageTextView); // popup menu _TabMenu = new Gtk.Menu(); _TabMenu.Shown += OnTabMenuShown; //FocusChild = _OutputTextView; //CanFocus = false; _TabLabel = new Gtk.Label(); TabImage = DefaultTabImage; _TabHBox = new Gtk.HBox(); _TabHBox.PackEnd(new Gtk.Fixed(), true, true, 0); _TabHBox.PackEnd(_TabLabel, false, false, 0); _TabHBox.PackStart(TabImage, false, false, 2); _TabHBox.ShowAll(); _TabEventBox = new Gtk.EventBox(); _TabEventBox.VisibleWindow = false; _TabEventBox.ButtonPressEvent += new Gtk.ButtonPressEventHandler(OnTabButtonPress); _TabEventBox.Add(_TabHBox); _TabEventBox.ShowAll(); _ThemeSettings = new ThemeSettings(); // OPT-TODO: this should use a TaskStack instead of TaskQueue _LastSeenHighlightQueue = new TaskQueue("LastSeenHighlightQueue("+ID+")"); _LastSeenHighlightQueue.AbortedEvent += OnLastSeenHighlightQueueAbortedEvent; _LastSeenHighlightQueue.ExceptionEvent += OnLastSeenHighlightQueueExceptionEvent; }
private void BuildMenu() { menu = new Gtk.Menu (); menu.Deactivated += OnMenuDeactivated; }
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; }
static Gtk.Menu FromMenu (ContextMenu menu) { var result = new Gtk.Menu (); foreach (var menuItem in menu.Items) { var item = CreateMenuItem (menuItem); if (item != null) result.Append (item); } return result; }
public void ShowContextMenu(ActionItem aitem) { ActionMenuItem menuItem = (ActionMenuItem) aitem; Gtk.Menu m = new Gtk.Menu (); Gtk.MenuItem item = new Gtk.MenuItem (Catalog.GetString ("Insert Before")); m.Add (item); item.Activated += delegate (object s, EventArgs a) { InsertActionAt (menuItem, false, false); }; item = new Gtk.MenuItem (Catalog.GetString ("Insert After")); m.Add (item); item.Activated += delegate (object s, EventArgs a) { InsertActionAt (menuItem, true, false); }; m.Add (new Gtk.SeparatorMenuItem ()); item = new Gtk.ImageMenuItem (Gtk.Stock.Cut, null); m.Add (item); item.Activated += delegate (object s, EventArgs a) { menuItem.Cut (); }; item.Visible = false; // No copy & paste for now item = new Gtk.ImageMenuItem (Gtk.Stock.Copy, null); m.Add (item); item.Activated += delegate (object s, EventArgs a) { menuItem.Copy (); }; item.Visible = false; // No copy & paste for now item = new Gtk.ImageMenuItem (Gtk.Stock.Paste, null); m.Add (item); item.Activated += delegate (object s, EventArgs a) { Paste (menuItem); }; item.Visible = false; // No copy & paste for now item = new Gtk.ImageMenuItem (Gtk.Stock.Delete, null); m.Add (item); item.Activated += delegate (object s, EventArgs a) { menuItem.Delete (); }; m.ShowAll (); m.Popup (); }
void PopupQuickFixMenu (Gdk.EventButton evt) { var menu = new Gtk.Menu (); Gtk.Menu fixMenu = menu; ResolveResult resolveResult; ICSharpCode.NRefactory.CSharp.AstNode node; int items = 0; if (ResolveCommandHandler.ResolveAt (document, out resolveResult, out node)) { var possibleNamespaces = MonoDevelop.Refactoring.ResolveCommandHandler.GetPossibleNamespaces ( document, node, ref resolveResult ); bool addUsing = !(resolveResult is AmbiguousTypeResolveResult); if (addUsing) { foreach (var t in possibleNamespaces.Where (tp => tp.Item2)) { string ns = t.Item1; var menuItem = new Gtk.MenuItem (string.Format ("using {0};", ns)); menuItem.Activated += delegate { new MonoDevelop.Refactoring.ResolveCommandHandler.AddImport (document, resolveResult, ns, true, node).Run (); menu.Destroy (); }; menu.Add (menuItem); items++; } } bool resolveDirect = !(resolveResult is UnknownMemberResolveResult); if (resolveDirect) { foreach (var t in possibleNamespaces) { string ns = t.Item1; var menuItem = new Gtk.MenuItem (GettextCatalog.GetString ("{0}", ns + "." + document.Editor.GetTextBetween (node.StartLocation, node.EndLocation))); menuItem.Activated += delegate { new MonoDevelop.Refactoring.ResolveCommandHandler.AddImport (document, resolveResult, ns, false, node).Run (); menu.Destroy (); }; menu.Add (menuItem); items++; } } if (menu.Children.Any () && fixes.Any ()) { fixMenu = new Gtk.Menu (); var menuItem = new Gtk.MenuItem (GettextCatalog.GetString ("Quick Fixes")); menuItem.Submenu = fixMenu; menu.Add (menuItem); items++; } } PopulateFixes (fixMenu, ref items); if (items == 0) { menu.Destroy (); return; } document.Editor.SuppressTooltips = true; document.Editor.Parent.HideTooltip (); menu.ShowAll (); menu.SelectFirst (true); menuPushed = true; menu.Hidden += delegate { document.Editor.SuppressTooltips = false; }; menu.Destroyed += delegate { menuPushed = false; Hide (); }; var container = document.Editor.Parent; var child = (TextEditor.EditorContainerChild)container [this]; Gdk.Rectangle rect; /* if (child != null) { rect = new Gdk.Rectangle (child.X, child.Y + Allocation.Height - (int)document.Editor.VAdjustment.Value, 0, 0); } else {*/ var p = container.LocationToPoint (loc); rect = new Gdk.Rectangle (p.X + container.Allocation.X , p.Y + (int)document.Editor.LineHeight + container.Allocation.Y, 0, 0); //} GtkWorkarounds.ShowContextMenu (menu, document.Editor.Parent, null, rect); }
/// <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; }
/// <summary> /// Loads plugin. /// </summary> public void Load() { this.rootWindow = Global.DefaultRootWindow; this.architecture = Stuff.Architecture(); this.submenu = new Gtk.Menu(); Gtk.MenuItem mi = new Gtk.MenuItem(Catalog.GetString("_Take region screenshot")); this.submenu.Append(mi); mi.Activated += (s, e) => this.TakeRegionScreenshot(); mi.ButtonPressEvent += (s, e) => this.TakeRegionScreenshot(); mi = new Gtk.MenuItem(Catalog.GetString("Take screenshot of _entire screen")); this.submenu.Append(mi); mi.Activated += (s, e) => this.TakeScreenScreenshot(); mi.ButtonPressEvent += (s, e) => this.TakeScreenScreenshot(); mi = new Gtk.MenuItem(Catalog.GetString("_Pick color")); this.submenu.Append(mi); mi.Activated += (s, e) => this.PickColor(); mi.ButtonPressEvent += (s, e) => this.PickColor(); }
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; }