[Git][gajim/gajim][master] Rework Add Contact Dialog
Philipp Hörist
gitlab at dev.gajim.org
Sat Jul 7 00:46:32 CEST 2018
Philipp Hörist pushed to branch master at gajim / gajim
Commits:
0eeb111a by Sophie Herold at 2018-07-07T00:46:23+02:00
Rework Add Contact Dialog
- - - - -
3 changed files:
- gajim/app_actions.py
- gajim/data/gui/add_new_contact_window.ui
- gajim/dialogs.py
Changes:
=====================================
gajim/app_actions.py
=====================================
--- a/gajim/app_actions.py
+++ b/gajim/app_actions.py
@@ -134,7 +134,11 @@ def on_join_gc(action, param):
def on_add_contact(action, param):
- dialogs.AddNewContactWindow(param.get_string())
+ window = app.get_app_window(dialogs.AddNewContactWindow)
+ if window is None:
+ dialogs.AddNewContactWindow(param.get_string())
+ else:
+ window.present()
def on_single_message(action, param):
=====================================
gajim/data/gui/add_new_contact_window.ui
=====================================
--- a/gajim/data/gui/add_new_contact_window.ui
+++ b/gajim/data/gui/add_new_contact_window.ui
@@ -1,132 +1,234 @@
<?xml version="1.0" encoding="UTF-8"?>
-<!-- Generated with glade 3.18.3 -->
+<!-- Generated with glade 3.22.0 -->
<interface>
- <requires lib="gtk+" version="3.12"/>
+ <requires lib="gtk+" version="3.20"/>
+ <object class="GtkListStore" id="account_liststore">
+ <columns>
+ <!-- column-name id -->
+ <column type="gchararray"/>
+ <!-- column-name label -->
+ <column type="gchararray"/>
+ </columns>
+ </object>
<object class="GtkListStore" id="groups_liststore">
<columns>
<!-- column-name item -->
<column type="gchararray"/>
</columns>
</object>
- <object class="GtkListStore" id="liststore2">
+ <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"/>
+ </object>
+ <object class="GtkListStore" id="protocol">
<columns>
- <!-- column-name item -->
+ <!-- column-name label -->
+ <column type="gchararray"/>
+ <!-- column-name icon -->
+ <column type="gchararray"/>
+ <!-- column-name agent -->
<column type="gchararray"/>
</columns>
</object>
- <object class="GtkListStore" id="liststore3">
+ <object class="GtkListStore" id="protocol_jid">
<columns>
<!-- column-name item -->
<column type="gchararray"/>
</columns>
</object>
- <object class="GtkTextBuffer" id="textbuffer1">
- <property name="text" translatable="yes">I would like to add you to my contact list.</property>
- </object>
- <object class="GtkWindow" id="add_new_contact_window">
+ <object class="GtkBox" id="add_contact_box">
+ <property name="width_request">400</property>
+ <property name="visible">True</property>
<property name="can_focus">False</property>
- <property name="border_width">6</property>
- <property name="title" translatable="yes">Add New Contact</property>
- <property name="resizable">False</property>
- <property name="type_hint">dialog</property>
- <signal name="destroy" handler="on_add_new_contact_window_destroy" swapped="no"/>
- <signal name="key-press-event" handler="on_add_new_contact_window_key_press_event" swapped="no"/>
+ <property name="margin_left">18</property>
+ <property name="margin_right">18</property>
+ <property name="margin_bottom">18</property>
+ <property name="orientation">vertical</property>
+ <property name="spacing">6</property>
+ <property name="baseline_position">top</property>
<child>
- <object class="GtkBox" id="vbox8">
+ <object class="GtkLabel" id="prompt_label">
<property name="visible">True</property>
<property name="can_focus">False</property>
- <property name="orientation">vertical</property>
- <property name="spacing">6</property>
+ <property name="halign">center</property>
+ <property name="margin_top">18</property>
+ <property name="use_markup">True</property>
+ <property name="justify">center</property>
+ <property name="wrap">True</property>
+ <style>
+ <class name="dim-label"/>
+ </style>
+ </object>
+ <packing>
+ <property name="expand">False</property>
+ <property name="fill">False</property>
+ <property name="position">0</property>
+ </packing>
+ </child>
+ <child>
+ <object class="GtkGrid">
+ <property name="visible">True</property>
+ <property name="can_focus">False</property>
+ <property name="row_spacing">6</property>
+ <property name="column_spacing">12</property>
<child>
- <object class="GtkLabel" id="prompt_label">
+ <object class="GtkLabel" id="uid_label">
<property name="visible">True</property>
<property name="can_focus">False</property>
- <property name="use_markup">True</property>
+ <property name="halign">end</property>
+ <property name="label" translatable="yes">_Jabber ID</property>
+ <property name="use_underline">True</property>
+ <style>
+ <class name="dim-label"/>
+ </style>
+ </object>
+ <packing>
+ <property name="left_attach">0</property>
+ <property name="top_attach">2</property>
+ </packing>
+ </child>
+ <child>
+ <object class="GtkLabel" id="nickname_label">
+ <property name="visible">True</property>
+ <property name="can_focus">False</property>
+ <property name="halign">end</property>
+ <property name="label" translatable="yes">_Nickname</property>
+ <property name="use_underline">True</property>
+ <property name="xalign">0.03999999910593033</property>
+ <style>
+ <class name="dim-label"/>
+ </style>
+ </object>
+ <packing>
+ <property name="left_attach">0</property>
+ <property name="top_attach">3</property>
+ </packing>
+ </child>
+ <child>
+ <object class="GtkLabel" id="group_label">
+ <property name="visible">True</property>
+ <property name="can_focus">False</property>
+ <property name="halign">end</property>
+ <property name="label" translatable="yes">_Group</property>
+ <property name="use_underline">True</property>
<property name="xalign">0</property>
+ <style>
+ <class name="dim-label"/>
+ </style>
</object>
<packing>
- <property name="expand">False</property>
- <property name="fill">False</property>
- <property name="position">0</property>
+ <property name="left_attach">0</property>
+ <property name="top_attach">4</property>
+ </packing>
+ </child>
+ <child>
+ <object class="GtkEntry" id="uid_entry">
+ <property name="visible">True</property>
+ <property name="can_focus">True</property>
+ <property name="hexpand">True</property>
+ <property name="activates_default">True</property>
+ <property name="placeholder_text" translatable="yes">user at example.org</property>
+ </object>
+ <packing>
+ <property name="left_attach">1</property>
+ <property name="top_attach">2</property>
+ </packing>
+ </child>
+ <child>
+ <object class="GtkEntry" id="nickname_entry">
+ <property name="visible">True</property>
+ <property name="can_focus">True</property>
+ <property name="hexpand">True</property>
+ <property name="activates_default">True</property>
+ </object>
+ <packing>
+ <property name="left_attach">1</property>
+ <property name="top_attach">3</property>
</packing>
</child>
<child>
- <object class="GtkBox" id="account_hbox">
+ <object class="GtkComboBoxText" id="group_comboboxentry">
<property name="visible">True</property>
<property name="can_focus">False</property>
- <property name="spacing">6</property>
- <child>
- <object class="GtkLabel" id="account_label">
- <property name="visible">True</property>
- <property name="can_focus">False</property>
- <property name="label" translatable="yes">A_ccount:</property>
- <property name="use_underline">True</property>
- <property name="xalign">0</property>
+ <property name="hexpand">True</property>
+ <property name="has_entry">True</property>
+ <child internal-child="entry">
+ <object class="GtkEntry" id="comboboxtext-entry">
+ <property name="can_focus">True</property>
+ <property name="activates_default">True</property>
+ <property name="placeholder_text" translatable="yes">Choose or type new group name</property>
</object>
- <packing>
- <property name="expand">False</property>
- <property name="fill">False</property>
- <property name="position">0</property>
- </packing>
- </child>
- <child>
- <object class="GtkComboBox" id="account_combobox">
- <property name="visible">True</property>
- <property name="can_focus">False</property>
- <property name="model">liststore3</property>
- <signal name="changed" handler="on_account_combobox_changed" swapped="no"/>
- <child>
- <object class="GtkCellRendererText" id="cellrenderertext3"/>
- <attributes>
- <attribute name="text">0</attribute>
- </attributes>
- </child>
- </object>
- <packing>
- <property name="expand">False</property>
- <property name="fill">False</property>
- <property name="position">1</property>
- </packing>
- </child>
- <child>
- <placeholder/>
</child>
</object>
<packing>
- <property name="expand">True</property>
- <property name="fill">True</property>
- <property name="position">1</property>
+ <property name="left_attach">1</property>
+ <property name="top_attach">4</property>
</packing>
</child>
<child>
- <object class="GtkBox" id="protocol_hbox">
+ <object class="GtkLabel" id="account_label">
<property name="visible">True</property>
<property name="can_focus">False</property>
- <property name="spacing">6</property>
- <child>
- <object class="GtkLabel" id="protocol_label">
- <property name="visible">True</property>
- <property name="can_focus">False</property>
- <property name="label" translatable="yes">_Protocol:</property>
- <property name="use_underline">True</property>
- <property name="xalign">0</property>
- </object>
- <packing>
- <property name="expand">False</property>
- <property name="fill">False</property>
- <property name="position">0</property>
- </packing>
- </child>
+ <property name="halign">end</property>
+ <property name="margin_bottom">12</property>
+ <property name="label" translatable="yes">A_ccount</property>
+ <property name="use_underline">True</property>
+ <style>
+ <class name="dim-label"/>
+ </style>
+ </object>
+ <packing>
+ <property name="left_attach">0</property>
+ <property name="top_attach">0</property>
+ </packing>
+ </child>
+ <child>
+ <object class="GtkLabel" id="protocol_label">
+ <property name="visible">True</property>
+ <property name="can_focus">False</property>
+ <property name="halign">end</property>
+ <property name="label" translatable="yes">_Protocol</property>
+ <property name="use_underline">True</property>
+ <property name="xalign">0</property>
+ <style>
+ <class name="dim-label"/>
+ </style>
+ </object>
+ <packing>
+ <property name="left_attach">0</property>
+ <property name="top_attach">1</property>
+ </packing>
+ </child>
+ <child>
+ <object class="GtkBox">
+ <property name="visible">True</property>
+ <property name="can_focus">False</property>
+ <property name="spacing">12</property>
<child>
<object class="GtkComboBox" id="protocol_combobox">
<property name="visible">True</property>
<property name="can_focus">False</property>
+ <property name="model">protocol</property>
<signal name="changed" handler="on_protocol_combobox_changed" swapped="no"/>
+ <child>
+ <object class="GtkCellRendererPixbuf"/>
+ <attributes>
+ <attribute name="icon-name">1</attribute>
+ </attributes>
+ </child>
+ <child>
+ <object class="GtkCellRendererText">
+ <property name="xpad">5</property>
+ </object>
+ <attributes>
+ <attribute name="text">0</attribute>
+ </attributes>
+ </child>
</object>
<packing>
<property name="expand">False</property>
<property name="fill">False</property>
- <property name="position">1</property>
+ <property name="position">0</property>
</packing>
</child>
<child>
@@ -134,7 +236,7 @@
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="no_show_all">True</property>
- <property name="model">liststore2</property>
+ <property name="model">protocol_jid</property>
<signal name="changed" handler="on_protocol_jid_combobox_changed" swapped="no"/>
<child>
<object class="GtkCellRendererText" id="cellrenderertext2"/>
@@ -146,285 +248,224 @@
<packing>
<property name="expand">True</property>
<property name="fill">True</property>
- <property name="position">2</property>
+ <property name="position">1</property>
</packing>
</child>
</object>
<packing>
- <property name="expand">True</property>
- <property name="fill">True</property>
- <property name="position">2</property>
+ <property name="left_attach">1</property>
+ <property name="top_attach">1</property>
</packing>
</child>
<child>
- <object class="GtkGrid" id="subscription_table">
+ <object class="GtkComboBox" id="account_combobox">
<property name="visible">True</property>
<property name="can_focus">False</property>
- <property name="row_spacing">6</property>
- <property name="column_spacing">6</property>
- <child>
- <object class="GtkLabel" id="uid_label">
- <property name="visible">True</property>
- <property name="can_focus">False</property>
- <property name="label" translatable="yes">_User ID:</property>
- <property name="use_underline">True</property>
- <property name="xalign">0</property>
- </object>
- <packing>
- <property name="left_attach">0</property>
- <property name="top_attach">0</property>
- </packing>
- </child>
- <child>
- <object class="GtkLabel" id="label188">
- <property name="visible">True</property>
- <property name="can_focus">False</property>
- <property name="label" translatable="yes">_Nickname:</property>
- <property name="use_underline">True</property>
- <property name="xalign">0</property>
- </object>
- <packing>
- <property name="left_attach">0</property>
- <property name="top_attach">1</property>
- </packing>
- </child>
- <child>
- <object class="GtkLabel" id="label223">
- <property name="visible">True</property>
- <property name="can_focus">False</property>
- <property name="label" translatable="yes">_Group:</property>
- <property name="use_underline">True</property>
- <property name="xalign">0</property>
- </object>
- <packing>
- <property name="left_attach">0</property>
- <property name="top_attach">2</property>
- </packing>
- </child>
+ <property name="margin_bottom">12</property>
+ <property name="model">account_liststore</property>
+ <property name="entry_text_column">1</property>
+ <property name="id_column">0</property>
+ <signal name="changed" handler="on_account_combobox_changed" swapped="no"/>
<child>
- <object class="GtkEntry" id="uid_entry">
- <property name="visible">True</property>
- <property name="can_focus">True</property>
- <property name="hexpand">True</property>
- <property name="activates_default">True</property>
- <property name="placeholder_text" translatable="yes">Type User ID</property>
- </object>
- <packing>
- <property name="left_attach">1</property>
- <property name="top_attach">0</property>
- </packing>
- </child>
- <child>
- <object class="GtkEntry" id="nickname_entry">
- <property name="visible">True</property>
- <property name="can_focus">True</property>
- <property name="hexpand">True</property>
- <property name="activates_default">True</property>
- <property name="placeholder_text" translatable="yes">Type Nickname</property>
- </object>
- <packing>
- <property name="left_attach">1</property>
- <property name="top_attach">1</property>
- </packing>
- </child>
- <child>
- <object class="GtkComboBoxText" id="group_comboboxentry">
- <property name="visible">True</property>
- <property name="can_focus">False</property>
- <property name="hexpand">True</property>
- <property name="has_entry">True</property>
- <child internal-child="entry">
- <object class="GtkEntry" id="comboboxtext-entry">
- <property name="can_focus">True</property>
- <property name="placeholder_text" translatable="yes">Choose a group of type a new group</property>
- </object>
- </child>
- </object>
- <packing>
- <property name="left_attach">1</property>
- <property name="top_attach">2</property>
- </packing>
+ <object class="GtkCellRendererText" id="cellrenderertext3"/>
+ <attributes>
+ <attribute name="text">1</attribute>
+ </attributes>
</child>
</object>
<packing>
- <property name="expand">False</property>
- <property name="fill">True</property>
- <property name="position">3</property>
- </packing>
- </child>
- <child>
- <object class="GtkCheckButton" id="auto_authorize_checkbutton">
- <property name="label" translatable="yes">A_llow this contact to view my status</property>
- <property name="use_action_appearance">False</property>
- <property name="visible">True</property>
- <property name="can_focus">True</property>
- <property name="receives_default">False</property>
- <property name="no_show_all">True</property>
- <property name="use_underline">True</property>
- <property name="xalign">0</property>
- <property name="active">True</property>
- <property name="draw_indicator">True</property>
- </object>
- <packing>
- <property name="expand">False</property>
- <property name="fill">False</property>
- <property name="position">4</property>
+ <property name="left_attach">1</property>
+ <property name="top_attach">0</property>
</packing>
</child>
+ </object>
+ <packing>
+ <property name="expand">False</property>
+ <property name="fill">True</property>
+ <property name="padding">18</property>
+ <property name="position">3</property>
+ </packing>
+ </child>
+ <child>
+ <object class="GtkCheckButton" id="auto_authorize_checkbutton">
+ <property name="label" translatable="yes">A_llow contact to view my status</property>
+ <property name="visible">True</property>
+ <property name="can_focus">True</property>
+ <property name="receives_default">False</property>
+ <property name="no_show_all">True</property>
+ <property name="halign">start</property>
+ <property name="use_underline">True</property>
+ <property name="active">True</property>
+ <property name="draw_indicator">True</property>
+ </object>
+ <packing>
+ <property name="expand">False</property>
+ <property name="fill">False</property>
+ <property name="position">4</property>
+ </packing>
+ </child>
+ <child>
+ <object class="GtkScrolledWindow" id="message_scrolledwindow">
+ <property name="height_request">60</property>
+ <property name="visible">True</property>
+ <property name="can_focus">True</property>
+ <property name="no_show_all">True</property>
+ <property name="margin_top">18</property>
+ <property name="shadow_type">etched-in</property>
+ <property name="min_content_height">5</property>
<child>
- <object class="GtkScrolledWindow" id="message_scrolledwindow">
- <property name="height_request">60</property>
+ <object class="GtkTextView" id="message_textview">
<property name="visible">True</property>
<property name="can_focus">True</property>
- <property name="no_show_all">True</property>
- <property name="border_width">6</property>
- <property name="shadow_type">etched-in</property>
- <property name="min_content_height">5</property>
- <child>
- <object class="GtkTextView" id="message_textview">
- <property name="visible">True</property>
- <property name="can_focus">True</property>
- <property name="wrap_mode">word</property>
- <property name="buffer">textbuffer1</property>
- </object>
- </child>
+ <property name="wrap_mode">word</property>
+ <property name="left_margin">6</property>
+ <property name="right_margin">6</property>
+ <property name="top_margin">6</property>
+ <property name="bottom_margin">6</property>
+ <property name="buffer">message_textbuffer</property>
</object>
- <packing>
- <property name="expand">True</property>
- <property name="fill">True</property>
- <property name="position">5</property>
- </packing>
</child>
+ </object>
+ <packing>
+ <property name="expand">True</property>
+ <property name="fill">True</property>
+ <property name="position">4</property>
+ </packing>
+ </child>
+ <child>
+ <object class="GtkRevealer" id="save_message_revealer">
+ <property name="visible">True</property>
+ <property name="can_focus">False</property>
+ <property name="transition_type">crossfade</property>
<child>
<object class="GtkCheckButton" id="save_message_checkbutton">
<property name="label" translatable="yes">_Save subscription message</property>
- <property name="use_action_appearance">False</property>
<property name="visible">True</property>
<property name="can_focus">True</property>
<property name="receives_default">False</property>
+ <property name="halign">start</property>
<property name="use_underline">True</property>
- <property name="xalign">0</property>
<property name="draw_indicator">True</property>
</object>
- <packing>
- <property name="expand">True</property>
- <property name="fill">True</property>
- <property name="position">6</property>
- </packing>
</child>
+ </object>
+ <packing>
+ <property name="expand">False</property>
+ <property name="fill">True</property>
+ <property name="position">5</property>
+ </packing>
+ </child>
+ <child>
+ <object class="GtkBox" id="register_hbox">
+ <property name="visible">True</property>
+ <property name="can_focus">False</property>
+ <property name="no_show_all">True</property>
+ <property name="spacing">6</property>
<child>
- <object class="GtkBox" id="register_hbox">
+ <object class="GtkLabel" id="label224">
<property name="visible">True</property>
<property name="can_focus">False</property>
- <property name="no_show_all">True</property>
- <property name="spacing">6</property>
- <child>
- <object class="GtkLabel" id="label224">
- <property name="visible">True</property>
- <property name="can_focus">False</property>
- <property name="label" translatable="yes">You have to register with this transport
+ <property name="label" translatable="yes">You have to register with this transport
to be able to add a contact from this
protocol. Click on Register button to
proceed.</property>
- <property name="wrap">True</property>
- <property name="xalign">0</property>
- </object>
- <packing>
- <property name="expand">True</property>
- <property name="fill">True</property>
- <property name="position">0</property>
- </packing>
- </child>
- <child>
- <object class="GtkButton" id="register_button">
- <property name="label" translatable="yes">_Register</property>
- <property name="use_action_appearance">False</property>
- <property name="visible">True</property>
- <property name="can_focus">True</property>
- <property name="can_default">True</property>
- <property name="receives_default">False</property>
- <property name="halign">center</property>
- <property name="valign">center</property>
- <property name="use_underline">True</property>
- <signal name="clicked" handler="on_register_button_clicked" swapped="no"/>
- </object>
- <packing>
- <property name="expand">False</property>
- <property name="fill">False</property>
- <property name="position">1</property>
- </packing>
- </child>
+ <property name="wrap">True</property>
+ <property name="xalign">0</property>
</object>
<packing>
<property name="expand">True</property>
<property name="fill">True</property>
- <property name="position">7</property>
+ <property name="position">0</property>
</packing>
</child>
<child>
- <object class="GtkLabel" id="connected_label">
+ <object class="GtkButton" id="register_button">
+ <property name="label" translatable="yes">_Register</property>
<property name="visible">True</property>
- <property name="can_focus">False</property>
- <property name="no_show_all">True</property>
- <property name="label" translatable="yes">You must be connected to the transport to be able
+ <property name="can_focus">True</property>
+ <property name="can_default">True</property>
+ <property name="receives_default">False</property>
+ <property name="halign">center</property>
+ <property name="valign">center</property>
+ <property name="use_underline">True</property>
+ <signal name="clicked" handler="on_register_button_clicked" swapped="no"/>
+ </object>
+ <packing>
+ <property name="expand">False</property>
+ <property name="fill">False</property>
+ <property name="position">1</property>
+ </packing>
+ </child>
+ </object>
+ <packing>
+ <property name="expand">True</property>
+ <property name="fill">True</property>
+ <property name="padding">18</property>
+ <property name="position">7</property>
+ </packing>
+ </child>
+ <child>
+ <object class="GtkLabel" id="connected_label">
+ <property name="visible">True</property>
+ <property name="can_focus">False</property>
+ <property name="no_show_all">True</property>
+ <property name="label" translatable="yes">You must be connected to the transport to be able
to add a contact from this protocol.</property>
+ </object>
+ <packing>
+ <property name="expand">False</property>
+ <property name="fill">False</property>
+ <property name="position">8</property>
+ </packing>
+ </child>
+ <child>
+ <object class="GtkButtonBox" id="hbuttonbox1">
+ <property name="visible">True</property>
+ <property name="can_focus">False</property>
+ <property name="margin_top">18</property>
+ <property name="spacing">12</property>
+ <property name="layout_style">end</property>
+ <child>
+ <object class="GtkButton" id="cancel_button">
+ <property name="label">gtk-cancel</property>
+ <property name="visible">True</property>
+ <property name="can_focus">True</property>
+ <property name="can_default">True</property>
+ <property name="receives_default">False</property>
+ <property name="use_stock">True</property>
+ <signal name="clicked" handler="on_cancel_button_clicked" swapped="no"/>
</object>
<packing>
<property name="expand">False</property>
<property name="fill">False</property>
- <property name="position">8</property>
+ <property name="position">0</property>
</packing>
</child>
<child>
- <object class="GtkButtonBox" id="hbuttonbox1">
+ <object class="GtkButton" id="add_button">
+ <property name="label">gtk-add</property>
<property name="visible">True</property>
- <property name="can_focus">False</property>
- <property name="border_width">5</property>
- <property name="spacing">12</property>
- <property name="layout_style">end</property>
- <child>
- <object class="GtkButton" id="cancel_button">
- <property name="label">gtk-cancel</property>
- <property name="use_action_appearance">False</property>
- <property name="visible">True</property>
- <property name="can_focus">True</property>
- <property name="can_default">True</property>
- <property name="receives_default">False</property>
- <property name="use_stock">True</property>
- <signal name="clicked" handler="on_cancel_button_clicked" swapped="no"/>
- </object>
- <packing>
- <property name="expand">False</property>
- <property name="fill">False</property>
- <property name="position">0</property>
- </packing>
- </child>
- <child>
- <object class="GtkButton" id="add_button">
- <property name="label">gtk-add</property>
- <property name="use_action_appearance">False</property>
- <property name="visible">True</property>
- <property name="can_focus">True</property>
- <property name="can_default">True</property>
- <property name="has_default">True</property>
- <property name="receives_default">False</property>
- <property name="use_stock">True</property>
- <signal name="clicked" handler="on_add_button_clicked" swapped="no"/>
- </object>
- <packing>
- <property name="expand">False</property>
- <property name="fill">False</property>
- <property name="position">1</property>
- </packing>
- </child>
+ <property name="can_focus">True</property>
+ <property name="can_default">True</property>
+ <property name="receives_default">False</property>
+ <property name="use_stock">True</property>
+ <signal name="clicked" handler="on_add_button_clicked" swapped="no"/>
+ <style>
+ <class name="suggested-action"/>
+ </style>
</object>
<packing>
<property name="expand">False</property>
<property name="fill">False</property>
- <property name="position">9</property>
+ <property name="position">1</property>
</packing>
</child>
</object>
+ <packing>
+ <property name="expand">False</property>
+ <property name="fill">False</property>
+ <property name="position">9</property>
+ </packing>
</child>
</object>
</interface>
=====================================
gajim/dialogs.py
=====================================
--- a/gajim/dialogs.py
+++ b/gajim/dialogs.py
@@ -845,64 +845,63 @@ class ChangeStatusMessageDialog(TimeoutDialog):
ChangeMoodDialog(on_response, self.pep_dict['mood'],
self.pep_dict['mood_text'])
-class AddNewContactWindow:
+class AddNewContactWindow(Gtk.ApplicationWindow):
"""
Class for AddNewContactWindow
"""
- uid_labels = {'jabber': _('JID:'),
- 'gadu-gadu': _('GG Number:'),
- 'icq': _('ICQ Number:')}
+ uid_labels = {'jabber': _('Jabber ID'),
+ 'gadu-gadu': _('GG Number'),
+ 'icq': _('ICQ Number')}
def __init__(self, account=None, jid=None, user_nick=None, group=None):
+ Gtk.ApplicationWindow.__init__(self)
+ self.set_application(app.app)
+ self.set_position(Gtk.WindowPosition.CENTER)
+ self.set_show_menubar(False)
+ self.set_resizable(False)
+ self.set_title(_('Add Contact'))
+
+ self.connect('destroy', self.on_add_new_contact_window_destroy)
+ self.connect('key-press-event', self.on_add_new_contact_window_key_press_event)
+
self.account = account
self.adding_jid = False
- if account is None:
- # fill accounts with active accounts
- accounts = []
- for account in app.connections.keys():
- if account == 'Local':
- continue
- if app.connections[account].connected > 1:
- accounts.append(account)
- if not accounts:
- return
- if len(accounts) == 1:
- self.account = account
- else:
- accounts = [self.account]
- if self.account:
- location = app.interface.instances[self.account]
- else:
- location = app.interface.instances
- if 'add_contact' in location:
- location['add_contact'].window.present()
- # An instance is already opened
+
+ # fill accounts with active accounts
+ accounts = app.get_enabled_accounts_with_labels()
+
+ if not accounts:
return
- location['add_contact'] = self
+
+ if not account:
+ self.account = accounts[0][0]
+
self.xml = gtkgui_helpers.get_gtk_builder('add_new_contact_window.ui')
+ self.add(self.xml.get_object('add_contact_box'))
self.xml.connect_signals(self)
- self.window = self.xml.get_object('add_new_contact_window')
- for w in ('account_combobox', 'account_hbox', 'account_label',
+
+ for w in ('account_combobox', 'account_label', 'prompt_label',
'uid_label', 'uid_entry', 'protocol_combobox', 'protocol_jid_combobox',
- 'protocol_hbox', 'nickname_entry', 'message_scrolledwindow',
- 'save_message_checkbutton', 'register_hbox', 'subscription_table',
+ 'protocol_label', 'nickname_entry', 'message_scrolledwindow',
+ 'save_message_checkbutton', 'register_hbox',
'add_button', 'message_textview', 'connected_label',
- 'group_comboboxentry', 'auto_authorize_checkbutton'):
+ 'group_comboboxentry', 'auto_authorize_checkbutton',
+ 'save_message_revealer', 'nickname_label', 'group_label'):
self.__dict__[w] = self.xml.get_object(w)
- if account and len(app.connections) >= 2:
- self.default_desc = _('Please fill in the data of the contact you want '
- 'to add to your account <b>%s</b>') % account
- else:
- self.default_desc = _('Please fill in the data of the contact you '
- 'want to add')
- self.xml.get_object('prompt_label').set_markup(self.default_desc)
+
+ self.subscription_table = [self.uid_label, self.uid_entry,
+ self.nickname_label, self.nickname_entry,
+ self.group_label, self.group_comboboxentry]
+
+ self.add_button.grab_default()
+
self.agents = {'jabber': []}
self.gateway_prompt = {}
# types to which we are not subscribed but account has an agent for it
self.available_types = []
for acct in accounts:
- for j in app.contacts.get_jid_list(acct):
+ for j in app.contacts.get_jid_list(acct[0]):
if app.jid_is_transport(j):
type_ = app.get_transport_name_from_jid(j, False)
if not type_:
@@ -914,28 +913,20 @@ class AddNewContactWindow:
self.gateway_prompt[j] = {'desc': None, 'prompt': None}
# Now add the one to which we can register
for acct in accounts:
- for type_ in app.connections[acct].available_transports:
+ for type_ in app.connections[acct[0]].available_transports:
if type_ in self.agents:
continue
self.agents[type_] = []
- for jid_ in app.connections[acct].available_transports[type_]:
+ for jid_ in app.connections[acct[0]].available_transports[type_]:
if not jid_ in self.agents[type_]:
self.agents[type_].append(jid_)
self.gateway_prompt[jid_] = {'desc': None,
'prompt': None}
self.available_types.append(type_)
- # Combobox with transport/jabber icons
- liststore = Gtk.ListStore(str, str, str)
- cell = Gtk.CellRendererPixbuf()
- self.protocol_combobox.pack_start(cell, False)
- self.protocol_combobox.add_attribute(cell, 'icon_name', 1)
- cell = Gtk.CellRendererText()
- cell.set_property('xpad', 5)
- self.protocol_combobox.pack_start(cell, True)
- self.protocol_combobox.add_attribute(cell, 'text', 0)
- self.protocol_combobox.set_model(liststore)
+
uf_type = {'jabber': 'XMPP', 'gadu-gadu': 'Gadu Gadu', 'icq': 'ICQ'}
# Jabber as first
+ liststore = self.protocol_combobox.get_model()
liststore.append(['XMPP', 'xmpp', 'jabber'])
for type_ in self.agents:
if type_ == 'jabber':
@@ -950,8 +941,7 @@ class AddNewContactWindow:
app.connections[account].request_gateway_prompt(service)
self.protocol_combobox.set_active(0)
self.auto_authorize_checkbutton.show()
- liststore = Gtk.ListStore(str)
- self.protocol_jid_combobox.set_model(liststore)
+
if jid:
self.jid_escaped = True
type_ = app.get_transport_name_from_jid(jid)
@@ -992,7 +982,7 @@ class AddNewContactWindow:
self.uid_entry.grab_focus()
group_names = []
for acct in accounts:
- for g in app.groups[acct].keys():
+ for g in app.groups[acct[0]].keys():
if g not in helpers.special_groups and g not in group_names:
group_names.append(g)
group_names.sort()
@@ -1003,21 +993,25 @@ class AddNewContactWindow:
self.group_comboboxentry.set_active(i)
i += 1
- self.window.set_transient_for(app.interface.roster.window)
- self.window.show_all()
+ self.show_all()
- if self.account:
- self.account_label.hide()
- self.account_hbox.hide()
+ self.prompt_label.hide()
+ self.save_message_revealer.hide()
+
+ if len(accounts) > 1:
+ liststore = self.account_combobox.get_model()
+ for acc in accounts:
+ liststore.append(acc)
+
+ self.account_combobox.set_active_id(self.account)
else:
- liststore = Gtk.ListStore(str, str)
- for acct in accounts:
- liststore.append([acct, acct])
- self.account_combobox.set_model(liststore)
- self.account_combobox.set_active(0)
+ self.account_label.hide()
+ self.account_combobox.hide()
if len(self.agents) == 1:
- self.protocol_hbox.hide()
+ self.protocol_label.hide()
+ self.protocol_combobox.hide()
+ self.protocol_jid_combobox.hide()
if self.account:
message_buffer = self.message_textview.get_buffer()
@@ -1031,15 +1025,10 @@ class AddNewContactWindow:
self._nec_presence_received)
def on_add_new_contact_window_destroy(self, widget):
- if self.account:
- location = app.interface.instances[self.account]
- else:
- location = app.interface.instances
- del location['add_contact']
app.ged.remove_event_handler('presence-received', ged.GUI1,
- self._nec_presence_received)
+ self._nec_presence_received)
app.ged.remove_event_handler('gateway-prompt-received', ged.GUI1,
- self._nec_gateway_prompt_received)
+ self._nec_gateway_prompt_received)
def on_register_button_clicked(self, widget):
model = self.protocol_jid_combobox.get_model()
@@ -1049,13 +1038,17 @@ class AddNewContactWindow:
def on_add_new_contact_window_key_press_event(self, widget, event):
if event.keyval == Gdk.KEY_Escape: # ESCAPE
- self.window.destroy()
+ self.destroy()
def on_cancel_button_clicked(self, widget):
"""
When Cancel button is clicked
"""
- self.window.destroy()
+ self.destroy()
+
+ def on_message_textbuffer_changed(self, widget):
+ self.save_message_revealer.show()
+ self.save_message_revealer.set_reveal_child(True)
def on_add_button_clicked(self, widget):
"""
@@ -1063,6 +1056,11 @@ class AddNewContactWindow:
"""
jid = self.uid_entry.get_text().strip()
if not jid:
+ ErrorDialog(
+ _('%s Missing') % self.uid_label.get_text(),
+ _('You must supply the %s of the new contact.' %
+ self.uid_label.get_text())
+ )
return
model = self.protocol_combobox.get_model()
@@ -1102,6 +1100,13 @@ class AddNewContactWindow:
ErrorDialog(pritext, _('You cannot add yourself to your roster.'))
return
+ if not app.account_is_connected(self.account):
+ ErrorDialog(
+ _('Account Offline'),
+ _('Your account must be online to add new contacts.')
+ )
+ return
+
nickname = self.nickname_entry.get_text() or ''
# get value of account combobox, if account was not specified
if not self.account:
@@ -1135,14 +1140,13 @@ class AddNewContactWindow:
auto_auth = self.auto_authorize_checkbutton.get_active()
app.interface.roster.req_sub(self, jid, message, self.account,
groups=groups, nickname=nickname, auto_auth=auto_auth)
- self.window.destroy()
+ self.destroy()
def on_account_combobox_changed(self, widget):
- model = widget.get_model()
- iter_ = widget.get_active_iter()
- account = model[iter_][0]
+ account = widget.get_active_id()
message_buffer = self.message_textview.get_buffer()
message_buffer.set_text(helpers.get_subscription_request_msg(account))
+ self.account = account
def on_protocol_jid_combobox_changed(self, widget):
model = widget.get_model()
@@ -1153,12 +1157,16 @@ class AddNewContactWindow:
model = self.protocol_combobox.get_model()
iter_ = self.protocol_combobox.get_active_iter()
type_ = model[iter_][2]
+
desc = None
if self.agents[type_] and jid_ in self.gateway_prompt:
desc = self.gateway_prompt[jid_]['desc']
- if not desc:
- desc = self.default_desc
- self.xml.get_object('prompt_label').set_markup(desc)
+
+ if desc:
+ self.prompt_label.set_markup(desc)
+ self.prompt_label.show()
+ else:
+ self.prompt_label.hide()
prompt = None
if self.agents[type_] and jid_ in self.gateway_prompt:
@@ -1185,9 +1193,13 @@ class AddNewContactWindow:
jid_ = self.agents[type_][0]
if jid_ in self.gateway_prompt:
desc = self.gateway_prompt[jid_]['desc']
- if not desc:
- desc = self.default_desc
- self.xml.get_object('prompt_label').set_markup(desc)
+
+ if desc:
+ self.prompt_label.set_markup(desc)
+ self.prompt_label.show()
+ else:
+ self.prompt_label.hide()
+
if len(self.agents[type_]) > 1:
self.protocol_jid_combobox.show()
else:
@@ -1214,7 +1226,7 @@ class AddNewContactWindow:
self.register_hbox.show()
self.auto_authorize_checkbutton.hide()
self.connected_label.hide()
- self.subscription_table.hide()
+ self._subscription_table_hide()
self.add_button.set_sensitive(False)
else:
self.register_hbox.hide()
@@ -1224,13 +1236,13 @@ class AddNewContactWindow:
jid = model[row][0]
contact = app.contacts.get_first_contact_from_jid(
self.account, jid)
- if contact.show in ('offline', 'error'):
- self.subscription_table.hide()
+ if contact is None or contact.show in ('offline', 'error'):
+ self._subscription_table_hide()
self.connected_label.show()
self.add_button.set_sensitive(False)
self.auto_authorize_checkbutton.hide()
return
- self.subscription_table.show()
+ self._subscription_table_show()
self.auto_authorize_checkbutton.show()
self.connected_label.hide()
self.add_button.set_sensitive(True)
@@ -1242,7 +1254,7 @@ class AddNewContactWindow:
if _jid == jid:
self.register_hbox.hide()
self.connected_label.hide()
- self.subscription_table.show()
+ self._subscription_table_show()
self.auto_authorize_checkbutton.show()
self.add_button.set_sensitive(True)
@@ -1251,7 +1263,7 @@ class AddNewContactWindow:
row = self.protocol_jid_combobox.get_active()
_jid = model[row][0]
if _jid == jid:
- self.subscription_table.hide()
+ self._subscription_table_hide()
self.auto_authorize_checkbutton.hide()
self.connected_label.show()
self.add_button.set_sensitive(False)
@@ -1283,6 +1295,14 @@ class AddNewContactWindow:
if obj.prompt:
self.gateway_prompt[obj.jid]['prompt'] = obj.prompt
+ def _subscription_table_hide(self):
+ for widget in self.subscription_table:
+ widget.hide()
+
+ def _subscription_table_show(self):
+ for widget in self.subscription_table:
+ widget.show()
+
class AboutDialog(Gtk.AboutDialog):
def __init__(self):
Gtk.AboutDialog.__init__(self)
View it on GitLab: https://dev.gajim.org/gajim/gajim/commit/0eeb111a02d23fd3dfc39f7e40620fb76ebaddb4
--
View it on GitLab: https://dev.gajim.org/gajim/gajim/commit/0eeb111a02d23fd3dfc39f7e40620fb76ebaddb4
You're receiving this email because of your account on dev.gajim.org.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.gajim.org/pipermail/commits/attachments/20180707/fe009106/attachment-0001.html>
More information about the Commits
mailing list