Fix a critical error invoking popup on conversation list.
* src/client/conversation-list/conversation-list-view.vala, src/client/conversation-viewer/conversation-message.vala, src/client/sidebar/sidebar-tree.vala (TreeView): Use Gtk.Menu.popup_at_pointer() rather than deprecated popup() method. * src/client/util/util-gtk.vala (GtkUtil): Remove unused menu-related code.
This commit is contained in:
parent
b6980a2f37
commit
8afca7fb2e
4 changed files with 7 additions and 85 deletions
|
|
@ -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);
|
||||
|
|
|
|||
|
|
@ -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;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -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);
|
||||
|
|
|
|||
|
|
@ -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<weak Gtk.Widget> 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.)
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue