diff options
author | Michael Hutchinson <m.j.hutchinson@gmail.com> | 2011-11-05 03:19:42 +0400 |
---|---|---|
committer | Michael Hutchinson <m.j.hutchinson@gmail.com> | 2011-11-05 03:54:46 +0400 |
commit | a06b1be4e0e4fa82b01e100a8fa69d2f3204559f (patch) | |
tree | 0b0cf32732636b0790fb7d1a662e25c5d1570c9c /main/src/addins/MonoDevelop.Gettext/MonoDevelop.Gettext.Editor/POEditorWidget.cs | |
parent | 0916cdc6622ba836b6743ff6170053349026d7e6 (diff) |
[Gettext] Port to context menu API
Diffstat (limited to 'main/src/addins/MonoDevelop.Gettext/MonoDevelop.Gettext.Editor/POEditorWidget.cs')
-rw-r--r-- | main/src/addins/MonoDevelop.Gettext/MonoDevelop.Gettext.Editor/POEditorWidget.cs | 50 |
1 files changed, 38 insertions, 12 deletions
diff --git a/main/src/addins/MonoDevelop.Gettext/MonoDevelop.Gettext.Editor/POEditorWidget.cs b/main/src/addins/MonoDevelop.Gettext/MonoDevelop.Gettext.Editor/POEditorWidget.cs index b45dfefa45..4871063aff 100644 --- a/main/src/addins/MonoDevelop.Gettext/MonoDevelop.Gettext.Editor/POEditorWidget.cs +++ b/main/src/addins/MonoDevelop.Gettext/MonoDevelop.Gettext.Editor/POEditorWidget.cs @@ -96,6 +96,15 @@ namespace MonoDevelop.Gettext { this.project = project; this.Build (); + + //FIXME: avoid unnecessary creation of old treeview + scrolledwindow1.Remove (treeviewEntries); + treeviewEntries.Destroy (); + treeviewEntries = new ContextMenuTreeView (); + treeviewEntries.ShowAll (); + scrolledwindow1.Add (treeviewEntries); + ((ContextMenuTreeView)treeviewEntries).DoPopupMenu = ShowPopup; + this.headersEditor = new CatalogHeadersWidget (); this.notebookPages.AppendPage (headersEditor, new Gtk.Label ()); @@ -221,15 +230,6 @@ namespace MonoDevelop.Gettext UpdateProgressBar (); }; - this.treeviewEntries.PopupMenu += delegate { - ShowPopup (); - }; - - this.treeviewEntries.ButtonReleaseEvent += delegate(object sender, Gtk.ButtonReleaseEventArgs e) { - if (e.Event.Button == 3) - ShowPopup (); - }; - searchEntryFilter.Ready = true; searchEntryFilter.Visible = true; searchEntryFilter.ForceFilterButtonVisible = true; @@ -519,11 +519,11 @@ namespace MonoDevelop.Gettext this.notebookTranslated.AppendPage (window, label); } - void ShowPopup () + void ShowPopup (EventButton evt) { Gtk.Menu contextMenu = CreateContextMenu (); if (contextMenu != null) - contextMenu.Popup (); + GtkWorkarounds.ShowContextMenu (contextMenu, this, evt); } Gtk.Menu CreateContextMenu () @@ -1287,5 +1287,31 @@ namespace MonoDevelop.Gettext } } #endregion + + 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 && evnt.TriggersContextMenu ()) { + DoPopupMenu (evnt); + return true; + } + + return res; + } + + protected override bool OnPopupMenu () + { + if (DoPopupMenu != null) { + DoPopupMenu (null); + return true; + } + return base.OnPopupMenu (); + } + } } -} +}
\ No newline at end of file |