diff options
author | Michael Meeks <michael.meeks@novell.com> | 2010-03-26 03:51:31 +0800 |
---|---|---|
committer | Michael Meeks <michael.meeks@novell.com> | 2010-03-26 03:58:31 +0800 |
commit | e79ac3b017cea004affe33bd6c64ab0b306998e4 (patch) | |
tree | de9c6a92f61765bc26d36264b70098b6438bf59b /addressbook/gui/contact-editor | |
parent | b44765efd012745ecbc9407a8649f0441b7b5fbf (diff) | |
download | gsoc2013-evolution-e79ac3b017cea004affe33bd6c64ab0b306998e4.tar.gz gsoc2013-evolution-e79ac3b017cea004affe33bd6c64ab0b306998e4.tar.zst gsoc2013-evolution-e79ac3b017cea004affe33bd6c64ab0b306998e4.zip |
Adapt and further compact the UI with new expander-alike
Diffstat (limited to 'addressbook/gui/contact-editor')
-rw-r--r-- | addressbook/gui/contact-editor/e-contact-editor.c | 126 |
1 files changed, 87 insertions, 39 deletions
diff --git a/addressbook/gui/contact-editor/e-contact-editor.c b/addressbook/gui/contact-editor/e-contact-editor.c index 7019e91dcd..61302854a8 100644 --- a/addressbook/gui/contact-editor/e-contact-editor.c +++ b/addressbook/gui/contact-editor/e-contact-editor.c @@ -742,32 +742,6 @@ init_email_record_location (EContactEditor *editor, gint record) } static void -init_email (EContactEditor *editor) -{ - gint i; - - for (i = 1; i <= EMAIL_SLOTS; i++) - init_email_record_location (editor, i); - - if (editor->compress_ui) { - GtkTable *table; - GtkWidget *check; - - gtk_widget_hide (e_builder_get_widget (editor->builder, "entry-email-4")); - gtk_widget_hide (e_builder_get_widget (editor->builder, "combobox-email-4")); - - table = GTK_TABLE (e_builder_get_widget (editor->builder, "email-table")); - check = e_builder_get_widget (editor->builder, "checkbutton-htmlmail"); - if (check != NULL && table != NULL) { - g_object_ref (G_OBJECT (check)); - gtk_container_remove (GTK_CONTAINER (check->parent), check); - gtk_table_attach_defaults (table, check, 2, 4, 1, 2); - g_object_unref (G_OBJECT (check)); - } - } -} - -static void fill_in_email_record (EContactEditor *editor, gint record, const gchar *address, gint location) { GtkWidget *location_combo_box; @@ -1161,24 +1135,83 @@ set_attributes_named (EVCard *vcard, const gchar *attr_name, GList *attr_list) } static void -expand_phone (EContactEditor *editor, gboolean expanded) +set_arrow_image (EContactEditor *editor, + const char *arrow_widget, + gboolean expanded) { - GtkWidget *phone_ext_table; - GtkWidget *phone_ext_arrow; + GtkWidget *arrow; - phone_ext_table = e_builder_get_widget (editor->builder, "table-phone-extended"); - phone_ext_arrow = e_builder_get_widget (editor->builder, "arrow-phone-expand"); + arrow = e_builder_get_widget (editor->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); +} - if (expanded) { - gtk_arrow_set (GTK_ARROW (phone_ext_arrow), GTK_ARROW_DOWN, GTK_SHADOW_NONE); - gtk_widget_show (phone_ext_table); - } else { - gtk_arrow_set (GTK_ARROW (phone_ext_arrow), GTK_ARROW_RIGHT, GTK_SHADOW_NONE); - gtk_widget_hide (phone_ext_table); +static void +expand_widget_list (EContactEditor *editor, + const char **widget_names, + gboolean expanded) +{ + int i; + for (i = 0; widget_names[i]; i++) + gtk_widget_set_visible ( + e_builder_get_widget (editor->builder, widget_names[i]), + expanded); +} + +static void +expand_phone (EContactEditor *editor, gboolean expanded) +{ + const char *names[] = { + "entry-phone-2", "combobox-phone-2", + "entry-phone-4", "combobox-phone-4", + "table-phone-extended", NULL + }; + set_arrow_image (editor, "arrow-phone-expand", expanded); + expand_widget_list (editor, names, expanded); +} + +static void +expand_mail (EContactEditor *editor, gboolean expanded) +{ + GtkTable *table; + GtkWidget *check; + const char *names[] = { + "entry-email-2", "combobox-email-2", + "entry-email-3", "combobox-email-3", + "entry-email-4", "combobox-email-4", + NULL + }; + set_arrow_image (editor, "arrow-mail-expand", expanded); + expand_widget_list (editor, names, expanded); + + /* move 'use html mail' into position */ + check = e_builder_get_widget (editor->builder, "checkbutton-htmlmail"); + table = GTK_TABLE (e_builder_get_widget (editor->builder, "email-table")); + if (check != NULL && table != NULL) { + g_object_ref (G_OBJECT (check)); + gtk_container_remove (GTK_CONTAINER (check->parent), check); + if (expanded) + gtk_table_attach_defaults (table, check, 0, 4, 2, 3); + else + gtk_table_attach_defaults (table, check, 2, 4, 0, 1); + g_object_unref (G_OBJECT (check)); } } static void +init_email (EContactEditor *editor) +{ + gint i; + + for (i = 1; i <= EMAIL_SLOTS; i++) + init_email_record_location (editor, i); + + expand_mail (editor, !editor->compress_ui); +} + +static void fill_in_phone_record (EContactEditor *editor, gint record, const gchar *phone, gint phone_type) { GtkWidget *phone_type_combo_box; @@ -3400,9 +3433,22 @@ expand_phone_toggle (EContactEditor *ce) phone_ext_table = e_builder_get_widget (ce->builder, "table-phone-extended"); #if GTK_CHECK_VERSION(2,19,7) - expand_phone (ce, gtk_widget_get_visible (phone_ext_table) ? FALSE : TRUE); + expand_phone (ce, !gtk_widget_get_visible (phone_ext_table)); +#else + expand_phone (ce, !GTK_WIDGET_VISIBLE (phone_ext_table)); +#endif +} + +static void +expand_mail_toggle (EContactEditor *ce) +{ + GtkWidget *mail; + + mail = e_builder_get_widget (ce->builder, "entry-email-4"); +#if GTK_CHECK_VERSION(2,19,7) + expand_mail (ce, !gtk_widget_get_visible (mail)); #else - expand_phone (ce, GTK_WIDGET_VISIBLE (phone_ext_table) ? FALSE : TRUE); + expand_mail (ce, !GTK_WIDGET_VISIBLE (mail)); #endif } @@ -3466,6 +3512,8 @@ 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->builder, "button-phone-expand"); g_signal_connect_swapped (widget, "clicked", G_CALLBACK (expand_phone_toggle), e_contact_editor); + widget = e_builder_get_widget (e_contact_editor->builder, "button-mail-expand"); + g_signal_connect_swapped (widget, "clicked", G_CALLBACK (expand_mail_toggle), e_contact_editor); widget = e_builder_get_widget (e_contact_editor->builder, "entry-fullname"); if (widget) |