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:
parent
11d3316af2
commit
f6470778a6
4 changed files with 26 additions and 26 deletions
|
@ -345,7 +345,7 @@ class Connection:
|
||||||
jid_from = prs.getFrom()
|
jid_from = prs.getFrom()
|
||||||
who = unicode(jid_from)
|
who = unicode(jid_from)
|
||||||
jid_stripped = jid_from.getStripped()
|
jid_stripped = jid_from.getStripped()
|
||||||
resource = jid_from.getResource()
|
resource = jid_from.getResource()
|
||||||
status = prs.getStatus()
|
status = prs.getStatus()
|
||||||
show = prs.getShow()
|
show = prs.getShow()
|
||||||
if not show in STATUS_LIST:
|
if not show in STATUS_LIST:
|
||||||
|
@ -393,9 +393,11 @@ class Connection:
|
||||||
_('You are not in the members list.')))
|
_('You are not in the members list.')))
|
||||||
elif errcode == '409': # nick conflict
|
elif errcode == '409': # nick conflict
|
||||||
# the jid_from in this case is FAKE JID: room_jid/nick
|
# 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)
|
room_jid = gajim.get_room_from_fjid(who)
|
||||||
self.dispatch('ASK_NEW_NICK', (room_jid, _('Unable to join room'),
|
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
|
else: # print in the window the error
|
||||||
self.dispatch('ERROR_ANSWER', ('', jid_stripped,
|
self.dispatch('ERROR_ANSWER', ('', jid_stripped,
|
||||||
errmsg, errcode))
|
errmsg, errcode))
|
||||||
|
|
24
src/gajim.py
24
src/gajim.py
|
@ -172,13 +172,14 @@ class Interface:
|
||||||
#('INFORMATION', account, (title_text, section_text))
|
#('INFORMATION', account, (title_text, section_text))
|
||||||
dialogs.InformationDialog(data[0], data[1])
|
dialogs.InformationDialog(data[0], data[1])
|
||||||
|
|
||||||
def handle_event_ask_new_nick(self, unused, data):
|
def handle_event_ask_new_nick(self, account, data):
|
||||||
#('ASK_NEW_NICK', account, (room_jid, title_text, prompt_text))
|
#('ASK_NEW_NICK', account, (room_jid, title_text, prompt_text, proposed_nick))
|
||||||
room_jid = data[0]
|
room_jid = data[0]
|
||||||
title = data[1]
|
title = data[1]
|
||||||
prompt = data[2]
|
prompt = data[2]
|
||||||
self.plugin.windows[account]['gc'][room_jid].show_change_nick_input_dialog(
|
proposed_nick = data[3]
|
||||||
title, prompt, room_jid = room_jid)
|
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):
|
def handle_event_http_auth(self, account, data):
|
||||||
#('HTTP_AUTH', account, (method, url, iq_obj))
|
#('HTTP_AUTH', account, (method, url, iq_obj))
|
||||||
|
@ -889,18 +890,9 @@ class Interface:
|
||||||
except:
|
except:
|
||||||
pass
|
pass
|
||||||
if img_decoded:
|
if img_decoded:
|
||||||
pixbufloader = gtk.gdk.PixbufLoader()
|
pixbuf = gtkgui_helpers.get_pixbuf_from_data(img_decoded)
|
||||||
try:
|
# store avatar for jid
|
||||||
pixbufloader.write(img_decoded)
|
self.avatar_pixbufs[jid] = pixbuf
|
||||||
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
|
|
||||||
|
|
||||||
def read_sleepy(self):
|
def read_sleepy(self):
|
||||||
'''Check idle status and change that status if needed'''
|
'''Check idle status and change that status if needed'''
|
||||||
|
|
|
@ -283,3 +283,15 @@ def get_abspath_for_script(scriptname, want_type = False):
|
||||||
return path_to_script, type
|
return path_to_script, type
|
||||||
else:
|
else:
|
||||||
return path_to_script
|
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
|
||||||
|
|
10
src/vcard.py
10
src/vcard.py
|
@ -181,10 +181,7 @@ class VcardWindow:
|
||||||
return
|
return
|
||||||
fd = open(f, 'rb')
|
fd = open(f, 'rb')
|
||||||
data = fd.read()
|
data = fd.read()
|
||||||
pixbufloader = gtk.gdk.PixbufLoader()
|
pixbuf = gtkgui_helpers.get_pixbuf_from_data(data)
|
||||||
pixbufloader.write(data)
|
|
||||||
pixbufloader.close()
|
|
||||||
pixbuf = pixbufloader.get_pixbuf()
|
|
||||||
image = self.xml.get_widget('PHOTO_image')
|
image = self.xml.get_widget('PHOTO_image')
|
||||||
image.set_from_pixbuf(pixbuf)
|
image.set_from_pixbuf(pixbuf)
|
||||||
self.avatar_encoded = base64.encodestring(data)
|
self.avatar_encoded = base64.encodestring(data)
|
||||||
|
@ -219,10 +216,7 @@ class VcardWindow:
|
||||||
except:
|
except:
|
||||||
pass
|
pass
|
||||||
if img_decoded:
|
if img_decoded:
|
||||||
pixbufloader = gtk.gdk.PixbufLoader()
|
pixbuf = gtkgui_helpers.get_pixbuf_from_data(img_decoded)
|
||||||
pixbufloader.write(img_decoded)
|
|
||||||
pixbufloader.close()
|
|
||||||
pixbuf = pixbufloader.get_pixbuf()
|
|
||||||
image = self.xml.get_widget('PHOTO_image')
|
image = self.xml.get_widget('PHOTO_image')
|
||||||
image.set_from_pixbuf(pixbuf)
|
image.set_from_pixbuf(pixbuf)
|
||||||
continue
|
continue
|
||||||
|
|
Loading…
Add table
Reference in a new issue