diff --git a/src/client/conversation-list/conversation-list-view.vala b/src/client/conversation-list/conversation-list-view.vala index abacb34e..3c7d6ec6 100644 --- a/src/client/conversation-list/conversation-list-view.vala +++ b/src/client/conversation-list/conversation-list-view.vala @@ -307,8 +307,7 @@ public class ConversationListView : Gtk.TreeView { Gtk.Menu context_menu = new Gtk.Menu.from_model(context_menu_model); context_menu.insert_action_group("win", this.main_window); - context_menu.show_all(); - context_menu.popup(null, null, null, event.button, event.time); + context_menu.popup_at_pointer(event); // When the conversation under the mouse is selected, stop event propagation return get_selection().path_is_selected(path); diff --git a/src/client/conversation-viewer/conversation-message.vala b/src/client/conversation-viewer/conversation-message.vala index fd16bc75..76b0a02e 100644 --- a/src/client/conversation-viewer/conversation-message.vala +++ b/src/client/conversation-viewer/conversation-message.vala @@ -859,7 +859,7 @@ public class ConversationMessage : Gtk.Grid { this.context_menu = new Gtk.Menu.from_model(model); this.context_menu.attach_to_widget(this, null); - this.context_menu.popup(null, null, null, 0, event.get_time()); + this.context_menu.popup_at_pointer(event); return true; } diff --git a/src/client/sidebar/sidebar-tree.vala b/src/client/sidebar/sidebar-tree.vala index cecfc405..7136f2fe 100644 --- a/src/client/sidebar/sidebar-tree.vala +++ b/src/client/sidebar/sidebar-tree.vala @@ -832,22 +832,17 @@ public class Sidebar.Tree : Gtk.TreeView { Gtk.Menu? context_menu = contextable.get_sidebar_context_menu(event); if (context_menu == null) return false; - - if (event != null) - context_menu.popup(null, null, null, event.button, event.time); - else - context_menu.popup(null, null, null, 0, Gtk.get_current_event_time()); - + + context_menu.popup_at_pointer(event); return true; } - + private bool popup_default_context_menu(Gdk.EventButton event) { if (default_context_menu != null) - default_context_menu.popup(null, null, null, event.button, event.time); - + default_context_menu.popup_at_pointer(event); return true; } - + public bool on_toggle_row(Gtk.TreeIter iter, Gtk.TreePath path) { // Determine whether to allow the row to toggle EntryWrapper? wrapper = get_wrapper_at_iter(iter); diff --git a/src/client/util/util-gtk.vala b/src/client/util/util-gtk.vala index 489d217e..f07dff79 100644 --- a/src/client/util/util-gtk.vala +++ b/src/client/util/util-gtk.vala @@ -6,78 +6,6 @@ namespace GtkUtil { -// Use this MenuPositionFunc to position a popup menu relative to a widget -// with Gtk.Menu.popup(). -// -// You *must* attach the button widget with Gtk.Menu.attach_to_widget() before -// this function can be used. -public void menu_popup_relative(Gtk.Menu menu, out int x, out int y, out bool push_in) { - menu.realize(); - - int rx, ry; - menu.get_attach_widget().get_window().get_origin(out rx, out ry); - - Gtk.Allocation menu_button_allocation; - menu.get_attach_widget().get_allocation(out menu_button_allocation); - - x = rx + menu_button_allocation.x; - y = ry + menu_button_allocation.y + menu_button_allocation.height; - - push_in = false; -} - -public void add_proxy_menu(Gtk.ToolItem tool_item, string label, Gtk.Menu proxy_menu) { - Gtk.MenuItem proxy_menu_item = new Gtk.MenuItem.with_label(label); - proxy_menu_item.submenu = proxy_menu; - tool_item.create_menu_proxy.connect((sender) => { - sender.set_proxy_menu_item("proxy", proxy_menu_item); - return true; - }); -} - -public void show_menuitem_accel_labels(Gtk.Widget widget) { - Gtk.MenuItem? item = widget as Gtk.MenuItem; - if (item == null) { - return; - } - - string? path = item.get_accel_path(); - if (path == null) { - return; - } - Gtk.AccelKey? key = null; - Gtk.AccelMap.lookup_entry(path, out key); - if (key == null) { - return; - } - item.foreach( - (widget) => { add_accel_to_label(widget, key); } - ); -} - -private void add_accel_to_label(Gtk.Widget widget, Gtk.AccelKey key) { - Gtk.AccelLabel? label = widget as Gtk.AccelLabel; - if (label == null) { - return; - } - - // We should check for (key.accel_flags & Gtk.AccelFlags.VISIBLE) before - // running the following code. However, there appears to be some - // funny business going on because key.accel_flags always turns up as 0, - // even though we explicitly set it to Gtk.AccelFlags.VISIBLE before. - label.set_accel(key.accel_key, key.accel_mods); - label.refetch(); -} - -/** - * Removes all items from a menu. - */ -public void clear_menu(Gtk.Menu menu) { - GLib.List children = menu.get_children(); - foreach (weak Gtk.Widget child in children) - menu.remove(child); -} - /** * Given an HTML-style color spec, parses the color and sets it to the source RGB of the Cairo context. * (Borrowed from Shotwell.)