当前位置: 首页>>代码示例>>C#>>正文


C# Gtk.Menu.ShowAll方法代码示例

本文整理汇总了C#中Gtk.Menu.ShowAll方法的典型用法代码示例。如果您正苦于以下问题:C# Gtk.Menu.ShowAll方法的具体用法?C# Gtk.Menu.ShowAll怎么用?C# Gtk.Menu.ShowAll使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Gtk.Menu的用法示例。


在下文中一共展示了Gtk.Menu.ShowAll方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: OnNoteOpened

		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);
		}
开发者ID:MichaelAquilina,项目名称:tomboy,代码行数:13,代码来源:BacklinksNoteAddin.cs

示例2: Run

		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);
			}
		}
开发者ID:FreeBSD-DotNet,项目名称:monodevelop,代码行数:43,代码来源:QuickFixHandler.cs

示例3: OnPopupMenu

        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;
        }
开发者ID:nailyk,项目名称:banshee-community-extensions,代码行数:42,代码来源:CS_AlbumListView.cs

示例4: OnNoteOpened

		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;
		}
开发者ID:MichaelAquilina,项目名称:tomboy,代码行数:22,代码来源:TasqueNoteAddin.cs

示例5: ShowPopup

        private void ShowPopup()
        {
            if ((presets == null) || (presets.Length == 0))
                return;

            EventHandler onActivated = delegate(object sender, EventArgs e) {
                Gtk.MenuItem item = (Gtk.MenuItem)sender;

                SetPlaceholderText(false);

                if (Text.Length > 0) {
                    if ((!Text.TrimEnd().EndsWith(" or")) && (!Text.TrimEnd().EndsWith(" OR")) &&
                        (!Text.TrimEnd().EndsWith(" and")) && (!Text.TrimEnd().EndsWith(" AND"))) {

                        if (!Text.EndsWith(" "))
                            Text += " ";

                        Text += "and ";
                    } else {
                        if (!Text.EndsWith(" "))
                            Text += " ";
                    }
                }

                var p = (SearchEntryPreset)item.Data["preset"];

                if (!string.IsNullOrEmpty(p.Value)) {
                    Text += p.Value;

                    if (!string.IsNullOrEmpty(p.Suggestion)) {
                        Text += " " + p.Suggestion;

                        GrabFocus();
                        SelectRegion(Text.Length - p.Suggestion.Length, Text.Length);
                    } else {
                        GrabFocus();
                        SelectRegion(Text.Length, Text.Length);
                    }
                }
            };

            if (presetsChanged) {

                if (popup != null)
                    popup.Dispose();

                popup = new Gtk.Menu();

                foreach (var p in presets) {
                    Gtk.MenuItem item = new Gtk.MenuItem(p.Caption);
                    item.Activated += onActivated;
                    item.Data["preset"] = p;

                    popup.Append(item);
                }

                popup.ShowAll();
                presetsChanged = false;
            }

            popup.Popup();
        }
开发者ID:pulb,项目名称:basenji,代码行数:62,代码来源:SearchEntry.cs

示例6: UpdateRoutesButton

 void UpdateRoutesButton()
 {
     var menu = new Gtk.Menu();
     foreach(var route in routesAtDay)
     {
         var name = String.Format("МЛ №{0} - {1}", route.Id, route.Driver.ShortName);
         var item = new MenuItemId<RouteList>(name);
         item.ID = route;
         item.Activated += AddToRLItem_Activated;
         menu.Append(item);
     }
     menu.ShowAll();
     menuAddToRL.Menu = menu;
 }
开发者ID:QualitySolution,项目名称:Vodovoz,代码行数:14,代码来源:RoutesAtDayDlg.cs

示例7: OnStatusIconPopupMenu

        private static void OnStatusIconPopupMenu(object sender, EventArgs e)
        {
            Trace.Call(sender, e);

            Gtk.Menu menu = new Gtk.Menu();

            Gtk.ImageMenuItem preferencesItem = new Gtk.ImageMenuItem(Gtk.Stock.Preferences, null);
            preferencesItem.Activated += delegate {
                try {
                    PreferencesDialog dialog = new PreferencesDialog(_MainWindow);
                    dialog.CurrentPage = PreferencesDialog.Page.Interface;
                    dialog.CurrentInterfacePage = PreferencesDialog.InterfacePage.Notification;
                } catch (Exception ex) {
                    ShowException(ex);
                }
            };
            menu.Add(preferencesItem);

            menu.Add(new Gtk.SeparatorMenuItem());

            Gtk.ImageMenuItem quitItem = new Gtk.ImageMenuItem(Gtk.Stock.Quit, null);
            quitItem.Activated += delegate {
                try {
                    Quit();
                } catch (Exception ex) {
                    ShowException(ex);
                }
            };
            menu.Add(quitItem);

            menu.ShowAll();
            menu.Popup();
        }
开发者ID:RoninBG,项目名称:smuxi,代码行数:33,代码来源:Frontend.cs

