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

Commits:

1 changed file:

Changes:

  • gajim/gtk/start_chat.py
    ... ... @@ -48,19 +48,15 @@ class StartChatDialog(Gtk.ApplicationWindow):
    48 48
             self.set_application(app.app)
    
    49 49
             self.set_position(Gtk.WindowPosition.CENTER)
    
    50 50
             self.set_show_menubar(False)
    
    51
    -        self.set_title(_('Start new Conversation'))
    
    51
    +        self.set_title(_('Start New Conversation'))
    
    52 52
             self.set_default_size(-1, 400)
    
    53 53
             self.ready_to_destroy = False
    
    54 54
             self._parameter_form = None
    
    55 55
             self._destroyed = False
    
    56 56
             self._search_stopped = False
    
    57 57
     
    
    58
    -        self.builder = get_builder('start_chat_dialog.ui')
    
    59
    -        self.listbox = self.builder.get_object('listbox')
    
    60
    -        self.search_entry = self.builder.get_object('search_entry')
    
    61
    -        self.box = self.builder.get_object('box')
    
    62
    -
    
    63
    -        self.add(self.box)
    
    58
    +        self._ui = get_builder('start_chat_dialog.ui')
    
    59
    +        self.add(self._ui.box)
    
    64 60
     
    
    65 61
             self.new_contact_row_visible = False
    
    66 62
             self.new_contact_rows = {}
    
    ... ... @@ -69,21 +65,21 @@ class StartChatDialog(Gtk.ApplicationWindow):
    69 65
             self.add_contacts()
    
    70 66
             self.add_groupchats()
    
    71 67
     
    
    72
    -        self.search_entry.connect('search-changed',
    
    73
    -                                  self._on_search_changed)
    
    74
    -        self.search_entry.connect('next-match',
    
    75
    -                                  self._select_new_match, 'next')
    
    76
    -        self.search_entry.connect('previous-match',
    
    77
    -                                  self._select_new_match, 'prev')
    
    78
    -        self.search_entry.connect('stop-search',
    
    79
    -                                  lambda *args: self.search_entry.set_text(''))
    
    68
    +        self._ui.search_entry.connect('search-changed',
    
    69
    +                                      self._on_search_changed)
    
    70
    +        self._ui.search_entry.connect('next-match',
    
    71
    +                                      self._select_new_match, 'next')
    
    72
    +        self._ui.search_entry.connect('previous-match',
    
    73
    +                                      self._select_new_match, 'prev')
    
    74
    +        self._ui.search_entry.connect(
    
    75
    +            'stop-search', lambda *args: self._ui.search_entry.set_text(''))
    
    80 76
     
    
    81
    -        self.listbox.set_filter_func(self._filter_func, None)
    
    82
    -        self.listbox.set_sort_func(self._sort_func, None)
    
    83
    -        self.listbox.connect('row-activated', self._on_row_activated)
    
    77
    +        self._ui.listbox.set_filter_func(self._filter_func, None)
    
    78
    +        self._ui.listbox.set_sort_func(self._sort_func, None)
    
    79
    +        self._ui.listbox.connect('row-activated', self._on_row_activated)
    
    84 80
     
    
    85 81
             self._muc_search_listbox = MUCSearch()
    
    86
    -        self._current_listbox = self.listbox
    
    82
    +        self._current_listbox = self._ui.listbox
    
    87 83
     
    
    88 84
             self.connect('key-press-event', self._on_key_press)
    
    89 85
             self.connect('destroy', self._destroy)
    
    ... ... @@ -102,7 +98,7 @@ class StartChatDialog(Gtk.ApplicationWindow):
    102 98
                         continue
    
    103 99
                     row = ContactRow(account, contact, jid,
    
    104 100
                                      contact.get_shown_name(), show_account)
    
    105
    -                self.listbox.add(row)
    
    101
    +                self._ui.listbox.add(row)
    
    106 102
     
    
    107 103
         def add_groupchats(self):
    
    108 104
             show_account = len(self.accounts) > 1
    
    ... ... @@ -125,7 +121,7 @@ class StartChatDialog(Gtk.ApplicationWindow):
    125 121
                         name = app.get_nick_from_jid(jid)
    
    126 122
                     row = ContactRow(account, None, jid, name,
    
    127 123
                                      show_account, True)
    
    128
    -                self.listbox.add(row)
    
    124
    +                self._ui.listbox.add(row)
    
    129 125
     
    
    130 126
         def _on_row_activated(self, listbox, row):
    
    131 127
             row = row.get_child()
    
    ... ... @@ -133,23 +129,23 @@ class StartChatDialog(Gtk.ApplicationWindow):
    133 129
     
    
    134 130
         def _on_key_press(self, widget, event):
    
    135 131
             if event.keyval in (Gdk.KEY_Down, Gdk.KEY_Tab):
    
    136
    -            self.search_entry.emit('next-match')
    
    132
    +            self._ui.search_entry.emit('next-match')
    
    137 133
                 return True
    
    138 134
     
    
    139 135
             if (event.state == Gdk.ModifierType.SHIFT_MASK and
    
    140 136
                     event.keyval == Gdk.KEY_ISO_Left_Tab):
    
    141
    -            self.search_entry.emit('previous-match')
    
    137
    +            self._ui.search_entry.emit('previous-match')
    
    142 138
                 return True
    
    143 139
     
    
    144 140
             if event.keyval == Gdk.KEY_Up:
    
    145
    -            self.search_entry.emit('previous-match')
    
    141
    +            self._ui.search_entry.emit('previous-match')
    
    146 142
                 return True
    
    147 143
     
    
    148 144
             if event.keyval == Gdk.KEY_Escape:
    
    149 145
                 self._search_stopped = True
    
    150 146
                 self._muc_search_listbox.remove_all()
    
    151
    -            if self.search_entry.get_text() != '':
    
    152
    -                self.search_entry.emit('stop-search')
    
    147
    +            if self._ui.search_entry.get_text() != '':
    
    148
    +                self._ui.search_entry.emit('stop-search')
    
    153 149
                 else:
    
    154 150
                     self.destroy()
    
    155 151
                 return True
    
    ... ... @@ -160,12 +156,12 @@ class StartChatDialog(Gtk.ApplicationWindow):
    160 156
                     self._start_search()
    
    161 157
                     return True
    
    162 158
     
    
    163
    -            row = self.listbox.get_selected_row()
    
    159
    +            row = self._ui.listbox.get_selected_row()
    
    164 160
                 if row is not None:
    
    165 161
                     row.emit('activate')
    
    166 162
                 return True
    
    167 163
     
    
    168
    -        self.search_entry.grab_focus_without_selecting()
    
    164
    +        self._ui.search_entry.grab_focus_without_selecting()
    
    169 165
     
    
    170 166
         def _start_new_chat(self, row):
    
    171 167
             if row.new:
    
    ... ... @@ -188,14 +184,14 @@ class StartChatDialog(Gtk.ApplicationWindow):
    188 184
         def _set_listbox(self, listbox):
    
    189 185
             if self._current_listbox == listbox:
    
    190 186
                 return
    
    191
    -        viewport = self.builder.scrolledwindow.get_child()
    
    187
    +        viewport = self._ui.scrolledwindow.get_child()
    
    192 188
             viewport.remove(viewport.get_child())
    
    193
    -        self.builder.scrolledwindow.remove(viewport)
    
    194
    -        self.builder.scrolledwindow.add(listbox)
    
    189
    +        self._ui.scrolledwindow.remove(viewport)
    
    190
    +        self._ui.scrolledwindow.add(listbox)
    
    195 191
             self._current_listbox = listbox
    
    196 192
     
    
    197 193
         def _current_listbox_is(self, box):
    
    198
    -        if self._current_listbox == self.listbox:
    
    194
    +        if self._current_listbox == self._ui.listbox:
    
    199 195
                 return box == Search.CONTACT
    
    200 196
             return box == Search.MUC
    
    201 197
     
    
    ... ... @@ -205,13 +201,13 @@ class StartChatDialog(Gtk.ApplicationWindow):
    205 201
                 self._set_listbox(self._muc_search_listbox)
    
    206 202
                 return
    
    207 203
     
    
    208
    -        self._set_listbox(self.listbox)
    
    204
    +        self._set_listbox(self._ui.listbox)
    
    209 205
             if '@' in search_text:
    
    210 206
                 self._add_new_jid_row()
    
    211 207
                 self._update_new_jid_rows(search_text)
    
    212 208
             else:
    
    213 209
                 self._remove_new_jid_row()
    
    214
    -        self.listbox.invalidate_filter()
    
    210
    +        self._ui.listbox.invalidate_filter()
    
    215 211
     
    
    216 212
         def _add_new_jid_row(self):
    
    217 213
             if self.new_contact_row_visible:
    
    ... ... @@ -222,8 +218,8 @@ class StartChatDialog(Gtk.ApplicationWindow):
    222 218
                 self.new_contact_rows[account] = row
    
    223 219
                 group_row = ContactRow(account, None, '', None, show_account, True)
    
    224 220
                 self.new_groupchat_rows[account] = group_row
    
    225
    -            self.listbox.add(row)
    
    226
    -            self.listbox.add(group_row)
    
    221
    +            self._ui.listbox.add(row)
    
    222
    +            self._ui.listbox.add(group_row)
    
    227 223
                 row.get_parent().show_all()
    
    228 224
             self.new_contact_row_visible = True
    
    229 225
     
    
    ... ... @@ -231,8 +227,10 @@ class StartChatDialog(Gtk.ApplicationWindow):
    231 227
             if not self.new_contact_row_visible:
    
    232 228
                 return
    
    233 229
             for account in self.new_contact_rows:
    
    234
    -            self.listbox.remove(self.new_contact_rows[account].get_parent())
    
    235
    -            self.listbox.remove(self.new_groupchat_rows[account].get_parent())
    
    230
    +            self._ui.listbox.remove(
    
    231
    +                self.new_contact_rows[account].get_parent())
    
    232
    +            self._ui.listbox.remove(
    
    233
    +                self.new_groupchat_rows[account].get_parent())
    
    236 234
             self.new_contact_row_visible = False
    
    237 235
     
    
    238 236
         def _update_new_jid_rows(self, search_text):
    
    ... ... @@ -241,7 +239,7 @@ class StartChatDialog(Gtk.ApplicationWindow):
    241 239
                 self.new_groupchat_rows[account].update_jid(search_text)
    
    242 240
     
    
    243 241
         def _select_new_match(self, entry, direction):
    
    244
    -        selected_row = self.listbox.get_selected_row()
    
    242
    +        selected_row = self._ui.listbox.get_selected_row()
    
    245 243
             if selected_row is None:
    
    246 244
                 return
    
    247 245
     
    
    ... ... @@ -253,11 +251,11 @@ class StartChatDialog(Gtk.ApplicationWindow):
    253 251
                 index -= 1
    
    254 252
     
    
    255 253
             while True:
    
    256
    -            new_selected_row = self.listbox.get_row_at_index(index)
    
    254
    +            new_selected_row = self._ui.listbox.get_row_at_index(index)
    
    257 255
                 if new_selected_row is None:
    
    258 256
                     return
    
    259 257
                 if new_selected_row.get_child_visible():
    
    260
    -                self.listbox.select_row(new_selected_row)
    
    258
    +                self._ui.listbox.select_row(new_selected_row)
    
    261 259
                     new_selected_row.grab_focus()
    
    262 260
                     return
    
    263 261
                 if direction == 'next':
    
    ... ... @@ -266,11 +264,11 @@ class StartChatDialog(Gtk.ApplicationWindow):
    266 264
                     index -= 1
    
    267 265
     
    
    268 266
         def select_first_row(self):
    
    269
    -        first_row = self.listbox.get_row_at_y(0)
    
    270
    -        self.listbox.select_row(first_row)
    
    267
    +        first_row = self._ui.listbox.get_row_at_y(0)
    
    268
    +        self._ui.listbox.select_row(first_row)
    
    271 269
     
    
    272 270
         def _filter_func(self, row, user_data):
    
    273
    -        search_text = self.search_entry.get_text().lower()
    
    271
    +        search_text = self._ui.search_entry.get_text().lower()
    
    274 272
             search_text_list = search_text.split()
    
    275 273
             row_text = row.get_child().get_search_text().lower()
    
    276 274
             for text in search_text_list:
    
    ... ... @@ -317,7 +315,7 @@ class StartChatDialog(Gtk.ApplicationWindow):
    317 315
             except NotConnected:
    
    318 316
                 return
    
    319 317
     
    
    320
    -        text = self.search_entry.get_text()
    
    318
    +        text = self._ui.search_entry.get_text()
    
    321 319
             text = text[2:].strip()
    
    322 320
             self._muc_search_listbox.start_search()
    
    323 321
     
    
    ... ... @@ -406,14 +404,14 @@ class ContactRow(Gtk.Grid):
    406 404
             else:
    
    407 405
                 scale = self.get_scale_factor()
    
    408 406
                 avatar = app.contacts.get_avatar(
    
    409
    -                account, jid, AvatarSize.ROSTER, scale)
    
    407
    +                account, jid, AvatarSize.CHAT, scale)
    
    410 408
                 if avatar is None:
    
    411 409
                     image = Gtk.Image.new_from_icon_name(
    
    412 410
                         'avatar-default', Gtk.IconSize.DND)
    
    413 411
                 else:
    
    414 412
                     image = Gtk.Image.new_from_surface(avatar)
    
    415 413
     
    
    416
    -        image.set_size_request(AvatarSize.ROSTER, AvatarSize.ROSTER)
    
    414
    +        image.set_size_request(AvatarSize.CHAT, AvatarSize.CHAT)
    
    417 415
             self.add(image)
    
    418 416
     
    
    419 417
             middle_box = Gtk.Box(orientation=Gtk.Orientation.VERTICAL, spacing=0)
    
    ... ... @@ -421,9 +419,9 @@ class ContactRow(Gtk.Grid):
    421 419
     
    
    422 420
             if self.name is None:
    
    423 421
                 if self.groupchat:
    
    424
    -                self.name = _('New Groupchat')
    
    422
    +                self.name = _('Join Group Chat')
    
    425 423
                 else:
    
    426
    -                self.name = _('New Contact')
    
    424
    +                self.name = _('Add Contact')
    
    427 425
     
    
    428 426
             self.name_label = Gtk.Label(label=self.name)
    
    429 427
             self.name_label.set_ellipsize(Pango.EllipsizeMode.END)