diff --git a/data/glade/profile_window.glade b/data/glade/profile_window.glade index 39c8acb9f..4c01dddd6 100644 --- a/data/glade/profile_window.glade +++ b/data/glade/profile_window.glade @@ -1828,159 +1828,187 @@ - + True - GTK_BUTTONBOX_END - 12 + False + 0 - + True - True - True - GTK_RELIEF_NORMAL - True - - - - - True - 0 - 0 - 0 - 0 - 0 - 0 - 0 - 0 - - - - True - False - 2 - - - - True - gtk-go-up - 4 - 0 - 0 - 0 - 0 - - - 0 - False - False - - - - - - True - _Publish - True - False - GTK_JUSTIFY_LEFT - False - False - 0 - 0.5 - 0 - 0 - PANGO_ELLIPSIZE_NONE - -1 - False - 0 - - - 0 - False - False - - - - - - + GTK_PROGRESS_LEFT_TO_RIGHT + 0 + 0.10000000149 + PANGO_ELLIPSIZE_NONE + + 0 + False + False + - + True - True - True - GTK_RELIEF_NORMAL - True - + GTK_BUTTONBOX_END + 12 - + True - 0 - 0 - 0 - 0 - 0 - 0 - 0 - 0 + True + True + GTK_RELIEF_NORMAL + True + - + True - False - 2 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 - + True - gtk-go-down - 4 - 0 - 0 - 0 - 0 + False + 2 + + + + True + gtk-go-up + 4 + 0 + 0 + 0 + 0 + + + 0 + False + False + + + + + + True + _Publish + True + False + GTK_JUSTIFY_LEFT + False + False + 0 + 0.5 + 0 + 0 + PANGO_ELLIPSIZE_NONE + -1 + False + 0 + + + 0 + False + False + + - - 0 - False - False - + + + + + + + + True + True + True + GTK_RELIEF_NORMAL + True + + + + + True + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 - + True - _Retrieve - True - False - GTK_JUSTIFY_LEFT - False - False - 0 - 0.5 - 0 - 0 - PANGO_ELLIPSIZE_NONE - -1 - False - 0 + False + 2 + + + + True + gtk-go-down + 4 + 0 + 0 + 0 + 0 + + + 0 + False + False + + + + + + True + _Retrieve + True + False + GTK_JUSTIFY_LEFT + False + False + 0 + 0.5 + 0 + 0 + PANGO_ELLIPSIZE_NONE + -1 + False + 0 + + + 0 + False + False + + - - 0 - False - False - + + 0 + True + True + diff --git a/src/gajim.py b/src/gajim.py index a673c7fbc..4a602a397 100755 --- a/src/gajim.py +++ b/src/gajim.py @@ -1009,7 +1009,7 @@ class Interface: return # Add it to roster contact = gajim.contacts.create_contact(jid = jid, name = name, - groups = groups, show = 'offline', sub = sub, ask = ask) + groups = groups, show = 'offline', sub = sub, ask = ask) gajim.contacts.add_contact(account, contact) self.roster.add_contact_to_roster(jid, account) else: @@ -1327,7 +1327,9 @@ class Interface: self.instances[account]['xml_console'].print_stanza(stanza, 'outgoing') def handle_event_vcard_published(self, account, array): - dialogs.InformationDialog(_('vCard publication succeeded'), _('Your personal information has been published successfully.')) + if self.instances[account].has_key('profile'): + win = self.instances[account]['profile'] + win.vcard_published() for gc_control in self.msg_win_mgr.get_controls(message_control.TYPE_GC): if gc_control.account == account: show = gajim.SHOW_LIST[gajim.connections[account].connected] @@ -1336,7 +1338,9 @@ class Interface: gc_control.room_jid, show, status) def handle_event_vcard_not_published(self, account, array): - dialogs.InformationDialog(_('vCard publication failed'), _('There was an error while publishing your personal information, try again later.')) + if self.instances[account].has_key('profile'): + win = self.instances[account]['profile'] + win.vcard_not_published() def handle_event_signed_in(self, account, empty): '''SIGNED_IN event is emitted when we sign in, so handle it''' diff --git a/src/profile_window.py b/src/profile_window.py index edb39b974..5d6f8baeb 100644 --- a/src/profile_window.py +++ b/src/profile_window.py @@ -60,12 +60,15 @@ class ProfileWindow: def __init__(self, account): self.xml = gtkgui_helpers.get_glade('profile_window.glade') self.window = self.xml.get_widget('profile_window') + self.progressbar = self.xml.get_widget('progressbar') self.account = account self.jid = gajim.get_jid_from_account(account) self.avatar_mime_type = None self.avatar_encoded = None + self.update_progressbar_timeout_id = gobject.timeout_add(100, + self.update_progressbar) # Create Image for avatar button image = gtk.Image() @@ -73,6 +76,10 @@ class ProfileWindow: self.xml.signal_autoconnect(self) self.window.show_all() + def update_progressbar(self): + self.progressbar.pulse() + return True # loop forever + def on_profile_window_destroy(self, widget): del gajim.interface.instances[self.account]['profile'] @@ -203,6 +210,12 @@ class ProfileWindow: vcard[i], 0) else: self.set_value(i + '_entry', vcard[i]) + if self.update_progressbar_timeout_id is not None: + gobject.source_remove(self.update_progressbar_timeout_id) + # redraw progressbar after avatar is set so that windows is already + # resized. Else progressbar is not correctly redrawn + gobject.idle_add(self.progressbar.set_fraction, 0) + self.update_progressbar_timeout_id = None def add_to_vcard(self, vcard, entry, txt): '''Add an information to the vCard dictionary''' @@ -260,6 +273,9 @@ class ProfileWindow: return vcard def on_publish_button_clicked(self, widget): + if self.update_progressbar_timeout_id: + # Operation in progress + return if gajim.connections[self.account].connected < 2: dialogs.ErrorDialog(_('You are not connected to the server'), _('Without a connection you can not publish your contact ' @@ -273,8 +289,28 @@ class ProfileWindow: nick = gajim.config.get_per('accounts', self.account, 'name') gajim.nicks[self.account] = nick gajim.connections[self.account].send_vcard(vcard) + self.update_progressbar_timeout_id = gobject.timeout_add(100, + self.update_progressbar) + + def vcard_published(self): + if self.update_progressbar_timeout_id is not None: + gobject.source_remove(self.update_progressbar_timeout_id) + self.progressbar.set_fraction(0) + self.update_progressbar_timeout_id = None + + def vcard_not_published(self): + if self.update_progressbar_timeout_id is not None: + gobject.source_remove(self.update_progressbar_timeout_id) + self.progressbar.set_fraction(0) + self.update_progressbar_timeout_id = None + dialogs.InformationDialog(_('vCard publication failed'), + _('There was an error while publishing your personal information, ' + 'try again later.')) def on_retrieve_button_clicked(self, widget): + if self.update_progressbar_timeout_id: + # Operation in progress + return entries = ['FN', 'NICKNAME', 'BDAY', 'EMAIL_HOME_USERID', 'URL', 'TEL_HOME_NUMBER', 'N_FAMILY', 'N_GIVEN', 'N_MIDDLE', 'N_PREFIX', 'N_SUFFIX', 'ADR_HOME_STREET', 'ADR_HOME_EXTADR', 'ADR_HOME_LOCALITY', @@ -294,4 +330,6 @@ class ProfileWindow: gajim.connections[self.account].request_vcard(self.jid) else: dialogs.ErrorDialog(_('You are not connected to the server'), - _('Without a connection, you can not get your contact information.')) + _('Without a connection, you can not get your contact information.')) + self.update_progressbar_timeout_id = gobject.timeout_add(100, + self.update_progressbar)