diff options
author | Michael Hutchinson <m.j.hutchinson@gmail.com> | 2011-11-05 03:51:33 +0400 |
---|---|---|
committer | Michael Hutchinson <m.j.hutchinson@gmail.com> | 2011-11-05 03:54:47 +0400 |
commit | 6aa38445e196e023fccbbfccbebc88fdf9774eed (patch) | |
tree | 184d3e0cde7f16666c1b546d4bf601001937d309 /extras | |
parent | 11acfca41a3b9d05833f4e17fbc074661ecf09fe (diff) |
[AddinAuthoring] Port to context menu API
Diffstat (limited to 'extras')
3 files changed, 37 insertions, 17 deletions
diff --git a/extras/MonoDevelop.AddinAuthoring/MonoDevelop.AddinAuthoring/ExtensionEditorWidget.cs b/extras/MonoDevelop.AddinAuthoring/MonoDevelop.AddinAuthoring/ExtensionEditorWidget.cs index d2868ed74a..9f9a953464 100644 --- a/extras/MonoDevelop.AddinAuthoring/MonoDevelop.AddinAuthoring/ExtensionEditorWidget.cs +++ b/extras/MonoDevelop.AddinAuthoring/MonoDevelop.AddinAuthoring/ExtensionEditorWidget.cs @@ -42,6 +42,14 @@ namespace MonoDevelop.AddinAuthoring { this.Build(); + //FIXME: avoid unnecessary creation of old treeview + scrolledwindow6.Remove (tree); + tree.Destroy (); + tree = new ContextMenuTreeView (); + tree.ShowAll (); + scrolledwindow6.Add (tree); + ((ContextMenuTreeView)tree).DoPopupMenu = ShowPopupMenu; + pixAddin = ImageService.GetPixbuf (MonoDevelop.Ide.Gui.Stock.Addin, IconSize.Menu); pixLocalAddin = ImageService.GetPixbuf ("md-addinauthoring-current-addin", IconSize.Menu); pixExtensionPoint = ImageService.GetPixbuf ("md-extension-point", IconSize.Menu); @@ -126,7 +134,7 @@ namespace MonoDevelop.AddinAuthoring state.Load (); } - void ShowPopupMenu () + void ShowPopupMenu (Gdk.EventButton evt) { TreeIter it; if (!tree.Selection.GetSelected (out it)) @@ -148,7 +156,7 @@ namespace MonoDevelop.AddinAuthoring mi.Activated += delegate { DeleteSelection (); }; menu.ShowAll (); - menu.Popup (); + GtkWorkarounds.ShowContextMenu (menu, tree, evt); } void PopulateNodeTypes (Gtk.Menu menu, TreeIter it) @@ -419,17 +427,6 @@ namespace MonoDevelop.AddinAuthoring currentEditor = null; } } - - protected virtual void OnTreePopupMenu(object o, Gtk.PopupMenuArgs args) - { - ShowPopupMenu (); - } - - protected virtual void OnTreeButtonReleaseEvent(object o, Gtk.ButtonReleaseEventArgs args) - { - if (args.Event.Button == 3) - ShowPopupMenu (); - } protected virtual void OnButtonRemoveClicked(object sender, System.EventArgs e) { @@ -456,5 +453,32 @@ namespace MonoDevelop.AddinAuthoring y += addNodeButton.Allocation.Bottom; pushIn = true; } + + //FIXME: this should be a re-usable class in MonoDevelop.Ide + class ContextMenuTreeView : Gtk.TreeView + { + public Action<Gdk.EventButton> DoPopupMenu { get; set; } + + protected override bool OnButtonPressEvent (Gdk.EventButton evnt) + { + bool res = base.OnButtonPressEvent (evnt); + + if (DoPopupMenu != null && Mono.TextEditor.GtkWorkarounds.TriggersContextMenu (evnt)) { + DoPopupMenu (evnt); + return true; + } + + return res; + } + + protected override bool OnPopupMenu () + { + if (DoPopupMenu != null) { + DoPopupMenu (null); + return true; + } + return base.OnPopupMenu (); + } + } } } diff --git a/extras/MonoDevelop.AddinAuthoring/gtk-gui/MonoDevelop.AddinAuthoring.ExtensionEditorWidget.cs b/extras/MonoDevelop.AddinAuthoring/gtk-gui/MonoDevelop.AddinAuthoring.ExtensionEditorWidget.cs index 4aef6d9537..728cff8542 100644 --- a/extras/MonoDevelop.AddinAuthoring/gtk-gui/MonoDevelop.AddinAuthoring.ExtensionEditorWidget.cs +++ b/extras/MonoDevelop.AddinAuthoring/gtk-gui/MonoDevelop.AddinAuthoring.ExtensionEditorWidget.cs @@ -176,8 +176,6 @@ namespace MonoDevelop.AddinAuthoring this.buttonAdd.Clicked += new global::System.EventHandler (this.OnButtonAddClicked); this.addNodeButton.Pressed += new global::System.EventHandler (this.OnAddNodeButtonPressed); this.buttonRemove.Clicked += new global::System.EventHandler (this.OnButtonRemoveClicked); - this.tree.PopupMenu += new global::Gtk.PopupMenuHandler (this.OnTreePopupMenu); - this.tree.ButtonReleaseEvent += new global::Gtk.ButtonReleaseEventHandler (this.OnTreeButtonReleaseEvent); } } } diff --git a/extras/MonoDevelop.AddinAuthoring/gtk-gui/gui.stetic b/extras/MonoDevelop.AddinAuthoring/gtk-gui/gui.stetic index bea15584b8..c4a20cf04a 100644 --- a/extras/MonoDevelop.AddinAuthoring/gtk-gui/gui.stetic +++ b/extras/MonoDevelop.AddinAuthoring/gtk-gui/gui.stetic @@ -1024,8 +1024,6 @@ <widget class="Gtk.TreeView" id="tree"> <property name="MemberName" /> <property name="CanFocus">True</property> - <signal name="PopupMenu" handler="OnTreePopupMenu" /> - <signal name="ButtonReleaseEvent" handler="OnTreeButtonReleaseEvent" /> </widget> </child> </widget> |