Philipp Hörist pushed to branch mainwindow at gajim / gajim

Commits:

6 changed files:

Changes:

  • gajim/gtk/chat_list.py
    ... ... @@ -37,6 +37,10 @@ def __init__(self, workspace_id):
    37 37
     
    
    38 38
             self.show_all()
    
    39 39
     
    
    40
    +    @property
    
    41
    +    def workspace_id(self):
    
    42
    +        return self._workspace_id
    
    43
    +
    
    40 44
         def get_unread_count(self):
    
    41 45
             return sum([chats.unread_count for chats in self._chats.values()])
    
    42 46
     
    

  • gajim/gtk/chat_list_stack.py
    ... ... @@ -20,6 +20,9 @@ class ChatListStack(Gtk.Stack):
    20 20
             'unread-count-changed': (GObject.SignalFlags.RUN_LAST,
    
    21 21
                                      None,
    
    22 22
                                      (str, int)),
    
    23
    +        'chat-selected': (GObject.SignalFlags.RUN_LAST,
    
    24
    +                          None,
    
    25
    +                          (str, str, str)),
    
    23 26
         }
    
    24 27
     
    
    25 28
         def __init__(self, main_window, ui, chat_stack):
    
    ... ... @@ -92,6 +95,7 @@ def _on_row_selected(self, _chat_list, row):
    92 95
             self._chat_stack.show_chat(row.account, row.jid)
    
    93 96
             if row.is_active:
    
    94 97
                 row.reset_unread()
    
    98
    +        self.emit('chat-selected', row.workspace_id, row.account, row.jid)
    
    95 99
     
    
    96 100
         def show_chat_list(self, workspace_id):
    
    97 101
             current_workspace_id = self.get_visible_child_name()
    
    ... ... @@ -111,9 +115,12 @@ def add_chat(self, workspace_id, account, jid, type_):
    111 115
                 chat_list = self.add_chat_list(workspace_id)
    
    112 116
             chat_list.add_chat(account, jid, type_)
    
    113 117
     
    
    114
    -    def select_chat(self, workspace_id, account, jid):
    
    115
    -        self.show_chat_list(workspace_id)
    
    116
    -        chat_list = self._chat_lists.get(workspace_id)
    
    118
    +    def select_chat(self, account, jid):
    
    119
    +        chat_list = self._find_chat(account, jid)
    
    120
    +        if chat_list is None:
    
    121
    +            return
    
    122
    +
    
    123
    +        self.show_chat_list(chat_list.workspace_id)
    
    117 124
             chat_list.select_chat(account, jid)
    
    118 125
     
    
    119 126
         def store_open_chats(self, workspace_id):
    

  • gajim/gtk/main.py
    ... ... @@ -205,19 +205,38 @@ def _add_group_chat(self, _action, param):
    205 205
             account, jid = param.unpack()
    
    206 206
             self.add_group_chat(account, jid)
    
    207 207
     
    
    208
    -    def add_group_chat(self, account, jid):
    
    208
    +    def add_group_chat(self, account, jid, select=False):
    
    209 209
             workspace_id = self._workspace_side_bar.get_active_workspace()
    
    210
    -        self.add_chat_for_workspace(workspace_id, account, jid, 'groupchat')
    
    210
    +        self.add_chat_for_workspace(workspace_id,
    
    211
    +                                    account,
    
    212
    +                                    jid,
    
    213
    +                                    'groupchat',
    
    214
    +                                    select=select)
    
    211 215
     
    
    212 216
         def _add_chat(self, _action, param):
    
    213 217
             account, jid, type_ = param.unpack()
    
    214 218
             self.add_chat(account, jid, type_)
    
    215 219
     
    
    216
    -    def add_chat(self, account, jid, type_):
    
    220
    +    def add_chat(self, account, jid, type_, select=False):
    
    217 221
             workspace_id = self._workspace_side_bar.get_active_workspace()
    
    218
    -        self.add_chat_for_workspace(workspace_id, account, jid, type_)
    
    222
    +        self.add_chat_for_workspace(workspace_id,
    
    223
    +                                    account,
    
    224
    +                                    jid,
    
    225
    +                                    type_,
    
    226
    +                                    select=select)
    
    227
    +
    
    228
    +    def add_chat_for_workspace(self,
    
    229
    +                               workspace_id,
    
    230
    +                               account,
    
    231
    +                               jid,
    
    232
    +                               type_,
    
    233
    +                               select=False):
    
    234
    +
    
    235
    +        if self.chat_exists(account, jid):
    
    236
    +            if select:
    
    237
    +                self._chat_list_stack.select_chat(account, jid)
    
    238
    +            return
    
    219 239
     
    
    220
    -    def add_chat_for_workspace(self, workspace_id, account, jid, type_):
    
    221 240
             if type_ == 'groupchat':
    
    222 241
                 self._chat_stack.add_group_chat(account, jid)
    
    223 242
             else:
    
    ... ... @@ -225,7 +244,8 @@ def add_chat_for_workspace(self, workspace_id, account, jid, type_):
    225 244
             self._chat_list_stack.add_chat(workspace_id, account, jid, type_)
    
    226 245
     
    
    227 246
             if self._startup_finished:
    
    228
    -            self._chat_list_stack.select_chat(workspace_id, account, jid)
    
    247
    +            if select:
    
    248
    +                self._chat_list_stack.select_chat(account, jid)
    
    229 249
                 self._chat_list_stack.store_open_chats(workspace_id)
    
    230 250
     
    
    231 251
         def _remove_chat(self, _action, param):
    
    ... ... @@ -242,10 +262,6 @@ def chat_exists_for_workspace(self, workspace_id, account, jid):
    242 262
             return self._chat_list_stack.contains_chat(
    
    243 263
                 account, jid, workspace_id=workspace_id)
    
    244 264
     
    
    245
    -    def select_chat(self, workspace_id, account, jid):
    
    246
    -        self._workspace_side_bar.activate_workspace(workspace_id)
    
    247
    -        self._chat_list_stack.select_chat(workspace_id, account, jid)
    
    248
    -
    
    249 265
         def get_control(self, account, jid):
    
    250 266
             return self._chat_stack.get_control(account, jid)
    
    251 267
     
    

  • gajim/gtk/start_chat.py
    ... ... @@ -295,8 +295,7 @@ def _start_new_chat(self, row):
    295 295
                 self._disco_muc(row.account, row.jid, request_vcard=row.new)
    
    296 296
     
    
    297 297
             else:
    
    298
    -            # app.interface.new_chat_from_jid(row.account, row.jid)
    
    299
    -            app.window.add_chat(row.account, row.jid, 'contact')
    
    298
    +            app.window.add_chat(row.account, row.jid, 'contact', select=True)
    
    300 299
                 self.ready_to_destroy = True
    
    301 300
                 self.destroy()
    
    302 301
     
    

  • gajim/gtk/workspace_side_bar.py
    ... ... @@ -22,12 +22,17 @@ def __init__(self, chat_list_stack):
    22 22
     
    
    23 23
             chat_list_stack.connect('unread-count-changed',
    
    24 24
                                     self._on_unread_count_changed)
    
    25
    +        chat_list_stack.connect('chat-selected',
    
    26
    +                                self._on_chat_selected)
    
    25 27
             self._workspaces = {}
    
    26 28
     
    
    27 29
         def _on_unread_count_changed(self, _chat_list_stack, workspace_id, count):
    
    28 30
             workspace = self._workspaces[workspace_id]
    
    29 31
             workspace.set_unread_count(count)
    
    30 32
     
    
    33
    +    def _on_chat_selected(self, _chat_list_stack, workspace_id, *args):
    
    34
    +        self.activate_workspace(workspace_id)
    
    35
    +
    
    31 36
         @staticmethod
    
    32 37
         def _sort_func(child1, child2):
    
    33 38
             if child1.sort_index < child2.sort_index:
    

  • gajim/gui_interface.py
    ... ... @@ -1469,16 +1469,11 @@ def create_groupchat(self, account, room_jid, config=None):
    1469 1469
             app.connections[account].get_module('MUC').create(muc_data)
    
    1470 1470
     
    
    1471 1471
         def show_add_join_groupchat(self, account, jid, nickname=None):
    
    1472
    -        workspace_id = app.window.get_active_workspace()
    
    1473
    -        if app.window.chat_exists_for_workspace(workspace_id, account, jid):
    
    1474
    -            app.window.select_chat(workspace_id, account, jid)
    
    1475
    -            return
    
    1476
    -
    
    1477 1472
             if not app.window.chat_exists(account, jid):
    
    1478 1473
                 client = app.get_client(account)
    
    1479 1474
                 client.get_module('MUC').join(jid, nick=nickname)
    
    1480 1475
     
    
    1481
    -        app.window.add_group_chat(account, str(jid))
    
    1476
    +        app.window.add_group_chat(account, str(jid), select=True)
    
    1482 1477
     
    
    1483 1478
         @staticmethod
    
    1484 1479
         def _on_muc_added(_muc_manger, _signal_name, account, jid):