nickname changes do instant apply now. fixes #1612

This commit is contained in:
Nikos Kouremenos 2006-02-23 14:36:41 +00:00
parent 65f89dcc18
commit 506e6752ea
3 changed files with 500 additions and 487 deletions

View file

@ -2230,6 +2230,7 @@ class Connection:
return return
def update_contact(self, jid, name, groups): def update_contact(self, jid, name, groups):
'''update roster item on jabber server'''
if self.connection: if self.connection:
self.connection.getRoster().setItem(jid = jid, name = name, self.connection.getRoster().setItem(jid = jid, name = name,
groups = groups) groups = groups)

View file

@ -6603,10 +6603,16 @@ Custom</property>
<property name="enable_popup">False</property> <property name="enable_popup">False</property>
<child> <child>
<widget class="GtkTable" id="table4"> <widget class="GtkVBox" id="vbox113">
<property name="border_width">6</property> <property name="border_width">6</property>
<property name="visible">True</property> <property name="visible">True</property>
<property name="n_rows">8</property> <property name="homogeneous">False</property>
<property name="spacing">6</property>
<child>
<widget class="GtkTable" id="table4">
<property name="visible">True</property>
<property name="n_rows">7</property>
<property name="n_columns">2</property> <property name="n_columns">2</property>
<property name="homogeneous">False</property> <property name="homogeneous">False</property>
<property name="row_spacing">0</property> <property name="row_spacing">0</property>
@ -6917,29 +6923,6 @@ Custom</property>
</packing> </packing>
</child> </child>
<child>
<widget class="GtkCheckButton" id="log_history_checkbutton">
<property name="border_width">5</property>
<property name="visible">True</property>
<property name="can_focus">True</property>
<property name="label" translatable="yes">_Log conversation history</property>
<property name="use_underline">True</property>
<property name="relief">GTK_RELIEF_NORMAL</property>
<property name="focus_on_click">True</property>
<property name="active">True</property>
<property name="inconsistent">False</property>
<property name="draw_indicator">True</property>
</widget>
<packing>
<property name="left_attach">0</property>
<property name="right_attach">2</property>
<property name="top_attach">7</property>
<property name="bottom_attach">8</property>
<property name="x_options">fill</property>
<property name="y_options"></property>
</packing>
</child>
<child> <child>
<widget class="GtkLabel" id="label237"> <widget class="GtkLabel" id="label237">
<property name="visible">True</property> <property name="visible">True</property>
@ -7121,6 +7104,32 @@ Custom</property>
</packing> </packing>
</child> </child>
</widget> </widget>
<packing>
<property name="padding">0</property>
<property name="expand">False</property>
<property name="fill">True</property>
</packing>
</child>
<child>
<widget class="GtkCheckButton" id="log_history_checkbutton">
<property name="visible">True</property>
<property name="can_focus">True</property>
<property name="label" translatable="yes">_Log conversation history</property>
<property name="use_underline">True</property>
<property name="relief">GTK_RELIEF_NORMAL</property>
<property name="focus_on_click">True</property>
<property name="active">True</property>
<property name="inconsistent">False</property>
<property name="draw_indicator">True</property>
</widget>
<packing>
<property name="padding">0</property>
<property name="expand">False</property>
<property name="fill">False</property>
</packing>
</child>
</widget>
<packing> <packing>
<property name="tab_expand">False</property> <property name="tab_expand">False</property>
<property name="tab_fill">True</property> <property name="tab_fill">True</property>
@ -9107,13 +9116,12 @@ Custom</property>
<widget class="GtkButton" id="close_button"> <widget class="GtkButton" id="close_button">
<property name="visible">True</property> <property name="visible">True</property>
<property name="can_default">True</property> <property name="can_default">True</property>
<property name="has_default">True</property>
<property name="can_focus">True</property> <property name="can_focus">True</property>
<property name="label">gtk-close</property> <property name="label">gtk-close</property>
<property name="use_stock">True</property> <property name="use_stock">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>
<signal name="clicked" handler="on_close_button_clicked" last_modification_time="Tue, 01 Mar 2005 15:03:12 GMT"/> <signal name="clicked" handler="on_close_button_clicked" last_modification_time="Thu, 23 Feb 2006 13:24:35 GMT"/>
</widget> </widget>
</child> </child>
</widget> </widget>

View file

