more user friendly Add contact window
This commit is contained in:
parent
ad61789101
commit
1d2380b6d7
|
@ -374,16 +374,77 @@ class addContact_Window:
|
||||||
self.plugin.roster.req_sub(self, who, txt, self.account)
|
self.plugin.roster.req_sub(self, who, txt, self.account)
|
||||||
widget.get_toplevel().destroy()
|
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()
|
||||||
|
str = str.replace("@", "%")
|
||||||
|
agent = model[index][1]
|
||||||
|
if agent:
|
||||||
|
str += "@" + agent
|
||||||
|
self.xml.get_widget('entry_who').set_text(str)
|
||||||
|
|
||||||
|
def on_cb_changed(self, widget):
|
||||||
|
self.fill_who()
|
||||||
|
|
||||||
|
def guess_agent(self):
|
||||||
|
login = self.xml.get_widget('entry_login').get_text()
|
||||||
|
cb = self.xml.get_widget('combobox_agent')
|
||||||
|
model = cb.get_model()
|
||||||
|
|
||||||
|
#If login contains only numbers, it's probably an ICQ number
|
||||||
|
try:
|
||||||
|
string.atoi(login)
|
||||||
|
except:
|
||||||
|
pass
|
||||||
|
else:
|
||||||
|
if 'ICQ' in self.agents:
|
||||||
|
cb.set_active(self.agents.index('ICQ'))
|
||||||
|
return
|
||||||
|
cb.set_active(0)
|
||||||
|
|
||||||
|
def on_entry_login_changed(self, widget):
|
||||||
|
self.guess_agent() #It changes the cb so automatically call fill_who()
|
||||||
|
|
||||||
def __init__(self, plugin, account, jid=None):
|
def __init__(self, plugin, account, jid=None):
|
||||||
self.plugin = plugin
|
self.plugin = plugin
|
||||||
self.account = account
|
self.account = account
|
||||||
self.xml = gtk.glade.XML(GTKGUI_GLADE, 'Add', APP)
|
self.xml = gtk.glade.XML(GTKGUI_GLADE, 'Add', APP)
|
||||||
self.window = self.xml.get_widget('Add')
|
self.window = self.xml.get_widget('Add')
|
||||||
|
liststore = gtk.ListStore(gobject.TYPE_STRING, gobject.TYPE_STRING)
|
||||||
|
liststore.append(['Jabber', ''])
|
||||||
|
self.agents = ['Jabber']
|
||||||
|
jid_agents = []
|
||||||
|
for j in self.plugin.roster.contacts[account]:
|
||||||
|
user = self.plugin.roster.contacts[account][j][0]
|
||||||
|
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!"
|
||||||
|
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()
|
||||||
if jid:
|
if jid:
|
||||||
self.xml.get_widget('entry_who').set_text(jid)
|
self.xml.get_widget('entry_who').set_text(jid)
|
||||||
self.xml.signal_connect('gtk_widget_destroy', self.delete_event)
|
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_button_sub_clicked', self.on_subscribe)
|
||||||
self.xml.signal_connect('on_cancel_clicked', self.on_cancel)
|
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)
|
||||||
|
|
||||||
class warning_Window:
|
class warning_Window:
|
||||||
"""Class for warning window : print a warning message"""
|
"""Class for warning window : print a warning message"""
|
||||||
|
|
|
@ -2170,53 +2170,16 @@ on the server.</property>
|
||||||
<property name="spacing">0</property>
|
<property name="spacing">0</property>
|
||||||
|
|
||||||
<child>
|
<child>
|
||||||
<widget class="GtkHBox" id="hbox11">
|
<widget class="GtkTable" id="table21">
|
||||||
<property name="visible">True</property>
|
<property name="visible">True</property>
|
||||||
|
<property name="n_rows">3</property>
|
||||||
|
<property name="n_columns">3</property>
|
||||||
<property name="homogeneous">False</property>
|
<property name="homogeneous">False</property>
|
||||||
<property name="spacing">0</property>
|
<property name="row_spacing">5</property>
|
||||||
|
<property name="column_spacing">5</property>
|
||||||
|
|
||||||
<child>
|
<child>
|
||||||
<widget class="GtkImage" id="image127">
|
<widget class="GtkEntry" id="entry_login">
|
||||||
<property name="visible">True</property>
|
|
||||||
<property name="stock">gtk-redo</property>
|
|
||||||
<property name="icon_size">4</property>
|
|
||||||
<property name="xalign">0.5</property>
|
|
||||||
<property name="yalign">0.5</property>
|
|
||||||
<property name="xpad">0</property>
|
|
||||||
<property name="ypad">0</property>
|
|
||||||
</widget>
|
|
||||||
<packing>
|
|
||||||
<property name="padding">0</property>
|
|
||||||
<property name="expand">True</property>
|
|
||||||
<property name="fill">True</property>
|
|
||||||
</packing>
|
|
||||||
</child>
|
|
||||||
|
|
||||||
<child>
|
|
||||||
<widget class="GtkLabel" id="label17">
|
|
||||||
<property name="width_request">145</property>
|
|
||||||
<property name="height_request">8</property>
|
|
||||||
<property name="visible">True</property>
|
|
||||||
<property name="label" translatable="yes">Send subscription to :</property>
|
|
||||||
<property name="use_underline">False</property>
|
|
||||||
<property name="use_markup">False</property>
|
|
||||||
<property name="justify">GTK_JUSTIFY_RIGHT</property>
|
|
||||||
<property name="wrap">False</property>
|
|
||||||
<property name="selectable">False</property>
|
|
||||||
<property name="xalign">0.5</property>
|
|
||||||
<property name="yalign">0.5</property>
|
|
||||||
<property name="xpad">0</property>
|
|
||||||
<property name="ypad">0</property>
|
|
||||||
</widget>
|
|
||||||
<packing>
|
|
||||||
<property name="padding">0</property>
|
|
||||||
<property name="expand">False</property>
|
|
||||||
<property name="fill">True</property>
|
|
||||||
</packing>
|
|
||||||
</child>
|
|
||||||
|
|
||||||
<child>
|
|
||||||
<widget class="GtkEntry" id="entry_who">
|
|
||||||
<property name="visible">True</property>
|
<property name="visible">True</property>
|
||||||
<property name="can_focus">True</property>
|
<property name="can_focus">True</property>
|
||||||
<property name="editable">True</property>
|
<property name="editable">True</property>
|
||||||
|
@ -2226,11 +2189,143 @@ on the server.</property>
|
||||||
<property name="has_frame">True</property>
|
<property name="has_frame">True</property>
|
||||||
<property name="invisible_char">*</property>
|
<property name="invisible_char">*</property>
|
||||||
<property name="activates_default">False</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"/>
|
||||||
</widget>
|
</widget>
|
||||||
<packing>
|
<packing>
|
||||||
<property name="padding">0</property>
|
<property name="left_attach">2</property>
|
||||||
<property name="expand">True</property>
|
<property name="right_attach">3</property>
|
||||||
<property name="fill">True</property>
|
<property name="top_attach">0</property>
|
||||||
|
<property name="bottom_attach">1</property>
|
||||||
|
<property name="y_options"></property>
|
||||||
|
</packing>
|
||||||
|
</child>
|
||||||
|
|
||||||
|
<child>
|
||||||
|
<widget class="GtkEntry" id="entry_who">
|
||||||
|
<property name="visible">True</property>
|
||||||
|
<property name="can_focus">True</property>
|
||||||
|
<property name="editable">False</property>
|
||||||
|
<property name="visibility">True</property>
|
||||||
|
<property name="max_length">0</property>
|
||||||
|
<property name="text" translatable="yes"></property>
|
||||||
|
<property name="has_frame">True</property>
|
||||||
|
<property name="invisible_char">*</property>
|
||||||
|
<property name="activates_default">False</property>
|
||||||
|
</widget>
|
||||||
|
<packing>
|
||||||
|
<property name="left_attach">2</property>
|
||||||
|
<property name="right_attach">3</property>
|
||||||
|
<property name="top_attach">2</property>
|
||||||
|
<property name="bottom_attach">3</property>
|
||||||
|
<property name="y_options"></property>
|
||||||
|
</packing>
|
||||||
|
</child>
|
||||||
|
|
||||||
|
<child>
|
||||||
|
<widget class="GtkImage" id="image184">
|
||||||
|
<property name="visible">True</property>
|
||||||
|
<property name="stock">gtk-add</property>
|
||||||
|
<property name="icon_size">4</property>
|
||||||
|
<property name="xalign">0.5</property>
|
||||||
|
<property name="yalign">0.5</property>
|
||||||
|
<property name="xpad">0</property>
|
||||||
|
<property name="ypad">0</property>
|
||||||
|
</widget>
|
||||||
|
<packing>
|
||||||
|
<property name="left_attach">0</property>
|
||||||
|
<property name="right_attach">1</property>
|
||||||
|
<property name="top_attach">0</property>
|
||||||
|
<property name="bottom_attach">3</property>
|
||||||
|
<property name="x_options">fill</property>
|
||||||
|
<property name="y_options">fill</property>
|
||||||
|
</packing>
|
||||||
|
</child>
|
||||||
|
|
||||||
|
<child>
|
||||||
|
<widget class="GtkLabel" id="label185">
|
||||||
|
<property name="visible">True</property>
|
||||||
|
<property name="label" translatable="yes">Login :</property>
|
||||||
|
<property name="use_underline">False</property>
|
||||||
|
<property name="use_markup">False</property>
|
||||||
|
<property name="justify">GTK_JUSTIFY_LEFT</property>
|
||||||
|
<property name="wrap">False</property>
|
||||||
|
<property name="selectable">False</property>
|
||||||
|
<property name="xalign">0</property>
|
||||||
|
<property name="yalign">0.5</property>
|
||||||
|
<property name="xpad">0</property>
|
||||||
|
<property name="ypad">0</property>
|
||||||
|
</widget>
|
||||||
|
<packing>
|
||||||
|
<property name="left_attach">1</property>
|
||||||
|
<property name="right_attach">2</property>
|
||||||
|
<property name="top_attach">0</property>
|
||||||
|
<property name="bottom_attach">1</property>
|
||||||
|
<property name="x_options">fill</property>
|
||||||
|
<property name="y_options"></property>
|
||||||
|
</packing>
|
||||||
|
</child>
|
||||||
|
|
||||||
|
<child>
|
||||||
|
<widget class="GtkLabel" id="label186">
|
||||||
|
<property name="visible">True</property>
|
||||||
|
<property name="label" translatable="yes">Agent :</property>
|
||||||
|
<property name="use_underline">False</property>
|
||||||
|
<property name="use_markup">False</property>
|
||||||
|
<property name="justify">GTK_JUSTIFY_LEFT</property>
|
||||||
|
<property name="wrap">False</property>
|
||||||
|
<property name="selectable">False</property>
|
||||||
|
<property name="xalign">0</property>
|
||||||
|
<property name="yalign">0.5</property>
|
||||||
|
<property name="xpad">0</property>
|
||||||
|
<property name="ypad">0</property>
|
||||||
|
</widget>
|
||||||
|
<packing>
|
||||||
|
<property name="left_attach">1</property>
|
||||||
|
<property name="right_attach">2</property>
|
||||||
|
<property name="top_attach">1</property>
|
||||||
|
<property name="bottom_attach">2</property>
|
||||||
|
<property name="x_options">fill</property>
|
||||||
|
<property name="y_options"></property>
|
||||||
|
</packing>
|
||||||
|
</child>
|
||||||
|
|
||||||
|
<child>
|
||||||
|
<widget class="GtkLabel" id="label187">
|
||||||
|
<property name="visible">True</property>
|
||||||
|
<property name="label" translatable="yes">Jabber ID :</property>
|
||||||
|
<property name="use_underline">False</property>
|
||||||
|
<property name="use_markup">False</property>
|
||||||
|
<property name="justify">GTK_JUSTIFY_LEFT</property>
|
||||||
|
<property name="wrap">False</property>
|
||||||
|
<property name="selectable">False</property>
|
||||||
|
<property name="xalign">0</property>
|
||||||
|
<property name="yalign">0.5</property>
|
||||||
|
<property name="xpad">0</property>
|
||||||
|
<property name="ypad">0</property>
|
||||||
|
</widget>
|
||||||
|
<packing>
|
||||||
|
<property name="left_attach">1</property>
|
||||||
|
<property name="right_attach">2</property>
|
||||||
|
<property name="top_attach">2</property>
|
||||||
|
<property name="bottom_attach">3</property>
|
||||||
|
<property name="x_options">fill</property>
|
||||||
|
<property name="y_options"></property>
|
||||||
|
</packing>
|
||||||
|
</child>
|
||||||
|
|
||||||
|
<child>
|
||||||
|
<widget class="GtkComboBox" id="combobox_agent">
|
||||||
|
<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"/>
|
||||||
|
</widget>
|
||||||
|
<packing>
|
||||||
|
<property name="left_attach">2</property>
|
||||||
|
<property name="right_attach">3</property>
|
||||||
|
<property name="top_attach">1</property>
|
||||||
|
<property name="bottom_attach">2</property>
|
||||||
|
<property name="x_options">fill</property>
|
||||||
|
<property name="y_options">fill</property>
|
||||||
</packing>
|
</packing>
|
||||||
</child>
|
</child>
|
||||||
</widget>
|
</widget>
|
||||||
|
|
Loading…
Reference in New Issue