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: try:
return resourceprep.prepare(unicode(resource)) return resourceprep.prepare(unicode(resource))
except UnicodeError: except UnicodeError:
raise InvalidFormat, "Invalid character in resource" raise InvalidFormat, 'Invalid character in resource.'
def prep(user, server, resource): def prep(user, server, resource):
'''Perform stringprep on all JID fragments and return the full jid''' '''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: if user:
try: try:
user = nodeprep.prepare(unicode(user)) user = nodeprep.prepare(unicode(user))
except UnicodeError: except UnicodeError:
raise InvalidFormat, "Invalid character in username" raise InvalidFormat, 'Invalid character in username.'
else: else:
user = None user = None
if not server: if not server:
raise InvalidFormat, "Server address required." raise InvalidFormat, 'Server address required.'
else: else:
try: try:
server = nameprep.prepare(unicode(server)) server = nameprep.prepare(unicode(server))
except UnicodeError: except UnicodeError:
raise InvalidFormat, "Invalid character in hostname" raise InvalidFormat, 'Invalid character in hostname'
if resource: if resource:
try: try:
resource = resourceprep.prepare(unicode(resource)) resource = resourceprep.prepare(unicode(resource))
except UnicodeError: except UnicodeError:
raise InvalidFormat, "Invalid character in resource" raise InvalidFormat, 'Invalid character in resource.'
else: else:
resource = None resource = None
if user: if user:
if resource: if resource:
return "%s@%s/%s" % (user, server, resource) return '%s@%s/%s' % (user, server, resource)
else: else:
return "%s@%s" % (user, server) return '%s@%s' % (user, server)
else: else:
if resource: if resource:
return "%s/%s" % (server, resource) return '%s/%s' % (server, resource)
else: else:
return server return server

View file

@ -2418,7 +2418,7 @@ class AccountCreationWizardWindow:
APP) APP)
self.window = self.xml.get_widget('account_creation_wizard_window') 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 = self.xml.get_widget('server_comboboxentry')
server_comboboxentry.child.connect('key_press_event', server_comboboxentry.child.connect('key_press_event',
self.on_server_comboboxentry_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.advanced_button = self.xml.get_widget('advanced_button')
self.finish_label = self.xml.get_widget('finish_label') self.finish_label = self.xml.get_widget('finish_label')
self.go_online_checkbutton = self.xml.get_widget('go_online_checkbutton') self.go_online_checkbutton = self.xml.get_widget('go_online_checkbutton')
self.progressbar = self.xml.get_widget('progressbar')
# Some vars # Some vars
self.sync = False self.sync = False
self.autoconnect = False self.autoconnect = False
self.update_progressbar_timeout_id = None
if len(gajim.connections) == 0: # is it the first accound we're creating? if len(gajim.connections) == 0: # is it the first accound we're creating?
# the first account *has* to sync by default # the first account *has* to sync by default
self.sync = True self.sync = True
@ -2486,7 +2489,7 @@ class AccountCreationWizardWindow:
def get_widgets(self): def get_widgets(self):
widgets = {} widgets = {}
for widget in ( for widget in (
'nick_entry', 'username_entry',
'server_comboboxentry', 'server_comboboxentry',
'pass_entry', 'pass_entry',
'save_password_checkbutton', 'save_password_checkbutton',
@ -2515,10 +2518,10 @@ class AccountCreationWizardWindow:
else: else:
widgets = self.get_widgets() 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: if not username:
pritext = _('Invalid nickname') pritext = _('Invalid username')
sectext = _('You must provide a nickname to configure this account.') sectext = _('You must provide a username to configure this account.')
dialogs.ErrorDialog(pritext, sectext).get_response() dialogs.ErrorDialog(pritext, sectext).get_response()
return return
server = widgets['server_comboboxentry'].child.get_text() server = widgets['server_comboboxentry'].child.get_text()
@ -2558,6 +2561,12 @@ class AccountCreationWizardWindow:
self.notebook.set_current_page(3) # show finish page self.notebook.set_current_page(3) # show finish page
else: else:
self.notebook.set_current_page(2) # show creqting page 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): def acc_is_ok(self, config):
'''Account creation succeeded''' '''Account creation succeeded'''
@ -2575,6 +2584,9 @@ class AccountCreationWizardWindow:
'You can set advanced account options by pressing Advanced button,\nor later by clicking in Accounts menuitem under Edit menu from the main window.') 'You can set advanced account options by pressing Advanced button,\nor later by clicking in Accounts menuitem under Edit menu from the main window.')
self.finish_label.set_text(finish_text) self.finish_label.set_text(finish_text)
self.notebook.set_current_page(3) # show finish page 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): def acc_is_not_ok(self, reason):
'''Account creation failed''' '''Account creation failed'''
@ -2599,13 +2611,13 @@ class AccountCreationWizardWindow:
if go_online: if go_online:
gajim.interface.roster.send_status(self.account, '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) self.update_jid(widget)
def on_server_comboboxentry_changed(self, widget): def on_server_comboboxentry_changed(self, widget):
self.update_jid(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 # Check for pressed @ and jump to combobox if found
if event.keyval == gtk.keysyms.at: if event.keyval == gtk.keysyms.at:
combobox = self.xml.get_widget('server_comboboxentry') combobox = self.xml.get_widget('server_comboboxentry')
@ -2619,14 +2631,14 @@ class AccountCreationWizardWindow:
combobox = self.xml.get_widget('server_comboboxentry') combobox = self.xml.get_widget('server_comboboxentry')
empty = len(combobox.get_active_text()) == 0 empty = len(combobox.get_active_text()) == 0
if backspace and empty: if backspace and empty:
nick_entry = self.xml.get_widget('nick_entry') username_entry = self.xml.get_widget('username_entry')
nick_entry.grab_focus() username_entry.grab_focus()
nick_entry.set_position(-1) username_entry.set_position(-1)
return True return True
def update_jid(self,widget): def update_jid(self,widget):
nick_entry = self.xml.get_widget('nick_entry') username_entry = self.xml.get_widget('username_entry')
name = nick_entry.get_text().decode('utf-8') name = username_entry.get_text().decode('utf-8')
combobox = self.xml.get_widget('server_comboboxentry') combobox = self.xml.get_widget('server_comboboxentry')
server = combobox.get_active_text() server = combobox.get_active_text()
jid_label = self.xml.get_widget('jid_label') jid_label = self.xml.get_widget('jid_label')

View file

@ -12773,7 +12773,7 @@ Status message</property>
<widget class="GtkRadioButton" id="remove_only_radiobutton"> <widget class="GtkRadioButton" id="remove_only_radiobutton">
<property name="visible">True</property> <property name="visible">True</property>
<property name="can_focus">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="use_underline">True</property>
<property name="relief">GTK_RELIEF_NORMAL</property> <property name="relief">GTK_RELIEF_NORMAL</property>
<property name="focus_on_click">True</property> <property name="focus_on_click">True</property>
@ -12792,7 +12792,7 @@ Status message</property>
<widget class="GtkRadioButton" id="remove_and_unregister_radiobutton"> <widget class="GtkRadioButton" id="remove_and_unregister_radiobutton">
<property name="visible">True</property> <property name="visible">True</property>
<property name="can_focus">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="use_underline">True</property>
<property name="relief">GTK_RELIEF_NORMAL</property> <property name="relief">GTK_RELIEF_NORMAL</property>
<property name="focus_on_click">True</property> <property name="focus_on_click">True</property>
@ -13716,7 +13716,7 @@ to the Jabber network.</property>
<property name="column_spacing">12</property> <property name="column_spacing">12</property>
<child> <child>
<widget class="GtkEntry" id="nick_entry"> <widget class="GtkEntry" id="username_entry">
<property name="visible">True</property> <property name="visible">True</property>
<property name="can_focus">True</property> <property name="can_focus">True</property>
<property name="has_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="has_frame">True</property>
<property name="invisible_char">*</property> <property name="invisible_char">*</property>
<property name="activates_default">False</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="changed" handler="on_username_entry_changed" last_modification_time="Sat, 05 Nov 2005 11:13:14 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="key_press_event" handler="on_username_entry_key_press_event" last_modification_time="Sat, 05 Nov 2005 11:13:18 GMT"/>
</widget> </widget>
<packing> <packing>
<property name="left_attach">1</property> <property name="left_attach">1</property>
@ -13884,7 +13884,7 @@ to the Jabber network.</property>
<child> <child>
<widget class="GtkLabel" id="label262"> <widget class="GtkLabel" id="label262">
<property name="visible">True</property> <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_underline">True</property>
<property name="use_markup">False</property> <property name="use_markup">False</property>
<property name="justify">GTK_JUSTIFY_LEFT</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="yalign">0.5</property>
<property name="xpad">0</property> <property name="xpad">0</property>
<property name="ypad">0</property> <property name="ypad">0</property>
<property name="mnemonic_widget">nick_entry</property>
<property name="ellipsize">PANGO_ELLIPSIZE_NONE</property> <property name="ellipsize">PANGO_ELLIPSIZE_NONE</property>
<property name="width_chars">-1</property> <property name="width_chars">-1</property>
<property name="single_line_mode">False</property> <property name="single_line_mode">False</property>
@ -14266,11 +14265,12 @@ to the Jabber network.</property>
<child> <child>
<widget class="GtkLabel" id="label366"> <widget class="GtkLabel" id="label366">
<property name="visible">True</property> <property name="visible">True</property>
<property name="label" translatable="yes">Account is being created <property name="label" translatable="yes">&lt;b&gt;Account is being created&lt;/b&gt;
Please wait.</property>
Please wait...</property>
<property name="use_underline">False</property> <property name="use_underline">False</property>
<property name="use_markup">False</property> <property name="use_markup">True</property>
<property name="justify">GTK_JUSTIFY_LEFT</property> <property name="justify">GTK_JUSTIFY_CENTER</property>
<property name="wrap">False</property> <property name="wrap">False</property>
<property name="selectable">False</property> <property name="selectable">False</property>
<property name="xalign">0.5</property> <property name="xalign">0.5</property>
@ -14290,7 +14290,7 @@ Please wait.</property>
</child> </child>
<child> <child>
<widget class="GtkProgressBar" id="progressbar1"> <widget class="GtkProgressBar" id="progressbar">
<property name="visible">True</property> <property name="visible">True</property>
<property name="orientation">GTK_PROGRESS_LEFT_TO_RIGHT</property> <property name="orientation">GTK_PROGRESS_LEFT_TO_RIGHT</property>
<property name="fraction">0</property> <property name="fraction">0</property>