@ -82,12 +82,14 @@ class VcardWindow:
# the contact variable is the jid if vcard is true # the contact variable is the jid if vcard is true
self.xml = gtk.glade.XML(GTKGUI_GLADE, 'vcard_information_window', APP) self.xml = gtk.glade.XML(GTKGUI_GLADE, 'vcard_information_window', APP)
self.window = self.xml.get_widget('vcard_information_window') self.window = self.xml.get_widget('vcard_information_window')
self.xml.get_widget('photo_vbuttonbox').set_no_show_all(True)
self.publish_button = self.xml.get_widget('publish_button') self.publish_button = self.xml.get_widget('publish_button')
self.retrieve_button = self.xml.get_widget('retrieve_button') self.retrieve_button = self.xml.get_widget('retrieve_button')
self.nickname_entry = self.xml.get_widget('nickname_entry')
self.publish_button.set_no_show_all(True) self.publish_button.set_no_show_all(True)
self.retrieve_button.set_no_show_all(True) self.retrieve_button.set_no_show_all(True)
self.xml.get_widget('photo_vbuttonbox').set_no_show_all(True)
self.contact = contact # don't use it if vcard is true self.contact = contact # don't use it if vcard is true
self.account = account self.account = account
@ -95,16 +97,22 @@ class VcardWindow:
self.avatar_mime_type = None self.avatar_mime_type = None
self.avatar_encoded = None self.avatar_encoded = None
if vcard: if vcard: # we view/edit our own vcard
self.jid = contact self.jid = contact
# remove Jabber tab & show publish/retrieve/set_avatar buttons # remove Jabber tab & show publish/retrieve/close/set_avatar buttons
# and make entries and textview editable
self.change_to_vcard() self.change_to_vcard()
else: else: # we see someone else's vcard
self.jid = contact.jid
self.publish_button.hide() self.publish_button.hide()
self.retrieve_button.hide() self.retrieve_button.hide()
self.jid = contact.jid
self.fill_jabber_page() self.fill_jabber_page()
# if we are editing our own vcard publish button should publish
# vcard data we have typed including nickname, it's why we connect only
# here (when we see someone else's vcard)
self.nickname_entry.connect('changed', self.on_nickname_entry_changed)
self.xml.signal_autoconnect(self) self.xml.signal_autoconnect(self)
self.window.show_all() self.window.show_all()
@ -131,27 +139,21 @@ class VcardWindow:
gajim.config.set_per('accounts', self.account, 'no_log_for', gajim.config.set_per('accounts', self.account, 'no_log_for',
' '.join(no_log_for)) ' '.join(no_log_for))
def on_close_button_clicked(self, widget): def on_nickname_entry_changed(self, widget):
'''Save contact information and update the roster on the Jabber server''' '''Save contact information and update
if self.vcard: the roster item on the Jabber server'''
self.window.destroy() new_name = self.nickname_entry.get_text().decode('utf-8')
return # update contact.name with new nickname if that is not ''
# update contact.name if it's not ''
name_entry = self.xml.get_widget('nickname_entry')
if not name_entry:
# This can happen when we don't show jabber page. For example when we
# show the vcard of a contact that request our subscription
self.window.destroy()
return
new_name = name_entry.get_text().decode('utf-8')
if new_name != self.contact.name and new_name != '': if new_name != self.contact.name and new_name != '':
self.contact.name = new_name self.contact.name = new_name
for i in gajim.interface.roster.get_contact_iter(self.contact.jid, # update roster model
model = gajim.interface.roster.tree.get_model()
for iter_ in gajim.interface.roster.get_contact_iter(self.contact.jid,
self.account): self.account):
gajim.interface.roster.tree.get_model().set_value(i, 1, new_name) model[iter_][1] = new_name
gajim.connections[self.account].update_contact(self.contact.jid, gajim.connections[self.account].update_contact(self.contact.jid,
self.contact.name, self.contact.groups) self.contact.name, self.contact.groups)
# Update opened chat window # update opened chat window
ctrl = gajim.interface.msg_win_mgr.get_control(self.contact.jid, ctrl = gajim.interface.msg_win_mgr.get_control(self.contact.jid,
self.account) self.account)
if ctrl: if ctrl:
@ -160,6 +162,8 @@ class VcardWindow:
self.account) self.account)
win.redraw_tab(ctrl) win.redraw_tab(ctrl)
win.show_title() win.show_title()
def on_close_button_clicked(self, widget):
self.window.destroy() self.window.destroy()
def on_clear_button_clicked(self, widget): def on_clear_button_clicked(self, widget):
@ -351,7 +355,7 @@ class VcardWindow:
if self.contact.ask == 'subscribe': if self.contact.ask == 'subscribe':
tooltips.set_tip(eb, tooltips.set_tip(eb,
_("You are waiting contact's answer about your subscription request")) _("You are waiting contact's answer about your subscription request"))
self.xml.get_widget('nickname_entry').set_text(self.contact.name) self.nickname_entry.set_text(self.contact.name)
log = True log = True
if self.contact.jid in gajim.config.get_per('accounts', self.account, if self.contact.jid in gajim.config.get_per('accounts', self.account,
'no_log_for').split(' '): 'no_log_for').split(' '):