diff options
author | Christian Schaarschmidt <schaarsc@gmx.de> | 2014-09-08 17:45:33 +0800 |
---|---|---|
committer | Milan Crha <mcrha@redhat.com> | 2014-09-08 17:45:33 +0800 |
commit | 3ee80c90378847641cd59eb21600a0f940ca6b7f (patch) | |
tree | cafff72074cee91e4d0f6a067159d32467fd75c3 /addressbook | |
parent | ef0efafe812285855e86ddd0d38546a1496bb45f (diff) | |
download | gsoc2013-evolution-3ee80c90378847641cd59eb21600a0f940ca6b7f.tar gsoc2013-evolution-3ee80c90378847641cd59eb21600a0f940ca6b7f.tar.gz gsoc2013-evolution-3ee80c90378847641cd59eb21600a0f940ca6b7f.tar.bz2 gsoc2013-evolution-3ee80c90378847641cd59eb21600a0f940ca6b7f.tar.lz gsoc2013-evolution-3ee80c90378847641cd59eb21600a0f940ca6b7f.tar.xz gsoc2013-evolution-3ee80c90378847641cd59eb21600a0f940ca6b7f.tar.zst gsoc2013-evolution-3ee80c90378847641cd59eb21600a0f940ca6b7f.zip |
Bug 736123 - Refactor contact-editor: use GtkExpander instead of custom code
This change also includes preparation for
bug 319195 - Contact dialog appallingly overcrowded
Diffstat (limited to 'addressbook')
-rw-r--r-- | addressbook/gui/contact-editor/contact-editor.ui | 442 | ||||
-rw-r--r-- | addressbook/gui/contact-editor/e-contact-editor.c | 434 |
2 files changed, 339 insertions, 537 deletions
diff --git a/addressbook/gui/contact-editor/contact-editor.ui b/addressbook/gui/contact-editor/contact-editor.ui index d4ae442f49..9ccb3e8ad9 100644 --- a/addressbook/gui/contact-editor/contact-editor.ui +++ b/addressbook/gui/contact-editor/contact-editor.ui @@ -307,49 +307,12 @@ <property name="orientation">vertical</property> <property name="spacing">10</property> <child> - <object class="GtkFrame" id="frame65"> + <object class="GtkVBox" id="vbox-contact-mail"> <property name="visible">True</property> - <property name="label_xalign">0</property> - <property name="shadow_type">none</property> - - <child> - <object class="GtkVBox" id="vboxmail"> - <property name="visible">True</property> - <property name="border_width">12</property> - <property name="orientation">vertical</property> - <property name="spacing">6</property> - - <child> - <object class="EContactEditorDynTable" type-func="e_contact_editor_dyntable_get_type" id="mail-dyntable"> - <property name="visible">True</property> - </object> - <packing> - <property name="position">0</property> - </packing> - </child> - - <child> - <object class="GtkCheckButton" id="checkbutton-htmlmail"> - <property name="label" translatable="yes">_Wants to receive HTML mail</property> - <property name="visible">True</property> - <property name="can_focus">True</property> - <property name="receives_default">False</property> - <property name="use_underline">True</property> - <property name="draw_indicator">True</property> - </object> - <packing> - <property name="position">1</property> - </packing> - </child> - - </object> - </child> - - <child type="label"> - <object class="GtkHBox" id="hbox561"> + <child> + <object class="GtkExpander" id="expander-contact-email"> <property name="visible">True</property> - <property name="spacing">4</property> - <child> + <child type="label"> <object class="GtkLabel" id="label400"> <property name="visible">True</property> <property name="label" translatable="yes">Email</property> @@ -357,37 +320,44 @@ <attribute name="weight" value="bold"/> </attributes> </object> + </child> + </object> + <packing> + <property name="position">0</property> + </packing> + </child> + <child> + <object class="GtkVBox" id="vboxmail"> + <property name="visible">True</property> + <property name="border_width">12</property> + <property name="orientation">vertical</property> + <property name="spacing">6</property> + <child> + <object class="EContactEditorDynTable" type-func="e_contact_editor_dyntable_get_type" + id="mail-dyntable"> + <property name="visible">True</property> + </object> <packing> - <property name="expand">False</property> - <property name="fill">False</property> <property name="position">0</property> </packing> </child> <child> - <object class="GtkButton" id="button-mail-expand"> - <property name="width_request">20</property> - <property name="height_request">20</property> + <object class="GtkCheckButton" id="checkbutton-htmlmail"> + <property name="label" translatable="yes">_Wants to receive HTML mail</property> <property name="visible">True</property> <property name="can_focus">True</property> <property name="receives_default">False</property> - <property name="relief">none</property> - <child internal-child="accessible"> - <object class="AtkObject" id="button-mail-expand-atkobject"> - <property name="AtkObject::accessible-name" translatable="yes">Email</property> - </object> - </child> - <child> - <object class="GtkArrow" id="arrow-mail-expand"> - <property name="visible">True</property> - <property name="shadow_type">none</property> - </object> - </child> + <property name="use_underline">True</property> + <property name="draw_indicator">True</property> </object> <packing> <property name="position">1</property> </packing> </child> </object> + <packing> + <property name="position">1</property> + </packing> </child> </object> <packing> @@ -397,83 +367,42 @@ </packing> </child> <child> - <object class="GtkVBox" id="vbox38"> + <object class="GtkVBox" id="vbox-contact-phone"> <property name="visible">True</property> - <property name="orientation">vertical</property> <child> - <object class="GtkFrame" id="frame64"> + <object class="GtkExpander" id="expander-contact-phone"> <property name="visible">True</property> - <property name="label_xalign">0</property> - <property name="shadow_type">none</property> - <child> - <object class="GtkVBox" id="vbox37"> - <property name="visible">True</property> - <property name="border_width">12</property> - <property name="orientation">vertical</property> - <property name="spacing">6</property> - - <child> - <object class="EContactEditorDynTable" type-func="e_contact_editor_dyntable_get_type" id="phone-dyntable"> - <property name="visible">True</property> - </object> - <packing> - <property name="position">0</property> - </packing> - </child> - - - </object> - </child> <child type="label"> - <object class="GtkHBox" id="hbox56"> + <object class="GtkLabel" id="label399"> <property name="visible">True</property> - <property name="spacing">4</property> - <child> - <object class="GtkLabel" id="label399"> - <property name="visible">True</property> - <property name="label" translatable="yes">Telephone</property> - <attributes> - <attribute name="weight" value="bold"/> - </attributes> - </object> - <packing> - <property name="expand">False</property> - <property name="fill">False</property> - <property name="position">0</property> - </packing> - </child> - <child> - <object class="GtkButton" id="button-phone-expand"> - <property name="width_request">20</property> - <property name="height_request">20</property> - <property name="visible">True</property> - <property name="can_focus">True</property> - <property name="receives_default">False</property> - <property name="relief">none</property> - <child internal-child="accessible"> - <object class="AtkObject" id="button-phone-expand-atkobject"> - <property name="AtkObject::accessible-name" translatable="yes">Telephone</property> - </object> - </child> - <child> - <object class="GtkArrow" id="arrow-phone-expand"> - <property name="visible">True</property> - <property name="shadow_type">none</property> - </object> - </child> - </object> - <packing> - <property name="position">1</property> - </packing> - </child> + <property name="label" translatable="yes">Telephone</property> + <attributes> + <attribute name="weight" value="bold"/> + </attributes> </object> </child> </object> <packing> - <property name="expand">False</property> <property name="position">0</property> </packing> </child> + <child> + <object class="GtkVBox" id="vbox-phone"> + <property name="visible">True</property> + <property name="border_width">12</property> + <property name="orientation">vertical</property> + <property name="spacing">6</property> + <child> + <object class="EContactEditorDynTable" type-func="e_contact_editor_dyntable_get_type" + id="phone-dyntable"> + <property name="visible">True</property> + </object> + <packing> + <property name="position">1</property> + </packing> + </child> + </object> + </child> </object> <packing> <property name="expand">False</property> @@ -481,75 +410,45 @@ </packing> </child> <child> - <object class="GtkFrame" id="sip-frame"> + <object class="GtkVBox" id="vbox-contact-sip"> <property name="visible">True</property> - <property name="label_xalign">0</property> - <property name="shadow_type">none</property> - - <child> - <object class="GtkVBox" id="vbox-sip"> + <child> + <object class="GtkExpander" id="expander-contact-sip"> + <property name="visible">True</property> + <child type="label"> + <object class="GtkLabel" id="label-sip"> <property name="visible">True</property> - <property name="border_width">12</property> - <property name="orientation">vertical</property> - <property name="spacing">6</property> - - <child> - <object class="EContactEditorDynTable" type-func="e_contact_editor_dyntable_get_type" id="sip-dyntable"> - <property name="visible">True</property> - </object> - <packing> - <property name="position">0</property> - </packing> - </child> - - </object> + <property name="label" translatable="yes">SIP Address</property> + <attributes> + <attribute name="weight" value="bold"/> + </attributes> + </object> </child> - - <child type="label"> - <object class="GtkHBox" id="hbox-sip"> + </object> + <packing> + <property name="position">0</property> + </packing> + </child> + <child> + <object class="GtkVBox" id="vbox-sip"> + <property name="visible">True</property> + <property name="border_width">12</property> + <property name="orientation">vertical</property> + <property name="spacing">6</property> + <child> + <object class="EContactEditorDynTable" type-func="e_contact_editor_dyntable_get_type" + id="sip-dyntable"> <property name="visible">True</property> - <property name="spacing">4</property> - <child> - <object class="GtkLabel" id="label-sip"> - <property name="visible">True</property> - <property name="label" translatable="yes">SIP Address</property> - <attributes> - <attribute name="weight" value="bold"/> - </attributes> - </object> - <packing> - <property name="expand">False</property> - <property name="fill">False</property> - <property name="position">0</property> - </packing> - </child> - <child> - <object class="GtkButton" id="button-sip-expand"> - <property name="width_request">20</property> - <property name="height_request">20</property> - <property name="visible">True</property> - <property name="can_focus">True</property> - <property name="receives_default">False</property> - <property name="relief">none</property> - <child internal-child="accessible"> - <object class="AtkObject" id="button-sip-expand-atkobject"> - <property name="AtkObject::accessible-name" translatable="yes">SIP Address</property> - </object> - </child> - <child> - <object class="GtkArrow" id="arrow-sip-expand"> - <property name="visible">True</property> - <property name="shadow_type">none</property> - </object> - </child> - </object> - <packing> - <property name="position">1</property> - </packing> - </child> </object> + <packing> + <property name="position">0</property> + </packing> </child> - + </object> + <packing> + <property name="position">1</property> + </packing> + </child> </object> <packing> <property name="expand">False</property> @@ -557,75 +456,45 @@ </packing> </child> <child> - <object class="GtkFrame" id="frame66"> + <object class="GtkVBox" id="vbox-contact-im"> <property name="visible">True</property> - <property name="label_xalign">0</property> - <property name="shadow_type">none</property> - - <child> - <object class="GtkVBox" id="vbox-im"> + <child> + <object class="GtkExpander" id="expander-contact-im"> + <property name="visible">True</property> + <child type="label"> + <object class="GtkLabel" id="label-im"> <property name="visible">True</property> - <property name="border_width">12</property> - <property name="orientation">vertical</property> - <property name="spacing">6</property> - - <child> - <object class="EContactEditorDynTable" type-func="e_contact_editor_dyntable_get_type" id="im-dyntable"> - <property name="visible">True</property> - </object> - <packing> - <property name="position">0</property> - </packing> - </child> - - </object> + <property name="label" translatable="yes">Instant Messaging</property> + <attributes> + <attribute name="weight" value="bold"/> + </attributes> + </object> </child> - - <child type="label"> - <object class="GtkHBox" id="hbox-im"> + </object> + <packing> + <property name="position">0</property> + </packing> + </child> + <child> + <object class="GtkVBox" id="vbox-im"> + <property name="visible">True</property> + <property name="border_width">12</property> + <property name="orientation">vertical</property> + <property name="spacing">6</property> + <child> + <object class="EContactEditorDynTable" type-func="e_contact_editor_dyntable_get_type" + id="im-dyntable"> <property name="visible">True</property> - <property name="spacing">4</property> - <child> - <object class="GtkLabel" id="label-im"> - <property name="visible">True</property> - <property name="label" translatable="yes">Instant Messaging</property> - <attributes> - <attribute name="weight" value="bold"/> - </attributes> - </object> - <packing> - <property name="expand">False</property> - <property name="fill">False</property> - <property name="position">0</property> - </packing> - </child> - <child> - <object class="GtkButton" id="button-im-expand"> - <property name="width_request">20</property> - <property name="height_request">20</property> - <property name="visible">True</property> - <property name="can_focus">True</property> - <property name="receives_default">False</property> - <property name="relief">none</property> - <child internal-child="accessible"> - <object class="AtkObject" id="button-im-expand-atkobject"> - <property name="AtkObject::accessible-name" translatable="yes">Instant Messaging</property> - </object> - </child> - <child> - <object class="GtkArrow" id="arrow-im-expand"> - <property name="visible">True</property> - <property name="shadow_type">none</property> - </object> - </child> - </object> - <packing> - <property name="position">1</property> - </packing> - </child> </object> + <packing> + <property name="position">0</property> + </packing> </child> - + </object> + <packing> + <property name="position">1</property> + </packing> + </child> </object> <packing> <property name="expand">False</property> @@ -653,7 +522,7 @@ </packing> </child> <child> - <object class="GtkScrolledWindow" id="scrolledwindow-size-leader"> + <object class="GtkScrolledWindow" id="scrolledwindow-personal"> <property name="visible">True</property> <property name="can_focus">True</property> <property name="hscrollbar_policy">automatic</property> @@ -670,12 +539,10 @@ <property name="visible">True</property> <property name="border_width">12</property> <property name="orientation">vertical</property> - <property name="spacing">12</property> + <property name="spacing">0</property> <child> - <object class="GtkFrame" id="frame67"> + <object class="GtkExpander" id="expander-personal-web"> <property name="visible">True</property> - <property name="label_xalign">0</property> - <property name="shadow_type">none</property> <child> <object class="GtkTable" id="table87"> <property name="visible">True</property> @@ -844,45 +711,12 @@ </object> </child> <child type="label"> - <object class="GtkHBox" id="hbox5617"> + <object class="GtkLabel" id="label410"> <property name="visible">True</property> - <property name="spacing">4</property> - <child> - <object class="GtkLabel" id="label410"> - <property name="visible">True</property> - <property name="label" translatable="yes">Web Addresses</property> - <attributes> - <attribute name="weight" value="bold"/> - </attributes> - </object> - <packing> - <property name="position">0</property> - </packing> - </child> - <child> - <object class="GtkButton" id="button-web-expand"> - <property name="width_request">20</property> - <property name="height_request">20</property> - <property name="visible">True</property> - <property name="can_focus">True</property> - <property name="receives_default">False</property> - <property name="relief">none</property> - <child internal-child="accessible"> - <object class="AtkObject" id="button-web-expand-atkobject"> - <property name="AtkObject::accessible-name" translatable="yes">Web addresses</property> - </object> - </child> - <child> - <object class="GtkArrow" id="arrow-web-expand"> - <property name="visible">True</property> - <property name="shadow_type">none</property> - </object> - </child> - </object> - <packing> - <property name="position">1</property> - </packing> - </child> + <property name="label" translatable="yes">Web Addresses</property> + <attributes> + <attribute name="weight" value="bold"/> + </attributes> </object> </child> </object> @@ -892,10 +726,8 @@ </packing> </child> <child> - <object class="GtkFrame" id="frame68"> + <object class="GtkExpander" id="expander-personal-job"> <property name="visible">True</property> - <property name="label_xalign">0</property> - <property name="shadow_type">none</property> <child> <object class="GtkTable" id="table88"> <property name="visible">True</property> @@ -1302,7 +1134,7 @@ </packing> </child> <child> - <object class="GtkScrolledWindow" id="scrolledwindow3"> + <object class="GtkScrolledWindow" id="scrolledwindow-mailing"> <property name="visible">True</property> <property name="can_focus">True</property> <property name="hscrollbar_policy">automatic</property> @@ -1319,11 +1151,13 @@ <property name="visible">True</property> <property name="orientation">vertical</property> <child> - <object class="GtkFrame" id="frame72"> + <object class="GtkFrame" id="frame-mailing-home"> <property name="visible">True</property> <property name="border_width">6</property> <property name="label_xalign">0</property> <property name="shadow_type">none</property> + <property name="vexpand">FALSE</property> + <property name="valign">GTK_ALIGN_START</property> <child> <object class="GtkAlignment" id="alignment1"> <property name="visible">True</property> @@ -1558,14 +1392,18 @@ </object> <packing> <property name="position">0</property> + <property name="expand">FALSE</property> + <property name="fill">FALSE</property> </packing> </child> <child> - <object class="GtkFrame" id="frame77"> + <object class="GtkFrame" id="frame-mailing-work"> <property name="visible">True</property> <property name="border_width">6</property> <property name="label_xalign">0</property> <property name="shadow_type">none</property> + <property name="vexpand">FALSE</property> + <property name="valign">GTK_ALIGN_START</property> <child> <object class="GtkAlignment" id="alignment6"> <property name="visible">True</property> @@ -1800,6 +1638,8 @@ </object> <packing> <property name="position">1</property> + <property name="expand">FALSE</property> + <property name="fill">FALSE</property> </packing> </child> <child> @@ -1807,6 +1647,8 @@ <property name="visible">True</property> <property name="can_focus">True</property> <property name="border_width">6</property> + <property name="vexpand">FALSE</property> + <property name="valign">GTK_ALIGN_START</property> <child> <object class="GtkAlignment" id="alignment7"> <property name="visible">True</property> @@ -2041,6 +1883,8 @@ </object> <packing> <property name="position">2</property> + <property name="expand">FALSE</property> + <property name="fill">FALSE</property> </packing> </child> </object> @@ -2063,7 +1907,7 @@ </packing> </child> <child> - <object class="GtkScrolledWindow" id="scrolledwindow41"> + <object class="GtkScrolledWindow" id="scrolledwindow-notes"> <property name="visible">True</property> <property name="can_focus">True</property> <property name="border_width">12</property> diff --git a/addressbook/gui/contact-editor/e-contact-editor.c b/addressbook/gui/contact-editor/e-contact-editor.c index f8021d2292..d8c15a483f 100644 --- a/addressbook/gui/contact-editor/e-contact-editor.c +++ b/addressbook/gui/contact-editor/e-contact-editor.c @@ -1092,166 +1092,40 @@ sensitize_email (EContactEditor *editor) } static void -set_arrow_image (EContactEditor *editor, - const gchar *arrow_widget, - gboolean expanded) +row_added_cb (GtkExpander *expander) { - GtkWidget *arrow; - - arrow = e_builder_get_widget (editor->priv->builder, arrow_widget); - if (expanded) - gtk_arrow_set ( - GTK_ARROW (arrow), GTK_ARROW_DOWN, GTK_SHADOW_NONE); - else - gtk_arrow_set ( - GTK_ARROW (arrow), GTK_ARROW_RIGHT, GTK_SHADOW_NONE); -} - -static gboolean -is_arrow_image_arrow_down (EContactEditor *editor, - const gchar *arrow_widget) -{ - GtkWidget *arrow; - gint value; - - arrow = e_builder_get_widget (editor->priv->builder, arrow_widget); - g_object_get (arrow, "arrow-type", &value, NULL); - - if (value == GTK_ARROW_DOWN) - return TRUE; - - return FALSE; -} - -static void -expand_widget_list (EContactEditor *editor, - const gchar **widget_names, - gboolean expanded) -{ - gint i; - for (i = 0; widget_names[i]; i++) - gtk_widget_set_visible ( - e_builder_get_widget (editor->priv->builder, widget_names[i]), - expanded); -} - -static void -expand_web (EContactEditor *editor, - gboolean expanded) -{ - const gchar *names[] = { - "label-videourl", "label-fburl", - "entry-videourl", "entry-fburl", - NULL - }; - set_arrow_image (editor, "arrow-web-expand", expanded); - expand_widget_list (editor, names, expanded); -} - -static void -expand_phone (EContactEditor *editor, - gboolean expanded) -{ - GtkWidget *w; - EContactEditorDynTable *dyntable; - - set_arrow_image (editor, "arrow-phone-expand", expanded); - - w = e_builder_get_widget (editor->priv->builder, "phone-dyntable"); - dyntable = E_CONTACT_EDITOR_DYNTABLE (w); - - if (expanded) - e_contact_editor_dyntable_set_show_max (dyntable, PHONE_SLOTS); - else - e_contact_editor_dyntable_set_show_max (dyntable, SLOTS_IN_COLLAPSED_STATE); -} - -static void -expand_sip (EContactEditor *editor, - gboolean expanded) -{ - GtkWidget *w; - EContactEditorDynTable *dyntable; - - set_arrow_image (editor, "arrow-sip-expand", expanded); - - w = e_builder_get_widget (editor->priv->builder, "sip-dyntable"); - dyntable = E_CONTACT_EDITOR_DYNTABLE (w); - - if (expanded) - e_contact_editor_dyntable_set_show_max (dyntable, SIP_SLOTS); - else - e_contact_editor_dyntable_set_show_max (dyntable, SLOTS_IN_COLLAPSED_STATE); -} - -static void -expand_im (EContactEditor *editor, - gboolean expanded) -{ - GtkWidget *w; - EContactEditorDynTable *dyntable; - - set_arrow_image (editor, "arrow-im-expand", expanded); - - w = e_builder_get_widget (editor->priv->builder, "im-dyntable"); - dyntable = E_CONTACT_EDITOR_DYNTABLE (w); - - if (expanded) - e_contact_editor_dyntable_set_show_max (dyntable, IM_SLOTS); - else - e_contact_editor_dyntable_set_show_max (dyntable, SLOTS_IN_COLLAPSED_STATE); -} - -static void -expand_mail (EContactEditor *editor, - gboolean expanded) -{ - GtkWidget *w; - EContactEditorDynTable *dyntable; - - set_arrow_image (editor, "arrow-mail-expand", expanded); - - w = e_builder_get_widget (editor->priv->builder, "mail-dyntable"); - dyntable = E_CONTACT_EDITOR_DYNTABLE (w); - - if (expanded) - e_contact_editor_dyntable_set_show_max (dyntable, EMAIL_SLOTS); - else - e_contact_editor_dyntable_set_show_max (dyntable, SLOTS_IN_COLLAPSED_STATE); -} - -static void -row_added_mail (EContactEditorDynTable *dyntable, EContactEditor *editor) -{ - expand_mail (editor, TRUE); + /* newly added row is always visible, setting expanded=true */ + gtk_expander_set_expanded (expander, TRUE); } static void init_email (EContactEditor *editor) { - GtkWidget *w; EContactEditorDynTable *dyntable; + GtkExpander *expander; - w = e_builder_get_widget (editor->priv->builder, "mail-dyntable"); - dyntable = E_CONTACT_EDITOR_DYNTABLE (w); + expander = GTK_EXPANDER ( + e_builder_get_widget (editor->priv->builder, "expander-contact-email")); + dyntable = E_CONTACT_EDITOR_DYNTABLE ( + e_builder_get_widget (editor->priv->builder, "mail-dyntable")); e_contact_editor_dyntable_set_max_entries (dyntable, EMAIL_SLOTS); e_contact_editor_dyntable_set_num_columns (dyntable, SLOTS_PER_LINE, TRUE); e_contact_editor_dyntable_set_show_min (dyntable, SLOTS_IN_COLLAPSED_STATE); g_signal_connect ( - w, "changed", + dyntable, "changed", G_CALLBACK (object_changed), editor); g_signal_connect_swapped ( - w, "activate", + dyntable, "activate", G_CALLBACK (entry_activated), editor); - g_signal_connect ( - w, "row-added", - G_CALLBACK (row_added_mail), editor); + g_signal_connect_swapped ( + dyntable, "row-added", + G_CALLBACK (row_added_cb), expander); init_email_record_location (editor); - expand_mail (editor, TRUE); + gtk_expander_set_expanded (expander, TRUE); } static void @@ -1402,37 +1276,33 @@ init_phone_record_type (EContactEditor *editor) } static void -row_added_phone (EContactEditorDynTable *dyntable, EContactEditor *editor) -{ - expand_phone (editor, TRUE); -} - -static void init_phone (EContactEditor *editor) { - GtkWidget *w; EContactEditorDynTable *dyntable; + GtkExpander *expander; - w = e_builder_get_widget (editor->priv->builder, "phone-dyntable"); - dyntable = E_CONTACT_EDITOR_DYNTABLE (w); + expander = GTK_EXPANDER ( + e_builder_get_widget (editor->priv->builder, "expander-contact-phone")); + dyntable = E_CONTACT_EDITOR_DYNTABLE ( + e_builder_get_widget (editor->priv->builder, "phone-dyntable")); e_contact_editor_dyntable_set_max_entries (dyntable, PHONE_SLOTS); e_contact_editor_dyntable_set_num_columns (dyntable, SLOTS_PER_LINE, TRUE); e_contact_editor_dyntable_set_show_min (dyntable, SLOTS_IN_COLLAPSED_STATE); g_signal_connect ( - w, "changed", + dyntable, "changed", G_CALLBACK (object_changed), editor); g_signal_connect_swapped ( - w, "activate", + dyntable, "activate", G_CALLBACK (entry_activated), editor); - g_signal_connect ( - w, "row-added", - G_CALLBACK (row_added_phone), editor); + g_signal_connect_swapped ( + dyntable, "row-added", + G_CALLBACK (row_added_cb), expander); init_phone_record_type (editor); - expand_phone (editor, TRUE); + gtk_expander_set_expanded (expander, TRUE); } static void @@ -1630,38 +1500,33 @@ init_sip_record_type (EContactEditor *editor) } static void -row_added_sip (EContactEditorDynTable *dyntable, - EContactEditor *editor) -{ - expand_sip (editor, TRUE); -} - -static void init_sip (EContactEditor *editor) { - GtkWidget *w; EContactEditorDynTable *dyntable; + GtkExpander *expander; - w = e_builder_get_widget (editor->priv->builder, "sip-dyntable"); - dyntable = E_CONTACT_EDITOR_DYNTABLE (w); + expander = GTK_EXPANDER ( + e_builder_get_widget (editor->priv->builder, "expander-contact-sip")); + dyntable = E_CONTACT_EDITOR_DYNTABLE ( + e_builder_get_widget (editor->priv->builder, "sip-dyntable")); e_contact_editor_dyntable_set_max_entries (dyntable, SIP_SLOTS); e_contact_editor_dyntable_set_num_columns (dyntable, SLOTS_PER_LINE, TRUE); e_contact_editor_dyntable_set_show_min (dyntable, SLOTS_IN_COLLAPSED_STATE); g_signal_connect ( - w, "changed", + dyntable, "changed", G_CALLBACK (object_changed), editor); g_signal_connect_swapped ( - w, "activate", + dyntable, "activate", G_CALLBACK (entry_activated), editor); - g_signal_connect ( - w, "row-added", - G_CALLBACK (row_added_sip), editor); + g_signal_connect_swapped ( + dyntable, "row-added", + G_CALLBACK (row_added_cb), expander); init_sip_record_type (editor); - expand_sip (editor, TRUE); + gtk_expander_set_expanded (expander, TRUE); } static void @@ -1714,12 +1579,6 @@ sensitize_sip (EContactEditor *editor) } static void -row_added_im (EContactEditorDynTable *dyntable, EContactEditor *editor) -{ - expand_im (editor, TRUE); -} - -static void init_im_record_type (EContactEditor *editor) { GtkWidget *w; @@ -1749,29 +1608,31 @@ init_im_record_type (EContactEditor *editor) static void init_im (EContactEditor *editor) { - GtkWidget *w; EContactEditorDynTable *dyntable; + GtkExpander *expander; - w = e_builder_get_widget (editor->priv->builder, "im-dyntable"); - dyntable = E_CONTACT_EDITOR_DYNTABLE (w); + expander = GTK_EXPANDER ( + e_builder_get_widget (editor->priv->builder, "expander-contact-im")); + dyntable = E_CONTACT_EDITOR_DYNTABLE ( + e_builder_get_widget (editor->priv->builder, "im-dyntable")); e_contact_editor_dyntable_set_max_entries (dyntable, IM_SLOTS); e_contact_editor_dyntable_set_num_columns (dyntable, SLOTS_PER_LINE, TRUE); e_contact_editor_dyntable_set_show_min (dyntable, SLOTS_IN_COLLAPSED_STATE); g_signal_connect ( - w, "changed", + dyntable, "changed", G_CALLBACK (object_changed), editor); g_signal_connect_swapped ( - w, "activate", + dyntable, "activate", G_CALLBACK (entry_activated), editor); - g_signal_connect ( - w, "row-added", - G_CALLBACK (row_added_im), editor); + g_signal_connect_swapped ( + dyntable, "row-added", + G_CALLBACK (row_added_cb), expander); init_im_record_type (editor); - expand_im (editor, TRUE); + gtk_expander_set_expanded (expander, TRUE); } static void @@ -1972,17 +1833,6 @@ sensitize_im (EContactEditor *editor) } static void -init_personal (EContactEditor *editor) -{ - gtk_expander_set_expanded ( - GTK_EXPANDER (e_builder_get_widget ( - editor->priv->builder, "expander-personal-misc")), - !editor->priv->compress_ui); - - expand_web (editor, !editor->priv->compress_ui); -} - -static void init_address_textview (EContactEditor *editor, gint record) { @@ -2042,11 +1892,6 @@ init_address (EContactEditor *editor) for (i = 0; i < ADDRESS_SLOTS; i++) init_address_record (editor, i); - - gtk_expander_set_expanded ( - GTK_EXPANDER (e_builder_get_widget ( - editor->priv->builder, "expander-address-other")), - !editor->priv->compress_ui); } static void @@ -2953,6 +2798,52 @@ sensitize_simple (EContactEditor *editor) } static void +configure_expander_state (EContactEditor *editor, + GSettings *settings, + const gchar *widget, + const gchar *settings_key) +{ + GtkExpander *expander; + gboolean expand; + + expander = GTK_EXPANDER (e_builder_get_widget (editor->priv->builder, widget)); + expand = g_settings_get_boolean (settings, settings_key); + gtk_expander_set_expanded (expander, expand); +} + +static void +configure_expander_initial_state (EContactEditor *editor) +{ + if (editor->priv->compress_ui) { + GtkBuilder *builder = editor->priv->builder; + gtk_expander_set_expanded (GTK_EXPANDER (e_builder_get_widget (builder, "expander-contact-email")), FALSE); + gtk_expander_set_expanded (GTK_EXPANDER (e_builder_get_widget (builder, "expander-contact-phone")), FALSE); + gtk_expander_set_expanded (GTK_EXPANDER (e_builder_get_widget (builder, "expander-contact-phone")), FALSE); + gtk_expander_set_expanded (GTK_EXPANDER (e_builder_get_widget (builder, "expander-contact-sip")), FALSE); + gtk_expander_set_expanded (GTK_EXPANDER (e_builder_get_widget (builder, "expander-contact-im")), FALSE); + gtk_expander_set_expanded (GTK_EXPANDER (e_builder_get_widget (builder, "expander-personal-web")), FALSE); + gtk_expander_set_expanded (GTK_EXPANDER (e_builder_get_widget (builder, "expander-personal-job")), FALSE); + gtk_expander_set_expanded (GTK_EXPANDER (e_builder_get_widget (builder, "expander-personal-misc")), FALSE); + gtk_expander_set_expanded (GTK_EXPANDER (e_builder_get_widget (builder, "expander-address-other")), FALSE); + } else { + GSettings *settings = g_settings_new ("org.gnome.evolution.addressbook"); + + configure_expander_state (editor, settings, "expander-contact-email", "editor-expand-contact-email"); + configure_expander_state (editor, settings, "expander-contact-phone", "editor-expand-contact-phone"); + configure_expander_state (editor, settings, "expander-contact-sip", "editor-expand-contact-sip"); + configure_expander_state (editor, settings, "expander-contact-im", "editor-expand-contact-im"); + + configure_expander_state (editor, settings, "expander-personal-web", "editor-expand-personal-web"); + configure_expander_state (editor, settings, "expander-personal-job", "editor-expand-personal-job"); + configure_expander_state (editor, settings, "expander-personal-misc", "editor-expand-personal-misc"); + + configure_expander_state (editor, settings, "expander-address-other", "editor-expand-mailing-other"); + + g_object_unref (settings); + } +} + +static void fill_in_all (EContactEditor *editor) { GtkWidget *focused_widget; @@ -2975,6 +2866,11 @@ fill_in_all (EContactEditor *editor) fill_in_im (editor); fill_in_address (editor); + /* set expander state after dyntables have been filled, + * otherwise dyntable and expander can get out of synch + */ + configure_expander_initial_state (editor); + if (weak_pointer) { g_object_remove_weak_pointer (G_OBJECT (focused_widget), &weak_pointer); gtk_widget_grab_focus (focused_widget); @@ -3022,6 +2918,44 @@ sensitize_all (EContactEditor *editor) } static void +configure_widget_visibility (EContactEditor *editor, + GSettings *settings, + const gchar *widget_name, + const gchar *settings_name) +{ + gboolean is_visible; + GtkWidget *widget; + + is_visible = g_settings_get_boolean (settings, settings_name); + widget = e_builder_get_widget (editor->priv->builder, widget_name); + gtk_widget_set_visible (widget, is_visible); +} + +static void +configure_visibility (EContactEditor *editor) +{ + GSettings *settings = g_settings_new ("org.gnome.evolution.addressbook"); + + configure_widget_visibility (editor, settings, "vbox-contact-phone", "editor-show-contact-phone"); + configure_widget_visibility (editor, settings, "vbox-contact-sip", "editor-show-contact-sip"); + configure_widget_visibility (editor, settings, "vbox-contact-im", "editor-show-contact-im"); + + configure_widget_visibility (editor, settings, "scrolledwindow-mailing", "editor-show-mailing-tab"); + configure_widget_visibility (editor, settings, "frame-mailing-home", "editor-show-mailing-home"); + configure_widget_visibility (editor, settings, "frame-mailing-work", "editor-show-mailing-work"); + configure_widget_visibility (editor, settings, "expander-address-other", "editor-show-mailing-other"); + + configure_widget_visibility (editor, settings, "scrolledwindow-personal", "editor-show-personal-tab"); + configure_widget_visibility (editor, settings, "expander-personal-web", "editor-show-personal-web"); + configure_widget_visibility (editor, settings, "expander-personal-job", "editor-show-personal-job"); + configure_widget_visibility (editor, settings, "expander-personal-misc", "editor-show-personal-misc"); + + configure_widget_visibility (editor, settings, "scrolledwindow-notes", "editor-show-notes-tab"); + + g_object_unref (settings); +} + +static void init_all (EContactEditor *editor) { const gchar *contents[] = { "viewport1", "viewport2", "viewport3", "text-comments" }; @@ -3034,9 +2968,10 @@ init_all (EContactEditor *editor) init_phone (editor); init_sip (editor); init_im (editor); - init_personal (editor); init_address (editor); + configure_visibility (editor); + /* with so many scrolled windows, we need to * do some manual sizing */ requisition.width = -1; @@ -4044,36 +3979,56 @@ setup_tab_order (GtkBuilder *builder) } static void -expand_web_toggle (EContactEditor *ce) +expand_dyntable (GtkExpander *expander, + EContactEditorDynTable *dyntable, + gint max_slots) { - GtkWidget *widget; - - widget = e_builder_get_widget (ce->priv->builder, "label-videourl"); - expand_web (ce, !gtk_widget_get_visible (widget)); + if (gtk_expander_get_expanded (expander)) { + e_contact_editor_dyntable_set_show_max (dyntable, max_slots); + } else { + e_contact_editor_dyntable_set_show_max (dyntable, + SLOTS_IN_COLLAPSED_STATE); + } } static void -expand_phone_toggle (EContactEditor *ce) +expander_contact_mail_cb (GObject *object, + GParamSpec *param_spec, + gpointer user_data) { - expand_phone (ce, !is_arrow_image_arrow_down (ce, "arrow-phone-expand")); + expand_dyntable (GTK_EXPANDER (object), + E_CONTACT_EDITOR_DYNTABLE (user_data), + EMAIL_SLOTS); } static void -expand_sip_toggle (EContactEditor *ce) +expander_contact_phone_cb (GObject *object, + GParamSpec *param_spec, + gpointer user_data) { - expand_sip (ce, !is_arrow_image_arrow_down (ce, "arrow-sip-expand")); + expand_dyntable (GTK_EXPANDER (object), + E_CONTACT_EDITOR_DYNTABLE (user_data), + PHONE_SLOTS); } static void -expand_im_toggle (EContactEditor *ce) +expander_contact_sip_cb (GObject *object, + GParamSpec *param_spec, + gpointer user_data) { - expand_im (ce, !is_arrow_image_arrow_down (ce, "arrow-im-expand")); + expand_dyntable (GTK_EXPANDER (object), + E_CONTACT_EDITOR_DYNTABLE (user_data), + SIP_SLOTS); } static void -expand_mail_toggle (EContactEditor *ce) +expander_contact_im_cb (GObject *object, + GParamSpec *param_spec, + gpointer user_data) { - expand_mail (ce, !is_arrow_image_arrow_down (ce, "arrow-mail-expand")); + expand_dyntable (GTK_EXPANDER (object), + E_CONTACT_EDITOR_DYNTABLE (user_data), + IM_SLOTS); } static void @@ -4097,7 +4052,7 @@ e_contact_editor_init (EContactEditor *e_contact_editor) EShell *shell; EClientCache *client_cache; GtkWidget *container; - GtkWidget *widget, *label; + GtkWidget *widget, *label, *dyntable; GtkEntryCompletion *completion; e_contact_editor->priv = G_TYPE_INSTANCE_GET_PRIVATE ( @@ -4188,31 +4143,34 @@ e_contact_editor_init (EContactEditor *e_contact_editor) g_signal_connect ( widget, "clicked", G_CALLBACK (show_help_cb), e_contact_editor); + widget = e_builder_get_widget ( - e_contact_editor->priv->builder, "button-web-expand"); - g_signal_connect_swapped ( - widget, "clicked", - G_CALLBACK (expand_web_toggle), e_contact_editor); - widget = e_builder_get_widget ( - e_contact_editor->priv->builder, "button-phone-expand"); - g_signal_connect_swapped ( - widget, "clicked", - G_CALLBACK (expand_phone_toggle), e_contact_editor); + e_contact_editor->priv->builder, "expander-contact-phone"); + dyntable = e_builder_get_widget ( + e_contact_editor->priv->builder, "phone-dyntable"); + g_signal_connect (widget, "notify::expanded", + G_CALLBACK (expander_contact_phone_cb), dyntable); + widget = e_builder_get_widget ( - e_contact_editor->priv->builder, "button-sip-expand"); - g_signal_connect_swapped ( - widget, "clicked", - G_CALLBACK (expand_sip_toggle), e_contact_editor); + e_contact_editor->priv->builder, "expander-contact-sip"); + dyntable = e_builder_get_widget ( + e_contact_editor->priv->builder, "sip-dyntable"); + g_signal_connect (widget, "notify::expanded", + G_CALLBACK (expander_contact_sip_cb), dyntable); + widget = e_builder_get_widget ( - e_contact_editor->priv->builder, "button-im-expand"); - g_signal_connect_swapped ( - widget, "clicked", - G_CALLBACK (expand_im_toggle), e_contact_editor); + e_contact_editor->priv->builder, "expander-contact-im"); + dyntable = e_builder_get_widget ( + e_contact_editor->priv->builder, "im-dyntable"); + g_signal_connect (widget, "notify::expanded", + G_CALLBACK (expander_contact_im_cb), dyntable); + widget = e_builder_get_widget ( - e_contact_editor->priv->builder, "button-mail-expand"); - g_signal_connect_swapped ( - widget, "clicked", - G_CALLBACK (expand_mail_toggle), e_contact_editor); + e_contact_editor->priv->builder, "expander-contact-email"); + dyntable = e_builder_get_widget ( + e_contact_editor->priv->builder, "mail-dyntable"); + g_signal_connect (widget, "notify::expanded", + G_CALLBACK (expander_contact_mail_cb), dyntable); widget = e_builder_get_widget ( e_contact_editor->priv->builder, "entry-fullname"); |