fix strings, add code for progressbar to work, fix a bit of ui

This commit is contained in:
Nikos Kouremenos 2005-11-05 11:28:19 +00:00
parent e0b1dd77f8
commit 8d26752f48
3 changed files with 46 additions and 33 deletions

View File

@ -84,44 +84,45 @@ def parse_resource(resource):
try:
return resourceprep.prepare(unicode(resource))
except UnicodeError:
raise InvalidFormat, "Invalid character in resource"
raise InvalidFormat, 'Invalid character in resource.'
def prep(user, server, resource):
'''Perform stringprep on all JID fragments and return the full jid'''
# This function comes from http://svn.twistedmatrix.com/cvs/trunk/twisted/words/protocols/jabber/jid.py
# This function comes from
#http://svn.twistedmatrix.com/cvs/trunk/twisted/words/protocols/jabber/jid.py
if user:
try:
user = nodeprep.prepare(unicode(user))
except UnicodeError:
raise InvalidFormat, "Invalid character in username"
raise InvalidFormat, 'Invalid character in username.'
else:
user = None
if not server:
raise InvalidFormat, "Server address required."
raise InvalidFormat, 'Server address required.'
else:
try:
server = nameprep.prepare(unicode(server))
except UnicodeError:
raise InvalidFormat, "Invalid character in hostname"
raise InvalidFormat, 'Invalid character in hostname'
if resource:
try:
resource = resourceprep.prepare(unicode(resource))
except UnicodeError:
raise InvalidFormat, "Invalid character in resource"
raise InvalidFormat, 'Invalid character in resource.'
else:
resource = None
if user:
if resource:
return "%s@%s/%s" % (user, server, resource)
return '%s@%s/%s' % (user, server, resource)
else:
return "%s@%s" % (user, server)
return '%s@%s' % (user, server)
else:
if resource:
return "%s/%s" % (server, resource)
return '%s/%s' % (server, resource)
else:
return server

View File

