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

Commits:

2 changed files:

Changes:

  • gajim/gtk/profile.py
    ... ... @@ -66,6 +66,7 @@ def __init__(self, account, *args):
    66 66
     
    
    67 67
             self._avatar_selector = None
    
    68 68
             self._current_avatar = None
    
    69
    +        self._current_vcard = None
    
    69 70
             self._avatar_nick_public = None
    
    70 71
     
    
    71 72
             # False  - no change to avatar
    
    ... ... @@ -75,8 +76,8 @@ def __init__(self, account, *args):
    75 76
     
    
    76 77
             self._ui.nickname_entry.set_text(app.nicks[account])
    
    77 78
     
    
    78
    -        self._profile = VCardGrid(self.account)
    
    79
    -        self._ui.profile_box.add(self._profile)
    
    79
    +        self._vcard_grid = VCardGrid(self.account)
    
    80
    +        self._ui.profile_box.add(self._vcard_grid)
    
    80 81
     
    
    81 82
             self.add(self._ui.profile_stack)
    
    82 83
             self.show_all()
    
    ... ... @@ -134,13 +135,13 @@ def _on_access_model_received(self, task):
    134 135
     
    
    135 136
         def _on_vcard_received(self, task):
    
    136 137
             try:
    
    137
    -            vcard = task.finish()
    
    138
    +            self._current_vcard = task.finish()
    
    138 139
             except StanzaError as error:
    
    139 140
                 log.info('Error loading VCard: %s', error)
    
    140
    -            vcard = VCard()
    
    141
    +            self._current_vcard = VCard()
    
    141 142
     
    
    142 143
             self._load_avatar()
    
    143
    -        self._profile.set_vcard(vcard)
    
    144
    +        self._vcard_grid.set_vcard(self._current_vcard.copy())
    
    144 145
             self._ui.profile_stack.set_visible_child_name('profile')
    
    145 146
             self._ui.spinner.stop()
    
    146 147
     
    
    ... ... @@ -169,11 +170,11 @@ def _add_actions(self):
    169 170
         def _on_action(self, action, _param):
    
    170 171
             name = action.get_name()
    
    171 172
             key = name.split('-')[1]
    
    172
    -        self._profile.add_new_property(key)
    
    173
    +        self._vcard_grid.add_new_property(key)
    
    173 174
             GLib.idle_add(scroll_to_end, self._ui.scrolled)
    
    174 175
     
    
    175 176
         def _on_edit_clicked(self, *args):
    
    176
    -        self._profile.set_editable(True)
    
    177
    +        self._vcard_grid.set_editable(True)
    
    177 178
             self._ui.edit_button.hide()
    
    178 179
             self._ui.add_entry_button.set_no_show_all(False)
    
    179 180
             self._ui.add_entry_button.show_all()
    
    ... ... @@ -185,7 +186,7 @@ def _on_edit_clicked(self, *args):
    185 186
             self._ui.privacy_button.show()
    
    186 187
     
    
    187 188
         def _on_cancel_clicked(self, _widget):
    
    188
    -        self._profile.set_editable(False)
    
    189
    +        self._vcard_grid.set_editable(False)
    
    189 190
             self._ui.edit_button.show()
    
    190 191
             self._ui.add_entry_button.hide()
    
    191 192
             self._ui.cancel_button.hide()
    
    ... ... @@ -196,6 +197,8 @@ def _on_cancel_clicked(self, _widget):
    196 197
             self._ui.nickname_entry.set_sensitive(False)
    
    197 198
             self._ui.avatar_image.set_from_surface(self._current_avatar)
    
    198 199
             self._ui.nickname_entry.set_text(app.nicks[self.account])
    
    200
    +        self._vcard_grid.clear()
    
    201
    +        self._vcard_grid.set_vcard(self._current_vcard.copy())
    
    199 202
             self._new_avatar = False
    
    200 203
     
    
    201 204
         def _on_save_clicked(self, _widget):
    
    ... ... @@ -210,11 +213,14 @@ def _on_save_clicked(self, _widget):
    210 213
             self._ui.privacy_button.hide()
    
    211 214
             self._ui.nickname_entry.set_sensitive(False)
    
    212 215
     
    
    213
    -        self._profile.validate()
    
    216
    +        self._vcard_grid.validate()
    
    217
    +
    
    218
    +        vcard = self._vcard_grid.get_vcard()
    
    219
    +        self._current_vcard = vcard.copy()
    
    214 220
     
    
    215 221
             con = app.connections[self.account]
    
    216 222
             con.get_module('VCard4').set_vcard(
    
    217
    -            self._profile.get_vcard(),
    
    223
    +            self._current_vcard,
    
    218 224
                 public=self._ui.vcard_access.get_active(),
    
    219 225
                 callback=self._on_save_finished)
    
    220 226
     
    
    ... ... @@ -302,6 +308,6 @@ def _on_save_finished(self, task):
    302 308
                 # TODO Handle error
    
    303 309
                 return
    
    304 310
     
    
    305
    -        self._profile.set_editable(False)
    
    311
    +        self._vcard_grid.set_editable(False)
    
    306 312
             self._ui.profile_stack.set_visible_child_name('profile')
    
    307 313
             self._ui.spinner.stop()

  • gajim/gtk/vcard_grid.py
    ... ... @@ -180,7 +180,6 @@ def add_new_property(self, name):
    180 180
             kwargs = DEFAULT_KWARGS[name]
    
    181 181
             prop = self._vcard.add_property(name, **kwargs)
    
    182 182
             self.add_property(prop, editable=True)
    
    183
    -        #GLib.idle_add(scroll_to_end, self.get_parent())
    
    184 183
     
    
    185 184
         def add_property(self, prop, editable=False):
    
    186 185
             prop_class = self._callbacks.get(prop.name)
    
    ... ... @@ -198,6 +197,14 @@ def remove_property(self, prop):
    198 197
             self._props.remove(prop)
    
    199 198
             self._vcard.remove_property(prop.get_base_property())
    
    200 199
     
    
    200
    +    def clear(self):
    
    201
    +        self._vcard = None
    
    202
    +        self._row_count = 0
    
    203
    +        for prop in list(self._props):
    
    204
    +            self.remove_row(prop.row_number)
    
    205
    +
    
    206
    +        self._props = []
    
    207
    +
    
    201 208
     
    
    202 209
     class DescriptionLabel(Gtk.Label):
    
    203 210
         def __init__(self, value):