[Anthony Lannuzel and I] add ability to synchronise contact list from another account.
This commit is contained in:
parent
ada5753cb9
commit
64af5db70c
|
@ -99,7 +99,7 @@
|
|||
<widget class="GtkTable" id="table24">
|
||||
<property name="border_width">6</property>
|
||||
<property name="visible">True</property>
|
||||
<property name="n_rows">4</property>
|
||||
<property name="n_rows">5</property>
|
||||
<property name="n_columns">3</property>
|
||||
<property name="homogeneous">False</property>
|
||||
<property name="row_spacing">6</property>
|
||||
|
@ -134,27 +134,6 @@
|
|||
</packing>
|
||||
</child>
|
||||
|
||||
<child>
|
||||
<widget class="GtkEntry" id="jid_entry">
|
||||
<property name="visible">True</property>
|
||||
<property name="can_focus">True</property>
|
||||
<property name="editable">True</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">True</property>
|
||||
</widget>
|
||||
<packing>
|
||||
<property name="left_attach">1</property>
|
||||
<property name="right_attach">3</property>
|
||||
<property name="top_attach">0</property>
|
||||
<property name="bottom_attach">1</property>
|
||||
<property name="y_options"></property>
|
||||
</packing>
|
||||
</child>
|
||||
|
||||
<child>
|
||||
<widget class="GtkLabel" id="label202">
|
||||
<property name="visible">True</property>
|
||||
|
@ -260,50 +239,6 @@
|
|||
</packing>
|
||||
</child>
|
||||
|
||||
<child>
|
||||
<widget class="GtkEntry" id="resource_entry">
|
||||
<property name="visible">True</property>
|
||||
<property name="tooltip" translatable="yes">Resource is sent to the Jabber server in order to separate the same JID in two or more parts depending on the number of the clients connected in the same server with the same account. So you might be connected in the same account with resource 'Home' and 'Work' at the same time. The resource which has the highest priority will get the events. (see below)</property>
|
||||
<property name="can_focus">True</property>
|
||||
<property name="editable">True</property>
|
||||
<property name="visibility">True</property>
|
||||
<property name="max_length">0</property>
|
||||
<property name="text" translatable="yes">Gajim</property>
|
||||
<property name="has_frame">True</property>
|
||||
<property name="invisible_char">*</property>
|
||||
<property name="activates_default">False</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">expand|shrink|fill</property>
|
||||
<property name="y_options"></property>
|
||||
</packing>
|
||||
</child>
|
||||
|
||||
<child>
|
||||
<widget class="GtkButton" id="change_password_button">
|
||||
<property name="visible">True</property>
|
||||
<property name="tooltip" translatable="yes">Click to change account's password</property>
|
||||
<property name="can_focus">True</property>
|
||||
<property name="label" translatable="yes">Chan_ge Password</property>
|
||||
<property name="use_underline">True</property>
|
||||
<property name="relief">GTK_RELIEF_NORMAL</property>
|
||||
<property name="focus_on_click">True</property>
|
||||
<signal name="clicked" handler="on_change_password_button_clicked" last_modification_time="Fri, 04 Mar 2005 11:33:37 GMT"/>
|
||||
</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="x_options">fill</property>
|
||||
<property name="y_options"></property>
|
||||
</packing>
|
||||
</child>
|
||||
|
||||
<child>
|
||||
<widget class="GtkLabel" id="label220">
|
||||
<property name="visible">True</property>
|
||||
|
@ -379,6 +314,133 @@
|
|||
<property name="y_options"></property>
|
||||
</packing>
|
||||
</child>
|
||||
|
||||
<child>
|
||||
<widget class="GtkExpander" id="expander1">
|
||||
<property name="visible">True</property>
|
||||
<property name="can_focus">True</property>
|
||||
<property name="expanded">False</property>
|
||||
<property name="spacing">0</property>
|
||||
|
||||
<child>
|
||||
<widget class="GtkHBox" id="hbox2968">
|
||||
<property name="visible">True</property>
|
||||
<property name="homogeneous">True</property>
|
||||
<property name="spacing">11</property>
|
||||
|
||||
<child>
|
||||
<widget class="GtkButton" id="synchronise_contacts_button">
|
||||
<property name="visible">True</property>
|
||||
<property name="can_focus">True</property>
|
||||
<property name="label" translatable="yes">Synchronise contacts</property>
|
||||
<property name="use_underline">True</property>
|
||||
<property name="relief">GTK_RELIEF_NORMAL</property>
|
||||
<property name="focus_on_click">True</property>
|
||||
<signal name="clicked" handler="on_synchronise_contacts_button_clicked" last_modification_time="Thu, 01 Mar 2007 11:05:20 GMT"/>
|
||||
</widget>
|
||||
<packing>
|
||||
<property name="padding">0</property>
|
||||
<property name="expand">False</property>
|
||||
<property name="fill">True</property>
|
||||
</packing>
|
||||
</child>
|
||||
|
||||
<child>
|
||||
<widget class="GtkButton" id="change_password_button">
|
||||
<property name="visible">True</property>
|
||||
<property name="tooltip" translatable="yes">Click to change account's password</property>
|
||||
<property name="can_focus">True</property>
|
||||
<property name="label" translatable="yes">Chan_ge Password</property>
|
||||
<property name="use_underline">True</property>
|
||||
<property name="relief">GTK_RELIEF_NORMAL</property>
|
||||
<property name="focus_on_click">True</property>
|
||||
<signal name="clicked" handler="on_change_password_button_clicked" last_modification_time="Fri, 04 Mar 2005 11:33:37 GMT"/>
|
||||
</widget>
|
||||
<packing>
|
||||
<property name="padding">0</property>
|
||||
<property name="expand">False</property>
|
||||
<property name="fill">True</property>
|
||||
</packing>
|
||||
</child>
|
||||
</widget>
|
||||
</child>
|
||||
|
||||
<child>
|
||||
<widget class="GtkLabel" id="label361">
|
||||
<property name="visible">True</property>
|
||||
<property name="label" translatable="yes">Administration operations</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.5</property>
|
||||
<property name="yalign">0.5</property>
|
||||
<property name="xpad">0</property>
|
||||
<property name="ypad">0</property>
|
||||
<property name="ellipsize">PANGO_ELLIPSIZE_NONE</property>
|
||||
<property name="width_chars">-1</property>
|
||||
<property name="single_line_mode">False</property>
|
||||
<property name="angle">0</property>
|
||||
</widget>
|
||||
<packing>
|
||||
<property name="type">label_item</property>
|
||||
</packing>
|
||||
</child>
|
||||
</widget>
|
||||
<packing>
|
||||
<property name="left_attach">0</property>
|
||||
<property name="right_attach">3</property>
|
||||
<property name="top_attach">4</property>
|
||||
<property name="bottom_attach">5</property>
|
||||
<property name="x_options">fill</property>
|
||||
<property name="y_options">fill</property>
|
||||
</packing>
|
||||
</child>
|
||||
|
||||
<child>
|
||||
<widget class="GtkEntry" id="jid_entry">
|
||||
<property name="visible">True</property>
|
||||
<property name="can_focus">True</property>
|
||||
<property name="editable">True</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">True</property>
|
||||
</widget>
|
||||
<packing>
|
||||
<property name="left_attach">1</property>
|
||||
<property name="right_attach">3</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="resource_entry">
|
||||
<property name="visible">True</property>
|
||||
<property name="tooltip" translatable="yes">Resource is sent to the Jabber server in order to separate the same JID in two or more parts depending on the number of the clients connected in the same server with the same account. So you might be connected in the same account with resource 'Home' and 'Work' at the same time. The resource which has the highest priority will get the events. (see below)</property>
|
||||
<property name="can_focus">True</property>
|
||||
<property name="editable">True</property>
|
||||
<property name="visibility">True</property>
|
||||
<property name="max_length">0</property>
|
||||
<property name="text" translatable="yes">Gajim</property>
|
||||
<property name="has_frame">True</property>
|
||||
<property name="invisible_char">*</property>
|
||||
<property name="activates_default">False</property>
|
||||
</widget>
|
||||
<packing>
|
||||
<property name="left_attach">1</property>
|
||||
<property name="right_attach">3</property>
|
||||
<property name="top_attach">2</property>
|
||||
<property name="bottom_attach">3</property>
|
||||
<property name="x_options">expand|shrink|fill</property>
|
||||
<property name="y_options"></property>
|
||||
</packing>
|
||||
</child>
|
||||
</widget>
|
||||
<packing>
|
||||
<property name="tab_expand">False</property>
|
||||
|
|
|
@ -0,0 +1,131 @@
|
|||
<?xml version="1.0" standalone="no"?> <!--*- mode: xml -*-->
|
||||
<!DOCTYPE glade-interface SYSTEM "http://glade.gnome.org/glade-2.0.dtd">
|
||||
|
||||
<glade-interface>
|
||||
|
||||
<widget class="GtkDialog" id="synchronise_select_account_dialog">
|
||||
<property name="border_width">12</property>
|
||||
<property name="title" translatable="yes">Synchronise contacts</property>
|
||||
<property name="type">GTK_WINDOW_TOPLEVEL</property>
|
||||
<property name="window_position">GTK_WIN_POS_NONE</property>
|
||||
<property name="modal">False</property>
|
||||
<property name="default_width">350</property>
|
||||
<property name="default_height">300</property>
|
||||
<property name="resizable">True</property>
|
||||
<property name="destroy_with_parent">False</property>
|
||||
<property name="decorated">True</property>
|
||||
<property name="skip_taskbar_hint">False</property>
|
||||
<property name="skip_pager_hint">False</property>
|
||||
<property name="type_hint">GDK_WINDOW_TYPE_HINT_NORMAL</property>
|
||||
<property name="gravity">GDK_GRAVITY_NORTH_WEST</property>
|
||||
<property name="focus_on_map">True</property>
|
||||
<property name="urgency_hint">False</property>
|
||||
<property name="has_separator">True</property>
|
||||
|
||||
<child internal-child="vbox">
|
||||
<widget class="GtkVBox" id="dialog-vbox7">
|
||||
<property name="visible">True</property>
|
||||
<property name="homogeneous">False</property>
|
||||
<property name="spacing">6</property>
|
||||
|
||||
<child internal-child="action_area">
|
||||
<widget class="GtkHButtonBox" id="dialog-action_area6">
|
||||
<property name="visible">True</property>
|
||||
<property name="layout_style">GTK_BUTTONBOX_END</property>
|
||||
|
||||
<child>
|
||||
<widget class="GtkButton" id="cancel_button">
|
||||
<property name="visible">True</property>
|
||||
<property name="can_default">True</property>
|
||||
<property name="can_focus">True</property>
|
||||
<property name="label">gtk-cancel</property>
|
||||
<property name="use_stock">True</property>
|
||||
<property name="relief">GTK_RELIEF_NORMAL</property>
|
||||
<property name="focus_on_click">True</property>
|
||||
<property name="response_id">-6</property>
|
||||
<signal name="clicked" handler="on_cancel_button_clicked" last_modification_time="Thu, 01 Mar 2007 14:08:01 GMT"/>
|
||||
</widget>
|
||||
</child>
|
||||
|
||||
<child>
|
||||
<widget class="GtkButton" id="ok_button">
|
||||
<property name="visible">True</property>
|
||||
<property name="can_default">True</property>
|
||||
<property name="can_focus">True</property>
|
||||
<property name="label">gtk-ok</property>
|
||||
<property name="use_stock">True</property>
|
||||
<property name="relief">GTK_RELIEF_NORMAL</property>
|
||||
<property name="focus_on_click">True</property>
|
||||
<property name="response_id">-5</property>
|
||||
<signal name="clicked" handler="on_ok_button_clicked" last_modification_time="Thu, 01 Mar 2007 14:07:38 GMT"/>
|
||||
</widget>
|
||||
</child>
|
||||
</widget>
|
||||
<packing>
|
||||
<property name="padding">0</property>
|
||||
<property name="expand">False</property>
|
||||
<property name="fill">True</property>
|
||||
<property name="pack_type">GTK_PACK_END</property>
|
||||
</packing>
|
||||
</child>
|
||||
|
||||
<child>
|
||||
<widget class="GtkLabel" id="label210">
|
||||
<property name="visible">True</property>
|
||||
<property name="label" translatable="yes">Select the account with which you want to synchronise</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.5</property>
|
||||
<property name="yalign">0.5</property>
|
||||
<property name="xpad">0</property>
|
||||
<property name="ypad">0</property>
|
||||
<property name="ellipsize">PANGO_ELLIPSIZE_NONE</property>
|
||||
<property name="width_chars">-1</property>
|
||||
<property name="single_line_mode">False</property>
|
||||
<property name="angle">0</property>
|
||||
</widget>
|
||||
<packing>
|
||||
<property name="padding">0</property>
|
||||
<property name="expand">False</property>
|
||||
<property name="fill">False</property>
|
||||
</packing>
|
||||
</child>
|
||||
|
||||
<child>
|
||||
<widget class="GtkScrolledWindow" id="scrolledwindow">
|
||||
<property name="width_request">150</property>
|
||||
<property name="visible">True</property>
|
||||
<property name="can_focus">True</property>
|
||||
<property name="hscrollbar_policy">GTK_POLICY_ALWAYS</property>
|
||||
<property name="vscrollbar_policy">GTK_POLICY_ALWAYS</property>
|
||||
<property name="shadow_type">GTK_SHADOW_IN</property>
|
||||
<property name="window_placement">GTK_CORNER_TOP_LEFT</property>
|
||||
|
||||
<child>
|
||||
<widget class="GtkTreeView" id="accounts_treeview">
|
||||
<property name="visible">True</property>
|
||||
<property name="can_focus">True</property>
|
||||
<property name="headers_visible">True</property>
|
||||
<property name="rules_hint">False</property>
|
||||
<property name="reorderable">False</property>
|
||||
<property name="enable_search">True</property>
|
||||
<property name="fixed_height_mode">False</property>
|
||||
<property name="hover_selection">False</property>
|
||||
<property name="hover_expand">False</property>
|
||||
</widget>
|
||||
</child>
|
||||
</widget>
|
||||
<packing>
|
||||
<property name="padding">0</property>
|
||||
<property name="expand">True</property>
|
||||
<property name="fill">True</property>
|
||||
</packing>
|
||||
</child>
|
||||
</widget>
|
||||
</child>
|
||||
</widget>
|
||||
|
||||
</glade-interface>
|
|
@ -0,0 +1,131 @@
|
|||
<?xml version="1.0" standalone="no"?> <!--*- mode: xml -*-->
|
||||
<!DOCTYPE glade-interface SYSTEM "http://glade.gnome.org/glade-2.0.dtd">
|
||||
|
||||
<glade-interface>
|
||||
|
||||
<widget class="GtkDialog" id="synchronise_select_contacts_dialog">
|
||||
<property name="border_width">12</property>
|
||||
<property name="title" translatable="yes">Synchronise : select contacts</property>
|
||||
<property name="type">GTK_WINDOW_TOPLEVEL</property>
|
||||
<property name="window_position">GTK_WIN_POS_NONE</property>
|
||||
<property name="modal">False</property>
|
||||
<property name="default_width">400</property>
|
||||
<property name="default_height">300</property>
|
||||
<property name="resizable">True</property>
|
||||
<property name="destroy_with_parent">False</property>
|
||||
<property name="decorated">True</property>
|
||||
<property name="skip_taskbar_hint">False</property>
|
||||
<property name="skip_pager_hint">False</property>
|
||||
<property name="type_hint">GDK_WINDOW_TYPE_HINT_NORMAL</property>
|
||||
<property name="gravity">GDK_GRAVITY_NORTH_WEST</property>
|
||||
<property name="focus_on_map">True</property>
|
||||
<property name="urgency_hint">False</property>
|
||||
<property name="has_separator">True</property>
|
||||
|
||||
<child internal-child="vbox">
|
||||
<widget class="GtkVBox" id="dialog-vbox7">
|
||||
<property name="visible">True</property>
|
||||
<property name="homogeneous">False</property>
|
||||
<property name="spacing">6</property>
|
||||
|
||||
<child internal-child="action_area">
|
||||
<widget class="GtkHButtonBox" id="dialog-action_area6">
|
||||
<property name="visible">True</property>
|
||||
<property name="layout_style">GTK_BUTTONBOX_END</property>
|
||||
|
||||
<child>
|
||||
<widget class="GtkButton" id="cancel_button">
|
||||
<property name="visible">True</property>
|
||||
<property name="can_default">True</property>
|
||||
<property name="can_focus">True</property>
|
||||
<property name="label">gtk-cancel</property>
|
||||
<property name="use_stock">True</property>
|
||||
<property name="relief">GTK_RELIEF_NORMAL</property>
|
||||
<property name="focus_on_click">True</property>
|
||||
<property name="response_id">-6</property>
|
||||
<signal name="clicked" handler="on_cancel_button_clicked" last_modification_time="Thu, 01 Mar 2007 14:08:01 GMT"/>
|
||||
</widget>
|
||||
</child>
|
||||
|
||||
<child>
|
||||
<widget class="GtkButton" id="ok_button">
|
||||
<property name="visible">True</property>
|
||||
<property name="can_default">True</property>
|
||||
<property name="can_focus">True</property>
|
||||
<property name="label">gtk-ok</property>
|
||||
<property name="use_stock">True</property>
|
||||
<property name="relief">GTK_RELIEF_NORMAL</property>
|
||||
<property name="focus_on_click">True</property>
|
||||
<property name="response_id">-5</property>
|
||||
<signal name="clicked" handler="on_ok_button_clicked" last_modification_time="Thu, 01 Mar 2007 14:07:38 GMT"/>
|
||||
</widget>
|
||||
</child>
|
||||
</widget>
|
||||
<packing>
|
||||
<property name="padding">0</property>
|
||||
<property name="expand">False</property>
|
||||
<property name="fill">True</property>
|
||||
<property name="pack_type">GTK_PACK_END</property>
|
||||
</packing>
|
||||
</child>
|
||||
|
||||
<child>
|
||||
<widget class="GtkLabel" id="label210">
|
||||
<property name="visible">True</property>
|
||||
<property name="label" translatable="yes">Select the contacts you want to synchronise</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.5</property>
|
||||
<property name="yalign">0.5</property>
|
||||
<property name="xpad">0</property>
|
||||
<property name="ypad">0</property>
|
||||
<property name="ellipsize">PANGO_ELLIPSIZE_NONE</property>
|
||||
<property name="width_chars">-1</property>
|
||||
<property name="single_line_mode">False</property>
|
||||
<property name="angle">0</property>
|
||||
</widget>
|
||||
<packing>
|
||||
<property name="padding">0</property>
|
||||
<property name="expand">False</property>
|
||||
<property name="fill">False</property>
|
||||
</packing>
|
||||
</child>
|
||||
|
||||
<child>
|
||||
<widget class="GtkScrolledWindow" id="scrolledwindow">
|
||||
<property name="width_request">150</property>
|
||||
<property name="visible">True</property>
|
||||
<property name="can_focus">True</property>
|
||||
<property name="hscrollbar_policy">GTK_POLICY_ALWAYS</property>
|
||||
<property name="vscrollbar_policy">GTK_POLICY_ALWAYS</property>
|
||||
<property name="shadow_type">GTK_SHADOW_NONE</property>
|
||||
<property name="window_placement">GTK_CORNER_TOP_LEFT</property>
|
||||
|
||||
<child>
|
||||
<widget class="GtkTreeView" id="contacts_treeview">
|
||||
<property name="visible">True</property>
|
||||
<property name="can_focus">True</property>
|
||||
<property name="headers_visible">True</property>
|
||||
<property name="rules_hint">False</property>
|
||||
<property name="reorderable">False</property>
|
||||
<property name="enable_search">True</property>
|
||||
<property name="fixed_height_mode">False</property>
|
||||
<property name="hover_selection">False</property>
|
||||
<property name="hover_expand">False</property>
|
||||
</widget>
|
||||
</child>
|
||||
</widget>
|
||||
<packing>
|
||||
<property name="padding">0</property>
|
||||
<property name="expand">True</property>
|
||||
<property name="fill">True</property>
|
||||
</packing>
|
||||
</child>
|
||||
</widget>
|
||||
</child>
|
||||
</widget>
|
||||
|
||||
</glade-interface>
|
|
@ -1588,6 +1588,13 @@ class AccountModificationWindow:
|
|||
gajim.interface.instances['manage_proxies'] = \
|
||||
ManageProxiesWindow()
|
||||
|
||||
def on_synchronise_contacts_button_clicked(self, widget):
|
||||
try:
|
||||
dialog = dialogs.SynchroniseSelectAccountDialog(self.account)
|
||||
except GajimGeneralException:
|
||||
# If we showed ErrorDialog, there will not be dialog instance
|
||||
return
|
||||
|
||||
def on_gpg_choose_button_clicked(self, widget, data = None):
|
||||
if gajim.connections.has_key(self.account):
|
||||
secret_keys = gajim.connections[self.account].ask_gpg_secrete_keys()
|
||||
|
|
130
src/dialogs.py
130
src/dialogs.py
|
@ -1319,6 +1319,136 @@ class JoinGroupchatWindow:
|
|||
|
||||
self.window.destroy()
|
||||
|
||||
class SynchroniseSelectAccountDialog:
|
||||
def __init__(self, account):
|
||||
# 'account' can be None if we are about to create our first one
|
||||
if not account or gajim.connections[account].connected < 2:
|
||||
ErrorDialog(_('You are not connected to the server'),
|
||||
_('Without a connection, you can not synchronise your contacts.'))
|
||||
raise GajimGeneralException, 'You are not connected to the server'
|
||||
self.account = account
|
||||
self.xml = gtkgui_helpers.get_glade('synchronise_select_account_dialog.glade')
|
||||
self.dialog = self.xml.get_widget('synchronise_select_account_dialog')
|
||||
self.accounts_treeview = self.xml.get_widget('accounts_treeview')
|
||||
model = gtk.ListStore(str, str, bool)
|
||||
self.accounts_treeview.set_model(model)
|
||||
# columns
|
||||
renderer = gtk.CellRendererText()
|
||||
self.accounts_treeview.insert_column_with_attributes(-1,
|
||||
_('Name'), renderer, text = 0)
|
||||
renderer = gtk.CellRendererText()
|
||||
self.accounts_treeview.insert_column_with_attributes(-1,
|
||||
_('Server'), renderer, text = 1)
|
||||
|
||||
self.xml.signal_autoconnect(self)
|
||||
self.init_accounts()
|
||||
self.dialog.show_all()
|
||||
|
||||
def on_accounts_window_key_press_event(self, widget, event):
|
||||
if event.keyval == gtk.keysyms.Escape:
|
||||
self.window.destroy()
|
||||
|
||||
def init_accounts(self):
|
||||
'''initialize listStore with existing accounts'''
|
||||
model = self.accounts_treeview.get_model()
|
||||
model.clear()
|
||||
for remote_account in gajim.connections:
|
||||
if remote_account == self.account:
|
||||
# Do not show the account we're sync'ing
|
||||
continue
|
||||
iter = model.append()
|
||||
model.set(iter, 0, remote_account, 1, gajim.get_hostname_from_account(
|
||||
remote_account))
|
||||
|
||||
def on_cancel_button_clicked(self, widget):
|
||||
self.dialog.destroy()
|
||||
|
||||
def on_ok_button_clicked(self, widget):
|
||||
sel = self.accounts_treeview.get_selection()
|
||||
(model, iter) = sel.get_selected()
|
||||
if not iter:
|
||||
return
|
||||
remote_account = model.get_value(iter, 0).decode('utf-8')
|
||||
|
||||
if gajim.connections[remote_account].connected < 2:
|
||||
ErrorDialog(_('This account is not connected to the server'),
|
||||
_('You cannot synchronize with an account unless it is connected.'))
|
||||
return
|
||||
else:
|
||||
try:
|
||||
dialog = SynchroniseSelectContactsDialog(self.account, remote_account)
|
||||
except GajimGeneralException:
|
||||
# if we showed ErrorDialog, there will not be dialog instance
|
||||
return
|
||||
self.dialog.destroy()
|
||||
|
||||
class SynchroniseSelectContactsDialog:
|
||||
def __init__(self, account, remote_account):
|
||||
self.local_account = account
|
||||
self.remote_account = remote_account
|
||||
self.xml = gtkgui_helpers.get_glade('synchronise_select_contacts_dialog.glade')
|
||||
self.dialog = self.xml.get_widget('synchronise_select_contacts_dialog')
|
||||
self.contacts_treeview = self.xml.get_widget('contacts_treeview')
|
||||
model = gtk.ListStore(bool, str)
|
||||
self.contacts_treeview.set_model(model)
|
||||
# columns
|
||||
renderer1 = gtk.CellRendererToggle()
|
||||
renderer1.set_property('activatable', True)
|
||||
renderer1.connect('toggled', self.toggled_callback)
|
||||
self.contacts_treeview.insert_column_with_attributes(-1,
|
||||
_('Synchronise'), renderer1, active = 0)
|
||||
renderer2 = gtk.CellRendererText()
|
||||
self.contacts_treeview.insert_column_with_attributes(-1,
|
||||
_('Name'), renderer2, text = 1)
|
||||
|
||||
self.xml.signal_autoconnect(self)
|
||||
self.init_contacts()
|
||||
self.dialog.show_all()
|
||||
|
||||
def toggled_callback(self, cell, path):
|
||||
model = self.contacts_treeview.get_model()
|
||||
iter = model.get_iter(path)
|
||||
model[iter][0] = not cell.get_active()
|
||||
|
||||
def on_contacts_window_key_press_event(self, widget, event):
|
||||
if event.keyval == gtk.keysyms.Escape:
|
||||
self.window.destroy()
|
||||
|
||||
def init_contacts(self):
|
||||
'''initialize listStore with existing accounts'''
|
||||
model = self.contacts_treeview.get_model()
|
||||
model.clear()
|
||||
|
||||
# recover local contacts
|
||||
local_jid_list = gajim.contacts.get_jid_list(self.local_account)
|
||||
|
||||
remote_jid_list = gajim.contacts.get_jid_list(self.remote_account)
|
||||
for remote_jid in remote_jid_list:
|
||||
if remote_jid not in local_jid_list:
|
||||
iter = model.append()
|
||||
model.set(iter, 0, True, 1, remote_jid)
|
||||
|
||||
def on_cancel_button_clicked(self, widget):
|
||||
self.dialog.destroy()
|
||||
|
||||
def on_ok_button_clicked(self, widget):
|
||||
model = self.contacts_treeview.get_model()
|
||||
iter = model.get_iter_root()
|
||||
while iter:
|
||||
if model[iter][0]:
|
||||
# it is selected
|
||||
remote_jid = model[iter][1].decode('utf-8')
|
||||
message = 'I\'m synchronizing my contacts from my %s account, could you please add this address to your contact list?' % \
|
||||
gajim.get_hostname_from_account(self.remote_account)
|
||||
remote_contact = gajim.contacts.get_first_contact_from_jid(
|
||||
self.remote_account, remote_jid)
|
||||
# keep same groups and same nickname
|
||||
gajim.interface.roster.req_sub(self, remote_jid, message,
|
||||
self.local_account, groups = remote_contact.groups,
|
||||
nickname = remote_contact.name, auto_auth = True)
|
||||
iter = model.iter_next(iter)
|
||||
self.dialog.destroy()
|
||||
|
||||
class NewChatDialog(InputDialog):
|
||||
def __init__(self, account):
|
||||
self.account = account
|
||||
|
|
Loading…
Reference in New Issue