@ -2418,7 +2418,7 @@ class AccountCreationWizardWindow:
APP)
self.window = self.xml.get_widget('account_creation_wizard_window')
# Connect events from comboboxentry.child
# Connect events from combousboxentry.child
server_comboboxentry = self.xml.get_widget('server_comboboxentry')
server_comboboxentry.child.connect('key_press_event',
self.on_server_comboboxentry_key_press_event)
@ -2443,10 +2443,13 @@ class AccountCreationWizardWindow:
self.advanced_button = self.xml.get_widget('advanced_button')
self.finish_label = self.xml.get_widget('finish_label')
self.go_online_checkbutton = self.xml.get_widget('go_online_checkbutton')
self.progressbar = self.xml.get_widget('progressbar')
# Some vars
self.sync = False
self.autoconnect = False
self.update_progressbar_timeout_id = None
if len(gajim.connections) == 0: # is it the first accound we're creating?
# the first account *has* to sync by default
self.sync = True
@ -2486,7 +2489,7 @@ class AccountCreationWizardWindow:
def get_widgets(self):
widgets = {}
for widget in (
'nick_entry',
'username_entry',
'server_comboboxentry',
'pass_entry',
'save_password_checkbutton',
@ -2515,10 +2518,10 @@ class AccountCreationWizardWindow:
else:
widgets = self.get_widgets()
username = widgets['nick_entry'].get_text().decode('utf-8')
username = widgets['username_entry'].get_text().decode('utf-8')
if not username:
pritext = _('Invalid nickname')
sectext = _('You must provide a nickname to configure this account.')
pritext = _('Invalid username')
sectext = _('You must provide a username to configure this account.')
dialogs.ErrorDialog(pritext, sectext).get_response()
return
server = widgets['server_comboboxentry'].child.get_text()
@ -2558,6 +2561,12 @@ class AccountCreationWizardWindow:
self.notebook.set_current_page(3) # show finish page
else:
self.notebook.set_current_page(2) # show creqting page
self.update_progressbar_timeout_id = gobject.timeout_add(100,
self.update_progressbar)
def update_progressbar(self):
self.progressbar.pulse()
return True # loop forever
def acc_is_ok(self, config):
'''Account creation succeeded'''
@ -2576,6 +2585,9 @@ class AccountCreationWizardWindow:
self.finish_label.set_text(finish_text)
self.notebook.set_current_page(3) # show finish page
if self.update_progressbar_timeout_id is not None:
gobject.source_remove(self.update_progressbar_timeout_id)
def acc_is_not_ok(self, reason):
'''Account creation failed'''
self.back_button.show()
@ -2599,13 +2611,13 @@ class AccountCreationWizardWindow:
if go_online:
gajim.interface.roster.send_status(self.account, 'online', '')
def on_nick_entry_changed(self, widget):
def on_username_entry_changed(self, widget):
self.update_jid(widget)
def on_server_comboboxentry_changed(self, widget):
self.update_jid(widget)
def on_nick_entry_key_press_event(self, widget, event):
def on_username_entry_key_press_event(self, widget, event):
# Check for pressed @ and jump to combobox if found
if event.keyval == gtk.keysyms.at:
combobox = self.xml.get_widget('server_comboboxentry')
@ -2619,14 +2631,14 @@ class AccountCreationWizardWindow:
combobox = self.xml.get_widget('server_comboboxentry')
empty = len(combobox.get_active_text()) == 0
if backspace and empty:
nick_entry = self.xml.get_widget('nick_entry')
nick_entry.grab_focus()
nick_entry.set_position(-1)
username_entry = self.xml.get_widget('username_entry')
username_entry.grab_focus()
username_entry.set_position(-1)
return True
def update_jid(self,widget):
nick_entry = self.xml.get_widget('nick_entry')
name = nick_entry.get_text().decode('utf-8')
username_entry = self.xml.get_widget('username_entry')
name = username_entry.get_text().decode('utf-8')
combobox = self.xml.get_widget('server_comboboxentry')
server = combobox.get_active_text()
jid_label = self.xml.get_widget('jid_label')

View File

@ -12773,7 +12773,7 @@ Status message</property>
<widget class="GtkRadioButton" id="remove_only_radiobutton">
<property name="visible">True</property>
<property name="can_focus">True</property>
<property name="label" translatable="yes">Remove account only from Gajim</property>
<property name="label" translatable="yes">Remove account _only from Gajim</property>
<property name="use_underline">True</property>
<property name="relief">GTK_RELIEF_NORMAL</property>
<property name="focus_on_click">True</property>
@ -12792,7 +12792,7 @@ Status message</property>
<widget class="GtkRadioButton" id="remove_and_unregister_radiobutton">
<property name="visible">True</property>
<property name="can_focus">True</property>
<property name="label" translatable="yes">Remove account from Gajim and from server</property>
<property name="label" translatable="yes">Remove account from Gajim and from _server</property>
<property name="use_underline">True</property>
<property name="relief">GTK_RELIEF_NORMAL</property>
<property name="focus_on_click">True</property>
@ -13716,7 +13716,7 @@ to the Jabber network.</property>
<property name="column_spacing">12</property>
<child>
<widget class="GtkEntry" id="nick_entry">
<widget class="GtkEntry" id="username_entry">
<property name="visible">True</property>
<property name="can_focus">True</property>
<property name="has_focus">True</property>
@ -13727,8 +13727,8 @@ to the Jabber network.</property>
<property name="has_frame">True</property>
<property name="invisible_char">*</property>
<property name="activates_default">False</property>
<signal name="changed" handler="on_nick_entry_changed" last_modification_time="Thu, 08 Sep 2005 15:49:27 GMT"/>
<signal name="key_press_event" handler="on_nick_entry_key_press_event" last_modification_time="Mon, 12 Sep 2005 18:51:33 GMT"/>
<signal name="changed" handler="on_username_entry_changed" last_modification_time="Sat, 05 Nov 2005 11:13:14 GMT"/>
<signal name="key_press_event" handler="on_username_entry_key_press_event" last_modification_time="Sat, 05 Nov 2005 11:13:18 GMT"/>
</widget>
<packing>
<property name="left_attach">1</property>
@ -13884,7 +13884,7 @@ to the Jabber network.</property>
<child>
<widget class="GtkLabel" id="label262">
<property name="visible">True</property>
<property name="label" translatable="yes">_Nickname:</property>
<property name="label" translatable="yes">_Username:</property>
<property name="use_underline">True</property>
<property name="use_markup">False</property>
<property name="justify">GTK_JUSTIFY_LEFT</property>
@ -13894,7 +13894,6 @@ to the Jabber network.</property>
<property name="yalign">0.5</property>
<property name="xpad">0</property>
<property name="ypad">0</property>
<property name="mnemonic_widget">nick_entry</property>
<property name="ellipsize">PANGO_ELLIPSIZE_NONE</property>
<property name="width_chars">-1</property>
<property name="single_line_mode">False</property>
@ -14266,11 +14265,12 @@ to the Jabber network.</property>
<child>
<widget class="GtkLabel" id="label366">
<property name="visible">True</property>
<property name="label" translatable="yes">Account is being created
Please wait.</property>
<property name="label" translatable="yes">&lt;b&gt;Account is being created&lt;/b&gt;
Please wait...</property>
<property name="use_underline">False</property>
<property name="use_markup">False</property>
<property name="justify">GTK_JUSTIFY_LEFT</property>
<property name="use_markup">True</property>
<property name="justify">GTK_JUSTIFY_CENTER</property>
<property name="wrap">False</property>
<property name="selectable">False</property>
<property name="xalign">0.5</property>
@ -14290,7 +14290,7 @@ Please wait.</property>
</child>
<child>
<widget class="GtkProgressBar" id="progressbar1">
<widget class="GtkProgressBar" id="progressbar">
<property name="visible">True</property>
<property name="orientation">GTK_PROGRESS_LEFT_TO_RIGHT</property>
<property name="fraction">0</property>