| ... |
... |
@@ -95,9 +95,9 @@ def __destroy(widget: Gtk.Widget) -> None: |
|
95
|
95
|
|
|
96
|
96
|
|
|
97
|
97
|
@wrap_with_event_box
|
|
98
|
|
-class MoreMenuButton(Gtk.MenuButton):
|
|
|
98
|
+class MoreMenuButton(Gtk.Button):
|
|
99
|
99
|
def __init__(self, row, contact, name):
|
|
100
|
|
- Gtk.MenuButton.__init__(self)
|
|
|
100
|
+ Gtk.Button.__init__(self)
|
|
101
|
101
|
self.set_valign(Gtk.Align.START)
|
|
102
|
102
|
self.set_halign(Gtk.Align.END)
|
|
103
|
103
|
self.set_relief(Gtk.ReliefStyle.NONE)
|
| ... |
... |
@@ -111,11 +111,9 @@ def __init__(self, row, contact, name): |
|
111
|
111
|
image = Gtk.Image.new_from_icon_name(
|
|
112
|
112
|
'feather-more-horizontal-symbolic', Gtk.IconSize.BUTTON)
|
|
113
|
113
|
self.add(image)
|
|
114
|
|
- self._create_popover()
|
|
115
|
|
-
|
|
116
|
114
|
self.connect('clicked', self._on_click)
|
|
117
|
115
|
|
|
118
|
|
- def _on_click(self, _button):
|
|
|
116
|
+ def _on_click(self, _button: Gtk.Button) -> None:
|
|
119
|
117
|
show_retract = False
|
|
120
|
118
|
if self._contact.is_groupchat:
|
|
121
|
119
|
disco_info = app.storage.cache.get_last_disco_info(
|
| ... |
... |
@@ -125,9 +123,9 @@ def _on_click(self, _button): |
|
125
|
123
|
is_allowed = is_retraction_allowed(self_contact, contact)
|
|
126
|
124
|
if disco_info.has_message_moderation and is_allowed:
|
|
127
|
125
|
show_retract = True
|
|
128
|
|
- self._retract_button.set_visible(show_retract)
|
|
|
126
|
+ self._create_popover(show_retract)
|
|
129
|
127
|
|
|
130
|
|
- def _create_popover(self):
|
|
|
128
|
+ def _create_popover(self, show_retract: bool) -> None:
|
|
131
|
129
|
menu_box = Gtk.Box(orientation=Gtk.Orientation.VERTICAL, spacing=6)
|
|
132
|
130
|
menu_box.get_style_context().add_class('padding-6')
|
|
133
|
131
|
|
| ... |
... |
@@ -147,17 +145,25 @@ def _create_popover(self): |
|
147
|
145
|
'edit-copy-symbolic', Gtk.IconSize.MENU))
|
|
148
|
146
|
menu_box.add(copy_button)
|
|
149
|
147
|
|
|
150
|
|
- self._retract_button = Gtk.ModelButton()
|
|
151
|
|
- self._retract_button.set_halign(Gtk.Align.START)
|
|
152
|
|
- self._retract_button.connect(
|
|
153
|
|
- 'clicked', self._row.on_retract_message)
|
|
154
|
|
- self._retract_button.set_label(_('Retract'))
|
|
155
|
|
- self._retract_button.set_image(Gtk.Image.new_from_icon_name(
|
|
156
|
|
- 'edit-undo-symbolic', Gtk.IconSize.MENU))
|
|
157
|
|
- menu_box.add(self._retract_button)
|
|
|
148
|
+ if show_retract:
|
|
|
149
|
+ retract_button = Gtk.ModelButton()
|
|
|
150
|
+ retract_button.set_halign(Gtk.Align.START)
|
|
|
151
|
+ retract_button.connect(
|
|
|
152
|
+ 'clicked', self._row.on_retract_message)
|
|
|
153
|
+ retract_button.set_label(_('Retract'))
|
|
|
154
|
+ retract_button.set_image(Gtk.Image.new_from_icon_name(
|
|
|
155
|
+ 'edit-undo-symbolic', Gtk.IconSize.MENU))
|
|
|
156
|
+ menu_box.add(retract_button)
|
|
158
|
157
|
|
|
159
|
158
|
menu_box.show_all()
|
|
160
|
159
|
|
|
161
|
160
|
popover = Gtk.PopoverMenu()
|
|
162
|
161
|
popover.add(menu_box)
|
|
163
|
|
- self.set_popover(popover)
|
|
|
162
|
+ popover.set_relative_to(self)
|
|
|
163
|
+ popover.set_position(Gtk.PositionType.BOTTOM)
|
|
|
164
|
+ popover.connect('closed', self._on_closed)
|
|
|
165
|
+ popover.popup()
|
|
|
166
|
+
|
|
|
167
|
+ @staticmethod
|
|
|
168
|
+ def _on_closed(popover: Gtk.Popover) -> None:
|
|
|
169
|
+ GLib.idle_add(popover.destroy)
|