Daniel Brötzmann pushed to branch master at gajim / gajim

Commits:

5 changed files:

Changes:

  • gajim/gtk/chat_list.py
    ... ... @@ -90,9 +90,15 @@ def workspace_id(self) -> str:
    90 90
         def get_unread_count(self) -> int:
    
    91 91
             return sum([chats.unread_count for chats in self._chats.values()])
    
    92 92
     
    
    93
    -    def get_chat_unread_count(self, account: str, jid: JID) -> Optional[int]:
    
    93
    +    def get_chat_unread_count(self,
    
    94
    +                              account: str,
    
    95
    +                              jid: JID,
    
    96
    +                              include_silent: bool = False
    
    97
    +                              ) -> Optional[int]:
    
    94 98
             chat = self._chats.get((account, jid))
    
    95 99
             if chat is not None:
    
    100
    +            if include_silent:
    
    101
    +                return chat.get_real_unread_count()
    
    96 102
                 return chat.unread_count
    
    97 103
             return None
    
    98 104
     
    
    ... ... @@ -656,6 +662,9 @@ def _on_chatstate_update(self, contact, _signal_name):
    656 662
         def _on_nickname_update(self, _contact, _signal_name):
    
    657 663
             self.update_name()
    
    658 664
     
    
    665
    +    def get_real_unread_count(self) -> int:
    
    666
    +        return self._unread_count
    
    667
    +
    
    659 668
         @property
    
    660 669
         def unread_count(self) -> int:
    
    661 670
             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):
    81 81
             actions = [
    
    82 82
                 ('toggle-chat-pinned', 'as', self._toggle_chat_pinned),
    
    83 83
                 ('move-chat-to-workspace', 'as', self._move_chat_to_workspace),
    
    84
    +            ('mark-as-read', 'as', self._mark_as_read),
    
    84 85
             ]
    
    85 86
     
    
    86 87
             for action in actions:
    
    ... ... @@ -208,6 +209,10 @@ def _move_chat_to_workspace(self, _action, param):
    208 209
             self.store_open_chats(current_chatlist.workspace_id)
    
    209 210
             self.store_open_chats(new_workspace_id)
    
    210 211
     
    
    212
    +    def _mark_as_read(self, _action, param):
    
    213
    +        _workspace_id, account, jid = param.unpack()
    
    214
    +        self.mark_as_read(account, JID.from_string(jid))
    
    215
    +
    
    211 216
         def remove_chat(self, workspace_id: str, account: str, jid: JID) -> None:
    
    212 217
             chat_list = self._chat_lists[workspace_id]
    
    213 218
             type_ = chat_list.get_chat_type(account, jid)
    
    ... ... @@ -243,9 +248,14 @@ def get_total_unread_count(self) -> int:
    243 248
                 count += chat_list.get_unread_count()
    
    244 249
             return count
    
    245 250
     
    
    246
    -    def get_chat_unread_count(self, account: str, jid: JID) -> Optional[int]:
    
    251
    +    def get_chat_unread_count(self,
    
    252
    +                              account: str,
    
    253
    +                              jid: JID,
    
    254
    +                              include_silent: bool = False
    
    255
    +                              ) -> Optional[int]:
    
    247 256
             for chat_list in self._chat_lists.values():
    
    248
    -            count = chat_list.get_chat_unread_count(account, jid)
    
    257
    +            count = chat_list.get_chat_unread_count(
    
    258
    +                account, jid, include_silent)
    
    249 259
                 if count is not None:
    
    250 260
                     return count
    
    251 261
             return None
    

  • gajim/gtk/chat_stack.py
    ... ... @@ -24,6 +24,7 @@
    24 24
     
    
    25 25
     from nbxmpp import JID
    
    26 26
     
    
    27
    +from gajim.common import app
    
    27 28
     from gajim.common import ged
    
    28 29
     from gajim.common.i18n import _
    
    29 30
     
    
    ... ... @@ -150,6 +151,10 @@ def __init__(self):
    150 151
             image.get_style_context().add_class('dim-label')
    
    151 152
             self.add(image)
    
    152 153
     
    
    153
    -        label = Gtk.Label(label=_('Start a Chat'))
    
    154
    -        label.get_style_context().add_class('dim-label')
    
    155
    -        self.add(label)
    154
    +        button = Gtk.Button(label=_('Start Chatting…'))
    
    155
    +        button.set_halign(Gtk.Align.CENTER)
    
    156
    +        button.connect('clicked', self._on_start_chatting)
    
    157
    +        self.add(button)
    
    158
    +
    
    159
    +    def _on_start_chatting(self, _button):
    
    160
    +        app.app.activate_action('start-chat', GLib.Variant('s', ''))

  • gajim/gtk/main.py
    ... ... @@ -509,9 +509,14 @@ def get_total_unread_count(self) -> int:
    509 509
             chat_list_stack = self._chat_page.get_chat_list_stack()
    
    510 510
             return chat_list_stack.get_total_unread_count()
    
    511 511
     
    
    512
    -    def get_chat_unread_count(self, account: str, jid: JID) -> int:
    
    512
    +    def get_chat_unread_count(self,
    
    513
    +                              account: str,
    
    514
    +                              jid: JID,
    
    515
    +                              include_silent: bool = False
    
    516
    +                              ) -> int:
    
    513 517
             chat_list_stack = self._chat_page.get_chat_list_stack()
    
    514
    -        count = chat_list_stack.get_chat_unread_count(account, jid)
    
    518
    +        count = chat_list_stack.get_chat_unread_count(
    
    519
    +            account, jid, include_silent)
    
    515 520
             return count or 0
    
    516 521
     
    
    517 522
         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,
    521 521
             else:
    
    522 522
                 menu_items.append(('add-to-roster', _('Add to Contact List…')))
    
    523 523
     
    
    524
    +    unread_count = app.window.get_chat_unread_count(
    
    525
    +        account, jid, include_silent=True)
    
    526
    +    if unread_count is not None and unread_count > 0:
    
    527
    +        menu_items.append(('mark-as-read', _('Mark as read')))
    
    528
    +
    
    524 529
         menu = Gio.Menu()
    
    525 530
         for item in menu_items:
    
    526 531
             if isinstance(item[1], str):