[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()`.
This commit is contained in:
parent
92a048625a
commit
366b10f07b
@ -12,18 +12,11 @@ from __future__ import unicode_literals
|
|||||||
import logging
|
import logging
|
||||||
|
|
||||||
from gi.repository import GObject, Gtk
|
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
|
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__)
|
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)
|
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):
|
def __init__(self, title=None, cell_renderer=None, **args):
|
||||||
""" Constructor, see Gtk.TreeViewColumn """
|
""" Constructor, see Gtk.TreeViewColumn """
|
||||||
Gtk.TreeViewColumn.__init__(self, title, cell_renderer, **args)
|
Gtk.TreeViewColumn.__init__(self, title, cell_renderer, **args)
|
||||||
@ -356,7 +355,7 @@ class ListView(object):
|
|||||||
|
|
||||||
def on_treeview_header_right_clicked(self, column, event):
|
def on_treeview_header_right_clicked(self, column, event):
|
||||||
if event.button == 3:
|
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):
|
def register_checklist_menu(self, menu):
|
||||||
"""Register a checklist menu with the listview. It will automatically
|
"""Register a checklist menu with the listview. It will automatically
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user