From 366b10f07bd1a0a332eba5cfc46e94e928b319d7 Mon Sep 17 00:00:00 2001 From: Calum Lind Date: Wed, 19 Sep 2018 11:07:52 +0100 Subject: [PATCH] [GTK3] Fix displaying column popup menu Right-clicking on column header resulted in this error: TypeError: could not convert type EventButton to GdkEvent required for parameter 0 The following fixes and cleans up the issue: - Move the signal creation to the class, using the __gsignals__ dict. - Replace `Event` with `object` since we are passing an EventButton as Gtk3 no longer accepts it as an Event. - Replace deprecated menu `popup()` with `popup_at_pointer()` which also fixes a critical gdk error when using `popup()`. --- deluge/ui/gtk3/listview.py | 17 ++++++++--------- 1 file changed, 8 insertions(+), 9 deletions(-) diff --git a/deluge/ui/gtk3/listview.py b/deluge/ui/gtk3/listview.py index 4ed198b54..c4d352639 100644 --- a/deluge/ui/gtk3/listview.py +++ b/deluge/ui/gtk3/listview.py @@ -12,18 +12,11 @@ from __future__ import unicode_literals import logging from gi.repository import GObject, Gtk -from gi.repository.Gdk import Event # pylint: disable=ungrouped-imports -from gi.repository.GObject import TYPE_NONE, SignalFlags, signal_new -from deluge.common import decode_bytes +from deluge.common import PY2, decode_bytes from .common import load_pickled_state_file, save_pickled_state_file -# FIXME: ? -signal_new( - 'button-press-event', Gtk.TreeViewColumn, SignalFlags.RUN_LAST, TYPE_NONE, (Event,) -) - log = logging.getLogger(__name__) @@ -87,6 +80,12 @@ class ListView(object): Most of the code of this class comes from Quod Libet (http://www.sacredchao.net/quodlibet) """ + __gsignals__ = { + 'button-press-event' + if not PY2 + else b'button-press-event': (GObject.SIGNAL_RUN_LAST, None, (object,)) + } + def __init__(self, title=None, cell_renderer=None, **args): """ Constructor, see Gtk.TreeViewColumn """ Gtk.TreeViewColumn.__init__(self, title, cell_renderer, **args) @@ -356,7 +355,7 @@ class ListView(object): def on_treeview_header_right_clicked(self, column, event): if event.button == 3: - self.menu.popup(None, None, None, None, event.button, event.get_time()) + self.menu.popup_at_pointer() def register_checklist_menu(self, menu): """Register a checklist menu with the listview. It will automatically