示例8: BuildPopup

 private void BuildPopup()
 {
     popup = new Gtk.Menu();
     popup.Append( this.actAdd.CreateMenuItem() );
     popup.Append( this.actRemove.CreateMenuItem() );
     popup.Append( this.actModify.CreateMenuItem() );
     popup.Append( this.actSettings.CreateMenuItem() );
     popup.ShowAll();
 }
开发者ID:Baltasarq,项目名称:Tacto,代码行数:9,代码来源:MainWindowView.cs

示例9: PopulateAlbums

        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 ();
        }
开发者ID:Yetangitu,项目名称:f-spot,代码行数:22,代码来源:GalleryAddAlbum.cs

示例10: OnSelectIcon

		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;
		}
开发者ID:Kalnor,项目名称:monodevelop,代码行数:39,代码来源:ActionMenuItem.cs

示例11: PopupQuickFixMenu

		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 ();
			};
		}
开发者ID:yayanyang,项目名称:monodevelop,代码行数:43,代码来源:ContextActionWidget.cs

示例12: GetRightClickMenu

		Gtk.Menu GetRightClickMenu ()
		{
			if (tray.TomboyTrayMenu != null)
				tray.TomboyTrayMenu.Hide ();

			if (context_menu != null) {
				context_menu.Hide ();
				return context_menu;
			}

			context_menu = new Gtk.Menu ();

			Gtk.AccelGroup accel_group = new Gtk.AccelGroup ();
			context_menu.AccelGroup = accel_group;

			Gtk.ImageMenuItem item;

			sync_menu_item = new Gtk.ImageMenuItem (Catalog.GetString ("S_ynchronize Notes"));
			sync_menu_item.Image = new Gtk.Image (Gtk.Stock.Convert, Gtk.IconSize.Menu);
			UpdateMenuItems();
			Preferences.SettingChanged += Preferences_SettingChanged;
			sync_menu_item.Activated += SyncNotes;
			context_menu.Append (sync_menu_item);

			context_menu.Append (new Gtk.SeparatorMenuItem ());

			item = new Gtk.ImageMenuItem (Catalog.GetString ("_Preferences"));
			item.Image = new Gtk.Image (Gtk.Stock.Preferences, Gtk.IconSize.Menu);
			item.Activated += ShowPreferences;
			context_menu.Append (item);

			item = new Gtk.ImageMenuItem (Catalog.GetString ("_Help"));
			item.Image = new Gtk.Image (Gtk.Stock.Help, Gtk.IconSize.Menu);
			item.Activated += ShowHelpContents;
			context_menu.Append (item);

			item = new Gtk.ImageMenuItem (Catalog.GetString ("_About Tomboy"));
			item.Image = new Gtk.Image (Gtk.Stock.About, Gtk.IconSize.Menu);
			item.Activated += ShowAbout;
			context_menu.Append (item);

			context_menu.Append (new Gtk.SeparatorMenuItem ());

			item = new Gtk.ImageMenuItem (Catalog.GetString ("_Quit"));
			item.Image = new Gtk.Image (Gtk.Stock.Quit, Gtk.IconSize.Menu);
			item.Activated += Quit;
			context_menu.Append (item);

			context_menu.ShowAll ();
			return context_menu;
		}
开发者ID:MichaelAquilina,项目名称:tomboy,代码行数:51,代码来源:Tray.cs

示例13: ShowContextMenu

        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 ();
        }
开发者ID:mono,项目名称:stetic,代码行数:44,代码来源:ActionMenuBar.cs

示例14: PopupContextMenu

        // HERZUM SPRINT 2.3 TLAB-56 TLAB-57 TLAB-58 TLAB-59
        /*
        private void PopupContextMenu(IPrimaryToolDelegator mainTool, IDrawingEditor editor, ITool dt, MouseEvent ev)
        {
            m_contextMenu = new Gtk.Menu();
            Gtk.MenuItem editLabel = new Gtk.MenuItem("Edit label");

            editLabel.Activated += delegate(object sender, EventArgs e) 
            {
                SimpleTextTool textTool = new SimpleTextTool(editor, this, dt, ev);
                mainTool.DelegateTool = textTool;
                textTool.StartEditing();
            };
    
            m_contextMenu.Add(editLabel);
            m_contextMenu.ShowAll();

            m_contextMenu.Popup();
        }
        */

        private void PopupContextMenu(IPrimaryToolDelegator mainTool, IDrawingEditor editor, ITool dt, MouseEvent ev)
        {
            m_contextMenu = new Gtk.Menu();
            Gtk.MenuItem editLabel = new Gtk.MenuItem("Edit label");
            Gtk.MenuItem copy = new Gtk.MenuItem("Copy");
            Gtk.MenuItem cut = new Gtk.MenuItem("Cut");
            // Gtk.MenuItem paste = new Gtk.MenuItem("Paste");

            editLabel.Activated += delegate(object sender, EventArgs e) 
            {
                SimpleTextTool textTool = new SimpleTextTool(editor, this, dt, ev);
                mainTool.DelegateTool = textTool;
                textTool.StartEditing();
            };

            copy.Activated += delegate(object sender, EventArgs e) 
            {
                Clipboard.Copy(ExperimentNode.Owner as BaseExperiment);
            };

            cut.Activated += delegate(object sender, EventArgs e) 
            {
                Clipboard.Cut(ExperimentNode.Owner as BaseExperiment);
            };

            /*
            paste.Activated += delegate(object sender, EventArgs e) 
            {
                Clipboard.Paste(ExperimentNode.Owner as BaseExperiment);
                ExperimentCanvasPad ecp = ExperimentCanvasPadFactory.GetExperimentCanvasPad(m_applicationContext, this);
                ecp.DisplayAddedSubgraph(ExperimentNode.Owner as BaseExperiment); 
            };
            */

            m_contextMenu.Add(editLabel);
            m_contextMenu.Add(copy);
            m_contextMenu.Add(cut);
            // m_contextMenu.Add(paste);
            m_contextMenu.ShowAll();

            m_contextMenu.Popup();
        }
开发者ID:CoEST,项目名称:TraceLab,代码行数:63,代码来源:ComponentControl.cs

示例15: ContextMenu


//.........这里部分代码省略.........
				MenuItem mnuViewSource = new MenuItem("View Source");
				mnuViewSource.Enabled = !string.IsNullOrEmpty(viewSourceUrl);
				mnuViewSource.Click += delegate { ViewSource(viewSourceUrl); };

				MenuItem mnuOpenInSystemBrowser = new MenuItem("View In System Browser");//nice for debugging with firefox/firebug
				mnuOpenInSystemBrowser.Enabled = !string.IsNullOrEmpty(viewSourceUrl);
				mnuOpenInSystemBrowser.Click += delegate { ViewInSystemBrowser(viewSourceUrl); };


				string properties = (doc != null && doc.Uri == Document.Uri) ? "Page Properties" : "IFRAME Properties";
				
				MenuItem mnuProperties = new MenuItem(properties);
				mnuProperties.Enabled = doc != null;
				mnuProperties.Click += delegate { ShowPageProperties(doc); };
				
				menu.MenuItems.AddRange(optionals.ToArray());
				menu.MenuItems.Add(mnuSelectAll);
				menu.MenuItems.Add("-");
				menu.MenuItems.Add(mnuViewSource);
				menu.MenuItems.Add(mnuOpenInSystemBrowser);
				menu.MenuItems.Add(mnuProperties);
			}

			// get image urls
			Uri backgroundImageSrc = null, imageSrc = null;
			nsIURI src;
			try
			{
				src = info.GetBackgroundImageSrcAttribute();
				backgroundImageSrc = src.ToUri();
				Marshal.ReleaseComObject( src );
			}
			catch (COMException comException)
			{
				if ((comException.ErrorCode & 0xFFFFFFFF) != 0x80004005)
					throw comException;
			}

			try
			{
				src = info.GetImageSrcAttribute();
				if ( src != null )
				{
					imageSrc = src.ToUri();
					Marshal.ReleaseComObject( src );
				}
			}
			catch (COMException comException)
			{
				if ((comException.ErrorCode & 0xFFFFFFFF) != 0x80004005)
					throw comException;
			}
			
			// get associated link.  note that this needs to be done manually because GetAssociatedLink returns a non-zero
			// result when no associated link is available, so an exception would be thrown by nsString.Get()
			string associatedLink = null;
			try
			{
				using (nsAString str = new nsAString())
				{
					info.GetAssociatedLinkAttribute(str);
					associatedLink = str.ToString();
				}
			}
			catch (COMException comException) { }			
			
			GeckoContextMenuEventArgs e = new GeckoContextMenuEventArgs(
				PointToClient(MousePosition), menu, associatedLink, backgroundImageSrc, imageSrc,
				GeckoNode.Create(Xpcom.QueryInterface<nsIDOMNode>(info.GetTargetNodeAttribute()))
				);
			
			OnShowContextMenu(e);
			
			if (e.ContextMenu != null && e.ContextMenu.MenuItems.Count > 0)
			{
#if GTK
				// When using GTK we can't use SWF to display the context menu: SWF displays
				// the context menu and then tries to track the mouse so that it knows when to
				// close the context menu. However, GTK intercepts the mouse click before SWF gets
				// it, so the menu never closes. Instead we display a GTK menu and translate
				// the SWF menu items into Gtk.MenuItems.
				// TODO: currently this code only handles text menu items. Would be nice to also
				// translate images etc.
				var popupMenu = new Gtk.Menu();

				foreach (MenuItem swfMenuItem in e.ContextMenu.MenuItems)
				{
					var gtkMenuItem = new Gtk.MenuItem(swfMenuItem.Text);
					gtkMenuItem.Sensitive = swfMenuItem.Enabled;
					MenuItem origMenuItem = swfMenuItem;
					gtkMenuItem.Activated += (sender, ev) => origMenuItem.PerformClick();
					popupMenu.Append(gtkMenuItem);
				}
				popupMenu.ShowAll();
				popupMenu.Popup();
#else
				e.ContextMenu.Show(this, e.Location);
#endif
			}
		}
开发者ID:RSchwoerer,项目名称:Terminals,代码行数:101,代码来源:GeckoWebBrowser.cs


注:本文中的Gtk.Menu.ShowAll方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。