Daniel Brötzmann pushed to branch master at gajim / gajim
Commits: 15d763e0 by wurstsalat at 2021-12-06T23:00:57+01:00 ChatPlaceholderBox: Add button for Start Chat
- - - - - 89558698 by wurstsalat at 2021-12-06T23:22:02+01:00 ChatList: Add 'Mark as read' menu item
- - - - -
5 changed files:
- gajim/gtk/chat_list.py - gajim/gtk/chat_list_stack.py - gajim/gtk/chat_stack.py - gajim/gtk/main.py - gajim/gui_menu_builder.py
Changes:
===================================== gajim/gtk/chat_list.py ===================================== @@ -90,9 +90,15 @@ def workspace_id(self) -> str: def get_unread_count(self) -> int: return sum([chats.unread_count for chats in self._chats.values()])
- def get_chat_unread_count(self, account: str, jid: JID) -> Optional[int]: + def get_chat_unread_count(self, + account: str, + jid: JID, + include_silent: bool = False + ) -> Optional[int]: chat = self._chats.get((account, jid)) if chat is not None: + if include_silent: + return chat.get_real_unread_count() return chat.unread_count return None
@@ -656,6 +662,9 @@ def _on_chatstate_update(self, contact, _signal_name): def _on_nickname_update(self, _contact, _signal_name): self.update_name()
+ def get_real_unread_count(self) -> int: + return self._unread_count + @property def unread_count(self) -> int: if self.contact.is_groupchat and not self.contact.can_notify():
===================================== gajim/gtk/chat_list_stack.py ===================================== @@ -81,6 +81,7 @@ def _add_actions(self): actions = [ ('toggle-chat-pinned', 'as', self._toggle_chat_pinned), ('move-chat-to-workspace', 'as', self._move_chat_to_workspace), + ('mark-as-read', 'as', self._mark_as_read), ]
for action in actions: @@ -208,6 +209,10 @@ def _move_chat_to_workspace(self, _action, param): self.store_open_chats(current_chatlist.workspace_id) self.store_open_chats(new_workspace_id)
+ def _mark_as_read(self, _action, param): + _workspace_id, account, jid = param.unpack() + self.mark_as_read(account, JID.from_string(jid)) + def remove_chat(self, workspace_id: str, account: str, jid: JID) -> None: chat_list = self._chat_lists[workspace_id] type_ = chat_list.get_chat_type(account, jid) @@ -243,9 +248,14 @@ def get_total_unread_count(self) -> int: count += chat_list.get_unread_count() return count
- def get_chat_unread_count(self, account: str, jid: JID) -> Optional[int]: + def get_chat_unread_count(self, + account: str, + jid: JID, + include_silent: bool = False + ) -> Optional[int]: for chat_list in self._chat_lists.values(): - count = chat_list.get_chat_unread_count(account, jid) + count = chat_list.get_chat_unread_count( + account, jid, include_silent) if count is not None: return count return None
===================================== gajim/gtk/chat_stack.py ===================================== @@ -24,6 +24,7 @@
from nbxmpp import JID
+from gajim.common import app from gajim.common import ged from gajim.common.i18n import _
@@ -150,6 +151,10 @@ def __init__(self): image.get_style_context().add_class('dim-label') self.add(image)
- label = Gtk.Label(label=_('Start a Chat')) - label.get_style_context().add_class('dim-label') - self.add(label) + button = Gtk.Button(label=_('Start Chatting…')) + button.set_halign(Gtk.Align.CENTER) + button.connect('clicked', self._on_start_chatting) + self.add(button) + + def _on_start_chatting(self, _button): + app.app.activate_action('start-chat', GLib.Variant('s', ''))
===================================== gajim/gtk/main.py ===================================== @@ -509,9 +509,14 @@ def get_total_unread_count(self) -> int: chat_list_stack = self._chat_page.get_chat_list_stack() return chat_list_stack.get_total_unread_count()
- def get_chat_unread_count(self, account: str, jid: JID) -> int: + def get_chat_unread_count(self, + account: str, + jid: JID, + include_silent: bool = False + ) -> int: chat_list_stack = self._chat_page.get_chat_list_stack() - count = chat_list_stack.get_chat_unread_count(account, jid) + count = chat_list_stack.get_chat_unread_count( + account, jid, include_silent) return count or 0
def mark_as_read(self, account: str, jid: JID,
===================================== gajim/gui_menu_builder.py ===================================== @@ -521,6 +521,11 @@ def get_chat_list_row_menu(workspace_id: str, account: str, else: menu_items.append(('add-to-roster', _('Add to Contact List…')))
+ unread_count = app.window.get_chat_unread_count( + account, jid, include_silent=True) + if unread_count is not None and unread_count > 0: + menu_items.append(('mark-as-read', _('Mark as read'))) + menu = Gio.Menu() for item in menu_items: if isinstance(item[1], str):
View it on GitLab: https://dev.gajim.org/gajim/gajim/-/compare/3d10db13f68bae934527169be5661681...