Daniel Brötzmann pushed to branch gtk4 at gajim / gajim
Commits:
de6eb308 by wurstsalat at 2024-10-05T12:33:58+02:00
fix message avatar menu handling
- - - - -
1 changed file:
- gajim/gtk/conversation/rows/widgets.py
Changes:
=====================================
gajim/gtk/conversation/rows/widgets.py
=====================================
@@ -4,7 +4,6 @@
from __future__ import annotations
-from typing import Any
from typing import TYPE_CHECKING
from datetime import datetime
@@ -27,7 +26,6 @@
from gajim.gtk.conversation.reactions_bar import AddReactionButton
from gajim.gtk.menus import get_groupchat_participant_menu
from gajim.gtk.util import GajimPopover
-from gajim.gtk.util import get_cursor
if TYPE_CHECKING:
from gajim.gtk.conversation.rows.message import MessageRow
@@ -436,13 +434,16 @@ def __init__(self, contact: ChatContactT) -> None:
self.append(self._image)
if self._contact.is_groupchat:
- self.connect('realize', self._on_realize)
+ self.set_cursor(Gdk.Cursor.new_from_name('pointer'))
- gesture_left_click = Gtk.GestureClick(button=1)
+ self._menu_popover = GajimPopover(None)
+ self.append(self._menu_popover)
+
+ gesture_left_click = Gtk.GestureClick(button=Gdk.BUTTON_PRIMARY)
gesture_left_click.connect('pressed', self._on_avatar_clicked)
self.add_controller(gesture_left_click)
- gesture_right_click = Gtk.GestureClick(button=3)
+ gesture_right_click = Gtk.GestureClick(button=Gdk.BUTTON_SECONDARY)
gesture_right_click.connect('pressed', self._on_avatar_clicked)
self.add_controller(gesture_right_click)
@@ -454,38 +455,26 @@ def set_name(self, name: str) -> None:
self._name = name
def set_merged(self, merged: bool) -> None:
- # TODO GTK4
- # self._image.set_no_show_all(merged)
self._image.set_visible(not merged)
- @staticmethod
- def _on_realize(event_box: Gtk.Box) -> None:
- # TODO GTK4
- return
- window = event_box.get_window()
- if window is not None:
- window.set_cursor(get_cursor('pointer'))
-
def _on_avatar_clicked(
self,
gesture_click : Gtk.GestureClick,
_n_press: int,
- _x: float,
- _y: float,
+ x: float,
+ y: float,
) -> int:
-
if not isinstance(self._contact, GroupchatContact):
return Gdk.EVENT_STOP
- # TODO GTK4
if gesture_click.get_current_button() == Gdk.BUTTON_PRIMARY:
app.window.activate_action('mention', GLib.Variant('s',
self._name))
elif gesture_click.get_current_button() == Gdk.BUTTON_SECONDARY:
- self._show_participant_menu(self._name,
gesture_click.get_current_event())
+ self._show_participant_menu(self._name, x, y)
return Gdk.EVENT_STOP
- def _show_participant_menu(self, nick: str, event: Any) -> None:
+ def _show_participant_menu(self, nick: str, x: float, y: float) -> None:
assert isinstance(self._contact, GroupchatContact)
if not self._contact.is_joined:
return
@@ -502,5 +491,7 @@ def _show_participant_menu(self, nick: str, event: Any) ->
None:
self._contact.account, self_contact, contact
)
- popover = GajimPopover(menu, relative_to=self, event=event)
- popover.popup()
+ # TODO GTK4: Menu moves content of adjacent widgets
+ self._menu_popover.set_menu_model(menu)
+ self._menu_popover.set_pointing_to_coord(x, y)
+ self._menu_popover.popup()
View it on GitLab:
https://dev.gajim.org/gajim/gajim/-/commit/de6eb308dbbaf3f112d5492d0658dc0332d80901
--
View it on GitLab:
https://dev.gajim.org/gajim/gajim/-/commit/de6eb308dbbaf3f112d5492d0658dc0332d80901
You're receiving this email because of your account on dev.gajim.org.
_______________________________________________
Commits mailing list -- [email protected]
To unsubscribe send an email to [email protected]