change callback, widget and variable names for Add window in glade and in the code
This commit is contained in:
parent
9c7b25c3b8
commit
fa5b500aa4
|
@ -266,85 +266,81 @@ class awayMsg_Window:
|
|||
|
||||
class addContact_Window:
|
||||
"""Class for Add user window"""
|
||||
def delete_event(self, widget):
|
||||
"""close window"""
|
||||
del self.plugin.windows['add']
|
||||
|
||||
def on_cancel(self, widget):
|
||||
def on_cancel_button_clicked(self, widget):
|
||||
"""When Cancel button is clicked"""
|
||||
widget.get_toplevel().destroy()
|
||||
|
||||
def on_subscribe(self, widget):
|
||||
def on_subscribe_button_clicked(self, widget):
|
||||
"""When Subscribe button is clicked"""
|
||||
textview_sub = self.xml.get_widget("textview_sub")
|
||||
who = self.xml.get_widget('entry_who').get_text()
|
||||
pseudo = self.xml.get_widget('entry_pseudo').get_text()
|
||||
if not who:
|
||||
jid = self.xml.get_widget('jid_entry').get_text()
|
||||
nickname = self.xml.get_widget('nickname_entry').get_text()
|
||||
if not jid:
|
||||
return
|
||||
if who.find('@') < 0:
|
||||
if jid.find('@') < 0:
|
||||
warning_Window(_("The contact's name must be something like login@hostname"))
|
||||
return
|
||||
buf = textview_sub.get_buffer()
|
||||
start_iter = buf.get_start_iter()
|
||||
end_iter = buf.get_end_iter()
|
||||
txt = buf.get_text(start_iter, end_iter, 0)
|
||||
self.plugin.roster.req_sub(self, who, txt, self.account, pseudo)
|
||||
if self.xml.get_widget('checkbutton_auth').get_active():
|
||||
self.plugin.send('AUTH', self.account, who)
|
||||
message_buffer = self.xml.get_widget('message_textview').get_buffer()
|
||||
start_iter = message_buffer.get_start_iter()
|
||||
end_iter = message_buffer.get_end_iter()
|
||||
message = message_buffer.get_text(start_iter, end_iter, 0)
|
||||
self.plugin.roster.req_sub(self, jid, message, self.account, nickname)
|
||||
if self.xml.get_widget('auto_authorize_checkbutton').get_active():
|
||||
self.plugin.send('AUTH', self.account, jid)
|
||||
widget.get_toplevel().destroy()
|
||||
|
||||
def fill_who(self):
|
||||
cb = self.xml.get_widget('combobox_agent')
|
||||
model = cb.get_model()
|
||||
index = cb.get_active()
|
||||
str = self.xml.get_widget('entry_login').get_text()
|
||||
def fill_jid(self):
|
||||
agent_combobox = self.xml.get_widget('agent_combobox')
|
||||
model = agent_combobox.get_model()
|
||||
index = agent_combobox.get_active()
|
||||
jid = self.xml.get_widget('uid_entry').get_text()
|
||||
if index > 0:
|
||||
str = str.replace("@", "%")
|
||||
jid = jid.replace('@', '%')
|
||||
agent = model[index][1]
|
||||
if agent:
|
||||
str += "@" + agent
|
||||
self.xml.get_widget('entry_who').set_text(str)
|
||||
jid += '@' + agent
|
||||
self.xml.get_widget('jid_entry').set_text(jid)
|
||||
|
||||
def on_cb_changed(self, widget):
|
||||
self.fill_who()
|
||||
def on_agent_combobox_changed(self, widget):
|
||||
self.fill_jid()
|
||||
|
||||
def guess_agent(self):
|
||||
login = self.xml.get_widget('entry_login').get_text()
|
||||
cb = self.xml.get_widget('combobox_agent')
|
||||
model = cb.get_model()
|
||||
uid = self.xml.get_widget('uid_entry').get_text()
|
||||
agent_combobox = self.xml.get_widget('agent_combobox')
|
||||
model = agent_combobox.get_model()
|
||||
|
||||
#If login contains only numbers, it's probably an ICQ number
|
||||
try:
|
||||
string.atoi(login)
|
||||
string.atoi(uid)
|
||||
except:
|
||||
pass
|
||||
else:
|
||||
if 'ICQ' in self.agents:
|
||||
cb.set_active(self.agents.index('ICQ'))
|
||||
agent_combobox.set_active(self.agents.index('ICQ'))
|
||||
return
|
||||
cb.set_active(0)
|
||||
agent_combobox.set_active(0)
|
||||
|
||||
def set_pseudo(self):
|
||||
login = self.xml.get_widget('entry_login').get_text()
|
||||
pseudo = self.xml.get_widget('entry_pseudo').get_text()
|
||||
if pseudo == self.old_login_value:
|
||||
self.xml.get_widget('entry_pseudo').set_text(login)
|
||||
def set_nickname(self):
|
||||
uid = self.xml.get_widget('uid_entry').get_text()
|
||||
nickname = self.xml.get_widget('nickname_entry').get_text()
|
||||
if nickname == self.old_uid_value:
|
||||
self.xml.get_widget('nickname_entry').set_text(uid.split('@')[0])
|
||||
|
||||
def on_entry_login_changed(self, widget):
|
||||
def on_uid_entry_changed(self, widget):
|
||||
self.guess_agent()
|
||||
self.set_pseudo()
|
||||
self.fill_who()
|
||||
self.old_login_value = self.xml.get_widget('entry_login').get_text()
|
||||
self.set_nickname()
|
||||
self.fill_jid()
|
||||
uid = self.xml.get_widget('uid_entry').get_text()
|
||||
self.old_uid_value = uid.split('@')[0]
|
||||
|
||||
def __init__(self, plugin, account, jid=None):
|
||||
if not plugin.connected[account]:
|
||||
warning_Window(_("You must be connected to add a contact"))
|
||||
warning_Window(_('You must be connected to add a contact'))
|
||||
return
|
||||
self.plugin = plugin
|
||||
self.account = account
|
||||
self.xml = gtk.glade.XML(GTKGUI_GLADE, 'Add', APP)
|
||||
self.window = self.xml.get_widget('Add')
|
||||
self.old_login_value = ''
|
||||
self.xml = gtk.glade.XML(GTKGUI_GLADE, 'add_window', APP)
|
||||
self.window = self.xml.get_widget('add_window')
|
||||
self.old_uid_value = ''
|
||||
liststore = gtk.ListStore(gobject.TYPE_STRING, gobject.TYPE_STRING)
|
||||
liststore.append(['Jabber', ''])
|
||||
self.agents = ['Jabber']
|
||||
|
@ -354,34 +350,29 @@ class addContact_Window:
|
|||
if 'Agents' in user.groups:
|
||||
jid_agents.append(j)
|
||||
for a in jid_agents:
|
||||
if a.find("aim") > -1:
|
||||
name = "AIM"
|
||||
elif a.find("icq") > -1:
|
||||
name = "ICQ"
|
||||
elif a.find("msn") > -1:
|
||||
name = "MSN"
|
||||
elif a.find("yahoo") > -1:
|
||||
name = "Yahoo!"
|
||||
if a.find('aim') > -1:
|
||||
name = 'AIM'
|
||||
elif a.find('icq') > -1:
|
||||
name = 'ICQ'
|
||||
elif a.find('msn') > -1:
|
||||
name = 'MSN'
|
||||
elif a.find('yahoo') > -1:
|
||||
name = 'Yahoo!'
|
||||
else:
|
||||
name = a
|
||||
iter = liststore.append([name, a])
|
||||
self.agents.append(name)
|
||||
cb = self.xml.get_widget('combobox_agent')
|
||||
cb.set_model(liststore)
|
||||
cb.set_active(0)
|
||||
self.fill_who()
|
||||
agent_combobox = self.xml.get_widget('agent_combobox')
|
||||
agent_combobox.set_model(liststore)
|
||||
agent_combobox.set_active(0)
|
||||
self.fill_jid()
|
||||
if jid:
|
||||
self.xml.get_widget('entry_who').set_text(jid)
|
||||
jida = jid.split("@")
|
||||
self.xml.get_widget('entry_login').set_text(jida[0])
|
||||
if jida[1] in jid_agents:
|
||||
cb.set_active(jid_agents.index(jida[1])+1)
|
||||
self.xml.signal_connect('gtk_widget_destroy', self.delete_event)
|
||||
self.xml.signal_connect('on_button_sub_clicked', self.on_subscribe)
|
||||
self.xml.signal_connect('on_cancel_clicked', self.on_cancel)
|
||||
self.xml.signal_connect('on_cb_changed', self.on_cb_changed)
|
||||
self.xml.signal_connect('on_entry_login_changed', \
|
||||
self.on_entry_login_changed)
|
||||
self.xml.get_widget('jid_entry').set_text(jid)
|
||||
jid_splited = jid.split('@')
|
||||
self.xml.get_widget('entry_login').set_text(jid_splited[0])
|
||||
if jid_splited[1] in jid_agents:
|
||||
agent_combobox.set_active(jid_agents.index(jid_splited[1])+1)
|
||||
self.xml.signal_autoconnect(self)
|
||||
|
||||
class warning_Window:
|
||||
"""Class for warning window : print a warning message"""
|
||||
|
|
|
@ -2163,7 +2163,7 @@ on the server as a vCard</property>
|
|||
</child>
|
||||
</widget>
|
||||
|
||||
<widget class="GtkWindow" id="Add">
|
||||
<widget class="GtkWindow" id="add_window">
|
||||
<property name="border_width">5</property>
|
||||
<property name="width_request">400</property>
|
||||
<property name="height_request">334</property>
|
||||
|
@ -2292,7 +2292,7 @@ on the server as a vCard</property>
|
|||
</child>
|
||||
|
||||
<child>
|
||||
<widget class="GtkEntry" id="entry_login">
|
||||
<widget class="GtkEntry" id="uid_entry">
|
||||
<property name="visible">True</property>
|
||||
<property name="can_focus">True</property>
|
||||
<property name="editable">True</property>
|
||||
|
@ -2302,7 +2302,7 @@ on the server as a vCard</property>
|
|||
<property name="has_frame">True</property>
|
||||
<property name="invisible_char">*</property>
|
||||
<property name="activates_default">False</property>
|
||||
<signal name="changed" handler="on_entry_login_changed" last_modification_time="Wed, 02 Feb 2005 22:34:32 GMT"/>
|
||||
<signal name="changed" handler="on_uid_entry_changed" last_modification_time="Mon, 28 Feb 2005 23:05:24 GMT"/>
|
||||
</widget>
|
||||
<packing>
|
||||
<property name="left_attach">1</property>
|
||||
|
@ -2314,10 +2314,10 @@ on the server as a vCard</property>
|
|||
</child>
|
||||
|
||||
<child>
|
||||
<widget class="GtkComboBox" id="combobox_agent">
|
||||
<widget class="GtkComboBox" id="agent_combobox">
|
||||
<property name="visible">True</property>
|
||||
<property name="items" translatable="yes"></property>
|
||||
<signal name="changed" handler="on_cb_changed" last_modification_time="Wed, 02 Feb 2005 22:32:45 GMT"/>
|
||||
<signal name="changed" handler="on_agent_combobox_changed" last_modification_time="Mon, 28 Feb 2005 22:56:52 GMT"/>
|
||||
</widget>
|
||||
<packing>
|
||||
<property name="left_attach">1</property>
|
||||
|
@ -2330,7 +2330,7 @@ on the server as a vCard</property>
|
|||
</child>
|
||||
|
||||
<child>
|
||||
<widget class="GtkEntry" id="entry_who">
|
||||
<widget class="GtkEntry" id="jid_entry">
|
||||
<property name="visible">True</property>
|
||||
<property name="can_focus">True</property>
|
||||
<property name="editable">False</property>
|
||||
|
@ -2351,7 +2351,7 @@ on the server as a vCard</property>
|
|||
</child>
|
||||
|
||||
<child>
|
||||
<widget class="GtkEntry" id="entry_pseudo">
|
||||
<widget class="GtkEntry" id="nickname_entry">
|
||||
<property name="visible">True</property>
|
||||
<property name="can_focus">True</property>
|
||||
<property name="editable">True</property>
|
||||
|
@ -2372,7 +2372,7 @@ on the server as a vCard</property>
|
|||
</child>
|
||||
|
||||
<child>
|
||||
<widget class="GtkCheckButton" id="checkbutton_auth">
|
||||
<widget class="GtkCheckButton" id="auto_authorize_checkbutton">
|
||||
<property name="visible">True</property>
|
||||
<property name="can_focus">True</property>
|
||||
<property name="label" translatable="yes">Automatically authorize contact</property>
|
||||
|
@ -2406,11 +2406,11 @@ on the server as a vCard</property>
|
|||
<property name="can_focus">True</property>
|
||||
<property name="hscrollbar_policy">GTK_POLICY_AUTOMATIC</property>
|
||||
<property name="vscrollbar_policy">GTK_POLICY_AUTOMATIC</property>
|
||||
<property name="shadow_type">GTK_SHADOW_NONE</property>
|
||||
<property name="shadow_type">GTK_SHADOW_IN</property>
|
||||
<property name="window_placement">GTK_CORNER_TOP_LEFT</property>
|
||||
|
||||
<child>
|
||||
<widget class="GtkTextView" id="textview_sub">
|
||||
<widget class="GtkTextView" id="message_textview">
|
||||
<property name="visible">True</property>
|
||||
<property name="can_focus">True</property>
|
||||
<property name="editable">True</property>
|
||||
|
@ -2455,7 +2455,7 @@ on the server as a vCard</property>
|
|||
<property name="spacing">10</property>
|
||||
|
||||
<child>
|
||||
<widget class="GtkButton" id="button11">
|
||||
<widget class="GtkButton" id="cancel_button">
|
||||
<property name="visible">True</property>
|
||||
<property name="can_default">True</property>
|
||||
<property name="can_focus">True</property>
|
||||
|
@ -2463,18 +2463,18 @@ on the server as a vCard</property>
|
|||
<property name="use_stock">True</property>
|
||||
<property name="relief">GTK_RELIEF_NORMAL</property>
|
||||
<property name="focus_on_click">True</property>
|
||||
<signal name="clicked" handler="on_cancel_clicked" last_modification_time="Wed, 17 Mar 2004 19:44:15 GMT"/>
|
||||
<signal name="clicked" handler="on_cancel_button_clicked" last_modification_time="Mon, 28 Feb 2005 22:46:06 GMT"/>
|
||||
</widget>
|
||||
</child>
|
||||
|
||||
<child>
|
||||
<widget class="GtkButton" id="button_sub">
|
||||
<widget class="GtkButton" id="subscribe_button">
|
||||
<property name="visible">True</property>
|
||||
<property name="can_default">True</property>
|
||||
<property name="can_focus">True</property>
|
||||
<property name="relief">GTK_RELIEF_NORMAL</property>
|
||||
<property name="focus_on_click">True</property>
|
||||
<signal name="clicked" handler="on_button_sub_clicked" last_modification_time="Sun, 26 Oct 2003 21:38:59 GMT"/>
|
||||
<signal name="clicked" handler="on_subscribe_button_clicked" last_modification_time="Mon, 28 Feb 2005 22:46:16 GMT"/>
|
||||
|
||||
<child>
|
||||
<widget class="GtkAlignment" id="alignment39">
|
||||
|
|
Loading…
Reference in New Issue