Daniel Brötzmann pushed to branch mainwindow at gajim / gajim
Commits:
-
4e168244
by wurstsalat at 2021-11-14T13:40:49+01:00
4 changed files:
Changes:
| ... | ... | @@ -17,6 +17,8 @@ |
| 17 | 17 |
from gi.repository import Gtk
|
| 18 | 18 |
from gi.repository import Gdk
|
| 19 | 19 |
|
| 20 |
+from nbxmpp import JID
|
|
| 21 |
+ |
|
| 20 | 22 |
from gajim.common import app
|
| 21 | 23 |
from gajim.common import helpers
|
| 22 | 24 |
from gajim.common.app import interface
|
| ... | ... | @@ -262,6 +264,12 @@ def start_chat(_action, param): |
| 262 | 264 |
account, jid = param.get_strv()
|
| 263 | 265 |
app.interface.start_chat_from_jid(account, jid)
|
| 264 | 266 |
|
| 267 |
+def forget_groupchat(_action, param):
|
|
| 268 |
+ account, jid = param.unpack()
|
|
| 269 |
+ client = app.get_client(account)
|
|
| 270 |
+ client.get_module('Bookmarks').remove(JID.from_string(jid))
|
|
| 271 |
+ window = open_window('StartChatDialog')
|
|
| 272 |
+ window.remove_row(account, jid)
|
|
| 265 | 273 |
|
| 266 | 274 |
def on_groupchat_join(_action, param):
|
| 267 | 275 |
account, jid = param.get_strv()
|
| ... | ... | @@ -398,6 +398,7 @@ def add_actions(self): |
| 398 | 398 |
('open-link', 'as', app_actions.open_link),
|
| 399 | 399 |
('open-mail', 's', app_actions.open_mail),
|
| 400 | 400 |
('create-groupchat', 's', app_actions.on_create_gc),
|
| 401 |
+ ('forget-groupchat', 'as', app_actions.forget_groupchat),
|
|
| 401 | 402 |
('groupchat-join', 'as', app_actions.on_groupchat_join),
|
| 402 | 403 |
]
|
| 403 | 404 |
|
| ... | ... | @@ -35,6 +35,8 @@ |
| 35 | 35 |
from gajim.common.const import MUC_DISCO_ERRORS
|
| 36 | 36 |
from gajim.common.modules.util import as_task
|
| 37 | 37 |
|
| 38 |
+from gajim.gui_menu_builder import get_start_chat_row_menu
|
|
| 39 |
+ |
|
| 38 | 40 |
from .chat_filter import ChatFilter
|
| 39 | 41 |
from .groupchat_info import GroupChatInfoScrolled
|
| 40 | 42 |
from .groupchat_nick import NickChooser
|
| ... | ... | @@ -126,6 +128,12 @@ def __init__(self): |
| 126 | 128 |
def set_search_text(self, text):
|
| 127 | 129 |
self._ui.search_entry.set_text(text)
|
| 128 | 130 |
|
| 131 |
+ def remove_row(self, account: str, jid: str) -> None:
|
|
| 132 |
+ for row in self._ui.listbox.get_children():
|
|
| 133 |
+ if row.account == account and row.jid == jid:
|
|
| 134 |
+ row.destroy()
|
|
| 135 |
+ return
|
|
| 136 |
+ |
|
| 129 | 137 |
def _global_search_active(self):
|
| 130 | 138 |
return self._ui.global_search_toggle.get_active()
|
| 131 | 139 |
|
| ... | ... | @@ -747,9 +755,32 @@ def __init__(self, account, contact, jid, name, show_account, |
| 747 | 755 |
|
| 748 | 756 |
grid.add(box)
|
| 749 | 757 |
|
| 750 |
- self.add(grid)
|
|
| 758 |
+ eventbox = Gtk.EventBox()
|
|
| 759 |
+ eventbox.connect('button-press-event', self._popup_menu)
|
|
| 760 |
+ eventbox.add(grid)
|
|
| 761 |
+ self.add(eventbox)
|
|
| 751 | 762 |
self.show_all()
|
| 752 | 763 |
|
| 764 |
+ def _popup_menu(self, _widget, event):
|
|
| 765 |
+ if not self.groupchat:
|
|
| 766 |
+ return
|
|
| 767 |
+ |
|
| 768 |
+ if event.button != 3: # right click
|
|
| 769 |
+ return
|
|
| 770 |
+ |
|
| 771 |
+ menu = get_start_chat_row_menu(self.account, self.jid)
|
|
| 772 |
+ |
|
| 773 |
+ rectangle = Gdk.Rectangle()
|
|
| 774 |
+ rectangle.x = event.x
|
|
| 775 |
+ rectangle.y = event.y
|
|
| 776 |
+ rectangle.width = rectangle.height = 1
|
|
| 777 |
+ |
|
| 778 |
+ popover = Gtk.Popover.new_from_model(self, menu)
|
|
| 779 |
+ popover.set_relative_to(self)
|
|
| 780 |
+ popover.set_position(Gtk.PositionType.RIGHT)
|
|
| 781 |
+ popover.set_pointing_to(rectangle)
|
|
| 782 |
+ popover.popup()
|
|
| 783 |
+ |
|
| 753 | 784 |
def _get_avatar_image(self, contact):
|
| 754 | 785 |
if self.new:
|
| 755 | 786 |
icon_name = 'avatar-default'
|
| ... | ... | @@ -485,6 +485,22 @@ def get_subscription_menu(account: str, jid: str) -> Gio.Menu: |
| 485 | 485 |
return menu
|
| 486 | 486 |
|
| 487 | 487 |
|
| 488 |
+def get_start_chat_row_menu(account: str, jid: Union[JID, str]) -> Gio.Menu:
|
|
| 489 |
+ jid = str(jid)
|
|
| 490 |
+ menu_items: List[Tuple[str, str]] = [
|
|
| 491 |
+ ('forget-groupchat', _('Forget this Group Chat')),
|
|
| 492 |
+ ]
|
|
| 493 |
+ menu = Gio.Menu()
|
|
| 494 |
+ for item in menu_items:
|
|
| 495 |
+ action, label = item
|
|
| 496 |
+ action = f'app.{action}'
|
|
| 497 |
+ menuitem = Gio.MenuItem.new(label, action)
|
|
| 498 |
+ variant_list = GLib.Variant('as', [account, jid])
|
|
| 499 |
+ menuitem.set_action_and_target_value(action, variant_list)
|
|
| 500 |
+ menu.append_item(menuitem)
|
|
| 501 |
+ return menu
|
|
| 502 |
+ |
|
| 503 |
+ |
|
| 488 | 504 |
def get_chat_list_row_menu(workspace_id: str, account: str,
|
| 489 | 505 |
jid: Union[JID, str], pinned: bool) -> Gio.Menu:
|
| 490 | 506 |
jid = str(jid)
|