From daacc7334dc6d399f938f2f068b44d356f6c4b26 Mon Sep 17 00:00:00 2001 From: Nikos Kouremenos Date: Sat, 18 Jun 2005 23:44:33 +0000 Subject: [PATCH] we can change nick by IRC command too (/nick foo); input dialog also has get_response() now --- src/common/connection.py | 2 +- src/dialogs.py | 11 ++++++++--- src/groupchat_window.py | 21 ++++++++++++--------- src/gtkgui.glade | 5 ++--- 4 files changed, 23 insertions(+), 16 deletions(-) diff --git a/src/common/connection.py b/src/common/connection.py index 18a6c1aae..ac06658a6 100644 --- a/src/common/connection.py +++ b/src/common/connection.py @@ -1042,7 +1042,7 @@ class Connection: to = room_jid) self.connection.send(iq) - def change_gc_nick(self, nick, room_jid): + def change_gc_nick(self, room_jid, nick): if not self.connection: return self.connection.send(common.xmpp.Presence(to = '%s/%s' % (room_jid, diff --git a/src/dialogs.py b/src/dialogs.py index b4b04d469..0dcd7fe73 100644 --- a/src/dialogs.py +++ b/src/dialogs.py @@ -496,7 +496,12 @@ class InputDialog: label.set_text(label_str) if input_str: self.input_entry.set_text(input_str) - self.input_entry.select_region(0, -1) # select all + self.input_entry.select_region(0, -1) # select all + + def get_response(self): + response = self.dialog.run() + self.dialog.destroy() + return response class ErrorDialog(HigDialog): def __init__(self, pritext, sectext=''): @@ -710,12 +715,12 @@ _('Without a connection, you can not change your password.')).get_response() if rep == gtk.RESPONSE_OK: password1 = self.password1_entry.get_text() if not password1: - ErrorDialog(_('Invalid password.'), \ + ErrorDialog(_('Invalid password.'), _('You must enter a password.')).get_response() continue password2 = self.password2_entry.get_text() if password1 != password2: - ErrorDialog(_("Passwords don't match."), \ + ErrorDialog(_("Passwords don't match."), _('The passwords typed in both fields must be identical.')).get_response() continue message = password1 diff --git a/src/groupchat_window.py b/src/groupchat_window.py index 1f3f37af8..10afa2371 100644 --- a/src/groupchat_window.py +++ b/src/groupchat_window.py @@ -274,7 +274,7 @@ class GroupchatWindow(chat.Chat): elif statusCode == '303': # Someone changed his nick self.print_conversation(_('%s is now known as %s') % (nick, new_nick), room_jid) - if nick == self.nicks[room_jid]: # We changed out nick + if nick == self.nicks[room_jid]: # We changed our nick self.nicks[room_jid] = new_nick self.remove_user(room_jid, nick) if nick == self.nicks[room_jid] and statusCode != '303': # We became offline @@ -317,13 +317,11 @@ class GroupchatWindow(chat.Chat): def on_change_subject_menuitem_activate(self, widget): room_jid = self.get_active_jid() - # I don't know how this works with markup... Let's find out! label_text = self.name_labels[room_jid].get_text() # whole text (including JID) - subject = label_text[label_text.find('\n') + 1:] # just the text after the newline *shrug* + subject = label_text[label_text.find('\n') + 1:] # just the text after the newline instance = dialogs.InputDialog(_('Changing the Subject'), _('Please specify the new subject:'), subject) - response = instance.dialog.run() - instance.dialog.destroy() + response = instance.get_response() if response == gtk.RESPONSE_OK: subject = instance.input_entry.get_text() gajim.connections[self.account].send_gc_subject(room_jid, subject) @@ -331,13 +329,12 @@ class GroupchatWindow(chat.Chat): def on_change_nick_menuitem_activate(self, widget): room_jid = self.get_active_jid() nick = self.nicks[room_jid] - instance = dialogs.InputDialog(_('Changing out Nickname'), + instance = dialogs.InputDialog(_('Changing our Nickname'), _('Please specify the new nickname you want to use:'), nick) - response = instance.dialog.run() - instance.dialog.destroy() + response = response = instance.get_response() if response == gtk.RESPONSE_OK: nick = instance.input_entry.get_text() - gajim.connections[self.account].change_gc_nick(nick, room_jid) + gajim.connections[self.account].change_gc_nick(room_jid, nick) def on_configure_room_menuitem_activate(self, widget): room_jid = self.get_active_jid() @@ -504,6 +501,12 @@ class GroupchatWindow(chat.Chat): self.gc_refer_to_nick_char in text.lower().split()): other_tags_for_name.append('bold') other_tags_for_text.append('marked') + + if text.startswith('/nick '): + new_nick = text[6:] + if len(new_nick.split()) == 1: #dont accept /nick foo bar + gajim.connections[self.account].change_gc_nick(room_jid, new_nick) + return False chat.Chat.print_conversation_line(self, text, room_jid, kind, contact, tim, other_tags_for_name, [], other_tags_for_text) diff --git a/src/gtkgui.glade b/src/gtkgui.glade index 932fb306c..d79b6a634 100644 --- a/src/gtkgui.glade +++ b/src/gtkgui.glade @@ -10817,7 +10817,6 @@ JID: whatever@jabber.org False GDK_WINDOW_TYPE_HINT_DIALOG GDK_GRAVITY_NORTH_WEST - True @@ -10959,7 +10958,7 @@ JID: whatever@jabber.org True Enter the user ID of the contact you would like to -send a chat message to +send a chat message to: False False GTK_JUSTIFY_LEFT @@ -15290,7 +15289,7 @@ the Jabber network. True - Change _Nick + Change _Nickname True