Add profile button to add contact dialog
This lets the user query the VCard of the contact before adding
This commit is contained in:
parent
64d1401307
commit
de790f5e4c
|
@ -16,6 +16,11 @@
|
|||
<column type="gchararray"/>
|
||||
</columns>
|
||||
</object>
|
||||
<object class="GtkImage" id="image1">
|
||||
<property name="visible">True</property>
|
||||
<property name="can_focus">False</property>
|
||||
<property name="icon_name">user-info-symbolic</property>
|
||||
</object>
|
||||
<object class="GtkTextBuffer" id="message_textbuffer">
|
||||
<property name="text" translatable="yes">I would like to add you to my contact list.</property>
|
||||
<signal name="end-user-action" handler="on_message_textbuffer_changed" swapped="no"/>
|
||||
|
@ -144,6 +149,7 @@
|
|||
<packing>
|
||||
<property name="left_attach">1</property>
|
||||
<property name="top_attach">3</property>
|
||||
<property name="width">2</property>
|
||||
</packing>
|
||||
</child>
|
||||
<child>
|
||||
|
@ -163,6 +169,7 @@
|
|||
<packing>
|
||||
<property name="left_attach">1</property>
|
||||
<property name="top_attach">4</property>
|
||||
<property name="width">2</property>
|
||||
</packing>
|
||||
</child>
|
||||
<child>
|
||||
|
@ -254,6 +261,7 @@
|
|||
<packing>
|
||||
<property name="left_attach">1</property>
|
||||
<property name="top_attach">1</property>
|
||||
<property name="width">2</property>
|
||||
</packing>
|
||||
</child>
|
||||
<child>
|
||||
|
@ -275,6 +283,22 @@
|
|||
<packing>
|
||||
<property name="left_attach">1</property>
|
||||
<property name="top_attach">0</property>
|
||||
<property name="width">2</property>
|
||||
</packing>
|
||||
</child>
|
||||
<child>
|
||||
<object class="GtkButton" id="show_contact_info_button">
|
||||
<property name="visible">True</property>
|
||||
<property name="sensitive">False</property>
|
||||
<property name="can_focus">True</property>
|
||||
<property name="receives_default">True</property>
|
||||
<property name="tooltip_text" translatable="yes">Query Contact Info</property>
|
||||
<property name="image">image1</property>
|
||||
<signal name="clicked" handler="on_show_contact_info_button_clicked" swapped="no"/>
|
||||
</object>
|
||||
<packing>
|
||||
<property name="left_attach">2</property>
|
||||
<property name="top_attach">2</property>
|
||||
</packing>
|
||||
</child>
|
||||
</object>
|
||||
|
|
|
@ -15,6 +15,7 @@
|
|||
from gi.repository import Gdk
|
||||
from gi.repository import Gtk
|
||||
|
||||
from gajim import vcard
|
||||
from gajim.common import app
|
||||
from gajim.common import ged
|
||||
from gajim.common import helpers
|
||||
|
@ -58,8 +59,9 @@ class AddNewContactWindow(Gtk.ApplicationWindow):
|
|||
self.xml.connect_signals(self)
|
||||
|
||||
for w in ('account_combobox', 'account_label', 'prompt_label',
|
||||
'uid_label', 'uid_entry', 'protocol_combobox',
|
||||
'protocol_jid_combobox', 'protocol_label', 'nickname_entry',
|
||||
'uid_label', 'uid_entry', 'show_contact_info_button',
|
||||
'protocol_combobox', 'protocol_jid_combobox',
|
||||
'protocol_label', 'nickname_entry',
|
||||
'message_scrolledwindow', 'save_message_checkbutton',
|
||||
'register_hbox', 'add_button', 'message_textview',
|
||||
'connected_label', 'group_comboboxentry',
|
||||
|
@ -68,6 +70,7 @@ class AddNewContactWindow(Gtk.ApplicationWindow):
|
|||
self.__dict__[w] = self.xml.get_object(w)
|
||||
|
||||
self.subscription_table = [self.uid_label, self.uid_entry,
|
||||
self.show_contact_info_button,
|
||||
self.nickname_label, self.nickname_entry,
|
||||
self.group_label, self.group_comboboxentry]
|
||||
|
||||
|
@ -191,6 +194,7 @@ class AddNewContactWindow(Gtk.ApplicationWindow):
|
|||
self.account))
|
||||
message_buffer.set_text(msg)
|
||||
|
||||
self.uid_entry.connect('changed', self.on_uid_entry_changed)
|
||||
self.show_all()
|
||||
|
||||
app.ged.register_event_handler('gateway-prompt-received', ged.GUI1,
|
||||
|
@ -204,6 +208,26 @@ class AddNewContactWindow(Gtk.ApplicationWindow):
|
|||
app.ged.remove_event_handler('gateway-prompt-received', ged.GUI1,
|
||||
self._nec_gateway_prompt_received)
|
||||
|
||||
def on_uid_entry_changed(self, widget):
|
||||
is_empty = bool(not self.uid_entry.get_text() == '')
|
||||
self.show_contact_info_button.set_sensitive(is_empty)
|
||||
|
||||
def on_show_contact_info_button_clicked(self, widget):
|
||||
"""
|
||||
Ask for vCard
|
||||
"""
|
||||
jid = self.uid_entry.get_text().strip()
|
||||
|
||||
if jid in app.interface.instances[self.account]['infos']:
|
||||
app.interface.instances[self.account]['infos'][jid].window.present()
|
||||
else:
|
||||
contact = app.contacts.create_contact(jid=jid, account=self.account)
|
||||
app.interface.instances[self.account]['infos'][jid] = \
|
||||
vcard.VcardWindow(contact, self.account)
|
||||
# Remove xmpp page
|
||||
app.interface.instances[self.account]['infos'][jid].xml.\
|
||||
get_object('information_notebook').remove_page(0)
|
||||
|
||||
def on_register_button_clicked(self, widget):
|
||||
model = self.protocol_jid_combobox.get_model()
|
||||
row = self.protocol_jid_combobox.get_active()
|
||||
|
|
Loading…
Reference in New Issue