we now show a happy dialog on nick conflict asking (and even proposing new nick); also refactor code and add a new gtkgui helper

This commit is contained in:
Nikos Kouremenos 2005-10-03 18:19:31 +00:00
parent 11d3316af2
commit f6470778a6
4 changed files with 26 additions and 26 deletions

View File

@ -345,7 +345,7 @@ class Connection:
jid_from = prs.getFrom()
who = unicode(jid_from)
jid_stripped = jid_from.getStripped()
resource = jid_from.getResource()
resource = jid_from.getResource()
status = prs.getStatus()
show = prs.getShow()
if not show in STATUS_LIST:
@ -393,9 +393,11 @@ class Connection:
_('You are not in the members list.')))
elif errcode == '409': # nick conflict
# the jid_from in this case is FAKE JID: room_jid/nick
# resource holds the bad nick so propose a new one
proposed_nickname = resource + '_'
room_jid = gajim.get_room_from_fjid(who)
self.dispatch('ASK_NEW_NICK', (room_jid, _('Unable to join room'),
_('Your desired nickname is in use or registered by another occupant. Please use another:')))
_('Your desired nickname is in use or registered by another occupant.\nPlease specify another nickname below:'), proposed_nickname))
else: # print in the window the error
self.dispatch('ERROR_ANSWER', ('', jid_stripped,
errmsg, errcode))

View File

@ -172,13 +172,14 @@ class Interface:
#('INFORMATION', account, (title_text, section_text))
dialogs.InformationDialog(data[0], data[1])
def handle_event_ask_new_nick(self, unused, data):
#('ASK_NEW_NICK', account, (room_jid, title_text, prompt_text))
def handle_event_ask_new_nick(self, account, data):
#('ASK_NEW_NICK', account, (room_jid, title_text, prompt_text, proposed_nick))
room_jid = data[0]
title = data[1]
prompt = data[2]
self.plugin.windows[account]['gc'][room_jid].show_change_nick_input_dialog(
title, prompt, room_jid = room_jid)
proposed_nick = data[3]
self.windows[account]['gc'][room_jid].show_change_nick_input_dialog(
title, prompt, proposed_nick, room_jid)
def handle_event_http_auth(self, account, data):
#('HTTP_AUTH', account, (method, url, iq_obj))
@ -889,18 +890,9 @@ class Interface:
except:
pass
if img_decoded:
pixbufloader = gtk.gdk.PixbufLoader()
try:
pixbufloader.write(img_decoded)
pixbuf = pixbufloader.get_pixbuf()
pixbufloader.close()
# store avatar for jid
self.avatar_pixbufs[jid] = pixbuf
# we may get "unknown image format" and/or something like pixbuf can be None
except (gobject.GError, AttributeError):
pass
pixbuf = gtkgui_helpers.get_pixbuf_from_data(img_decoded)
# store avatar for jid
self.avatar_pixbufs[jid] = pixbuf
def read_sleepy(self):
'''Check idle status and change that status if needed'''

View File

@ -283,3 +283,15 @@ def get_abspath_for_script(scriptname, want_type = False):
return path_to_script, type
else:
return path_to_script
def get_pixbuf_from_data(file_data):
'''wants img data and returns gtk pixbuf'''
pixbufloader = gtk.gdk.PixbufLoader()
try:
pixbufloader.write(file_data)
pixbufloader.close()
pixbuf = pixbufloader.get_pixbuf()
except gobject.GError: # 'unknown image format'
pixbuf = None
return pixbuf

View File

@ -181,10 +181,7 @@ class VcardWindow:
return
fd = open(f, 'rb')
data = fd.read()
pixbufloader = gtk.gdk.PixbufLoader()
pixbufloader.write(data)
pixbufloader.close()
pixbuf = pixbufloader.get_pixbuf()
pixbuf = gtkgui_helpers.get_pixbuf_from_data(data)
image = self.xml.get_widget('PHOTO_image')
image.set_from_pixbuf(pixbuf)
self.avatar_encoded = base64.encodestring(data)
@ -219,10 +216,7 @@ class VcardWindow:
except:
pass
if img_decoded:
pixbufloader = gtk.gdk.PixbufLoader()
pixbufloader.write(img_decoded)
pixbufloader.close()
pixbuf = pixbufloader.get_pixbuf()
pixbuf = gtkgui_helpers.get_pixbuf_from_data(img_decoded)
image = self.xml.get_widget('PHOTO_image')
image.set_from_pixbuf(pixbuf)
continue