From b5c4edb60a099da0f8b9135a268836909aa5cb2c Mon Sep 17 00:00:00 2001 From: Yann Leboulanger <asterix@lagaule.org> Date: Tue, 19 Sep 2006 07:52:40 +0000 Subject: [PATCH] add progressbar in profile window. For #1840 --- data/glade/profile_window.glade | 264 ++++++++++++++++++-------------- src/gajim.py | 10 +- src/profile_window.py | 40 ++++- 3 files changed, 192 insertions(+), 122 deletions(-) diff --git a/data/glade/profile_window.glade b/data/glade/profile_window.glade index 39c8acb9f0..4c01dddd60 100644 --- a/data/glade/profile_window.glade +++ b/data/glade/profile_window.glade @@ -1828,159 +1828,187 @@ </child> <child> - <widget class="GtkHButtonBox" id="information_hbuttonbox"> + <widget class="GtkHBox" id="hbox2"> <property name="visible">True</property> - <property name="layout_style">GTK_BUTTONBOX_END</property> - <property name="spacing">12</property> + <property name="homogeneous">False</property> + <property name="spacing">0</property> <child> - <widget class="GtkButton" id="publish_button"> + <widget class="GtkProgressBar" id="progressbar"> <property name="visible">True</property> - <property name="can_default">True</property> - <property name="can_focus">True</property> - <property name="relief">GTK_RELIEF_NORMAL</property> - <property name="focus_on_click">True</property> - <signal name="clicked" handler="on_publish_button_clicked"/> + <property name="orientation">GTK_PROGRESS_LEFT_TO_RIGHT</property> + <property name="fraction">0</property> + <property name="pulse_step">0.10000000149</property> + <property name="ellipsize">PANGO_ELLIPSIZE_NONE</property> + </widget> + <packing> + <property name="padding">0</property> + <property name="expand">False</property> + <property name="fill">False</property> + </packing> + </child> + + <child> + <widget class="GtkHButtonBox" id="information_hbuttonbox"> + <property name="visible">True</property> + <property name="layout_style">GTK_BUTTONBOX_END</property> + <property name="spacing">12</property> <child> - <widget class="GtkAlignment" id="alignment1"> + <widget class="GtkButton" id="publish_button"> <property name="visible">True</property> - <property name="xalign">0</property> - <property name="yalign">0</property> - <property name="xscale">0</property> - <property name="yscale">0</property> - <property name="top_padding">0</property> - <property name="bottom_padding">0</property> - <property name="left_padding">0</property> - <property name="right_padding">0</property> + <property name="can_default">True</property> + <property name="can_focus">True</property> + <property name="relief">GTK_RELIEF_NORMAL</property> + <property name="focus_on_click">True</property> + <signal name="clicked" handler="on_publish_button_clicked"/> <child> - <widget class="GtkHBox" id="hbox1"> + <widget class="GtkAlignment" id="alignment1"> <property name="visible">True</property> - <property name="homogeneous">False</property> - <property name="spacing">2</property> - - <child> - <widget class="GtkImage" id="image1"> - <property name="visible">True</property> - <property name="stock">gtk-go-up</property> - <property name="icon_size">4</property> - <property name="xalign">0</property> - <property name="yalign">0</property> - <property name="xpad">0</property> - <property name="ypad">0</property> - </widget> - <packing> - <property name="padding">0</property> - <property name="expand">False</property> - <property name="fill">False</property> - </packing> - </child> + <property name="xalign">0</property> + <property name="yalign">0</property> + <property name="xscale">0</property> + <property name="yscale">0</property> + <property name="top_padding">0</property> + <property name="bottom_padding">0</property> + <property name="left_padding">0</property> + <property name="right_padding">0</property> <child> - <widget class="GtkLabel" id="label1"> + <widget class="GtkHBox" id="hbox1"> <property name="visible">True</property> - <property name="label" translatable="yes">_Publish</property> - <property name="use_underline">True</property> - <property name="use_markup">False</property> - <property name="justify">GTK_JUSTIFY_LEFT</property> - <property name="wrap">False</property> - <property name="selectable">False</property> - <property name="xalign">0</property> - <property name="yalign">0.5</property> - <property name="xpad">0</property> - <property name="ypad">0</property> - <property name="ellipsize">PANGO_ELLIPSIZE_NONE</property> - <property name="width_chars">-1</property> - <property name="single_line_mode">False</property> - <property name="angle">0</property> + <property name="homogeneous">False</property> + <property name="spacing">2</property> + + <child> + <widget class="GtkImage" id="image1"> + <property name="visible">True</property> + <property name="stock">gtk-go-up</property> + <property name="icon_size">4</property> + <property name="xalign">0</property> + <property name="yalign">0</property> + <property name="xpad">0</property> + <property name="ypad">0</property> + </widget> + <packing> + <property name="padding">0</property> + <property name="expand">False</property> + <property name="fill">False</property> + </packing> + </child> + + <child> + <widget class="GtkLabel" id="label1"> + <property name="visible">True</property> + <property name="label" translatable="yes">_Publish</property> + <property name="use_underline">True</property> + <property name="use_markup">False</property> + <property name="justify">GTK_JUSTIFY_LEFT</property> + <property name="wrap">False</property> + <property name="selectable">False</property> + <property name="xalign">0</property> + <property name="yalign">0.5</property> + <property name="xpad">0</property> + <property name="ypad">0</property> + <property name="ellipsize">PANGO_ELLIPSIZE_NONE</property> + <property name="width_chars">-1</property> + <property name="single_line_mode">False</property> + <property name="angle">0</property> + </widget> + <packing> + <property name="padding">0</property> + <property name="expand">False</property> + <property name="fill">False</property> + </packing> + </child> </widget> - <packing> - <property name="padding">0</property> - <property name="expand">False</property> - <property name="fill">False</property> - </packing> </child> </widget> </child> </widget> </child> - </widget> - </child> - - <child> - <widget class="GtkButton" id="retrieve_button"> - <property name="visible">True</property> - <property name="can_default">True</property> - <property name="can_focus">True</property> - <property name="relief">GTK_RELIEF_NORMAL</property> - <property name="focus_on_click">True</property> - <signal name="clicked" handler="on_retrieve_button_clicked"/> <child> - <widget class="GtkAlignment" id="alignment2"> + <widget class="GtkButton" id="retrieve_button"> <property name="visible">True</property> - <property name="xalign">0</property> - <property name="yalign">0</property> - <property name="xscale">0</property> - <property name="yscale">0</property> - <property name="top_padding">0</property> - <property name="bottom_padding">0</property> - <property name="left_padding">0</property> - <property name="right_padding">0</property> + <property name="can_default">True</property> + <property name="can_focus">True</property> + <property name="relief">GTK_RELIEF_NORMAL</property> + <property name="focus_on_click">True</property> + <signal name="clicked" handler="on_retrieve_button_clicked"/> <child> - <widget class="GtkHBox" id="hbox2"> + <widget class="GtkAlignment" id="alignment2"> <property name="visible">True</property> - <property name="homogeneous">False</property> - <property name="spacing">2</property> - - <child> - <widget class="GtkImage" id="image2"> - <property name="visible">True</property> - <property name="stock">gtk-go-down</property> - <property name="icon_size">4</property> - <property name="xalign">0</property> - <property name="yalign">0</property> - <property name="xpad">0</property> - <property name="ypad">0</property> - </widget> - <packing> - <property name="padding">0</property> - <property name="expand">False</property> - <property name="fill">False</property> - </packing> - </child> + <property name="xalign">0</property> + <property name="yalign">0</property> + <property name="xscale">0</property> + <property name="yscale">0</property> + <property name="top_padding">0</property> + <property name="bottom_padding">0</property> + <property name="left_padding">0</property> + <property name="right_padding">0</property> <child> - <widget class="GtkLabel" id="label2"> + <widget class="GtkHBox" id="hbox2"> <property name="visible">True</property> - <property name="label" translatable="yes">_Retrieve</property> - <property name="use_underline">True</property> - <property name="use_markup">False</property> - <property name="justify">GTK_JUSTIFY_LEFT</property> - <property name="wrap">False</property> - <property name="selectable">False</property> - <property name="xalign">0</property> - <property name="yalign">0.5</property> - <property name="xpad">0</property> - <property name="ypad">0</property> - <property name="ellipsize">PANGO_ELLIPSIZE_NONE</property> - <property name="width_chars">-1</property> - <property name="single_line_mode">False</property> - <property name="angle">0</property> + <property name="homogeneous">False</property> + <property name="spacing">2</property> + + <child> + <widget class="GtkImage" id="image2"> + <property name="visible">True</property> + <property name="stock">gtk-go-down</property> + <property name="icon_size">4</property> + <property name="xalign">0</property> + <property name="yalign">0</property> + <property name="xpad">0</property> + <property name="ypad">0</property> + </widget> + <packing> + <property name="padding">0</property> + <property name="expand">False</property> + <property name="fill">False</property> + </packing> + </child> + + <child> + <widget class="GtkLabel" id="label2"> + <property name="visible">True</property> + <property name="label" translatable="yes">_Retrieve</property> + <property name="use_underline">True</property> + <property name="use_markup">False</property> + <property name="justify">GTK_JUSTIFY_LEFT</property> + <property name="wrap">False</property> + <property name="selectable">False</property> + <property name="xalign">0</property> + <property name="yalign">0.5</property> + <property name="xpad">0</property> + <property name="ypad">0</property> + <property name="ellipsize">PANGO_ELLIPSIZE_NONE</property> + <property name="width_chars">-1</property> + <property name="single_line_mode">False</property> + <property name="angle">0</property> + </widget> + <packing> + <property name="padding">0</property> + <property name="expand">False</property> + <property name="fill">False</property> + </packing> + </child> </widget> - <packing> - <property name="padding">0</property> - <property name="expand">False</property> - <property name="fill">False</property> - </packing> </child> </widget> </child> </widget> </child> </widget> + <packing> + <property name="padding">0</property> + <property name="expand">True</property> + <property name="fill">True</property> + </packing> </child> </widget> <packing> diff --git a/src/gajim.py b/src/gajim.py index a673c7fbc3..4a602a397c 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 edb39b974e..5d6f8baebf 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) -- GitLab