From 12a91dbb21f2a052d26460c9aad30835fd17456b Mon Sep 17 00:00:00 2001 From: Milan Crha Date: Thu, 18 Nov 2010 13:35:36 +0100 Subject: Bug #633779 - GtkComboBoxText issues --- addressbook/gui/contact-editor/e-contact-editor.c | 28 ++++++++++++++++++++--- 1 file changed, 25 insertions(+), 3 deletions(-) (limited to 'addressbook/gui/contact-editor/e-contact-editor.c') diff --git a/addressbook/gui/contact-editor/e-contact-editor.c b/addressbook/gui/contact-editor/e-contact-editor.c index e67305bb80..e1794572a5 100644 --- a/addressbook/gui/contact-editor/e-contact-editor.c +++ b/addressbook/gui/contact-editor/e-contact-editor.c @@ -722,6 +722,8 @@ init_email_record_location (EContactEditor *editor, gint record) GtkWidget *email_entry; gchar *widget_name; gint i; + GtkTreeIter iter; + GtkListStore *store; widget_name = g_strdup_printf ("entry-email-%d", record); email_entry = e_builder_get_widget (editor->builder, widget_name); @@ -731,10 +733,14 @@ init_email_record_location (EContactEditor *editor, gint record) location_combo_box = GTK_COMBO_BOX (e_builder_get_widget (editor->builder, widget_name)); g_free (widget_name); - gtk_list_store_clear (GTK_LIST_STORE (gtk_combo_box_get_model (location_combo_box))); + store = GTK_LIST_STORE (gtk_combo_box_get_model (location_combo_box)); + gtk_list_store_clear (store); for (i = 0; i < G_N_ELEMENTS (common_location); i++) { - gtk_combo_box_text_append_text (GTK_COMBO_BOX_TEXT (location_combo_box), _(common_location[i].pretty_name)); + gtk_list_store_append (store, &iter); + gtk_list_store_set (store, &iter, + 0, _(common_location[i].pretty_name), + -1); } g_signal_connect_swapped (location_combo_box, "changed", G_CALLBACK (gtk_widget_grab_focus), email_entry); @@ -2371,13 +2377,29 @@ extract_simple_field (EContactEditor *editor, GtkWidget *widget, gint field_id) const gchar *text = gtk_entry_get_text (GTK_ENTRY (widget)); e_contact_set (contact, field_id, (gchar *) text); } - else if (GTK_IS_COMBO_BOX (widget)) { + else if (GTK_IS_COMBO_BOX_TEXT (widget)) { gchar *text = gtk_combo_box_text_get_active_text (GTK_COMBO_BOX_TEXT (widget)); e_contact_set (contact, field_id, text); g_free (text); } + else if (GTK_IS_COMBO_BOX (widget)) { + GtkTreeIter iter; + gchar *text = NULL; + + if (gtk_combo_box_get_active_iter (GTK_COMBO_BOX (widget), &iter)) { + GtkListStore *store = GTK_LIST_STORE (gtk_combo_box_get_model (GTK_COMBO_BOX (widget))); + + gtk_tree_model_get (GTK_TREE_MODEL (store), &iter, + 0, &text, + -1); + } + + e_contact_set (contact, field_id, text); + + g_free (text); + } else if (GTK_IS_TEXT_VIEW (widget)) { GtkTextBuffer *buffer = gtk_text_view_get_buffer (GTK_TEXT_VIEW (widget)); GtkTextIter start, end; -- cgit v1.2.3 From 4231716442dc6bca34a563a17c068d126b37ea7c Mon Sep 17 00:00:00 2001 From: Milan Crha Date: Tue, 14 Dec 2010 17:44:16 +0100 Subject: Show common addressbook and calendar errors in an alert sink --- addressbook/gui/contact-editor/e-contact-editor.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) (limited to 'addressbook/gui/contact-editor/e-contact-editor.c') diff --git a/addressbook/gui/contact-editor/e-contact-editor.c b/addressbook/gui/contact-editor/e-contact-editor.c index e1794572a5..d071e9bab6 100644 --- a/addressbook/gui/contact-editor/e-contact-editor.c +++ b/addressbook/gui/contact-editor/e-contact-editor.c @@ -208,7 +208,7 @@ e_contact_editor_contact_added (EABEditor *editor, if (g_error_matches (error, E_BOOK_ERROR, E_BOOK_ERROR_CANCELLED)) return; - eab_error_dialog (_("Error adding contact"), error); + eab_error_dialog (NULL, _("Error adding contact"), error); } static void @@ -222,7 +222,7 @@ e_contact_editor_contact_modified (EABEditor *editor, if (g_error_matches (error, E_BOOK_ERROR, E_BOOK_ERROR_CANCELLED)) return; - eab_error_dialog (_("Error modifying contact"), error); + eab_error_dialog (NULL, _("Error modifying contact"), error); } static void @@ -236,7 +236,7 @@ e_contact_editor_contact_deleted (EABEditor *editor, if (g_error_matches (error, E_BOOK_ERROR, E_BOOK_ERROR_CANCELLED)) return; - eab_error_dialog (_("Error removing contact"), error); + eab_error_dialog (NULL, _("Error removing contact"), error); } static void @@ -2735,7 +2735,7 @@ contact_editor_book_loaded_cb (ESource *source, g_warn_if_fail (book == NULL); parent = eab_editor_get_window (EAB_EDITOR (editor)); - eab_load_error_dialog (GTK_WIDGET (parent), source, error); + eab_load_error_dialog (GTK_WIDGET (parent), NULL, source, error); source_combo_box = e_builder_get_widget ( editor->builder, "source-combo-box-source"); -- cgit v1.2.3 From 2485ba3936c9fdd4e185393d49c34dae7ba1f49d Mon Sep 17 00:00:00 2001 From: Matthew Barnes Date: Thu, 13 Jan 2011 10:54:58 -0500 Subject: Fudge gtk_widget_get_preferred_size() for gtk2. Easy enough to fake gtk_widget_get_preferred_size() in gtk2 using gtk_widget_size_request(). Reduces diff noise with gtk3 branch. --- addressbook/gui/contact-editor/e-contact-editor.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'addressbook/gui/contact-editor/e-contact-editor.c') diff --git a/addressbook/gui/contact-editor/e-contact-editor.c b/addressbook/gui/contact-editor/e-contact-editor.c index d071e9bab6..4ca2dd624b 100644 --- a/addressbook/gui/contact-editor/e-contact-editor.c +++ b/addressbook/gui/contact-editor/e-contact-editor.c @@ -2706,8 +2706,8 @@ init_all (EContactEditor *editor) /* with so many scrolled windows, we need to do some manual sizing */ - gtk_widget_size_request ( - e_builder_get_widget (editor->builder, "vbox-size-leader"), &tab_req); + gtk_widget_get_preferred_size ( + e_builder_get_widget (editor->builder, "vbox-size-leader"), &tab_req, NULL); gtk_widget_set_size_request ( e_builder_get_widget (editor->builder, "scrolledwindow-size-leader"), tab_req.width, tab_req.height + 8); -- cgit v1.2.3 From a3ba231fcc2746e664a67c85d88eb49a64813989 Mon Sep 17 00:00:00 2001 From: Matthew Barnes Date: Tue, 9 Nov 2010 08:48:33 -0500 Subject: Drop backward-compatibility cruft. --- addressbook/gui/contact-editor/e-contact-editor.c | 3 --- 1 file changed, 3 deletions(-) (limited to 'addressbook/gui/contact-editor/e-contact-editor.c') diff --git a/addressbook/gui/contact-editor/e-contact-editor.c b/addressbook/gui/contact-editor/e-contact-editor.c index 4ca2dd624b..44a272f3a3 100644 --- a/addressbook/gui/contact-editor/e-contact-editor.c +++ b/addressbook/gui/contact-editor/e-contact-editor.c @@ -53,9 +53,6 @@ #include "e-contact-editor-fullname.h" -/* backward-compatibility cruft */ -#include "e-util/gtk-compat.h" - #define EMAIL_SLOTS 4 #define PHONE_SLOTS 8 #define IM_SLOTS 4 -- cgit v1.2.3 From cadcc080eeb998a52b2163604e07fa5a71089391 Mon Sep 17 00:00:00 2001 From: Matthew Barnes Date: Thu, 13 Jan 2011 23:22:29 -0500 Subject: Adapt to GtkComboBox class reorg. --- addressbook/gui/contact-editor/e-contact-editor.c | 27 ++++++++++++++++++----- 1 file changed, 21 insertions(+), 6 deletions(-) (limited to 'addressbook/gui/contact-editor/e-contact-editor.c') diff --git a/addressbook/gui/contact-editor/e-contact-editor.c b/addressbook/gui/contact-editor/e-contact-editor.c index 44a272f3a3..2ef0fd0ee9 100644 --- a/addressbook/gui/contact-editor/e-contact-editor.c +++ b/addressbook/gui/contact-editor/e-contact-editor.c @@ -537,8 +537,13 @@ file_as_set_style (EContactEditor *editor, gint style) company = gtk_entry_get_text (GTK_ENTRY (company_w)); if (style == -1) { - string = gtk_combo_box_text_get_active_text (GTK_COMBO_BOX_TEXT (combo_file_as)); - strings = g_list_append (strings, string); + GtkWidget *entry; + + entry = gtk_bin_get_child (GTK_BIN (combo_file_as)); + if (entry) { + string = g_strdup (gtk_entry_get_text (GTK_ENTRY (entry))); + strings = g_list_append (strings, string); + } } for (i = 0; i < 6; i++) { @@ -554,11 +559,16 @@ file_as_set_style (EContactEditor *editor, gint style) if (combo_file_as) { GList *l; + GtkListStore *list_store; + GtkTreeIter iter; - gtk_list_store_clear (GTK_LIST_STORE (gtk_combo_box_get_model (combo_file_as))); + list_store = GTK_LIST_STORE (gtk_combo_box_get_model (combo_file_as)); + + gtk_list_store_clear (list_store); for (l = strings; l; l = l->next) { - gtk_combo_box_text_append_text (GTK_COMBO_BOX_TEXT (combo_file_as), l->data); + gtk_list_store_append (list_store, &iter); + gtk_list_store_set (list_store, &iter, 0, l->data, -1); } } @@ -592,7 +602,12 @@ name_entry_changed (GtkWidget *widget, EContactEditor *editor) static void file_as_combo_changed (GtkWidget *widget, EContactEditor *editor) { - gchar *string = gtk_combo_box_text_get_active_text (GTK_COMBO_BOX_TEXT (widget)); + GtkWidget *entry; + gchar *string = NULL; + + entry = gtk_bin_get_child (GTK_BIN (widget)); + if (entry) + string = g_strdup (gtk_entry_get_text (GTK_ENTRY (entry))); if (string && *string) { gchar *title; @@ -2550,7 +2565,7 @@ init_simple (EContactEditor *editor) widget = e_builder_get_widget (editor->builder, "entry-fullname"); g_signal_connect (widget, "changed", G_CALLBACK (name_entry_changed), editor); widget = e_builder_get_widget (editor->builder, "combo-file-as"); - gtk_combo_box_set_entry_text_column (GTK_COMBO_BOX_ENTRY (widget), 0); + gtk_combo_box_set_entry_text_column (GTK_COMBO_BOX (widget), 0); g_signal_connect (widget, "changed", G_CALLBACK (file_as_combo_changed), editor); widget = e_builder_get_widget (editor->builder, "entry-company"); g_signal_connect (widget, "changed", G_CALLBACK (company_entry_changed), editor); -- cgit v1.2.3 From dbc22f9de50142b8339fa843575a5e15bd3fe8ff Mon Sep 17 00:00:00 2001 From: Matthew Barnes Date: Sun, 30 Jan 2011 11:32:55 -0500 Subject: More whitespace cleanup. --- addressbook/gui/contact-editor/e-contact-editor.c | 489 ++++++++++++---------- 1 file changed, 271 insertions(+), 218 deletions(-) (limited to 'addressbook/gui/contact-editor/e-contact-editor.c') diff --git a/addressbook/gui/contact-editor/e-contact-editor.c b/addressbook/gui/contact-editor/e-contact-editor.c index 2ef0fd0ee9..55709ed081 100644 --- a/addressbook/gui/contact-editor/e-contact-editor.c +++ b/addressbook/gui/contact-editor/e-contact-editor.c @@ -71,17 +71,17 @@ enum { NUM_IM_COLUMNS }; -static void e_contact_editor_init (EContactEditor *editor); -static void e_contact_editor_class_init (EContactEditorClass *klass); +static void e_contact_editor_init (EContactEditor *editor); +static void e_contact_editor_class_init (EContactEditorClass *klass); static void e_contact_editor_set_property (GObject *object, guint prop_id, const GValue *value, GParamSpec *pspec); static void e_contact_editor_get_property (GObject *object, guint prop_id, GValue *value, GParamSpec *pspec); static void e_contact_editor_dispose (GObject *object); -static void e_contact_editor_raise (EABEditor *editor); -static void e_contact_editor_show (EABEditor *editor); -static void e_contact_editor_save_contact (EABEditor *editor, gboolean should_close); -static void e_contact_editor_close (EABEditor *editor); -static gboolean e_contact_editor_is_valid (EABEditor *editor); +static void e_contact_editor_raise (EABEditor *editor); +static void e_contact_editor_show (EABEditor *editor); +static void e_contact_editor_save_contact (EABEditor *editor, gboolean should_close); +static void e_contact_editor_close (EABEditor *editor); +static gboolean e_contact_editor_is_valid (EABEditor *editor); static gboolean e_contact_editor_is_changed (EABEditor *editor); static GtkWindow* e_contact_editor_get_window (EABEditor *editor); @@ -290,61 +290,85 @@ e_contact_editor_class_init (EContactEditorClass *klass) editor_class->contact_deleted = e_contact_editor_contact_deleted; editor_class->editor_closed = e_contact_editor_closed; - g_object_class_install_property (object_class, PROP_SOURCE_BOOK, - g_param_spec_object ("source_book", - "Source Book", - NULL, - E_TYPE_BOOK, - G_PARAM_READWRITE)); - - g_object_class_install_property (object_class, PROP_TARGET_BOOK, - g_param_spec_object ("target_book", - "Target Book", - NULL, - E_TYPE_BOOK, - G_PARAM_READWRITE)); - - g_object_class_install_property (object_class, PROP_CONTACT, - g_param_spec_object ("contact", - "Contact", - NULL, - E_TYPE_CONTACT, - G_PARAM_READWRITE)); - - g_object_class_install_property (object_class, PROP_IS_NEW_CONTACT, - g_param_spec_boolean ("is_new_contact", - "Is New Contact", - NULL, - FALSE, - G_PARAM_READWRITE)); - - g_object_class_install_property (object_class, PROP_WRITABLE_FIELDS, - g_param_spec_object ("writable_fields", - "Writable Fields", - NULL, - E_TYPE_LIST, - G_PARAM_READWRITE)); - - g_object_class_install_property (object_class, PROP_REQUIRED_FIELDS, - g_param_spec_object ("required_fields", - "Required Fields", - NULL, - E_TYPE_LIST, - G_PARAM_READWRITE)); - - g_object_class_install_property (object_class, PROP_EDITABLE, - g_param_spec_boolean ("editable", - "Editable", - NULL, - FALSE, - G_PARAM_READWRITE)); - - g_object_class_install_property (object_class, PROP_CHANGED, - g_param_spec_boolean ("changed", - "Changed", - NULL, - FALSE, - G_PARAM_READWRITE)); + g_object_class_install_property ( + object_class, + PROP_SOURCE_BOOK, + g_param_spec_object ( + "source_book", + "Source Book", + NULL, + E_TYPE_BOOK, + G_PARAM_READWRITE)); + + g_object_class_install_property ( + object_class, + PROP_TARGET_BOOK, + g_param_spec_object ( + "target_book", + "Target Book", + NULL, + E_TYPE_BOOK, + G_PARAM_READWRITE)); + + g_object_class_install_property ( + object_class, + PROP_CONTACT, + g_param_spec_object ( + "contact", + "Contact", + NULL, + E_TYPE_CONTACT, + G_PARAM_READWRITE)); + + g_object_class_install_property ( + object_class, + PROP_IS_NEW_CONTACT, + g_param_spec_boolean ( + "is_new_contact", + "Is New Contact", + NULL, + FALSE, + G_PARAM_READWRITE)); + + g_object_class_install_property ( + object_class, + PROP_WRITABLE_FIELDS, + g_param_spec_object ( + "writable_fields", + "Writable Fields", + NULL, + E_TYPE_LIST, + G_PARAM_READWRITE)); + + g_object_class_install_property ( + object_class, + PROP_REQUIRED_FIELDS, + g_param_spec_object ( + "required_fields", + "Required Fields", + NULL, + E_TYPE_LIST, + G_PARAM_READWRITE)); + + g_object_class_install_property ( + object_class, + PROP_EDITABLE, + g_param_spec_boolean ( + "editable", + "Editable", + NULL, + FALSE, + G_PARAM_READWRITE)); + + g_object_class_install_property ( + object_class, + PROP_CHANGED, + g_param_spec_boolean ( + "changed", + "Changed", + NULL, + FALSE, + G_PARAM_READWRITE)); } static void @@ -392,13 +416,13 @@ style_makes_sense (const EContactName *name, const gchar *company, gint style) case 0: /* Fall Through */ case 1: return TRUE; - case 2: - if (name) { - if (name->additional && *name->additional) - return TRUE; - else - return FALSE; - } + case 2: + if (name) { + if (name->additional && *name->additional) + return TRUE; + else + return FALSE; + } case 3: if (company && *company) return TRUE; @@ -420,7 +444,7 @@ name_to_style (const EContactName *name, const gchar *company, gint style) { gchar *string; gchar *strings[4], **stringptr; - gchar *midstring[4], **midstrptr; + gchar *midstring[4], **midstrptr; gchar *substring; switch (style) { case 0: @@ -445,17 +469,17 @@ name_to_style (const EContactName *name, const gchar *company, gint style) *stringptr = NULL; string = g_strjoinv(" ", strings); break; - case 2: - midstrptr=midstring; - if (name) { - if (name->family && *name->family) + case 2: + midstrptr=midstring; + if (name) { + if (name->family && *name->family) *(midstrptr++) = name->family; - if (name->given && *name->given) + if (name->given && *name->given) *(midstrptr++) = name->given; - } - *midstrptr = NULL; - stringptr = strings; - *(stringptr++) = g_strjoinv(", ", midstring); + } + *midstrptr = NULL; + stringptr = strings; + *(stringptr++) = g_strjoinv(", ", midstring); if (name) { if (name->additional && *name->additional) *(stringptr++) = name->additional; @@ -709,22 +733,22 @@ set_entry_text (EContactEditor *editor, GtkEntry *entry, const gchar *string) string = ""; if (strcmp (string, oldstring)) { - g_signal_handlers_block_matched (entry, G_SIGNAL_MATCH_DATA, - 0, 0, NULL, NULL, editor); + g_signal_handlers_block_matched ( + entry, G_SIGNAL_MATCH_DATA, 0, 0, NULL, NULL, editor); gtk_entry_set_text (entry, string); - g_signal_handlers_unblock_matched (entry, G_SIGNAL_MATCH_DATA, - 0, 0, NULL, NULL, editor); + g_signal_handlers_unblock_matched ( + entry, G_SIGNAL_MATCH_DATA, 0, 0, NULL, NULL, editor); } } static void set_combo_box_active (EContactEditor *editor, GtkComboBox *combo_box, gint active) { - g_signal_handlers_block_matched (combo_box, G_SIGNAL_MATCH_DATA, - 0, 0, NULL, NULL, editor); + g_signal_handlers_block_matched ( + combo_box, G_SIGNAL_MATCH_DATA, 0, 0, NULL, NULL, editor); gtk_combo_box_set_active (combo_box, active); - g_signal_handlers_unblock_matched (combo_box, G_SIGNAL_MATCH_DATA, - 0, 0, NULL, NULL, editor); + g_signal_handlers_unblock_matched ( + combo_box, G_SIGNAL_MATCH_DATA, 0, 0, NULL, NULL, editor); } static void @@ -776,8 +800,9 @@ fill_in_email_record (EContactEditor *editor, gint record, const gchar *address, email_entry = e_builder_get_widget (editor->builder, widget_name); g_free (widget_name); - set_combo_box_active (editor, GTK_COMBO_BOX (location_combo_box), - location >= 0 ? location : email_default[2]); + set_combo_box_active ( + editor, GTK_COMBO_BOX (location_combo_box), + location >= 0 ? location : email_default[2]); set_entry_text (editor, GTK_ENTRY (email_entry), address ? address : ""); } @@ -854,7 +879,8 @@ get_phone_type (EVCardAttribute *attr) for (i = 0; i < G_N_ELEMENTS (phones); i++) { if (e_vcard_attribute_has_type (attr, phones[i].type_1) && - (phones[i].type_2 == NULL || e_vcard_attribute_has_type (attr, phones[i].type_2))) + (phones[i].type_2 == NULL || + e_vcard_attribute_has_type (attr, phones[i].type_2))) return i; } @@ -997,8 +1023,9 @@ fill_in_email (EContactEditor *editor) if (slot < 1) break; - fill_in_email_record (editor, slot, email_address, - get_email_location (attr)); + fill_in_email_record ( + editor, slot, email_address, + get_email_location (attr)); record_n++; } @@ -1109,10 +1136,9 @@ init_item_sensitiveable_combo_box (GtkComboBox *combo) cell = gtk_cell_renderer_text_new (); gtk_cell_layout_pack_start (GTK_CELL_LAYOUT (combo), cell, TRUE); - gtk_cell_layout_set_attributes (GTK_CELL_LAYOUT (combo), cell, - "text", 0, - "sensitive", 1, - NULL); + gtk_cell_layout_set_attributes ( + GTK_CELL_LAYOUT (combo), cell, + "text", 0, "sensitive", 1, NULL); } /* EContact can get attributes by field ID only, and there is none for TEL, so we need this */ @@ -1156,8 +1182,8 @@ set_attributes_named (EVCard *vcard, const gchar *attr_name, GList *attr_list) static void set_arrow_image (EContactEditor *editor, - const gchar *arrow_widget, - gboolean expanded) + const gchar *arrow_widget, + gboolean expanded) { GtkWidget *arrow; @@ -1170,8 +1196,8 @@ set_arrow_image (EContactEditor *editor, static void expand_widget_list (EContactEditor *editor, - const gchar **widget_names, - gboolean expanded) + const gchar **widget_names, + gboolean expanded) { gint i; for (i = 0; widget_names[i]; i++) @@ -1261,9 +1287,9 @@ fill_in_phone_record (EContactEditor *editor, gint record, const gchar *phone, g phone_entry = e_builder_get_widget (editor->builder, widget_name); g_free (widget_name); - set_combo_box_active (editor, GTK_COMBO_BOX (phone_type_combo_box), - phone_type >= 0 ? phone_type : - phones_default[record - 1]); + set_combo_box_active ( + editor, GTK_COMBO_BOX (phone_type_combo_box), + phone_type >= 0 ? phone_type : phones_default[record - 1]); set_entry_text (editor, GTK_ENTRY (phone_entry), phone ? phone : ""); if (phone && *phone && record >= 5) @@ -1316,8 +1342,8 @@ fill_in_phone (EContactEditor *editor) if (slot < 1) break; - fill_in_phone_record (editor, slot, phone, - get_phone_type (attr)); + fill_in_phone_record ( + editor, slot, phone, get_phone_type (attr)); record_n++; } @@ -1604,11 +1630,13 @@ fill_in_im_record (EContactEditor *editor, gint record, gint service, const gcha g_free (widget_name); #ifdef ENABLE_IM_LOCATION - set_combo_box_active (editor, GTK_COMBO_BOX (location_combo_box), - location >= 0 ? location : 0); + set_combo_box_active ( + editor, GTK_COMBO_BOX (location_combo_box), + location >= 0 ? location : 0); #endif - set_combo_box_active (editor, GTK_COMBO_BOX (service_combo_box), - service >= 0 ? service : im_service_default[record - 1]); + set_combo_box_active ( + editor, GTK_COMBO_BOX (service_combo_box), + service >= 0 ? service : im_service_default[record - 1]); set_entry_text (editor, GTK_ENTRY (name_entry), name ? name : ""); } @@ -1641,8 +1669,9 @@ fill_in_im (EContactEditor *editor) if (slot < 1) break; - fill_in_im_record (editor, slot, i, im_name, - get_im_location (attr)); + fill_in_im_record ( + editor, slot, i, im_name, + get_im_location (attr)); record_n++; } @@ -1738,8 +1767,10 @@ extract_im (EContactEditor *editor) old_service_attr_list = l; service_attr_list[i] = g_list_concat (service_attr_list[i], old_service_attr_list); - e_contact_set_attributes (editor->contact, im_service[i].field, - service_attr_list[i]); + e_contact_set_attributes ( + editor->contact, + im_service[i].field, + service_attr_list[i]); free_attr_list (service_attr_list[i]); } @@ -1832,8 +1863,8 @@ static void init_personal (EContactEditor *editor) { gtk_expander_set_expanded ( - GTK_EXPANDER (e_builder_get_widget (editor->builder, - "expander-personal-misc")), + GTK_EXPANDER (e_builder_get_widget ( + editor->builder, "expander-personal-misc")), !editor->compress_ui); expand_web (editor, !editor->compress_ui); @@ -1888,8 +1919,8 @@ init_address (EContactEditor *editor) init_address_record (editor, i); gtk_expander_set_expanded ( - GTK_EXPANDER (e_builder_get_widget (editor->builder, - "expander-address-other")), + GTK_EXPANDER (e_builder_get_widget ( + editor->builder, "expander-address-other")), !editor->compress_ui); } @@ -1935,8 +1966,10 @@ fill_in_address_label_textview (EContactEditor *editor, gint record, const gchar } static void -fill_in_address_field (EContactEditor *editor, gint record, const gchar *widget_field_name, - const gchar *string) +fill_in_address_field (EContactEditor *editor, + gint record, + const gchar *widget_field_name, + const gchar *string) { gchar *entry_name; GtkWidget *entry; @@ -2140,8 +2173,10 @@ sensitize_address_textview (EContactEditor *editor, gint record, gboolean enable } static void -sensitize_address_field (EContactEditor *editor, gint record, const gchar *widget_field_name, - gboolean enabled) +sensitize_address_field (EContactEditor *editor, + gint record, + const gchar *widget_field_name, + gboolean enabled) { gchar *widget_name; GtkWidget *entry; @@ -2286,8 +2321,9 @@ init_simple_field (EContactEditor *editor, GtkWidget *widget) } else if (E_IS_URL_ENTRY (widget)) { changed_object = G_OBJECT (e_url_entry_get_entry (E_URL_ENTRY (widget))); - g_signal_connect_swapped (GTK_WIDGET (changed_object), "activate", - G_CALLBACK (entry_activated), editor); + g_signal_connect_swapped ( + changed_object, "activate", + G_CALLBACK (entry_activated), editor); } else if (E_IS_DATE_EDIT (widget)) { changed_object = G_OBJECT (widget); @@ -2311,8 +2347,8 @@ fill_in_simple_field (EContactEditor *editor, GtkWidget *widget, gint field_id) contact = editor->contact; - g_signal_handlers_block_matched (widget, G_SIGNAL_MATCH_DATA, - 0, 0, NULL, NULL, editor); + g_signal_handlers_block_matched ( + widget, G_SIGNAL_MATCH_DATA, 0, 0, NULL, NULL, editor); if (GTK_IS_ENTRY (widget)) { gchar *text = e_contact_get (contact, field_id); @@ -2339,10 +2375,9 @@ fill_in_simple_field (EContactEditor *editor, GtkWidget *widget, gint field_id) else if (E_IS_DATE_EDIT (widget)) { EContactDate *date = e_contact_get (contact, field_id); if (date) - e_date_edit_set_date (E_DATE_EDIT (widget), - date->year, - date->month, - date->day); + e_date_edit_set_date ( + E_DATE_EDIT (widget), + date->year, date->month, date->day); else e_date_edit_set_time (E_DATE_EDIT (widget), -1); @@ -2374,8 +2409,8 @@ fill_in_simple_field (EContactEditor *editor, GtkWidget *widget, gint field_id) g_warning (G_STRLOC ": Unhandled widget class in mappings!"); } - g_signal_handlers_unblock_matched (widget, G_SIGNAL_MATCH_DATA, - 0, 0, NULL, NULL, editor); + g_signal_handlers_unblock_matched ( + widget, G_SIGNAL_MATCH_DATA, 0, 0, NULL, NULL, editor); } static void @@ -2430,10 +2465,11 @@ extract_simple_field (EContactEditor *editor, GtkWidget *widget, gint field_id) } else if (E_IS_DATE_EDIT (widget)) { EContactDate date; - if (e_date_edit_get_date (E_DATE_EDIT (widget), - (gint *)&date.year, - (gint *)&date.month, - (gint *)&date.day)) + if (e_date_edit_get_date ( + E_DATE_EDIT (widget), + (gint *)&date.year, + (gint *)&date.month, + (gint *)&date.day)) e_contact_set (contact, field_id, &date); else e_contact_set (contact, field_id, NULL); @@ -2446,8 +2482,9 @@ extract_simple_field (EContactEditor *editor, GtkWidget *widget, gint field_id) { gchar *img_buff = NULL; if (editor->image_set && - e_image_chooser_get_image_data (E_IMAGE_CHOOSER (widget), - &img_buff, &photo.data.inlined.length)) { + e_image_chooser_get_image_data ( + E_IMAGE_CHOOSER (widget), + &img_buff, &photo.data.inlined.length)) { GdkPixbuf *pixbuf, *new; GdkPixbufLoader *loader = gdk_pixbuf_loader_new (); @@ -2596,9 +2633,7 @@ fill_in_simple (EContactEditor *editor) /* Update broken-up name */ - g_object_get (editor->contact, - "name", &name, - NULL); + g_object_get (editor->contact, "name", &name, NULL); if (editor->name) e_contact_name_free (editor->name); @@ -2717,7 +2752,7 @@ init_all (EContactEditor *editor) init_address (editor); /* with so many scrolled windows, we need to - do some manual sizing */ + * do some manual sizing */ gtk_widget_get_preferred_size ( e_builder_get_widget (editor->builder, "vbox-size-leader"), &tab_req, NULL); gtk_widget_set_size_request ( @@ -2808,14 +2843,10 @@ full_name_response (GtkDialog *dialog, gint response, EContactEditor *editor) gint style = 0; gboolean editable = FALSE; - g_object_get (dialog, - "editable", &editable, - NULL); + g_object_get (dialog, "editable", &editable, NULL); if (editable && response == GTK_RESPONSE_OK) { - g_object_get (dialog, - "name", &name, - NULL); + g_object_get (dialog, "name", &name, NULL); style = file_as_get_style (editor); @@ -2862,16 +2893,17 @@ full_name_clicked (GtkWidget *button, EContactEditor *editor) dialog = GTK_DIALOG (e_contact_editor_fullname_new (editor->name)); fullname_supported = is_field_supported (editor, E_CONTACT_FULL_NAME); - g_object_set (dialog, - "editable", fullname_supported & editor->target_editable, - NULL); + g_object_set ( + dialog, "editable", + fullname_supported & editor->target_editable, NULL); g_signal_connect(dialog, "response", G_CALLBACK (full_name_response), editor); /* Close the fullname dialog if the editor is closed */ - g_signal_connect_swapped (EAB_EDITOR (editor), "editor_closed", - G_CALLBACK (full_name_editor_delete_event_cb), GTK_WIDGET (dialog)); + g_signal_connect_swapped ( + editor, "editor_closed", + G_CALLBACK (full_name_editor_delete_event_cb), dialog); gtk_widget_show (GTK_WIDGET (dialog)); editor->fullname_dialog = GTK_WIDGET (dialog); @@ -2921,9 +2953,9 @@ categories_clicked (GtkWidget *button, EContactEditor *editor) g_free (categories); return; }else if (!(dialog = GTK_DIALOG (e_categories_dialog_new (categories)))) { - e_alert_run_dialog_for_args (GTK_WINDOW (editor->app), - "addressbook:edit-categories", - NULL); + e_alert_run_dialog_for_args ( + GTK_WINDOW (editor->app), + "addressbook:edit-categories", NULL); g_free (categories); return; } @@ -2932,8 +2964,9 @@ categories_clicked (GtkWidget *button, EContactEditor *editor) G_CALLBACK (categories_response), editor); /* Close the category dialog if the editor is closed*/ - g_signal_connect_swapped (EAB_EDITOR (editor), "editor_closed", - G_CALLBACK (categories_editor_delete_event_cb), GTK_WIDGET (dialog)); + g_signal_connect_swapped ( + editor, "editor_closed", + G_CALLBACK (categories_editor_delete_event_cb), dialog); gtk_widget_show (GTK_WIDGET (dialog)); g_free (categories); @@ -3039,27 +3072,30 @@ image_clicked (GtkWidget *button, EContactEditor *editor) GtkImage *preview; if (!editor->file_selector) { - editor->file_selector = gtk_file_chooser_dialog_new (title, - GTK_WINDOW (editor->app), - GTK_FILE_CHOOSER_ACTION_OPEN, - GTK_STOCK_CANCEL, GTK_RESPONSE_CANCEL, - GTK_STOCK_OPEN, GTK_RESPONSE_ACCEPT, - no_image, GTK_RESPONSE_NO, - NULL); + editor->file_selector = gtk_file_chooser_dialog_new ( + title, GTK_WINDOW (editor->app), + GTK_FILE_CHOOSER_ACTION_OPEN, + GTK_STOCK_CANCEL, GTK_RESPONSE_CANCEL, + GTK_STOCK_OPEN, GTK_RESPONSE_ACCEPT, + no_image, GTK_RESPONSE_NO, + NULL); preview = GTK_IMAGE (gtk_image_new ()); gtk_file_chooser_set_preview_widget ((GtkFileChooser *)editor->file_selector, GTK_WIDGET (preview)); - g_signal_connect (editor->file_selector, "update-preview", - G_CALLBACK (update_preview_cb), preview); + g_signal_connect ( + editor->file_selector, "update-preview", + G_CALLBACK (update_preview_cb), preview); gtk_dialog_set_default_response (GTK_DIALOG (editor->file_selector), GTK_RESPONSE_ACCEPT); gtk_file_chooser_set_current_folder (GTK_FILE_CHOOSER (editor->file_selector), g_get_home_dir ()); - g_signal_connect (editor->file_selector, "response", - G_CALLBACK (file_chooser_response), editor); + g_signal_connect ( + editor->file_selector, "response", + G_CALLBACK (file_chooser_response), editor); - g_signal_connect_after (editor->file_selector, - "delete-event", G_CALLBACK (file_selector_deleted), - editor->file_selector); + g_signal_connect_after ( + editor->file_selector, "delete-event", + G_CALLBACK (file_selector_deleted), + editor->file_selector); } /* Display the dialog */ @@ -3116,8 +3152,9 @@ contact_added_cb (EBook *book, const GError *error, const gchar *id, EditorClose if (ce->source_book != ce->target_book && e_book_is_writable (ce->source_book) && !error && ce->is_new_contact == FALSE) { ecs->new_id = g_strdup (id); - e_book_remove_contact_async (ce->source_book, ce->contact, - (EBookAsyncCallback) contact_moved_cb, ecs); + e_book_remove_contact_async ( + ce->source_book, ce->contact, + (EBookAsyncCallback) contact_moved_cb, ecs); return; } @@ -3186,15 +3223,18 @@ real_save_contact (EContactEditor *ce, gboolean should_close) if (ce->source_book != ce->target_book) { /* Two-step move; add to target, then remove from source */ - eab_merging_book_add_contact (ce->target_book, ce->contact, - (EBookIdAsyncCallback) contact_added_cb, ecs); + eab_merging_book_add_contact ( + ce->target_book, ce->contact, + (EBookIdAsyncCallback) contact_added_cb, ecs); } else { if (ce->is_new_contact) - eab_merging_book_add_contact (ce->target_book, ce->contact, - (EBookIdAsyncCallback) contact_added_cb, ecs); + eab_merging_book_add_contact ( + ce->target_book, ce->contact, + (EBookIdAsyncCallback) contact_added_cb, ecs); else - eab_merging_book_commit_contact (ce->target_book, ce->contact, - (EBookAsyncCallback) contact_modified_cb, ecs); + eab_merging_book_commit_contact ( + ce->target_book, ce->contact, + (EBookAsyncCallback) contact_modified_cb, ecs); } } @@ -3209,9 +3249,10 @@ save_contact (EContactEditor *ce, gboolean should_close) return; if (ce->target_editable && !e_book_is_writable (ce->source_book)) { - if (e_alert_run_dialog_for_args (GTK_WINDOW (ce->app), - "addressbook:prompt-move", - NULL) == GTK_RESPONSE_NO) + if (e_alert_run_dialog_for_args ( + GTK_WINDOW (ce->app), + "addressbook:prompt-move", + NULL) == GTK_RESPONSE_NO) return; } @@ -3357,10 +3398,10 @@ e_contact_editor_is_valid (EABEditor *editor) if (validation_error) { g_string_append (errmsg, "."); - e_alert_run_dialog_for_args (GTK_WINDOW (ce->app), - "addressbook:generic-error", - _("Invalid contact."), errmsg->str, - NULL); + e_alert_run_dialog_for_args ( + GTK_WINDOW (ce->app), + "addressbook:generic-error", + _("Invalid contact."), errmsg->str, NULL); g_string_free (errmsg, TRUE); return FALSE; } @@ -3625,8 +3666,9 @@ e_contact_editor_init (EContactEditor *e_contact_editor) /* Connect to the deletion of the dialog */ - g_signal_connect (e_contact_editor->app, "delete_event", - G_CALLBACK (app_delete_event_cb), e_contact_editor); + g_signal_connect ( + e_contact_editor->app, "delete_event", + G_CALLBACK (app_delete_event_cb), e_contact_editor); /* set the icon */ gtk_window_set_icon_name (GTK_WINDOW (e_contact_editor->app), "contact-editor"); @@ -3691,17 +3733,17 @@ e_contact_editor_dispose (GObject *object) } static void -supported_fields_cb (EBook *book, const GError *error, - EList *fields, EContactEditor *ce) +supported_fields_cb (EBook *book, + const GError *error, + EList *fields, + EContactEditor *ce) { if (!g_slist_find (eab_editor_get_all_editors (), ce)) { g_warning ("supported_fields_cb called for book that's still around, but contact editor that's been destroyed."); return; } - g_object_set (ce, - "writable_fields", fields, - NULL); + g_object_set (ce, "writable_fields", fields, NULL); eab_editor_show (EAB_EDITOR (ce)); @@ -3709,8 +3751,10 @@ supported_fields_cb (EBook *book, const GError *error, } static void -required_fields_cb (EBook *book, const GError *error, - EList *fields, EContactEditor *ce) +required_fields_cb (EBook *book, + const GError *error, + EList *fields, + EContactEditor *ce) { if (!g_slist_find (eab_editor_get_all_editors (), ce)) { @@ -3718,9 +3762,7 @@ required_fields_cb (EBook *book, const GError *error, return; } - g_object_set (ce, - "required_fields", fields, - NULL); + g_object_set (ce, "required_fields", fields, NULL); } @@ -3739,12 +3781,13 @@ e_contact_editor_new (EShell *shell, editor = g_object_new (E_TYPE_CONTACT_EDITOR, "shell", shell, NULL); - g_object_set (editor, - "source_book", book, - "contact", contact, - "is_new_contact", is_new_contact, - "editable", editable, - NULL); + g_object_set ( + editor, + "source_book", book, + "contact", contact, + "is_new_contact", is_new_contact, + "editable", editable, + NULL); if (book) e_book_get_supported_fields_async ( @@ -3798,13 +3841,18 @@ e_contact_editor_set_property (GObject *object, guint prop_id, const GValue *val editor->target_book = editor->source_book; g_object_ref (editor->target_book); - editor->target_editable_id = g_signal_connect (editor->target_book, "writable_status", - G_CALLBACK (writable_changed), editor); - - e_book_get_supported_fields_async (editor->target_book, - (EBookEListAsyncCallback) supported_fields_cb, editor); - e_book_get_required_fields_async (editor->target_book, - (EBookEListAsyncCallback) required_fields_cb, editor); + editor->target_editable_id = g_signal_connect ( + editor->target_book, "writable_status", + G_CALLBACK (writable_changed), editor); + + e_book_get_supported_fields_async ( + editor->target_book, + (EBookEListAsyncCallback) + supported_fields_cb, editor); + e_book_get_required_fields_async ( + editor->target_book, + (EBookEListAsyncCallback) + required_fields_cb, editor); } writable = e_book_is_writable (editor->target_book); @@ -3837,14 +3885,19 @@ e_contact_editor_set_property (GObject *object, guint prop_id, const GValue *val editor->target_book = target_book; g_object_ref (editor->target_book); - editor->target_editable_id = g_signal_connect (editor->target_book, "writable_status", - G_CALLBACK (writable_changed), editor); - - e_book_get_supported_fields_async (editor->target_book, - (EBookEListAsyncCallback) supported_fields_cb, editor); + editor->target_editable_id = g_signal_connect ( + editor->target_book, "writable_status", + G_CALLBACK (writable_changed), editor); - e_book_get_required_fields_async (editor->target_book, - (EBookEListAsyncCallback) required_fields_cb, editor); + e_book_get_supported_fields_async ( + editor->target_book, + (EBookEListAsyncCallback) + supported_fields_cb, editor); + + e_book_get_required_fields_async ( + editor->target_book, + (EBookEListAsyncCallback) + required_fields_cb, editor); if (!editor->is_new_contact) editor->changed = TRUE; -- cgit v1.2.3 From 274697623e2a6749a3b173c28f4832d9e88019e3 Mon Sep 17 00:00:00 2001 From: Matthew Barnes Date: Sat, 12 Feb 2011 11:37:05 -0500 Subject: Remove NULL checks for GObject methods. As of GLib 2.28 all GObject virtual methods, including constructed(), are safe to chain up to unconditionally. Remove unnecessary checks. --- addressbook/gui/contact-editor/e-contact-editor.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'addressbook/gui/contact-editor/e-contact-editor.c') diff --git a/addressbook/gui/contact-editor/e-contact-editor.c b/addressbook/gui/contact-editor/e-contact-editor.c index 55709ed081..4c0bf2e905 100644 --- a/addressbook/gui/contact-editor/e-contact-editor.c +++ b/addressbook/gui/contact-editor/e-contact-editor.c @@ -3728,8 +3728,8 @@ e_contact_editor_dispose (GObject *object) e_contact_editor->cancellable = NULL; } - if (G_OBJECT_CLASS (parent_class)->dispose) - (* G_OBJECT_CLASS (parent_class)->dispose) (object); + /* Chain up to parent's dispose() method. */ + G_OBJECT_CLASS (parent_class)->dispose (object); } static void -- cgit v1.2.3 From dda941f4254d929ff2db392b3789bf52df36fe41 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Dan=20Vr=C3=A1til?= Date: Thu, 5 May 2011 10:40:41 -0400 Subject: Bug 649381 - Memory leaks in contact editor --- addressbook/gui/contact-editor/e-contact-editor.c | 7 +++++++ 1 file changed, 7 insertions(+) (limited to 'addressbook/gui/contact-editor/e-contact-editor.c') diff --git a/addressbook/gui/contact-editor/e-contact-editor.c b/addressbook/gui/contact-editor/e-contact-editor.c index 4c0bf2e905..1e3e0b5bcc 100644 --- a/addressbook/gui/contact-editor/e-contact-editor.c +++ b/addressbook/gui/contact-editor/e-contact-editor.c @@ -1028,6 +1028,8 @@ fill_in_email (EContactEditor *editor) get_email_location (attr)); record_n++; + + g_free (email_address); } } @@ -1346,6 +1348,8 @@ fill_in_phone (EContactEditor *editor) editor, slot, phone, get_phone_type (attr)); record_n++; + + g_free (phone); } } @@ -1674,6 +1678,8 @@ fill_in_im (EContactEditor *editor) get_im_location (attr)); record_n++; + + g_free (im_name); } } } @@ -2649,6 +2655,7 @@ fill_in_simple (EContactEditor *editor) title = g_strdup_printf (_("Contact Editor - %s"), filename); gtk_window_set_title (GTK_WINDOW (editor->app), title); g_free (title); + g_free (filename); } else gtk_window_set_title (GTK_WINDOW (editor->app), _("Contact Editor")); -- cgit v1.2.3 From 54da4fc09cf226fdb59b9f0c70555e2e57dc1f91 Mon Sep 17 00:00:00 2001 From: Matthew Barnes Date: Sun, 8 May 2011 13:24:42 -0400 Subject: Coding style cleanups. --- addressbook/gui/contact-editor/e-contact-editor.c | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) (limited to 'addressbook/gui/contact-editor/e-contact-editor.c') diff --git a/addressbook/gui/contact-editor/e-contact-editor.c b/addressbook/gui/contact-editor/e-contact-editor.c index 1e3e0b5bcc..4b259e098b 100644 --- a/addressbook/gui/contact-editor/e-contact-editor.c +++ b/addressbook/gui/contact-editor/e-contact-editor.c @@ -2393,7 +2393,7 @@ fill_in_simple_field (EContactEditor *editor, GtkWidget *widget, gint field_id) EContactPhoto *photo = e_contact_get (contact, field_id); if (photo && photo->type == E_CONTACT_PHOTO_TYPE_INLINED) { e_image_chooser_set_image_data (E_IMAGE_CHOOSER (widget), - (gchar *)photo->data.inlined.data, + (gchar *) photo->data.inlined.data, photo->data.inlined.length); editor->image_set = TRUE; } @@ -2494,7 +2494,7 @@ extract_simple_field (EContactEditor *editor, GtkWidget *widget, gint field_id) GdkPixbuf *pixbuf, *new; GdkPixbufLoader *loader = gdk_pixbuf_loader_new (); - photo.data.inlined.data = (guchar *)img_buff; + photo.data.inlined.data = (guchar *) img_buff; img_buff = NULL; gdk_pixbuf_loader_write (loader, photo.data.inlined.data, photo.data.inlined.length, NULL); gdk_pixbuf_loader_close (loader, NULL); @@ -2532,7 +2532,7 @@ extract_simple_field (EContactEditor *editor, GtkWidget *widget, gint field_id) gdk_pixbuf_save_to_buffer (new, &img_buff, &photo.data.inlined.length, format_name, NULL, NULL); - photo.data.inlined.data = (guchar *)img_buff; + photo.data.inlined.data = (guchar *) img_buff; img_buff = NULL; g_free (format_name); g_object_unref (new); @@ -2563,7 +2563,7 @@ extract_simple_field (EContactEditor *editor, GtkWidget *widget, gint field_id) else if (GTK_IS_TOGGLE_BUTTON (widget)) { gboolean val = gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (widget)); - e_contact_set (contact, field_id, val?(gpointer)1:NULL); + e_contact_set (contact, field_id, val?(gpointer) 1:NULL); } else { g_warning (G_STRLOC ": Unhandled widget class in mappings!"); @@ -2927,7 +2927,7 @@ categories_response (GtkDialog *dialog, gint response, EContactEditor *editor) if (entry && GTK_IS_ENTRY (entry)) gtk_entry_set_text (GTK_ENTRY (entry), categories); else - e_contact_set (editor->contact, E_CONTACT_CATEGORIES, (gchar *)categories); + e_contact_set (editor->contact, E_CONTACT_CATEGORIES, (gchar *) categories); } gtk_widget_destroy (GTK_WIDGET (dialog)); editor->categories_dialog = NULL; @@ -3087,7 +3087,7 @@ image_clicked (GtkWidget *button, EContactEditor *editor) no_image, GTK_RESPONSE_NO, NULL); preview = GTK_IMAGE (gtk_image_new ()); - gtk_file_chooser_set_preview_widget ((GtkFileChooser *)editor->file_selector, GTK_WIDGET (preview)); + gtk_file_chooser_set_preview_widget ((GtkFileChooser *) editor->file_selector, GTK_WIDGET (preview)); g_signal_connect ( editor->file_selector, "update-preview", G_CALLBACK (update_preview_cb), preview); @@ -3798,7 +3798,7 @@ e_contact_editor_new (EShell *shell, if (book) e_book_get_supported_fields_async ( - book, (EBookEListAsyncCallback)supported_fields_cb, editor); + book, (EBookEListAsyncCallback) supported_fields_cb, editor); return editor; } -- cgit v1.2.3 From 5146ff4c535f443fe25290eb96631e91ad44c8ef Mon Sep 17 00:00:00 2001 From: Matthew Barnes Date: Sat, 21 May 2011 10:02:58 -0400 Subject: Coding style and whitespace cleanup. --- addressbook/gui/contact-editor/e-contact-editor.c | 641 +++++++++++++++------- 1 file changed, 443 insertions(+), 198 deletions(-) (limited to 'addressbook/gui/contact-editor/e-contact-editor.c') diff --git a/addressbook/gui/contact-editor/e-contact-editor.c b/addressbook/gui/contact-editor/e-contact-editor.c index 4b259e098b..f6e7f0ff71 100644 --- a/addressbook/gui/contact-editor/e-contact-editor.c +++ b/addressbook/gui/contact-editor/e-contact-editor.c @@ -71,25 +71,34 @@ enum { NUM_IM_COLUMNS }; -static void e_contact_editor_init (EContactEditor *editor); -static void e_contact_editor_class_init (EContactEditorClass *klass); -static void e_contact_editor_set_property (GObject *object, guint prop_id, const GValue *value, GParamSpec *pspec); -static void e_contact_editor_get_property (GObject *object, guint prop_id, GValue *value, GParamSpec *pspec); -static void e_contact_editor_dispose (GObject *object); - -static void e_contact_editor_raise (EABEditor *editor); -static void e_contact_editor_show (EABEditor *editor); -static void e_contact_editor_save_contact (EABEditor *editor, gboolean should_close); -static void e_contact_editor_close (EABEditor *editor); -static gboolean e_contact_editor_is_valid (EABEditor *editor); -static gboolean e_contact_editor_is_changed (EABEditor *editor); -static GtkWindow* e_contact_editor_get_window (EABEditor *editor); - -static void save_contact (EContactEditor *ce, gboolean should_close); -static void entry_activated (EContactEditor *editor); - -static void set_entry_text (EContactEditor *editor, GtkEntry *entry, const gchar *string); -static void sensitize_ok (EContactEditor *ce); +static void e_contact_editor_init (EContactEditor *editor); +static void e_contact_editor_class_init (EContactEditorClass *klass); +static void e_contact_editor_set_property (GObject *object, + guint prop_id, + const GValue *value, + GParamSpec *pspec); +static void e_contact_editor_get_property (GObject *object, + guint prop_id, + GValue *value, + GParamSpec *pspec); +static void e_contact_editor_dispose (GObject *object); +static void e_contact_editor_raise (EABEditor *editor); +static void e_contact_editor_show (EABEditor *editor); +static void e_contact_editor_save_contact (EABEditor *editor, + gboolean should_close); +static void e_contact_editor_close (EABEditor *editor); +static gboolean e_contact_editor_is_valid (EABEditor *editor); +static gboolean e_contact_editor_is_changed (EABEditor *editor); +static GtkWindow * + e_contact_editor_get_window (EABEditor *editor); +static void save_contact (EContactEditor *ce, + gboolean should_close); +static void entry_activated (EContactEditor *editor); + +static void set_entry_text (EContactEditor *editor, + GtkEntry *entry, + const gchar *string); +static void sensitize_ok (EContactEditor *ce); static EABEditorClass *parent_class = NULL; @@ -260,7 +269,9 @@ e_contact_editor_get_type (void) (GInstanceInitFunc) e_contact_editor_init, }; - contact_editor_type = g_type_register_static (EAB_TYPE_EDITOR, "EContactEditor", &contact_editor_info, 0); + contact_editor_type = g_type_register_static ( + EAB_TYPE_EDITOR, "EContactEditor", + &contact_editor_info, 0); } return contact_editor_type; @@ -430,7 +441,9 @@ style_makes_sense (const EContactName *name, const gchar *company, gint style) return FALSE; case 4: /* Fall Through */ case 5: - if (company && *company && name && ((name->given && *name->given) || (name->family && *name->family))) + if (company && *company && name && + ((name->given && *name->given) || + (name->family && *name->family))) return TRUE; else return FALSE; @@ -518,8 +531,11 @@ name_to_style (const EContactName *name, const gchar *company, gint style) static gint file_as_get_style (EContactEditor *editor) { - GtkEntry *file_as = GTK_ENTRY (gtk_bin_get_child (GTK_BIN (e_builder_get_widget(editor->builder, "combo-file-as")))); - GtkEntry *company_w = GTK_ENTRY (e_builder_get_widget (editor->builder, "entry-company")); + GtkEntry *file_as = GTK_ENTRY ( + gtk_bin_get_child (GTK_BIN ( + e_builder_get_widget(editor->builder, "combo-file-as")))); + GtkEntry *company_w = GTK_ENTRY ( + e_builder_get_widget (editor->builder, "entry-company")); gchar *filestring; gchar *trystring; EContactName *name = editor->name; @@ -551,8 +567,10 @@ file_as_set_style (EContactEditor *editor, gint style) gchar *string; gint i; GList *strings = NULL; - GtkComboBox *combo_file_as = GTK_COMBO_BOX (e_builder_get_widget (editor->builder, "combo-file-as")); - GtkEntry *company_w = GTK_ENTRY (e_builder_get_widget (editor->builder, "entry-company")); + GtkComboBox *combo_file_as = GTK_COMBO_BOX ( + e_builder_get_widget (editor->builder, "combo-file-as")); + GtkEntry *company_w = GTK_ENTRY ( + e_builder_get_widget (editor->builder, "entry-company")); const gchar *company; if (!(combo_file_as && GTK_IS_COMBO_BOX (combo_file_as))) @@ -586,7 +604,8 @@ file_as_set_style (EContactEditor *editor, gint style) GtkListStore *list_store; GtkTreeIter iter; - list_store = GTK_LIST_STORE (gtk_combo_box_get_model (combo_file_as)); + list_store = GTK_LIST_STORE ( + gtk_combo_box_get_model (combo_file_as)); gtk_list_store_clear (list_store); @@ -601,7 +620,9 @@ file_as_set_style (EContactEditor *editor, gint style) if (style != -1) { string = name_to_style (editor->name, company, style); - set_entry_text (editor, GTK_ENTRY (gtk_bin_get_child (GTK_BIN (combo_file_as))), string); + set_entry_text ( + editor, GTK_ENTRY (gtk_bin_get_child ( + GTK_BIN (combo_file_as))), string); g_free (string); } } @@ -683,16 +704,24 @@ sensitize_ok (EContactEditor *ce) { GtkWidget *widget; gboolean allow_save; - GtkWidget *entry_fullname = e_builder_get_widget (ce->builder, "entry-fullname" ); - GtkWidget *entry_file_as = gtk_bin_get_child (GTK_BIN (e_builder_get_widget (ce->builder, "combo-file-as"))); - GtkWidget *company_name = e_builder_get_widget (ce->builder, "entry-company"); - const gchar *name_entry_string = gtk_entry_get_text (GTK_ENTRY (entry_fullname)); - const gchar *file_as_entry_string = gtk_entry_get_text (GTK_ENTRY (entry_file_as)); - const gchar *company_name_string = gtk_entry_get_text (GTK_ENTRY (company_name)); - - allow_save = ce->target_editable && ce->changed ? TRUE : FALSE; - - if (!strcmp (name_entry_string, "") || !strcmp (file_as_entry_string, "")) { + GtkWidget *entry_fullname = + e_builder_get_widget (ce->builder, "entry-fullname" ); + GtkWidget *entry_file_as = + gtk_bin_get_child (GTK_BIN ( + e_builder_get_widget (ce->builder, "combo-file-as"))); + GtkWidget *company_name = + e_builder_get_widget (ce->builder, "entry-company"); + const gchar *name_entry_string = + gtk_entry_get_text (GTK_ENTRY (entry_fullname)); + const gchar *file_as_entry_string = + gtk_entry_get_text (GTK_ENTRY (entry_file_as)); + const gchar *company_name_string = + gtk_entry_get_text (GTK_ENTRY (company_name)); + + allow_save = ce->target_editable && ce->changed; + + if (!strcmp (name_entry_string, "") || + !strcmp (file_as_entry_string, "")) { if (strcmp (company_name_string , "")) { allow_save = TRUE; } @@ -766,7 +795,8 @@ init_email_record_location (EContactEditor *editor, gint record) g_free (widget_name); widget_name = g_strdup_printf ("combobox-email-%d", record); - location_combo_box = GTK_COMBO_BOX (e_builder_get_widget (editor->builder, widget_name)); + location_combo_box = GTK_COMBO_BOX ( + e_builder_get_widget (editor->builder, widget_name)); g_free (widget_name); store = GTK_LIST_STORE (gtk_combo_box_get_model (location_combo_box)); @@ -779,14 +809,25 @@ init_email_record_location (EContactEditor *editor, gint record) -1); } - g_signal_connect_swapped (location_combo_box, "changed", G_CALLBACK (gtk_widget_grab_focus), email_entry); - g_signal_connect (location_combo_box, "changed", G_CALLBACK (object_changed), editor); - g_signal_connect (email_entry, "changed", G_CALLBACK (object_changed), editor); - g_signal_connect_swapped (email_entry, "activate", G_CALLBACK (entry_activated), editor); + g_signal_connect_swapped ( + location_combo_box, "changed", + G_CALLBACK (gtk_widget_grab_focus), email_entry); + g_signal_connect ( + location_combo_box, "changed", + G_CALLBACK (object_changed), editor); + g_signal_connect ( + email_entry, "changed", + G_CALLBACK (object_changed), editor); + g_signal_connect_swapped ( + email_entry, "activate", + G_CALLBACK (entry_activated), editor); } static void -fill_in_email_record (EContactEditor *editor, gint record, const gchar *address, gint location) +fill_in_email_record (EContactEditor *editor, + gint record, + const gchar *address, + gint location) { GtkWidget *location_combo_box; GtkWidget *email_entry; @@ -807,7 +848,10 @@ fill_in_email_record (EContactEditor *editor, gint record, const gchar *address, } static void -extract_email_record (EContactEditor *editor, gint record, gchar **address, gint *location) +extract_email_record (EContactEditor *editor, + gint record, + gchar **address, + gint *location) { GtkWidget *location_combo_box; GtkWidget *email_entry; @@ -949,7 +993,10 @@ set_ui_slot (EVCardAttribute *attr, gint slot) } static gint -alloc_ui_slot (EContactEditor *editor, const gchar *widget_base, gint preferred_slot, gint num_slots) +alloc_ui_slot (EContactEditor *editor, + const gchar *widget_base, + gint preferred_slot, + gint num_slots) { gchar *widget_name; GtkWidget *widget; @@ -1006,20 +1053,25 @@ fill_in_email (EContactEditor *editor) /* Clear */ for (record_n = 1; record_n <= EMAIL_SLOTS; record_n++) { - fill_in_email_record (editor, record_n, NULL, email_default[record_n - 1]); + fill_in_email_record ( + editor, record_n, NULL, email_default[record_n - 1]); } /* Fill in */ - email_attr_list = e_contact_get_attributes (editor->contact, E_CONTACT_EMAIL); + email_attr_list = e_contact_get_attributes ( + editor->contact, E_CONTACT_EMAIL); - for (record_n = 1, l = email_attr_list; l && record_n <= EMAIL_SLOTS; l = g_list_next (l)) { + for (record_n = 1, l = email_attr_list; + l && record_n <= EMAIL_SLOTS; l = g_list_next (l)) { EVCardAttribute *attr = l->data; gchar *email_address; gint slot; email_address = e_vcard_attribute_get_value (attr); - slot = alloc_ui_slot (editor, "entry-email", get_ui_slot (attr), EMAIL_SLOTS); + slot = alloc_ui_slot ( + editor, "entry-email", + get_ui_slot (attr), EMAIL_SLOTS); if (slot < 1) break; @@ -1049,12 +1101,14 @@ extract_email (EContactEditor *editor) if (!STRING_IS_EMPTY (address)) { EVCardAttribute *attr; - attr = e_vcard_attribute_new ("", e_contact_vcard_attribute (E_CONTACT_EMAIL)); + attr = e_vcard_attribute_new ( + "", e_contact_vcard_attribute (E_CONTACT_EMAIL)); if (location >= 0) - e_vcard_attribute_add_param_with_value (attr, - e_vcard_attribute_param_new (EVC_TYPE), - email_index_to_location (location)); + e_vcard_attribute_add_param_with_value ( + attr, + e_vcard_attribute_param_new (EVC_TYPE), + email_index_to_location (location)); e_vcard_attribute_add_value (attr, address); set_ui_slot (attr, i); @@ -1143,9 +1197,11 @@ init_item_sensitiveable_combo_box (GtkComboBox *combo) "text", 0, "sensitive", 1, NULL); } -/* EContact can get attributes by field ID only, and there is none for TEL, so we need this */ +/* EContact can get attributes by field ID only, + * and there is none for TEL, so we need this */ static GList * -get_attributes_named (EVCard *vcard, const gchar *attr_name) +get_attributes_named (EVCard *vcard, + const gchar *attr_name) { GList *attr_list_in; GList *attr_list_out = NULL; @@ -1160,16 +1216,21 @@ get_attributes_named (EVCard *vcard, const gchar *attr_name) name = e_vcard_attribute_get_name (attr); if (!g_ascii_strcasecmp (attr_name, name)) { - attr_list_out = g_list_append (attr_list_out, e_vcard_attribute_copy (attr)); + attr_list_out = g_list_append ( + attr_list_out, + e_vcard_attribute_copy (attr)); } } return attr_list_out; } -/* EContact can set attributes by field ID only, and there is none for TEL, so we need this */ +/* EContact can set attributes by field ID only, + * and there is none for TEL, so we need this */ static void -set_attributes_named (EVCard *vcard, const gchar *attr_name, GList *attr_list) +set_attributes_named (EVCard *vcard, + const gchar *attr_name, + GList *attr_list) { GList *l; @@ -1191,9 +1252,11 @@ set_arrow_image (EContactEditor *editor, arrow = e_builder_get_widget (editor->builder, arrow_widget); if (expanded) - gtk_arrow_set (GTK_ARROW (arrow), GTK_ARROW_DOWN, GTK_SHADOW_NONE); + 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); + gtk_arrow_set ( + GTK_ARROW (arrow), GTK_ARROW_RIGHT, GTK_SHADOW_NONE); } static void @@ -1275,7 +1338,10 @@ init_email (EContactEditor *editor) } static void -fill_in_phone_record (EContactEditor *editor, gint record, const gchar *phone, gint phone_type) +fill_in_phone_record (EContactEditor *editor, + gint record, + const gchar *phone, + gint phone_type) { GtkWidget *phone_type_combo_box; GtkWidget *phone_entry; @@ -1299,7 +1365,10 @@ fill_in_phone_record (EContactEditor *editor, gint record, const gchar *phone, g } static void -extract_phone_record (EContactEditor *editor, gint record, gchar **phone, gint *phone_type) +extract_phone_record (EContactEditor *editor, + gint record, + gchar **phone, + gint *phone_type) { GtkWidget *phone_type_combo_box; GtkWidget *phone_entry; @@ -1334,7 +1403,8 @@ fill_in_phone (EContactEditor *editor) phone_attr_list = get_attributes_named (E_VCARD (editor->contact), "TEL"); - for (record_n = 1, l = phone_attr_list; l && record_n <= PHONE_SLOTS; l = g_list_next (l)) { + for (record_n = 1, l = phone_attr_list; + l && record_n <= PHONE_SLOTS; l = g_list_next (l)) { EVCardAttribute *attr = l->data; gchar *phone; gint slot; @@ -1433,7 +1503,10 @@ init_phone_record_type (EContactEditor *editor, gint record) init_item_sensitiveable_combo_box (GTK_COMBO_BOX (phone_type_combo_box)); - store = GTK_LIST_STORE (gtk_combo_box_get_model (GTK_COMBO_BOX (phone_type_combo_box))); + store = GTK_LIST_STORE ( + gtk_combo_box_get_model ( + GTK_COMBO_BOX (phone_type_combo_box))); + for (i = 0; i < G_N_ELEMENTS (phones); i++) { GtkTreeIter iter; @@ -1445,10 +1518,18 @@ init_phone_record_type (EContactEditor *editor, gint record) -1); } - g_signal_connect_swapped (phone_type_combo_box, "changed", G_CALLBACK (gtk_widget_grab_focus), phone_entry); - g_signal_connect (phone_type_combo_box, "changed", G_CALLBACK (object_changed), editor); - g_signal_connect (phone_entry, "changed", G_CALLBACK (object_changed), editor); - g_signal_connect_swapped (phone_entry, "activate", G_CALLBACK (entry_activated), editor); + g_signal_connect_swapped ( + phone_type_combo_box, "changed", + G_CALLBACK (gtk_widget_grab_focus), phone_entry); + g_signal_connect ( + phone_type_combo_box, "changed", + G_CALLBACK (object_changed), editor); + g_signal_connect ( + phone_entry, "changed", + G_CALLBACK (object_changed), editor); + g_signal_connect_swapped ( + phone_entry, "activate", + G_CALLBACK (entry_activated), editor); } static void @@ -1540,7 +1621,10 @@ init_im_record_location (EContactEditor *editor, gint record) init_item_sensitiveable_combo_box (GTK_COMBO_BOX (location_combo_box)); - store = GTK_LIST_STORE (gtk_combo_box_get_model (GTK_COMBO_BOX (location_combo_box))); + store = GTK_LIST_STORE ( + gtk_combo_box_get_model ( + GTK_COMBO_BOX (location_combo_box))); + for (i = 0; i < G_N_ELEMENTS (common_location); i++) { GtkTreeIter iter; @@ -1552,7 +1636,9 @@ init_im_record_location (EContactEditor *editor, gint record) -1); } - g_signal_connect (location_combo_box, "changed", G_CALLBACK (object_changed), editor); + g_signal_connect ( + location_combo_box, "changed", + G_CALLBACK (object_changed), editor); #endif } @@ -1580,7 +1666,10 @@ init_im_record_service (EContactEditor *editor, gint record) init_item_sensitiveable_combo_box (GTK_COMBO_BOX (service_combo_box)); - store = GTK_LIST_STORE (gtk_combo_box_get_model (GTK_COMBO_BOX (service_combo_box))); + store = GTK_LIST_STORE ( + gtk_combo_box_get_model ( + GTK_COMBO_BOX (service_combo_box))); + for (i = 0; i < G_N_ELEMENTS (im_service); i++) { GtkTreeIter iter; @@ -1592,10 +1681,18 @@ init_im_record_service (EContactEditor *editor, gint record) -1); } - g_signal_connect_swapped (service_combo_box, "changed", G_CALLBACK (gtk_widget_grab_focus), name_entry); - g_signal_connect (service_combo_box, "changed", G_CALLBACK (object_changed), editor); - g_signal_connect (name_entry, "changed", G_CALLBACK (object_changed), editor); - g_signal_connect_swapped (name_entry, "activate", G_CALLBACK (entry_activated), editor); + g_signal_connect_swapped ( + service_combo_box, "changed", + G_CALLBACK (gtk_widget_grab_focus), name_entry); + g_signal_connect ( + service_combo_box, "changed", + G_CALLBACK (object_changed), editor); + g_signal_connect ( + name_entry, "changed", + G_CALLBACK (object_changed), editor); + g_signal_connect_swapped ( + name_entry, "activate", + G_CALLBACK (entry_activated), editor); } static void @@ -1610,7 +1707,11 @@ init_im (EContactEditor *editor) } static void -fill_in_im_record (EContactEditor *editor, gint record, gint service, const gchar *name, gint location) +fill_in_im_record (EContactEditor *editor, + gint record, + gint service, + const gchar *name, + gint location) { GtkWidget *service_combo_box; #ifdef ENABLE_IM_LOCATION @@ -1685,7 +1786,11 @@ fill_in_im (EContactEditor *editor) } static void -extract_im_record (EContactEditor *editor, gint record, gint *service, gchar **name, gint *location) +extract_im_record (EContactEditor *editor, + gint record, + gint *service, + gchar **name, + gint *location) { GtkWidget *service_combo_box; #ifdef ENABLE_IM_LOCATION @@ -1735,12 +1840,15 @@ extract_im (EContactEditor *editor) extract_im_record (editor, i, &service, &name, &location); if (!STRING_IS_EMPTY (name)) { - attr = e_vcard_attribute_new ("", e_contact_vcard_attribute (im_service [service].field)); + attr = e_vcard_attribute_new ( + "", e_contact_vcard_attribute ( + im_service[service].field)); if (location >= 0) - e_vcard_attribute_add_param_with_value (attr, - e_vcard_attribute_param_new (EVC_TYPE), - im_index_to_location (location)); + e_vcard_attribute_add_param_with_value ( + attr, + e_vcard_attribute_param_new (EVC_TYPE), + im_index_to_location (location)); e_vcard_attribute_add_value (attr, name); set_ui_slot (attr, i); @@ -1759,11 +1867,15 @@ extract_im (EContactEditor *editor) /* Splice in the old attributes, minus the filled_in_slots first */ - old_service_attr_list = e_contact_get_attributes (editor->contact, im_service[i].field); - filled_in_slots = MIN (remaining_slots, g_list_length (old_service_attr_list)); + old_service_attr_list = e_contact_get_attributes ( + editor->contact, im_service[i].field); + filled_in_slots = + MIN (remaining_slots, + g_list_length (old_service_attr_list)); remaining_slots -= filled_in_slots; - for (l = old_service_attr_list, j = 0; l && j < filled_in_slots; l = l_next, j++) { + for (l = old_service_attr_list, j = 0; + l && j < filled_in_slots; l = l_next, j++) { l_next = g_list_next (l); e_vcard_attribute_free (l->data); @@ -1771,7 +1883,8 @@ extract_im (EContactEditor *editor) } old_service_attr_list = l; - service_attr_list[i] = g_list_concat (service_attr_list[i], old_service_attr_list); + service_attr_list[i] = g_list_concat ( + service_attr_list[i], old_service_attr_list); e_contact_set_attributes ( editor->contact, @@ -1879,30 +1992,41 @@ init_personal (EContactEditor *editor) static void init_address_textview (EContactEditor *editor, gint record) { - gchar *textview_name; - GtkWidget *textview; + gchar *textview_name; + GtkWidget *textview; GtkTextBuffer *text_buffer; - textview_name = g_strdup_printf ("textview-%s-address", address_name [record]); + textview_name = g_strdup_printf ( + "textview-%s-address", address_name [record]); textview = e_builder_get_widget (editor->builder, textview_name); g_free (textview_name); text_buffer = gtk_text_view_get_buffer (GTK_TEXT_VIEW (textview)); - g_signal_connect (text_buffer, "changed", G_CALLBACK (object_changed), editor); + + g_signal_connect ( + text_buffer, "changed", + G_CALLBACK (object_changed), editor); } static void -init_address_field (EContactEditor *editor, gint record, const gchar *widget_field_name) +init_address_field (EContactEditor *editor, + gint record, + const gchar *widget_field_name) { - gchar *entry_name; + gchar *entry_name; GtkWidget *entry; - entry_name = g_strdup_printf ("entry-%s-%s", address_name [record], widget_field_name); + entry_name = g_strdup_printf ( + "entry-%s-%s", address_name [record], widget_field_name); entry = e_builder_get_widget (editor->builder, entry_name); g_free (entry_name); - g_signal_connect (entry, "changed", G_CALLBACK (object_changed), editor); - g_signal_connect_swapped (entry, "activate", G_CALLBACK (entry_activated), editor); + g_signal_connect ( + entry, "changed", + G_CALLBACK (object_changed), editor); + g_signal_connect_swapped ( + entry, "activate", + G_CALLBACK (entry_activated), editor); } static void @@ -1931,7 +2055,9 @@ init_address (EContactEditor *editor) } static void -fill_in_address_textview (EContactEditor *editor, gint record, EContactAddress *address) +fill_in_address_textview (EContactEditor *editor, + gint record, + EContactAddress *address) { gchar *textview_name; GtkWidget *textview; @@ -1957,7 +2083,9 @@ fill_in_address_textview (EContactEditor *editor, gint record, EContactAddress * } static void -fill_in_address_label_textview (EContactEditor *editor, gint record, const gchar *label) +fill_in_address_label_textview (EContactEditor *editor, + gint record, + const gchar *label) { gchar *textview_name; GtkWidget *textview; @@ -1980,7 +2108,8 @@ fill_in_address_field (EContactEditor *editor, gchar *entry_name; GtkWidget *entry; - entry_name = g_strdup_printf ("entry-%s-%s", address_name [record], widget_field_name); + entry_name = g_strdup_printf ( + "entry-%s-%s", address_name [record], widget_field_name); entry = e_builder_get_widget (editor->builder, entry_name); g_free (entry_name); @@ -1988,7 +2117,8 @@ fill_in_address_field (EContactEditor *editor, } static void -fill_in_address_record (EContactEditor *editor, gint record) +fill_in_address_record (EContactEditor *editor, + gint record) { EContactAddress *address; gchar *address_label; @@ -2029,7 +2159,9 @@ fill_in_address (EContactEditor *editor) } static void -extract_address_textview (EContactEditor *editor, gint record, EContactAddress *address) +extract_address_textview (EContactEditor *editor, + gint record, + EContactAddress *address) { gchar *textview_name; GtkWidget *textview; @@ -2070,12 +2202,15 @@ extract_address_textview (EContactEditor *editor, gint record, EContactAddress * } static gchar * -extract_address_field (EContactEditor *editor, gint record, const gchar *widget_field_name) +extract_address_field (EContactEditor *editor, + gint record, + const gchar *widget_field_name) { gchar *entry_name; GtkWidget *entry; - entry_name = g_strdup_printf ("entry-%s-%s", address_name [record], widget_field_name); + entry_name = g_strdup_printf ( + "entry-%s-%s", address_name [record], widget_field_name); entry = e_builder_get_widget (editor->builder, entry_name); g_free (entry_name); @@ -2083,7 +2218,9 @@ extract_address_field (EContactEditor *editor, gint record, const gchar *widget_ } static gchar * -append_to_address_label (gchar *address_label, const gchar *part, gboolean newline) +append_to_address_label (gchar *address_label, + const gchar *part, + gboolean newline) { gchar *new_address_label; @@ -2091,7 +2228,9 @@ append_to_address_label (gchar *address_label, const gchar *part, gboolean newli return address_label; if (address_label) - new_address_label = g_strjoin (newline ? "\n" : ", ", address_label, part, NULL); + new_address_label = g_strjoin ( + newline ? "\n" : ", ", + address_label, part, NULL); else new_address_label = g_strdup (part); @@ -2100,18 +2239,27 @@ append_to_address_label (gchar *address_label, const gchar *part, gboolean newli } static void -set_address_label (EContact *contact, EContactField field, EContactAddress *address) +set_address_label (EContact *contact, + EContactField field, + EContactAddress *address) { gchar *address_label = NULL; if (address) { - address_label = append_to_address_label (address_label, address->street, TRUE); - address_label = append_to_address_label (address_label, address->ext, TRUE); - address_label = append_to_address_label (address_label, address->locality, TRUE); - address_label = append_to_address_label (address_label, address->region, FALSE); - address_label = append_to_address_label (address_label, address->code, TRUE); - address_label = append_to_address_label (address_label, address->po, TRUE); - address_label = append_to_address_label (address_label, address->country, TRUE); + address_label = append_to_address_label ( + address_label, address->street, TRUE); + address_label = append_to_address_label ( + address_label, address->ext, TRUE); + address_label = append_to_address_label ( + address_label, address->locality, TRUE); + address_label = append_to_address_label ( + address_label, address->region, FALSE); + address_label = append_to_address_label ( + address_label, address->code, TRUE); + address_label = append_to_address_label ( + address_label, address->po, TRUE); + address_label = append_to_address_label ( + address_label, address->country, TRUE); } e_contact_set (contact, field, address_label); @@ -2160,7 +2308,9 @@ extract_address (EContactEditor *editor) } static void -sensitize_address_textview (EContactEditor *editor, gint record, gboolean enabled) +sensitize_address_textview (EContactEditor *editor, + gint record, + gboolean enabled) { gchar *widget_name; GtkWidget *textview; @@ -2188,11 +2338,13 @@ sensitize_address_field (EContactEditor *editor, GtkWidget *entry; GtkWidget *label; - widget_name = g_strdup_printf ("entry-%s-%s", address_name [record], widget_field_name); + widget_name = g_strdup_printf ( + "entry-%s-%s", address_name [record], widget_field_name); entry = e_builder_get_widget (editor->builder, widget_name); g_free (widget_name); - widget_name = g_strdup_printf ("label-%s-%s", address_name [record], widget_field_name); + widget_name = g_strdup_printf ( + "label-%s-%s", address_name [record], widget_field_name); label = e_builder_get_widget (editor->builder, widget_name); g_free (widget_name); @@ -2316,34 +2468,40 @@ init_simple_field (EContactEditor *editor, GtkWidget *widget) if (GTK_IS_ENTRY (widget)) { changed_object = G_OBJECT (widget); - g_signal_connect_swapped (widget, "activate", G_CALLBACK (entry_activated), editor); - } - else if (GTK_IS_COMBO_BOX (widget)) { - changed_object = G_OBJECT (/*gtk_bin_get_child (GTK_BIN*/ (widget)/*)*/); - g_signal_connect_swapped (gtk_bin_get_child (GTK_BIN (widget)), "activate", G_CALLBACK (entry_activated), editor); - } - else if (GTK_IS_TEXT_VIEW (widget)) { - changed_object = G_OBJECT (gtk_text_view_get_buffer (GTK_TEXT_VIEW (widget))); - } - else if (E_IS_URL_ENTRY (widget)) { - changed_object = G_OBJECT (e_url_entry_get_entry (E_URL_ENTRY (widget))); + g_signal_connect_swapped ( + widget, "activate", + G_CALLBACK (entry_activated), editor); + } else if (GTK_IS_COMBO_BOX (widget)) { + changed_object = G_OBJECT (widget); + g_signal_connect_swapped ( + gtk_bin_get_child (GTK_BIN (widget)), "activate", + G_CALLBACK (entry_activated), editor); + } else if (GTK_IS_TEXT_VIEW (widget)) { + changed_object = G_OBJECT ( + gtk_text_view_get_buffer (GTK_TEXT_VIEW (widget))); + } else if (E_IS_URL_ENTRY (widget)) { + changed_object = G_OBJECT ( + e_url_entry_get_entry (E_URL_ENTRY (widget))); g_signal_connect_swapped ( changed_object, "activate", G_CALLBACK (entry_activated), editor); - } - else if (E_IS_DATE_EDIT (widget)) { + } else if (E_IS_DATE_EDIT (widget)) { changed_object = G_OBJECT (widget); - } - else if (E_IS_IMAGE_CHOOSER (widget)) { + } else if (E_IS_IMAGE_CHOOSER (widget)) { changed_object = G_OBJECT (widget); - g_signal_connect (widget, "changed", G_CALLBACK (image_chooser_changed), editor); - } - else if (GTK_IS_TOGGLE_BUTTON (widget)) { - g_signal_connect (widget, "toggled", G_CALLBACK (object_changed), editor); + g_signal_connect ( + widget, "changed", + G_CALLBACK (image_chooser_changed), editor); + } else if (GTK_IS_TOGGLE_BUTTON (widget)) { + g_signal_connect ( + widget, "toggled", + G_CALLBACK (object_changed), editor); } if (changed_object) - g_signal_connect (changed_object, "changed", G_CALLBACK (object_changed), editor); + g_signal_connect ( + changed_object, "changed", + G_CALLBACK (object_changed), editor); } static void @@ -2363,7 +2521,9 @@ fill_in_simple_field (EContactEditor *editor, GtkWidget *widget, gint field_id) } else if (GTK_IS_COMBO_BOX (widget)) { gchar *text = e_contact_get (contact, field_id); - gtk_entry_set_text (GTK_ENTRY (gtk_bin_get_child (GTK_BIN (widget))), STRING_MAKE_NON_NULL (text)); + gtk_entry_set_text ( + GTK_ENTRY (gtk_bin_get_child (GTK_BIN (widget))), + STRING_MAKE_NON_NULL (text)); g_free (text); } else if (GTK_IS_TEXT_VIEW (widget)) { @@ -2392,14 +2552,19 @@ fill_in_simple_field (EContactEditor *editor, GtkWidget *widget, gint field_id) else if (E_IS_IMAGE_CHOOSER (widget)) { EContactPhoto *photo = e_contact_get (contact, field_id); if (photo && photo->type == E_CONTACT_PHOTO_TYPE_INLINED) { - e_image_chooser_set_image_data (E_IMAGE_CHOOSER (widget), - (gchar *) photo->data.inlined.data, - photo->data.inlined.length); + e_image_chooser_set_image_data ( + E_IMAGE_CHOOSER (widget), + (gchar *) photo->data.inlined.data, + photo->data.inlined.length); editor->image_set = TRUE; } else { - gchar *file_name = e_icon_factory_get_icon_filename ("avatar-default", GTK_ICON_SIZE_DIALOG); - e_image_chooser_set_from_file (E_IMAGE_CHOOSER (widget), file_name); + gchar *file_name; + + file_name = e_icon_factory_get_icon_filename ( + "avatar-default", GTK_ICON_SIZE_DIALOG); + e_image_chooser_set_from_file ( + E_IMAGE_CHOOSER (widget), file_name); editor->image_set = FALSE; g_free (file_name); } @@ -2442,7 +2607,11 @@ extract_simple_field (EContactEditor *editor, GtkWidget *widget, gint field_id) gchar *text = NULL; if (gtk_combo_box_get_active_iter (GTK_COMBO_BOX (widget), &iter)) { - GtkListStore *store = GTK_LIST_STORE (gtk_combo_box_get_model (GTK_COMBO_BOX (widget))); + GtkListStore *store; + + store = GTK_LIST_STORE ( + gtk_combo_box_get_model ( + GTK_COMBO_BOX (widget))); gtk_tree_model_get (GTK_TREE_MODEL (store), &iter, 0, &text, @@ -2496,7 +2665,10 @@ extract_simple_field (EContactEditor *editor, GtkWidget *widget, gint field_id) photo.data.inlined.data = (guchar *) img_buff; img_buff = NULL; - gdk_pixbuf_loader_write (loader, photo.data.inlined.data, photo.data.inlined.length, NULL); + gdk_pixbuf_loader_write ( + loader, + photo.data.inlined.data, + photo.data.inlined.length, NULL); gdk_pixbuf_loader_close (loader, NULL); pixbuf = gdk_pixbuf_loader_get_pixbuf (loader); @@ -2526,12 +2698,15 @@ extract_simple_field (EContactEditor *editor, GtkWidget *widget, gint field_id) new = e_icon_factory_pixbuf_scale (pixbuf, width, height); if (new) { - GdkPixbufFormat *format = gdk_pixbuf_loader_get_format (loader); - gchar *format_name = gdk_pixbuf_format_get_name (format); + GdkPixbufFormat *format = + gdk_pixbuf_loader_get_format (loader); + gchar *format_name = + gdk_pixbuf_format_get_name (format); g_free (photo.data.inlined.data); - gdk_pixbuf_save_to_buffer (new, &img_buff, - &photo.data.inlined.length, - format_name, NULL, NULL); + gdk_pixbuf_save_to_buffer ( + new, &img_buff, + &photo.data.inlined.length, + format_name, NULL, NULL); photo.data.inlined.data = (guchar *) img_buff; img_buff = NULL; g_free (format_name); @@ -2987,7 +3162,8 @@ image_selected (EContactEditor *editor) gchar *file_name; GtkWidget *image_chooser; - file_name = gtk_file_chooser_get_filename (GTK_FILE_CHOOSER (editor->file_selector)); + file_name = gtk_file_chooser_get_filename ( + GTK_FILE_CHOOSER (editor->file_selector)); if (!file_name) return; @@ -3009,13 +3185,18 @@ image_cleared (EContactEditor *editor) GtkWidget *image_chooser; gchar *file_name; - image_chooser = e_builder_get_widget (editor->builder, "image-chooser"); + image_chooser = e_builder_get_widget ( + editor->builder, "image-chooser"); - file_name = e_icon_factory_get_icon_filename ("avatar-default", GTK_ICON_SIZE_DIALOG); + file_name = e_icon_factory_get_icon_filename ( + "avatar-default", GTK_ICON_SIZE_DIALOG); - g_signal_handlers_block_by_func (image_chooser, image_chooser_changed, editor); - e_image_chooser_set_from_file (E_IMAGE_CHOOSER (image_chooser), file_name); - g_signal_handlers_unblock_by_func (image_chooser, image_chooser_changed, editor); + g_signal_handlers_block_by_func ( + image_chooser, image_chooser_changed, editor); + e_image_chooser_set_from_file ( + E_IMAGE_CHOOSER (image_chooser), file_name); + g_signal_handlers_unblock_by_func ( + image_chooser, image_chooser_changed, editor); g_free (file_name); @@ -3058,9 +3239,11 @@ update_preview_cb (GtkFileChooser *file_chooser, gpointer data) pixbuf = gdk_pixbuf_new_from_file_at_size (filename, 128, 128, NULL); if (!pixbuf) { gchar *alternate_file; - alternate_file = e_icon_factory_get_icon_filename ("avatar-default", GTK_ICON_SIZE_DIALOG); + alternate_file = e_icon_factory_get_icon_filename ( + "avatar-default", GTK_ICON_SIZE_DIALOG); if (alternate_file) { - pixbuf = gdk_pixbuf_new_from_file_at_size (alternate_file, 128, 128, NULL); + pixbuf = gdk_pixbuf_new_from_file_at_size ( + alternate_file, 128, 128, NULL); g_free (alternate_file); } } @@ -3087,13 +3270,19 @@ image_clicked (GtkWidget *button, EContactEditor *editor) no_image, GTK_RESPONSE_NO, NULL); preview = GTK_IMAGE (gtk_image_new ()); - gtk_file_chooser_set_preview_widget ((GtkFileChooser *) editor->file_selector, GTK_WIDGET (preview)); + gtk_file_chooser_set_preview_widget ( + GTK_FILE_CHOOSER (editor->file_selector), + GTK_WIDGET (preview)); g_signal_connect ( editor->file_selector, "update-preview", G_CALLBACK (update_preview_cb), preview); - gtk_dialog_set_default_response (GTK_DIALOG (editor->file_selector), GTK_RESPONSE_ACCEPT); + gtk_dialog_set_default_response ( + GTK_DIALOG (editor->file_selector), + GTK_RESPONSE_ACCEPT); - gtk_file_chooser_set_current_folder (GTK_FILE_CHOOSER (editor->file_selector), g_get_home_dir ()); + gtk_file_chooser_set_current_folder ( + GTK_FILE_CHOOSER (editor->file_selector), + g_get_home_dir ()); g_signal_connect ( editor->file_selector, "response", @@ -3151,7 +3340,10 @@ contact_moved_cb (EBook *book, const GError *error, EditorCloseStruct *ecs) } static void -contact_added_cb (EBook *book, const GError *error, const gchar *id, EditorCloseStruct *ecs) +contact_added_cb (EBook *book, + const GError *error, + const gchar *id, + EditorCloseStruct *ecs) { EContactEditor *ce = ecs->ce; gboolean should_close = ecs->should_close; @@ -3264,7 +3456,8 @@ save_contact (EContactEditor *ce, gboolean should_close) } entry_fullname = e_builder_get_widget (ce->builder, "entry-fullname" ); - entry_file_as = gtk_bin_get_child (GTK_BIN (e_builder_get_widget (ce->builder, "combo-file-as"))); + entry_file_as = gtk_bin_get_child ( + GTK_BIN (e_builder_get_widget (ce->builder, "combo-file-as"))); company_name = e_builder_get_widget (ce->builder, "entry-company"); name_entry_string = gtk_entry_get_text (GTK_ENTRY (entry_fullname)); file_as_entry_string = gtk_entry_get_text (GTK_ENTRY (entry_file_as)); @@ -3629,7 +3822,8 @@ e_contact_editor_init (EContactEditor *e_contact_editor) widget = e_contact_editor->app; gtk_widget_ensure_style (widget); - gtk_window_set_type_hint (GTK_WINDOW (widget), GDK_WINDOW_TYPE_HINT_NORMAL); + gtk_window_set_type_hint ( + GTK_WINDOW (widget), GDK_WINDOW_TYPE_HINT_NORMAL); container = gtk_dialog_get_action_area (GTK_DIALOG (widget)); gtk_container_set_border_width (GTK_CONTAINER (container), 12); container = gtk_dialog_get_content_area (GTK_DIALOG (widget)); @@ -3637,30 +3831,61 @@ e_contact_editor_init (EContactEditor *e_contact_editor) init_all (e_contact_editor); - widget = e_builder_get_widget (e_contact_editor->builder, "button-image"); - g_signal_connect (widget, "clicked", G_CALLBACK (image_clicked), e_contact_editor); - - widget = e_builder_get_widget(e_contact_editor->builder, "button-fullname"); - g_signal_connect (widget, "clicked", G_CALLBACK (full_name_clicked), e_contact_editor); - widget = e_builder_get_widget(e_contact_editor->builder, "button-categories"); - g_signal_connect (widget, "clicked", G_CALLBACK (categories_clicked), e_contact_editor); - widget = e_builder_get_widget (e_contact_editor->builder, "source-combo-box-source"); - e_util_set_source_combo_box_list (widget, "/apps/evolution/addressbook/sources"); - g_signal_connect (widget, "changed", G_CALLBACK (source_changed), e_contact_editor); - label = e_builder_get_widget (e_contact_editor->builder, "where-label"); + widget = e_builder_get_widget ( + e_contact_editor->builder, "button-image"); + g_signal_connect ( + widget, "clicked", + G_CALLBACK (image_clicked), e_contact_editor); + widget = e_builder_get_widget ( + e_contact_editor->builder, "button-fullname"); + g_signal_connect ( + widget, "clicked", + G_CALLBACK (full_name_clicked), e_contact_editor); + widget = e_builder_get_widget ( + e_contact_editor->builder, "button-categories"); + g_signal_connect ( + widget, "clicked", + G_CALLBACK (categories_clicked), e_contact_editor); + widget = e_builder_get_widget ( + e_contact_editor->builder, "source-combo-box-source"); + e_util_set_source_combo_box_list ( + widget, "/apps/evolution/addressbook/sources"); + g_signal_connect ( + widget, "changed", + G_CALLBACK (source_changed), e_contact_editor); + label = e_builder_get_widget ( + e_contact_editor->builder, "where-label"); gtk_label_set_mnemonic_widget (GTK_LABEL (label), widget); - widget = e_builder_get_widget (e_contact_editor->builder, "button-ok"); - g_signal_connect (widget, "clicked", G_CALLBACK (file_save_and_close_cb), e_contact_editor); - widget = e_builder_get_widget (e_contact_editor->builder, "button-cancel"); - g_signal_connect (widget, "clicked", G_CALLBACK (file_cancel_cb), e_contact_editor); - widget = e_builder_get_widget (e_contact_editor->builder, "button-help"); - g_signal_connect (widget, "clicked", G_CALLBACK (show_help_cb), e_contact_editor); - widget = e_builder_get_widget (e_contact_editor->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->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, "button-ok"); + g_signal_connect ( + widget, "clicked", + G_CALLBACK (file_save_and_close_cb), e_contact_editor); + widget = e_builder_get_widget ( + e_contact_editor->builder, "button-cancel"); + g_signal_connect ( + widget, "clicked", + G_CALLBACK (file_cancel_cb), e_contact_editor); + widget = e_builder_get_widget ( + e_contact_editor->builder, "button-help"); + g_signal_connect ( + widget, "clicked", + G_CALLBACK (show_help_cb), e_contact_editor); + widget = e_builder_get_widget ( + e_contact_editor->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->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) @@ -3715,7 +3940,9 @@ e_contact_editor_dispose (GObject *object) } if (e_contact_editor->target_book) { - g_signal_handler_disconnect (e_contact_editor->target_book, e_contact_editor->target_editable_id); + g_signal_handler_disconnect ( + e_contact_editor->target_book, + e_contact_editor->target_editable_id); g_object_unref (e_contact_editor->target_book); e_contact_editor->target_book = NULL; } @@ -3746,7 +3973,9 @@ supported_fields_cb (EBook *book, EContactEditor *ce) { if (!g_slist_find (eab_editor_get_all_editors (), ce)) { - g_warning ("supported_fields_cb called for book that's still around, but contact editor that's been destroyed."); + g_warning ( + "supported_fields_cb called for book that's still " + "around, but contact editor that's been destroyed."); return; } @@ -3765,7 +3994,9 @@ required_fields_cb (EBook *book, { if (!g_slist_find (eab_editor_get_all_editors (), ce)) { - g_warning ("supported_fields_cb called for book that's still around, but contact editor that's been destroyed."); + g_warning ( + "supported_fields_cb called for book that's still " + "around, but contact editor that's been destroyed."); return; } @@ -3798,7 +4029,8 @@ e_contact_editor_new (EShell *shell, if (book) e_book_get_supported_fields_async ( - book, (EBookEListAsyncCallback) supported_fields_cb, editor); + book, (EBookEListAsyncCallback) + supported_fields_cb, editor); return editor; } @@ -3821,7 +4053,10 @@ writable_changed (EBook *book, gboolean writable, EContactEditor *ce) } static void -e_contact_editor_set_property (GObject *object, guint prop_id, const GValue *value, GParamSpec *pspec) +e_contact_editor_set_property (GObject *object, + guint prop_id, + const GValue *value, + GParamSpec *pspec) { EContactEditor *editor; @@ -3930,11 +4165,11 @@ e_contact_editor_set_property (GObject *object, guint prop_id, const GValue *val break; case PROP_IS_NEW_CONTACT: - editor->is_new_contact = g_value_get_boolean (value) ? TRUE : FALSE; + editor->is_new_contact = g_value_get_boolean (value); break; case PROP_EDITABLE: { - gboolean new_value = g_value_get_boolean (value) ? TRUE : FALSE; + gboolean new_value = g_value_get_boolean (value); gboolean changed = (editor->target_editable != new_value); editor->target_editable = new_value; @@ -3945,7 +4180,7 @@ e_contact_editor_set_property (GObject *object, guint prop_id, const GValue *val } case PROP_CHANGED: { - gboolean new_value = g_value_get_boolean (value) ? TRUE : FALSE; + gboolean new_value = g_value_get_boolean (value); gboolean changed = (editor->changed != new_value); editor->changed = new_value; @@ -3982,7 +4217,10 @@ e_contact_editor_set_property (GObject *object, guint prop_id, const GValue *val } static void -e_contact_editor_get_property (GObject *object, guint prop_id, GValue *value, GParamSpec *pspec) +e_contact_editor_get_property (GObject *object, + guint prop_id, + GValue *value, + GParamSpec *pspec) { EContactEditor *e_contact_editor; @@ -4003,26 +4241,33 @@ e_contact_editor_get_property (GObject *object, guint prop_id, GValue *value, GP break; case PROP_IS_NEW_CONTACT: - g_value_set_boolean (value, e_contact_editor->is_new_contact ? TRUE : FALSE); + g_value_set_boolean ( + value, e_contact_editor->is_new_contact); break; case PROP_EDITABLE: - g_value_set_boolean (value, e_contact_editor->target_editable ? TRUE : FALSE); + g_value_set_boolean ( + value, e_contact_editor->target_editable); break; case PROP_CHANGED: - g_value_set_boolean (value, e_contact_editor->changed ? TRUE : FALSE); + g_value_set_boolean ( + value, e_contact_editor->changed); break; case PROP_WRITABLE_FIELDS: if (e_contact_editor->writable_fields) - g_value_set_object (value, e_list_duplicate (e_contact_editor->writable_fields)); + g_value_set_object ( + value, e_list_duplicate ( + e_contact_editor->writable_fields)); else g_value_set_object (value, NULL); break; case PROP_REQUIRED_FIELDS: if (e_contact_editor->required_fields) - g_value_set_object (value, e_list_duplicate (e_contact_editor->required_fields)); + g_value_set_object ( + value, e_list_duplicate ( + e_contact_editor->required_fields)); else g_value_set_object (value, NULL); break; -- cgit v1.2.3 From c24038c4f62f37b89d1bda9542ca5ccc843d4ea0 Mon Sep 17 00:00:00 2001 From: Milan Crha Date: Fri, 27 May 2011 15:23:07 +0200 Subject: Bug #646109 - Fix use of include to make sure translations work --- addressbook/gui/contact-editor/e-contact-editor.c | 2 ++ 1 file changed, 2 insertions(+) (limited to 'addressbook/gui/contact-editor/e-contact-editor.c') diff --git a/addressbook/gui/contact-editor/e-contact-editor.c b/addressbook/gui/contact-editor/e-contact-editor.c index f6e7f0ff71..4cdf1e2185 100644 --- a/addressbook/gui/contact-editor/e-contact-editor.c +++ b/addressbook/gui/contact-editor/e-contact-editor.c @@ -20,7 +20,9 @@ * */ +#ifdef HAVE_CONFIG_H #include +#endif #include "eab-editor.h" #include "e-contact-editor.h" -- cgit v1.2.3 From 7b4910d63646159ac5dcc3d774c6ec3e7f18cce9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Dan=20Vr=C3=A1til?= Date: Thu, 2 Jun 2011 18:45:23 +0200 Subject: Bug #636809 - Address labels formatting improvements Address labels should be formated according to country specific standards. --- addressbook/gui/contact-editor/e-contact-editor.c | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) (limited to 'addressbook/gui/contact-editor/e-contact-editor.c') diff --git a/addressbook/gui/contact-editor/e-contact-editor.c b/addressbook/gui/contact-editor/e-contact-editor.c index 4cdf1e2185..f545594039 100644 --- a/addressbook/gui/contact-editor/e-contact-editor.c +++ b/addressbook/gui/contact-editor/e-contact-editor.c @@ -2247,7 +2247,16 @@ set_address_label (EContact *contact, { gchar *address_label = NULL; - if (address) { + if (!address) { + e_contact_set (contact, field, NULL); + return; + } + + address_label = eab_format_address (contact, + (field == E_CONTACT_ADDRESS_LABEL_WORK) ? E_CONTACT_ADDRESS_WORK : + E_CONTACT_ADDRESS_HOME); + + if (!address_label) { address_label = append_to_address_label ( address_label, address->street, TRUE); address_label = append_to_address_label ( -- cgit v1.2.3 From 2dc0a29c7a168d7cf026561173443acaf9db8b9b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Dan=20Vr=C3=A1til?= Date: Fri, 3 Jun 2011 11:51:38 +0200 Subject: Bug #332907 - Contact editor duplication alert misleading --- addressbook/gui/contact-editor/e-contact-editor.c | 21 ++++++++++++++++++++- 1 file changed, 20 insertions(+), 1 deletion(-) (limited to 'addressbook/gui/contact-editor/e-contact-editor.c') diff --git a/addressbook/gui/contact-editor/e-contact-editor.c b/addressbook/gui/contact-editor/e-contact-editor.c index f545594039..1df7b62082 100644 --- a/addressbook/gui/contact-editor/e-contact-editor.c +++ b/addressbook/gui/contact-editor/e-contact-editor.c @@ -641,6 +641,8 @@ name_entry_changed (GtkWidget *widget, EContactEditor *editor) editor->name = e_contact_name_from_string (string); file_as_set_style (editor, style); + editor->check_merge = TRUE; + sensitize_ok (editor); if (string && !*string) gtk_window_set_title (GTK_WINDOW (editor->app), _("Contact Editor")); @@ -742,6 +744,19 @@ object_changed (GObject *object, EContactEditor *editor) return; } + if (!editor->check_merge && GTK_IS_WIDGET (object)) { + const gchar *widget_name; + + widget_name = gtk_widget_get_name (GTK_WIDGET (object)); + + if (widget_name && + ((g_str_equal (widget_name, "fullname")) || + (g_str_equal (widget_name, "nickname")) || + (g_str_equal (widget_name, "file-as")) || + (g_str_has_prefix (widget_name, "email-")))) + editor->check_merge = TRUE; + } + if (!editor->changed) { editor->changed = TRUE; sensitize_ok (editor); @@ -3441,10 +3456,13 @@ real_save_contact (EContactEditor *ce, gboolean should_close) eab_merging_book_add_contact ( ce->target_book, ce->contact, (EBookIdAsyncCallback) contact_added_cb, ecs); - else + else if (ce->check_merge) eab_merging_book_commit_contact ( ce->target_book, ce->contact, (EBookAsyncCallback) contact_modified_cb, ecs); + else + e_book_commit_contact_async (ce->target_book, ce->contact, + (EBookAsyncCallback) contact_modified_cb, ecs); } } @@ -3814,6 +3832,7 @@ e_contact_editor_init (EContactEditor *e_contact_editor) e_contact_editor->contact = NULL; e_contact_editor->changed = FALSE; + e_contact_editor->check_merge = FALSE; e_contact_editor->image_set = FALSE; e_contact_editor->image_changed = FALSE; e_contact_editor->in_async_call = FALSE; -- cgit v1.2.3 From e7954c3f251aabbf95d099159709c8c66dfedc44 Mon Sep 17 00:00:00 2001 From: Matthew Barnes Date: Sat, 4 Jun 2011 15:53:10 -0500 Subject: Coding style and whitespace cleanups. --- addressbook/gui/contact-editor/e-contact-editor.c | 41 ++++++++++++++++------- 1 file changed, 29 insertions(+), 12 deletions(-) (limited to 'addressbook/gui/contact-editor/e-contact-editor.c') diff --git a/addressbook/gui/contact-editor/e-contact-editor.c b/addressbook/gui/contact-editor/e-contact-editor.c index 1df7b62082..b636190777 100644 --- a/addressbook/gui/contact-editor/e-contact-editor.c +++ b/addressbook/gui/contact-editor/e-contact-editor.c @@ -1787,7 +1787,9 @@ fill_in_im (EContactEditor *editor) gint slot; im_name = e_vcard_attribute_get_value (attr); - slot = alloc_ui_slot (editor, "entry-im-name", get_ui_slot (attr), IM_SLOTS); + slot = alloc_ui_slot ( + editor, "entry-im-name", + get_ui_slot (attr), IM_SLOTS); if (slot < 1) break; @@ -1870,7 +1872,8 @@ extract_im (EContactEditor *editor) e_vcard_attribute_add_value (attr, name); set_ui_slot (attr, i); - service_attr_list[service] = g_list_append (service_attr_list[service], attr); + service_attr_list[service] = g_list_append ( + service_attr_list[service], attr); } g_free (name); @@ -2795,7 +2798,8 @@ init_simple (EContactEditor *editor) gint i; for (i = 0; i < G_N_ELEMENTS (simple_field_map); i++) { - widget = e_builder_get_widget (editor->builder, simple_field_map[i].widget_name); + widget = e_builder_get_widget ( + editor->builder, simple_field_map[i].widget_name); if (!widget) continue; @@ -2829,7 +2833,8 @@ fill_in_simple (EContactEditor *editor) !simple_field_map[i].process_data) continue; - widget = e_builder_get_widget (editor->builder, simple_field_map[i].widget_name); + widget = e_builder_get_widget ( + editor->builder, simple_field_map[i].widget_name); if (!widget) continue; @@ -2878,7 +2883,8 @@ extract_simple (EContactEditor *editor) !simple_field_map[i].process_data) continue; - widget = e_builder_get_widget (editor->builder, simple_field_map[i].widget_name); + widget = e_builder_get_widget ( + editor->builder, simple_field_map[i].widget_name); if (!widget) continue; @@ -2899,7 +2905,8 @@ sensitize_simple (EContactEditor *editor) GtkWidget *widget; gboolean enabled = TRUE; - widget = e_builder_get_widget (editor->builder, simple_field_map[i].widget_name); + widget = e_builder_get_widget ( + editor->builder, simple_field_map[i].widget_name); if (!widget) continue; @@ -3121,15 +3128,23 @@ static void categories_response (GtkDialog *dialog, gint response, EContactEditor *editor) { const gchar *categories; - GtkWidget *entry = e_builder_get_widget(editor->builder, "entry-categories"); + GtkWidget *entry; + + entry = e_builder_get_widget (editor->builder, "entry-categories"); if (response == GTK_RESPONSE_OK) { - categories = e_categories_dialog_get_categories (E_CATEGORIES_DIALOG (dialog)); - if (entry && GTK_IS_ENTRY (entry)) - gtk_entry_set_text (GTK_ENTRY (entry), categories); + categories = e_categories_dialog_get_categories ( + E_CATEGORIES_DIALOG (dialog)); + if (GTK_IS_ENTRY (entry)) + gtk_entry_set_text ( + GTK_ENTRY (entry), categories); else - e_contact_set (editor->contact, E_CONTACT_CATEGORIES, (gchar *) categories); + e_contact_set ( + editor->contact, + E_CONTACT_CATEGORIES, + (gchar *) categories); } + gtk_widget_destroy (GTK_WIDGET (dialog)); editor->categories_dialog = NULL; } @@ -4150,7 +4165,9 @@ e_contact_editor_set_property (GObject *object, break; if (editor->target_book) { - g_signal_handler_disconnect (editor->target_book, editor->target_editable_id); + g_signal_handler_disconnect ( + editor->target_book, + editor->target_editable_id); g_object_unref (editor->target_book); } -- cgit v1.2.3 From 84339b3be5a771406fcd5898bbd21dc1c5b98c82 Mon Sep 17 00:00:00 2001 From: Milan Crha Date: Tue, 14 Jun 2011 08:54:20 +0200 Subject: Do not use deprecated EBook/ECal API --- addressbook/gui/contact-editor/e-contact-editor.c | 382 +++++++++++----------- 1 file changed, 195 insertions(+), 187 deletions(-) (limited to 'addressbook/gui/contact-editor/e-contact-editor.c') diff --git a/addressbook/gui/contact-editor/e-contact-editor.c b/addressbook/gui/contact-editor/e-contact-editor.c index b636190777..4088837f90 100644 --- a/addressbook/gui/contact-editor/e-contact-editor.c +++ b/addressbook/gui/contact-editor/e-contact-editor.c @@ -35,7 +35,7 @@ #include #include -#include +#include #include #include #include @@ -107,8 +107,8 @@ static EABEditorClass *parent_class = NULL; /* The arguments we take */ enum { PROP_0, - PROP_SOURCE_BOOK, - PROP_TARGET_BOOK, + PROP_SOURCE_CLIENT, + PROP_TARGET_CLIENT, PROP_CONTACT, PROP_IS_NEW_CONTACT, PROP_EDITABLE, @@ -213,7 +213,7 @@ e_contact_editor_contact_added (EABEditor *editor, if (!error) return; - if (g_error_matches (error, E_BOOK_ERROR, E_BOOK_ERROR_CANCELLED)) + if (g_error_matches (error, E_CLIENT_ERROR, E_CLIENT_ERROR_CANCELLED)) return; eab_error_dialog (NULL, _("Error adding contact"), error); @@ -227,7 +227,7 @@ e_contact_editor_contact_modified (EABEditor *editor, if (!error) return; - if (g_error_matches (error, E_BOOK_ERROR, E_BOOK_ERROR_CANCELLED)) + if (g_error_matches (error, E_CLIENT_ERROR, E_CLIENT_ERROR_CANCELLED)) return; eab_error_dialog (NULL, _("Error modifying contact"), error); @@ -241,7 +241,7 @@ e_contact_editor_contact_deleted (EABEditor *editor, if (!error) return; - if (g_error_matches (error, E_BOOK_ERROR, E_BOOK_ERROR_CANCELLED)) + if (g_error_matches (error, E_CLIENT_ERROR, E_CLIENT_ERROR_CANCELLED)) return; eab_error_dialog (NULL, _("Error removing contact"), error); @@ -305,22 +305,22 @@ e_contact_editor_class_init (EContactEditorClass *klass) g_object_class_install_property ( object_class, - PROP_SOURCE_BOOK, + PROP_SOURCE_CLIENT, g_param_spec_object ( - "source_book", - "Source Book", + "source_client", + "Source EBookClient", NULL, - E_TYPE_BOOK, + E_TYPE_BOOK_CLIENT, G_PARAM_READWRITE)); g_object_class_install_property ( object_class, - PROP_TARGET_BOOK, + PROP_TARGET_CLIENT, g_param_spec_object ( - "target_book", - "Target Book", + "target_client", + "Target EBookClient", NULL, - E_TYPE_BOOK, + E_TYPE_BOOK_CLIENT, G_PARAM_READWRITE)); g_object_class_install_property ( @@ -346,21 +346,19 @@ e_contact_editor_class_init (EContactEditorClass *klass) g_object_class_install_property ( object_class, PROP_WRITABLE_FIELDS, - g_param_spec_object ( + g_param_spec_pointer ( "writable_fields", "Writable Fields", NULL, - E_TYPE_LIST, G_PARAM_READWRITE)); g_object_class_install_property ( object_class, PROP_REQUIRED_FIELDS, - g_param_spec_object ( + g_param_spec_pointer ( "required_fields", "Required Fields", NULL, - E_TYPE_LIST, G_PARAM_READWRITE)); g_object_class_install_property ( @@ -394,9 +392,8 @@ entry_activated (EContactEditor *editor) static gboolean is_field_supported (EContactEditor *editor, EContactField field_id) { - EList *fields; + GSList *fields, *iter; const gchar *field; - EIterator *iter; fields = editor->writable_fields; if (!fields) @@ -406,10 +403,8 @@ is_field_supported (EContactEditor *editor, EContactField field_id) if (!field) return FALSE; - for (iter = e_list_get_iterator (fields); - e_iterator_is_valid (iter); - e_iterator_next (iter)) { - const gchar *this_field = e_iterator_get (iter); + for (iter = fields; iter; iter = iter->next) { + const gchar *this_field = iter->data; if (!this_field) continue; @@ -692,7 +687,7 @@ fill_in_source_field (EContactEditor *editor) { GtkWidget *source_menu; - if (!editor->target_book) + if (!editor->target_client) return; source_menu = e_builder_get_widget ( @@ -700,7 +695,7 @@ fill_in_source_field (EContactEditor *editor) e_source_combo_box_set_active ( E_SOURCE_COMBO_BOX (source_menu), - e_book_get_source (editor->target_book)); + e_client_get_source (E_CLIENT (editor->target_client))); } static void @@ -2976,25 +2971,27 @@ init_all (EContactEditor *editor) } static void -contact_editor_book_loaded_cb (ESource *source, +contact_editor_book_loaded_cb (GObject *source_object, GAsyncResult *result, - EContactEditor *editor) + gpointer user_data) { - EBook *book; + ESource *source = E_SOURCE (source_object); + EContactEditor *editor = user_data; + EClient *client = NULL; GError *error = NULL; - book = e_load_book_source_finish (source, result, &error); + if (!e_client_utils_open_new_finish (source, result, &client, &error)) + client = NULL; - if (g_error_matches (error, G_IO_ERROR, G_IO_ERROR_CANCELLED)) { - g_warn_if_fail (book == NULL); + if (g_error_matches (error, G_IO_ERROR, G_IO_ERROR_CANCELLED) || + g_error_matches (error, E_CLIENT_ERROR, E_CLIENT_ERROR_CANCELLED)) { + g_warn_if_fail (client == NULL); g_error_free (error); - goto exit; - } else if (error != NULL) { GtkWidget *source_combo_box; GtkWindow *parent; - g_warn_if_fail (book == NULL); + g_warn_if_fail (client == NULL); parent = eab_editor_get_window (EAB_EDITOR (editor)); eab_load_error_dialog (GTK_WIDGET (parent), NULL, source, error); @@ -3005,17 +3002,18 @@ contact_editor_book_loaded_cb (ESource *source, E_SOURCE_COMBO_BOX (source_combo_box), source); g_error_free (error); - goto exit; - } + } else { + EBookClient *book_client; - g_return_if_fail (E_IS_BOOK (book)); + book_client = E_BOOK_CLIENT (client); + g_return_if_fail (book_client != NULL); - /* FIXME Write a private contact_editor_set_target_book(). */ - g_object_set (editor, "target_book", book, NULL); + /* FIXME Write a private contact_editor_set_target_client(). */ + g_object_set (editor, "target_client", book_client, NULL); - g_object_unref (book); + g_object_unref (book_client); + } -exit: g_object_unref (editor); } @@ -3034,20 +3032,19 @@ source_changed (ESourceComboBox *source_combo_box, EContactEditor *editor) editor->cancellable = NULL; } - if (e_source_equal (e_book_get_source (editor->target_book), source)) + if (e_source_equal (e_client_get_source (E_CLIENT (editor->target_client)), source)) return; - if (e_source_equal (e_book_get_source (editor->source_book), source)) { - g_object_set (editor, "target_book", editor->source_book, NULL); + if (e_source_equal (e_client_get_source (E_CLIENT (editor->source_client)), source)) { + g_object_set (editor, "target_client", editor->source_client, NULL); return; } editor->cancellable = g_cancellable_new (); - e_load_book_source_async ( - source, parent, editor->cancellable, - (GAsyncReadyCallback) contact_editor_book_loaded_cb, - g_object_ref (editor)); + e_client_utils_open_new (source, E_CLIENT_SOURCE_TYPE_CONTACTS, FALSE, editor->cancellable, + e_client_utils_authenticate_handler, parent, + contact_editor_book_loaded_cb, g_object_ref (editor)); } static void @@ -3348,10 +3345,15 @@ typedef struct { } EditorCloseStruct; static void -contact_moved_cb (EBook *book, const GError *error, EditorCloseStruct *ecs) +contact_removed_cb (GObject *source_object, GAsyncResult *result, gpointer user_data) { + EBookClient *book_client = E_BOOK_CLIENT (source_object); + EditorCloseStruct *ecs = user_data; EContactEditor *ce = ecs->ce; gboolean should_close = ecs->should_close; + GError *error = NULL; + + e_book_client_remove_contact_finish (book_client, result, &error); gtk_widget_set_sensitive (ce->app, TRUE); ce->in_async_call = FALSE; @@ -3364,44 +3366,43 @@ contact_moved_cb (EBook *book, const GError *error, EditorCloseStruct *ecs) if (should_close) { eab_editor_close (EAB_EDITOR (ce)); - } - else { + } else { ce->changed = FALSE; - g_object_ref (ce->target_book); - g_object_unref (ce->source_book); - ce->source_book = ce->target_book; + g_object_ref (ce->target_client); + g_object_unref (ce->source_client); + ce->source_client = ce->target_client; sensitize_all (ce); } + if (error) + g_error_free (error); + g_object_unref (ce); g_free (ecs->new_id); g_free (ecs); } static void -contact_added_cb (EBook *book, - const GError *error, - const gchar *id, - EditorCloseStruct *ecs) +contact_added_cb (EBookClient *book_client, const GError *error, const gchar *id, gpointer closure) { + EditorCloseStruct *ecs = closure; EContactEditor *ce = ecs->ce; gboolean should_close = ecs->should_close; - if (ce->source_book != ce->target_book && e_book_is_writable (ce->source_book) && + if (ce->source_client != ce->target_client && !e_client_is_readonly (E_CLIENT (ce->source_client)) && !error && ce->is_new_contact == FALSE) { ecs->new_id = g_strdup (id); - e_book_remove_contact_async ( - ce->source_book, ce->contact, - (EBookAsyncCallback) contact_moved_cb, ecs); + e_book_client_remove_contact ( + ce->source_client, ce->contact, NULL, contact_removed_cb, ecs); return; } gtk_widget_set_sensitive (ce->app, TRUE); ce->in_async_call = FALSE; - e_contact_set (ce->contact, E_CONTACT_UID, (gchar *) id); + e_contact_set (ce->contact, E_CONTACT_UID, id); eab_editor_contact_added (EAB_EDITOR (ce), error, ce->contact); @@ -3410,8 +3411,7 @@ contact_added_cb (EBook *book, if (should_close) { eab_editor_close (EAB_EDITOR (ce)); - } - else { + } else { ce->changed = FALSE; sensitize_all (ce); } @@ -3422,8 +3422,9 @@ contact_added_cb (EBook *book, } static void -contact_modified_cb (EBook *book, const GError *error, EditorCloseStruct *ecs) +contact_modified_cb (EBookClient *book_client, const GError *error, gpointer closure) { + EditorCloseStruct *ecs = closure; EContactEditor *ce = ecs->ce; gboolean should_close = ecs->should_close; @@ -3446,6 +3447,20 @@ contact_modified_cb (EBook *book, const GError *error, EditorCloseStruct *ecs) g_free (ecs); } +static void +contact_modified_ready_cb (GObject *source_object, GAsyncResult *result, gpointer user_data) +{ + EBookClient *book_client = E_BOOK_CLIENT (source_object); + GError *error = NULL; + + e_book_client_modify_contact_finish (book_client, result, &error); + + contact_modified_cb (book_client, error, user_data); + + if (error) + g_error_free (error); +} + /* Emits the signal to request saving a contact */ static void real_save_contact (EContactEditor *ce, gboolean should_close) @@ -3461,23 +3476,24 @@ real_save_contact (EContactEditor *ce, gboolean should_close) gtk_widget_set_sensitive (ce->app, FALSE); ce->in_async_call = TRUE; - if (ce->source_book != ce->target_book) { + if (ce->source_client != ce->target_client) { /* Two-step move; add to target, then remove from source */ eab_merging_book_add_contact ( - ce->target_book, ce->contact, - (EBookIdAsyncCallback) contact_added_cb, ecs); + ce->target_client, ce->contact, + contact_added_cb, ecs); } else { if (ce->is_new_contact) eab_merging_book_add_contact ( - ce->target_book, ce->contact, - (EBookIdAsyncCallback) contact_added_cb, ecs); + ce->target_client, ce->contact, + contact_added_cb, ecs); else if (ce->check_merge) - eab_merging_book_commit_contact ( - ce->target_book, ce->contact, - (EBookAsyncCallback) contact_modified_cb, ecs); + eab_merging_book_modify_contact ( + ce->target_client, ce->contact, + contact_modified_cb, ecs); else - e_book_commit_contact_async (ce->target_book, ce->contact, - (EBookAsyncCallback) contact_modified_cb, ecs); + e_book_client_modify_contact ( + ce->target_client, ce->contact, NULL, + contact_modified_ready_cb, ecs); } } @@ -3488,10 +3504,10 @@ save_contact (EContactEditor *ce, gboolean should_close) const gchar *name_entry_string, *file_as_entry_string, *company_name_string; GtkWidget *entry_fullname, *entry_file_as, *company_name; - if (!ce->target_book) + if (!ce->target_client) return; - if (ce->target_editable && !e_book_is_writable (ce->source_book)) { + if (ce->target_editable && e_client_is_readonly (E_CLIENT (ce->source_client))) { if (e_alert_run_dialog_for_args ( GTK_WINDOW (ce->app), "addressbook:prompt-move", @@ -3592,7 +3608,7 @@ e_contact_editor_is_valid (EABEditor *editor) EContactEditor *ce = E_CONTACT_EDITOR (editor); GtkWidget *widget; gboolean validation_error = FALSE; - EIterator *iter; + GSList *iter; GString *errmsg = g_string_new (_("The contact data is invalid:\n\n")); widget = e_builder_get_widget (ce->builder, "dateedit-birthday"); @@ -3610,11 +3626,8 @@ e_contact_editor_is_valid (EABEditor *editor) validation_error = TRUE; } - iter = e_list_get_iterator (ce->required_fields); - for (e_iterator_last (iter); - e_iterator_is_valid (iter); - e_iterator_prev (iter)) { - const gchar *field_name = e_iterator_get (iter); + for (iter = ce->required_fields; iter; iter = iter->next) { + const gchar *field_name = iter->data; EContactField field_id = e_contact_field_id (field_name); if (is_non_string_field (field_id)) { @@ -3967,11 +3980,11 @@ e_contact_editor_dispose (GObject *object) } if (e_contact_editor->writable_fields) { - g_object_unref (e_contact_editor->writable_fields); + e_client_util_free_string_slist (e_contact_editor->writable_fields); e_contact_editor->writable_fields = NULL; } if (e_contact_editor->required_fields) { - g_object_unref (e_contact_editor->required_fields); + e_client_util_free_string_slist (e_contact_editor->required_fields); e_contact_editor->required_fields = NULL; } if (e_contact_editor->contact) { @@ -3979,17 +3992,17 @@ e_contact_editor_dispose (GObject *object) e_contact_editor->contact = NULL; } - if (e_contact_editor->source_book) { - g_object_unref (e_contact_editor->source_book); - e_contact_editor->source_book = NULL; + if (e_contact_editor->source_client) { + g_object_unref (e_contact_editor->source_client); + e_contact_editor->source_client = NULL; } - if (e_contact_editor->target_book) { + if (e_contact_editor->target_client) { g_signal_handler_disconnect ( - e_contact_editor->target_book, + e_contact_editor->target_client, e_contact_editor->target_editable_id); - g_object_unref (e_contact_editor->target_book); - e_contact_editor->target_book = NULL; + g_object_unref (e_contact_editor->target_client); + e_contact_editor->target_client = NULL; } if (e_contact_editor->name) { @@ -4012,46 +4025,78 @@ e_contact_editor_dispose (GObject *object) } static void -supported_fields_cb (EBook *book, - const GError *error, - EList *fields, - EContactEditor *ce) +supported_fields_cb (GObject *source_object, GAsyncResult *result, gpointer user_data) { + EBookClient *book_client = E_BOOK_CLIENT (source_object); + EContactEditor *ce = user_data; + gchar *prop_value = NULL; + GSList *fields; + GError *error = NULL; + + if (!e_client_get_backend_property_finish (E_CLIENT (book_client), result, &prop_value, &error)) + prop_value = NULL; + + if (error) { + g_debug ("%s: Failed to get supported fields: %s", G_STRFUNC, error->message); + g_error_free (error); + } + if (!g_slist_find (eab_editor_get_all_editors (), ce)) { g_warning ( "supported_fields_cb called for book that's still " "around, but contact editor that's been destroyed."); + g_free (prop_value); return; } + fields = e_client_util_parse_comma_strings (prop_value); + g_object_set (ce, "writable_fields", fields, NULL); + e_client_util_free_string_slist (fields); + g_free (prop_value); + eab_editor_show (EAB_EDITOR (ce)); sensitize_all (ce); } static void -required_fields_cb (EBook *book, - const GError *error, - EList *fields, - EContactEditor *ce) +required_fields_cb (GObject *source_object, GAsyncResult *result, gpointer user_data) { + EBookClient *book_client = E_BOOK_CLIENT (source_object); + EContactEditor *ce = user_data; + gchar *prop_value = NULL; + GSList *fields; + GError *error = NULL; + + if (!e_client_get_backend_property_finish (E_CLIENT (book_client), result, &prop_value, &error)) + prop_value = NULL; + + if (error) { + g_debug ("%s: Failed to get supported fields: %s", G_STRFUNC, error->message); + g_error_free (error); + } if (!g_slist_find (eab_editor_get_all_editors (), ce)) { g_warning ( "supported_fields_cb called for book that's still " "around, but contact editor that's been destroyed."); + g_free (prop_value); return; } + fields = e_client_util_parse_comma_strings (prop_value); + g_object_set (ce, "required_fields", fields, NULL); + e_client_util_free_string_slist (fields); + g_free (prop_value); } EABEditor * e_contact_editor_new (EShell *shell, - EBook *book, + EBookClient *book_client, EContact *contact, gboolean is_new_contact, gboolean editable) @@ -4059,34 +4104,29 @@ e_contact_editor_new (EShell *shell, EABEditor *editor; g_return_val_if_fail (E_IS_SHELL (shell), NULL); - g_return_val_if_fail (E_IS_BOOK (book), NULL); + g_return_val_if_fail (E_IS_BOOK_CLIENT (book_client), NULL); g_return_val_if_fail (E_IS_CONTACT (contact), NULL); editor = g_object_new (E_TYPE_CONTACT_EDITOR, "shell", shell, NULL); g_object_set ( editor, - "source_book", book, + "source_client", book_client, "contact", contact, "is_new_contact", is_new_contact, "editable", editable, NULL); - if (book) - e_book_get_supported_fields_async ( - book, (EBookEListAsyncCallback) - supported_fields_cb, editor); - return editor; } static void -writable_changed (EBook *book, gboolean writable, EContactEditor *ce) +notify_readonly_cb (EBookClient *book_client, EContactEditor *ce) { gint new_target_editable; gboolean changed = FALSE; - new_target_editable = e_book_is_writable (ce->target_book); + new_target_editable = !e_client_is_readonly (E_CLIENT (ce->target_client)); if (ce->target_editable != new_target_editable) changed = TRUE; @@ -4108,41 +4148,35 @@ e_contact_editor_set_property (GObject *object, editor = E_CONTACT_EDITOR (object); switch (prop_id) { - case PROP_SOURCE_BOOK: { + case PROP_SOURCE_CLIENT: { gboolean writable; gboolean changed = FALSE; - EBook *source_book; + EBookClient *source_client; - source_book = E_BOOK (g_value_get_object (value)); + source_client = E_BOOK_CLIENT (g_value_get_object (value)); - if (source_book == editor->source_book) + if (source_client == editor->source_client) break; - if (editor->source_book) - g_object_unref (editor->source_book); + if (editor->source_client) + g_object_unref (editor->source_client); - editor->source_book = source_book; - g_object_ref (editor->source_book); + editor->source_client = source_client; + g_object_ref (editor->source_client); - if (!editor->target_book) { - editor->target_book = editor->source_book; - g_object_ref (editor->target_book); + if (!editor->target_client) { + editor->target_client = editor->source_client; + g_object_ref (editor->target_client); editor->target_editable_id = g_signal_connect ( - editor->target_book, "writable_status", - G_CALLBACK (writable_changed), editor); - - e_book_get_supported_fields_async ( - editor->target_book, - (EBookEListAsyncCallback) - supported_fields_cb, editor); - e_book_get_required_fields_async ( - editor->target_book, - (EBookEListAsyncCallback) - required_fields_cb, editor); + editor->target_client, "notify::readonly", + G_CALLBACK (notify_readonly_cb), editor); + + e_client_get_backend_property (E_CLIENT (editor->target_client), BOOK_BACKEND_PROPERTY_SUPPORTED_FIELDS, NULL, supported_fields_cb, editor); + e_client_get_backend_property (E_CLIENT (editor->target_client), BOOK_BACKEND_PROPERTY_REQUIRED_FIELDS, NULL, required_fields_cb, editor); } - writable = e_book_is_writable (editor->target_book); + writable = !e_client_is_readonly (E_CLIENT (editor->target_client)); if (writable != editor->target_editable) { editor->target_editable = writable; changed = TRUE; @@ -4154,43 +4188,35 @@ e_contact_editor_set_property (GObject *object, break; } - case PROP_TARGET_BOOK: { + case PROP_TARGET_CLIENT: { gboolean writable; gboolean changed = FALSE; - EBook *target_book; + EBookClient *target_client; - target_book = E_BOOK (g_value_get_object (value)); + target_client = E_BOOK_CLIENT (g_value_get_object (value)); - if (target_book == editor->target_book) + if (target_client == editor->target_client) break; - if (editor->target_book) { - g_signal_handler_disconnect ( - editor->target_book, - editor->target_editable_id); - g_object_unref (editor->target_book); + if (editor->target_client) { + g_signal_handler_disconnect (editor->target_client, editor->target_editable_id); + g_object_unref (editor->target_client); } - editor->target_book = target_book; - g_object_ref (editor->target_book); + editor->target_client = target_client; + g_object_ref (editor->target_client); editor->target_editable_id = g_signal_connect ( - editor->target_book, "writable_status", - G_CALLBACK (writable_changed), editor); - - e_book_get_supported_fields_async ( - editor->target_book, - (EBookEListAsyncCallback) - supported_fields_cb, editor); - - e_book_get_required_fields_async ( - editor->target_book, - (EBookEListAsyncCallback) - required_fields_cb, editor); + editor->target_client, "notify::readonly", + G_CALLBACK (notify_readonly_cb), editor); + + e_client_get_backend_property (E_CLIENT (editor->target_client), BOOK_BACKEND_PROPERTY_SUPPORTED_FIELDS, NULL, supported_fields_cb, editor); + e_client_get_backend_property (E_CLIENT (editor->target_client), BOOK_BACKEND_PROPERTY_REQUIRED_FIELDS, NULL, required_fields_cb, editor); + if (!editor->is_new_contact) editor->changed = TRUE; - writable = e_book_is_writable (editor->target_book); + writable = !e_client_is_readonly (E_CLIENT (editor->target_client)); if (writable != editor->target_editable) { editor->target_editable = writable; @@ -4238,24 +4264,16 @@ e_contact_editor_set_property (GObject *object, } case PROP_WRITABLE_FIELDS: if (editor->writable_fields) - g_object_unref (editor->writable_fields); + e_client_util_free_string_slist (editor->writable_fields); - editor->writable_fields = g_value_get_object (value); - if (editor->writable_fields) - g_object_ref (editor->writable_fields); - else - editor->writable_fields = e_list_new (NULL, NULL, NULL); + editor->writable_fields = e_client_util_copy_string_slist (NULL, g_value_get_pointer (value)); sensitize_all (editor); break; case PROP_REQUIRED_FIELDS: if (editor->required_fields) - g_object_unref (editor->required_fields); - editor->required_fields = g_value_get_object (value); - if (editor->required_fields) - g_object_ref (editor->required_fields); - else - editor->required_fields = e_list_new (NULL, NULL, NULL); + e_client_util_free_string_slist (editor->required_fields); + editor->required_fields = e_client_util_copy_string_slist (NULL, g_value_get_pointer (value)); break; default: G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec); @@ -4274,12 +4292,12 @@ e_contact_editor_get_property (GObject *object, e_contact_editor = E_CONTACT_EDITOR (object); switch (prop_id) { - case PROP_SOURCE_BOOK: - g_value_set_object (value, e_contact_editor->source_book); + case PROP_SOURCE_CLIENT: + g_value_set_object (value, e_contact_editor->source_client); break; - case PROP_TARGET_BOOK: - g_value_set_object (value, e_contact_editor->target_book); + case PROP_TARGET_CLIENT: + g_value_set_object (value, e_contact_editor->target_client); break; case PROP_CONTACT: @@ -4303,20 +4321,10 @@ e_contact_editor_get_property (GObject *object, break; case PROP_WRITABLE_FIELDS: - if (e_contact_editor->writable_fields) - g_value_set_object ( - value, e_list_duplicate ( - e_contact_editor->writable_fields)); - else - g_value_set_object (value, NULL); + g_value_set_pointer (value, e_contact_editor->writable_fields); break; case PROP_REQUIRED_FIELDS: - if (e_contact_editor->required_fields) - g_value_set_object ( - value, e_list_duplicate ( - e_contact_editor->required_fields)); - else - g_value_set_object (value, NULL); + g_value_set_pointer (value, e_contact_editor->required_fields); break; default: G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec); -- cgit v1.2.3 From adc1173159d4d5d953340f8f3c813681007de524 Mon Sep 17 00:00:00 2001 From: Milan Crha Date: Mon, 27 Jun 2011 18:04:57 +0200 Subject: Check for cancelled GIO operation error code too --- addressbook/gui/contact-editor/e-contact-editor.c | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) (limited to 'addressbook/gui/contact-editor/e-contact-editor.c') diff --git a/addressbook/gui/contact-editor/e-contact-editor.c b/addressbook/gui/contact-editor/e-contact-editor.c index 4088837f90..7730f17a53 100644 --- a/addressbook/gui/contact-editor/e-contact-editor.c +++ b/addressbook/gui/contact-editor/e-contact-editor.c @@ -213,7 +213,8 @@ e_contact_editor_contact_added (EABEditor *editor, if (!error) return; - if (g_error_matches (error, E_CLIENT_ERROR, E_CLIENT_ERROR_CANCELLED)) + if (g_error_matches (error, E_CLIENT_ERROR, E_CLIENT_ERROR_CANCELLED) || + g_error_matches (error, G_IO_ERROR, G_IO_ERROR_CANCELLED)) return; eab_error_dialog (NULL, _("Error adding contact"), error); @@ -227,7 +228,8 @@ e_contact_editor_contact_modified (EABEditor *editor, if (!error) return; - if (g_error_matches (error, E_CLIENT_ERROR, E_CLIENT_ERROR_CANCELLED)) + if (g_error_matches (error, E_CLIENT_ERROR, E_CLIENT_ERROR_CANCELLED) || + g_error_matches (error, G_IO_ERROR, G_IO_ERROR_CANCELLED)) return; eab_error_dialog (NULL, _("Error modifying contact"), error); @@ -241,7 +243,8 @@ e_contact_editor_contact_deleted (EABEditor *editor, if (!error) return; - if (g_error_matches (error, E_CLIENT_ERROR, E_CLIENT_ERROR_CANCELLED)) + if (g_error_matches (error, E_CLIENT_ERROR, E_CLIENT_ERROR_CANCELLED) || + g_error_matches (error, G_IO_ERROR, G_IO_ERROR_CANCELLED)) return; eab_error_dialog (NULL, _("Error removing contact"), error); @@ -2983,8 +2986,8 @@ contact_editor_book_loaded_cb (GObject *source_object, if (!e_client_utils_open_new_finish (source, result, &client, &error)) client = NULL; - if (g_error_matches (error, G_IO_ERROR, G_IO_ERROR_CANCELLED) || - g_error_matches (error, E_CLIENT_ERROR, E_CLIENT_ERROR_CANCELLED)) { + if (g_error_matches (error, E_CLIENT_ERROR, E_CLIENT_ERROR_CANCELLED) || + g_error_matches (error, G_IO_ERROR, G_IO_ERROR_CANCELLED)) { g_warn_if_fail (client == NULL); g_error_free (error); } else if (error != NULL) { -- cgit v1.2.3 From ae9db3ed236b0c734fd12c8dc8c99764626bf0b8 Mon Sep 17 00:00:00 2001 From: Matthew Barnes Date: Fri, 1 Jul 2011 00:07:26 -0400 Subject: Coding style and whitespace cleanup. --- addressbook/gui/contact-editor/e-contact-editor.c | 484 ++++++++++++++-------- 1 file changed, 317 insertions(+), 167 deletions(-) (limited to 'addressbook/gui/contact-editor/e-contact-editor.c') diff --git a/addressbook/gui/contact-editor/e-contact-editor.c b/addressbook/gui/contact-editor/e-contact-editor.c index 7730f17a53..3d76a401eb 100644 --- a/addressbook/gui/contact-editor/e-contact-editor.c +++ b/addressbook/gui/contact-editor/e-contact-editor.c @@ -393,7 +393,8 @@ entry_activated (EContactEditor *editor) /* FIXME: Linear time... */ static gboolean -is_field_supported (EContactEditor *editor, EContactField field_id) +is_field_supported (EContactEditor *editor, + EContactField field_id) { GSList *fields, *iter; const gchar *field; @@ -421,7 +422,9 @@ is_field_supported (EContactEditor *editor, EContactField field_id) /* This function tells you whether name_to_style will make sense. */ static gboolean -style_makes_sense (const EContactName *name, const gchar *company, gint style) +style_makes_sense (const EContactName *name, + const gchar *company, + gint style) { switch (style) { case 0: /* Fall Through */ @@ -453,7 +456,9 @@ style_makes_sense (const EContactName *name, const gchar *company, gint style) } static gchar * -name_to_style (const EContactName *name, const gchar *company, gint style) +name_to_style (const EContactName *name, + const gchar *company, + gint style) { gchar *string; gchar *strings[4], **stringptr; @@ -628,7 +633,8 @@ file_as_set_style (EContactEditor *editor, gint style) } static void -name_entry_changed (GtkWidget *widget, EContactEditor *editor) +name_entry_changed (GtkWidget *widget, + EContactEditor *editor) { gint style = 0; const gchar *string; @@ -643,11 +649,13 @@ name_entry_changed (GtkWidget *widget, EContactEditor *editor) sensitize_ok (editor); if (string && !*string) - gtk_window_set_title (GTK_WINDOW (editor->app), _("Contact Editor")); + gtk_window_set_title ( + GTK_WINDOW (editor->app), _("Contact Editor")); } static void -file_as_combo_changed (GtkWidget *widget, EContactEditor *editor) +file_as_combo_changed (GtkWidget *widget, + EContactEditor *editor) { GtkWidget *entry; gchar *string = NULL; @@ -663,7 +671,8 @@ file_as_combo_changed (GtkWidget *widget, EContactEditor *editor) g_free (title); } else { - gtk_window_set_title (GTK_WINDOW (editor->app), _("Contact Editor")); + gtk_window_set_title ( + GTK_WINDOW (editor->app), _("Contact Editor")); } sensitize_ok (editor); @@ -671,7 +680,8 @@ file_as_combo_changed (GtkWidget *widget, EContactEditor *editor) } static void -company_entry_changed (GtkWidget *widget, EContactEditor *editor) +company_entry_changed (GtkWidget *widget, + EContactEditor *editor) { gint style = 0; @@ -735,7 +745,8 @@ sensitize_ok (EContactEditor *ce) } static void -object_changed (GObject *object, EContactEditor *editor) +object_changed (GObject *object, + EContactEditor *editor) { if (!editor->target_editable) { g_warning ("non-editable contact editor has an editable field in it."); @@ -762,14 +773,17 @@ object_changed (GObject *object, EContactEditor *editor) } static void -image_chooser_changed (GtkWidget *widget, EContactEditor *editor) +image_chooser_changed (GtkWidget *widget, + EContactEditor *editor) { editor->image_set = TRUE; editor->image_changed = TRUE; } static void -set_entry_text (EContactEditor *editor, GtkEntry *entry, const gchar *string) +set_entry_text (EContactEditor *editor, + GtkEntry *entry, + const gchar *string) { const gchar *oldstring = gtk_entry_get_text (entry); @@ -786,7 +800,9 @@ set_entry_text (EContactEditor *editor, GtkEntry *entry, const gchar *string) } static void -set_combo_box_active (EContactEditor *editor, GtkComboBox *combo_box, gint active) +set_combo_box_active (EContactEditor *editor, + GtkComboBox *combo_box, + gint active) { g_signal_handlers_block_matched ( combo_box, G_SIGNAL_MATCH_DATA, 0, 0, NULL, NULL, editor); @@ -796,7 +812,8 @@ set_combo_box_active (EContactEditor *editor, GtkComboBox *combo_box, gint activ } static void -init_email_record_location (EContactEditor *editor, gint record) +init_email_record_location (EContactEditor *editor, + gint record) { GtkComboBox *location_combo_box; GtkWidget *email_entry; @@ -899,7 +916,9 @@ im_index_to_location (gint index) } static void -phone_index_to_type (gint index, const gchar **type_1, const gchar **type_2) +phone_index_to_type (gint index, + const gchar **type_1, + const gchar **type_2) { *type_1 = phones [index].type_1; *type_2 = phones [index].type_2; @@ -1153,7 +1172,9 @@ extract_email (EContactEditor *editor) } static void -sensitize_email_record (EContactEditor *editor, gint record, gboolean enabled) +sensitize_email_record (EContactEditor *editor, + gint record, + gboolean enabled) { GtkWidget *location_combo_box; GtkWidget *email_entry; @@ -1287,7 +1308,8 @@ expand_widget_list (EContactEditor *editor, } static void -expand_web (EContactEditor *editor, gboolean expanded) +expand_web (EContactEditor *editor, + gboolean expanded) { const gchar *names[] = { "label-videourl", "label-fburl", @@ -1299,7 +1321,8 @@ expand_web (EContactEditor *editor, gboolean expanded) } static void -expand_phone (EContactEditor *editor, gboolean expanded) +expand_phone (EContactEditor *editor, + gboolean expanded) { const gchar *names[] = { "entry-phone-2", "combobox-phone-2", @@ -1311,7 +1334,8 @@ expand_phone (EContactEditor *editor, gboolean expanded) } static void -expand_mail (EContactEditor *editor, gboolean expanded) +expand_mail (EContactEditor *editor, + gboolean expanded) { GtkTable *table; GtkWidget *check; @@ -1559,7 +1583,8 @@ init_phone (EContactEditor *editor) } static void -sensitize_phone_types (EContactEditor *editor, GtkWidget *combo_box) +sensitize_phone_types (EContactEditor *editor, + GtkWidget *combo_box) { GtkTreeModel *model; GtkTreeIter iter; @@ -1585,7 +1610,9 @@ sensitize_phone_types (EContactEditor *editor, GtkWidget *combo_box) } static void -sensitize_phone_record (EContactEditor *editor, gint record, gboolean enabled) +sensitize_phone_record (EContactEditor *editor, + gint record, + gboolean enabled) { GtkWidget *phone_type_combo_box; GtkWidget *phone_entry; @@ -1621,7 +1648,8 @@ sensitize_phone (EContactEditor *editor) } static void -init_im_record_location (EContactEditor *editor, gint record) +init_im_record_location (EContactEditor *editor, + gint record) { #ifdef ENABLE_IM_LOCATION @@ -1658,7 +1686,8 @@ init_im_record_location (EContactEditor *editor, gint record) } static void -init_im_record_service (EContactEditor *editor, gint record) +init_im_record_service (EContactEditor *editor, + gint record) { GtkWidget *service_combo_box; GtkListStore *store; @@ -1914,6 +1943,7 @@ extract_im (EContactEditor *editor) g_free (service_attr_list); } + static void sensitize_im_types (EContactEditor *editor, GtkWidget *combo_box) { @@ -2109,7 +2139,8 @@ fill_in_address_label_textview (EContactEditor *editor, GtkWidget *textview; GtkTextBuffer *text_buffer; - textview_name = g_strdup_printf ("textview-%s-address", address_name [record]); + textview_name = g_strdup_printf ( + "textview-%s-address", address_name [record]); textview = e_builder_get_widget (editor->builder, textview_name); g_free (textview_name); @@ -2498,27 +2529,33 @@ init_simple_field (EContactEditor *editor, GtkWidget *widget) g_signal_connect_swapped ( widget, "activate", G_CALLBACK (entry_activated), editor); + } else if (GTK_IS_COMBO_BOX (widget)) { changed_object = G_OBJECT (widget); g_signal_connect_swapped ( gtk_bin_get_child (GTK_BIN (widget)), "activate", G_CALLBACK (entry_activated), editor); + } else if (GTK_IS_TEXT_VIEW (widget)) { changed_object = G_OBJECT ( gtk_text_view_get_buffer (GTK_TEXT_VIEW (widget))); + } else if (E_IS_URL_ENTRY (widget)) { changed_object = G_OBJECT ( e_url_entry_get_entry (E_URL_ENTRY (widget))); g_signal_connect_swapped ( changed_object, "activate", G_CALLBACK (entry_activated), editor); + } else if (E_IS_DATE_EDIT (widget)) { changed_object = G_OBJECT (widget); + } else if (E_IS_IMAGE_CHOOSER (widget)) { changed_object = G_OBJECT (widget); g_signal_connect ( widget, "changed", G_CALLBACK (image_chooser_changed), editor); + } else if (GTK_IS_TOGGLE_BUTTON (widget)) { g_signal_connect ( widget, "toggled", @@ -2545,27 +2582,27 @@ fill_in_simple_field (EContactEditor *editor, GtkWidget *widget, gint field_id) gchar *text = e_contact_get (contact, field_id); gtk_entry_set_text (GTK_ENTRY (widget), STRING_MAKE_NON_NULL (text)); g_free (text); - } - else if (GTK_IS_COMBO_BOX (widget)) { + + } else if (GTK_IS_COMBO_BOX (widget)) { gchar *text = e_contact_get (contact, field_id); gtk_entry_set_text ( GTK_ENTRY (gtk_bin_get_child (GTK_BIN (widget))), STRING_MAKE_NON_NULL (text)); g_free (text); - } - else if (GTK_IS_TEXT_VIEW (widget)) { + + } else if (GTK_IS_TEXT_VIEW (widget)) { GtkTextBuffer *buffer = gtk_text_view_get_buffer (GTK_TEXT_VIEW (widget)); gchar *text = e_contact_get (contact, field_id); gtk_text_buffer_set_text (buffer, STRING_MAKE_NON_NULL (text), -1); g_free (text); - } - else if (E_IS_URL_ENTRY (widget)) { + + } else if (E_IS_URL_ENTRY (widget)) { GtkWidget *entry = e_url_entry_get_entry (E_URL_ENTRY (widget)); gchar *text = e_contact_get (contact, field_id); gtk_entry_set_text (GTK_ENTRY (entry), STRING_MAKE_NON_NULL (text)); g_free (text); - } - else if (E_IS_DATE_EDIT (widget)) { + + } else if (E_IS_DATE_EDIT (widget)) { EContactDate *date = e_contact_get (contact, field_id); if (date) e_date_edit_set_date ( @@ -2575,8 +2612,8 @@ fill_in_simple_field (EContactEditor *editor, GtkWidget *widget, gint field_id) e_date_edit_set_time (E_DATE_EDIT (widget), -1); e_contact_date_free (date); - } - else if (E_IS_IMAGE_CHOOSER (widget)) { + + } else if (E_IS_IMAGE_CHOOSER (widget)) { EContactPhoto *photo = e_contact_get (contact, field_id); if (photo && photo->type == E_CONTACT_PHOTO_TYPE_INLINED) { e_image_chooser_set_image_data ( @@ -2597,13 +2634,13 @@ fill_in_simple_field (EContactEditor *editor, GtkWidget *widget, gint field_id) } editor->image_changed = FALSE; e_contact_photo_free (photo); - } - else if (GTK_IS_TOGGLE_BUTTON (widget)) { + + } else if (GTK_IS_TOGGLE_BUTTON (widget)) { gboolean val = e_contact_get (contact, field_id) != NULL; gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (widget), val); - } - else { + + } else { g_warning (G_STRLOC ": Unhandled widget class in mappings!"); } @@ -2612,7 +2649,9 @@ fill_in_simple_field (EContactEditor *editor, GtkWidget *widget, gint field_id) } static void -extract_simple_field (EContactEditor *editor, GtkWidget *widget, gint field_id) +extract_simple_field (EContactEditor *editor, + GtkWidget *widget, + gint field_id) { EContact *contact; @@ -2621,15 +2660,14 @@ extract_simple_field (EContactEditor *editor, GtkWidget *widget, gint field_id) if (GTK_IS_ENTRY (widget)) { const gchar *text = gtk_entry_get_text (GTK_ENTRY (widget)); e_contact_set (contact, field_id, (gchar *) text); - } - else if (GTK_IS_COMBO_BOX_TEXT (widget)) { + + } else if (GTK_IS_COMBO_BOX_TEXT (widget)) { gchar *text = gtk_combo_box_text_get_active_text (GTK_COMBO_BOX_TEXT (widget)); e_contact_set (contact, field_id, text); g_free (text); - } - else if (GTK_IS_COMBO_BOX (widget)) { + } else if (GTK_IS_COMBO_BOX (widget)) { GtkTreeIter iter; gchar *text = NULL; @@ -2648,8 +2686,8 @@ extract_simple_field (EContactEditor *editor, GtkWidget *widget, gint field_id) e_contact_set (contact, field_id, text); g_free (text); - } - else if (GTK_IS_TEXT_VIEW (widget)) { + + } else if (GTK_IS_TEXT_VIEW (widget)) { GtkTextBuffer *buffer = gtk_text_view_get_buffer (GTK_TEXT_VIEW (widget)); GtkTextIter start, end; gchar *text; @@ -2659,13 +2697,13 @@ extract_simple_field (EContactEditor *editor, GtkWidget *widget, gint field_id) text = gtk_text_buffer_get_text (buffer, &start, &end, FALSE); e_contact_set (contact, field_id, text); g_free (text); - } - else if (E_IS_URL_ENTRY (widget)) { + + } else if (E_IS_URL_ENTRY (widget)) { GtkWidget *entry = e_url_entry_get_entry (E_URL_ENTRY (widget)); const gchar *text = gtk_entry_get_text (GTK_ENTRY (entry)); e_contact_set (contact, field_id, (gchar *) text); - } - else if (E_IS_DATE_EDIT (widget)) { + + } else if (E_IS_DATE_EDIT (widget)) { EContactDate date; if (e_date_edit_get_date ( E_DATE_EDIT (widget), @@ -2675,13 +2713,12 @@ extract_simple_field (EContactEditor *editor, GtkWidget *widget, gint field_id) e_contact_set (contact, field_id, &date); else e_contact_set (contact, field_id, NULL); - } - else if (E_IS_IMAGE_CHOOSER (widget)) { + + } else if (E_IS_IMAGE_CHOOSER (widget)) { EContactPhoto photo; photo.type = E_CONTACT_PHOTO_TYPE_INLINED; photo.data.inlined.mime_type = NULL; - if (editor->image_changed) - { + if (editor->image_changed) { gchar *img_buff = NULL; if (editor->image_set && e_image_chooser_get_image_data ( @@ -2739,8 +2776,7 @@ extract_simple_field (EContactEditor *editor, GtkWidget *widget, gint field_id) g_free (format_name); g_object_unref (new); } - } - else if (prompt_response == GTK_RESPONSE_CANCEL) { + } else if (prompt_response == GTK_RESPONSE_CANCEL) { g_object_unref (pixbuf); g_object_unref (loader); return; @@ -2755,19 +2791,19 @@ extract_simple_field (EContactEditor *editor, GtkWidget *widget, gint field_id) g_free (photo.data.inlined.data); - } - else { + } else { editor->image_changed = FALSE; e_contact_set (contact, E_CONTACT_PHOTO, NULL); } } - } - else if (GTK_IS_TOGGLE_BUTTON (widget)) { - gboolean val = gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (widget)); - e_contact_set (contact, field_id, val?(gpointer) 1:NULL); - } - else { + } else if (GTK_IS_TOGGLE_BUTTON (widget)) { + gboolean val; + + val = gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (widget)); + e_contact_set (contact, field_id, val ? (gpointer) 1 : NULL); + + } else { g_warning (G_STRLOC ": Unhandled widget class in mappings!"); } } @@ -2809,12 +2845,20 @@ init_simple (EContactEditor *editor) /* Update file_as */ widget = e_builder_get_widget (editor->builder, "entry-fullname"); - g_signal_connect (widget, "changed", G_CALLBACK (name_entry_changed), editor); + g_signal_connect ( + widget, "changed", + G_CALLBACK (name_entry_changed), editor); + widget = e_builder_get_widget (editor->builder, "combo-file-as"); gtk_combo_box_set_entry_text_column (GTK_COMBO_BOX (widget), 0); - g_signal_connect (widget, "changed", G_CALLBACK (file_as_combo_changed), editor); + g_signal_connect ( + widget, "changed", + G_CALLBACK (file_as_combo_changed), editor); + widget = e_builder_get_widget (editor->builder, "entry-company"); - g_signal_connect (widget, "changed", G_CALLBACK (company_entry_changed), editor); + g_signal_connect ( + widget, "changed", + G_CALLBACK (company_entry_changed), editor); } static void @@ -2836,7 +2880,8 @@ fill_in_simple (EContactEditor *editor) if (!widget) continue; - fill_in_simple_field (editor, widget, simple_field_map[i].field_id); + fill_in_simple_field ( + editor, widget, simple_field_map[i].field_id); } /* --- Special cases --- */ @@ -2860,9 +2905,9 @@ fill_in_simple (EContactEditor *editor) gtk_window_set_title (GTK_WINDOW (editor->app), title); g_free (title); g_free (filename); - } - else - gtk_window_set_title (GTK_WINDOW (editor->app), _("Contact Editor")); + } else + gtk_window_set_title ( + GTK_WINDOW (editor->app), _("Contact Editor")); /* Update file_as combo options */ @@ -2886,7 +2931,8 @@ extract_simple (EContactEditor *editor) if (!widget) continue; - extract_simple_field (editor, widget, simple_field_map[i].field_id); + extract_simple_field ( + editor, widget, simple_field_map[i].field_id); } /* Special cases */ @@ -2956,6 +3002,7 @@ static void init_all (EContactEditor *editor) { GtkRequisition tab_req; + GtkWidget *widget; init_simple (editor); init_email (editor); @@ -2966,11 +3013,13 @@ init_all (EContactEditor *editor) /* with so many scrolled windows, we need to * do some manual sizing */ - gtk_widget_get_preferred_size ( - e_builder_get_widget (editor->builder, "vbox-size-leader"), &tab_req, NULL); + widget = e_builder_get_widget (editor->builder, "vbox-size-leader"); + gtk_widget_get_preferred_size (widget, &tab_req, NULL); + + widget = e_builder_get_widget ( + editor->builder, "scrolledwindow-size-leader"), gtk_widget_set_size_request ( - e_builder_get_widget (editor->builder, "scrolledwindow-size-leader"), - tab_req.width, tab_req.height + 8); + widget, tab_req.width, tab_req.height + 8); } static void @@ -2983,13 +3032,14 @@ contact_editor_book_loaded_cb (GObject *source_object, EClient *client = NULL; GError *error = NULL; - if (!e_client_utils_open_new_finish (source, result, &client, &error)) - client = NULL; + e_client_utils_open_new_finish (source, result, &client, &error); if (g_error_matches (error, E_CLIENT_ERROR, E_CLIENT_ERROR_CANCELLED) || g_error_matches (error, G_IO_ERROR, G_IO_ERROR_CANCELLED)) { g_warn_if_fail (client == NULL); g_error_free (error); + goto exit; + } else if (error != NULL) { GtkWidget *source_combo_box; GtkWindow *parent; @@ -3005,24 +3055,26 @@ contact_editor_book_loaded_cb (GObject *source_object, E_SOURCE_COMBO_BOX (source_combo_box), source); g_error_free (error); - } else { - EBookClient *book_client; + goto exit; + } - book_client = E_BOOK_CLIENT (client); - g_return_if_fail (book_client != NULL); + g_return_if_fail (E_IS_CLIENT (client)); - /* FIXME Write a private contact_editor_set_target_client(). */ - g_object_set (editor, "target_client", book_client, NULL); + /* FIXME Write a private contact_editor_set_target_client(). */ + g_object_set (editor, "target_client", client, NULL); - g_object_unref (book_client); - } + g_object_unref (client); +exit: g_object_unref (editor); } static void -source_changed (ESourceComboBox *source_combo_box, EContactEditor *editor) +source_changed (ESourceComboBox *source_combo_box, + EContactEditor *editor) { + ESource *target_source; + ESource *source_source; ESource *source; GtkWindow *parent; @@ -3035,23 +3087,32 @@ source_changed (ESourceComboBox *source_combo_box, EContactEditor *editor) editor->cancellable = NULL; } - if (e_source_equal (e_client_get_source (E_CLIENT (editor->target_client)), source)) + target_source = e_client_get_source (E_CLIENT (editor->target_client)); + source_source = e_client_get_source (E_CLIENT (editor->source_client)); + + if (e_source_equal (target_source, source)) return; - if (e_source_equal (e_client_get_source (E_CLIENT (editor->source_client)), source)) { - g_object_set (editor, "target_client", editor->source_client, NULL); + if (e_source_equal (source_source, source)) { + g_object_set ( + editor, "target_client", + editor->source_client, NULL); return; } editor->cancellable = g_cancellable_new (); - e_client_utils_open_new (source, E_CLIENT_SOURCE_TYPE_CONTACTS, FALSE, editor->cancellable, + e_client_utils_open_new ( + source, E_CLIENT_SOURCE_TYPE_CONTACTS, + FALSE, editor->cancellable, e_client_utils_authenticate_handler, parent, contact_editor_book_loaded_cb, g_object_ref (editor)); } static void -full_name_response (GtkDialog *dialog, gint response, EContactEditor *editor) +full_name_response (GtkDialog *dialog, + gint response, + EContactEditor *editor) { EContactName *name; GtkWidget *fname_widget; @@ -3065,13 +3126,19 @@ full_name_response (GtkDialog *dialog, gint response, EContactEditor *editor) style = file_as_get_style (editor); - fname_widget = e_builder_get_widget(editor->builder, "entry-fullname"); - if (fname_widget && GTK_IS_ENTRY (fname_widget)) { + fname_widget = e_builder_get_widget ( + editor->builder, "entry-fullname"); + + if (GTK_IS_ENTRY (fname_widget)) { + GtkEntry *entry; gchar *full_name = e_contact_name_to_string (name); - const gchar *old_full_name = gtk_entry_get_text (GTK_ENTRY (fname_widget)); + const gchar *old_full_name; + + entry = GTK_ENTRY (fname_widget); + old_full_name = gtk_entry_get_text (entry); if (strcmp (full_name, old_full_name)) - gtk_entry_set_text (GTK_ENTRY (fname_widget), full_name); + gtk_entry_set_text (entry, full_name); g_free (full_name); } @@ -3080,22 +3147,25 @@ full_name_response (GtkDialog *dialog, gint response, EContactEditor *editor) file_as_set_style (editor, style); } + gtk_widget_destroy (GTK_WIDGET (dialog)); editor->fullname_dialog = NULL; } static gint -full_name_editor_delete_event_cb (GtkWidget *widget, GdkEvent *event, gpointer data) +full_name_editor_delete_event_cb (GtkWidget *widget, + GdkEvent *event, + gpointer data) { - if (widget) { - if (GTK_IS_WIDGET (widget)) - gtk_widget_destroy (widget); - } + if (GTK_IS_WIDGET (widget)) + gtk_widget_destroy (widget); + return TRUE; } static void -full_name_clicked (GtkWidget *button, EContactEditor *editor) +full_name_clicked (GtkWidget *button, + EContactEditor *editor) { GtkDialog *dialog; gboolean fullname_supported; @@ -3112,8 +3182,9 @@ full_name_clicked (GtkWidget *button, EContactEditor *editor) dialog, "editable", fullname_supported & editor->target_editable, NULL); - g_signal_connect(dialog, "response", - G_CALLBACK (full_name_response), editor); + g_signal_connect ( + dialog, "response", + G_CALLBACK (full_name_response), editor); /* Close the fullname dialog if the editor is closed */ g_signal_connect_swapped ( @@ -3125,7 +3196,9 @@ full_name_clicked (GtkWidget *button, EContactEditor *editor) } static void -categories_response (GtkDialog *dialog, gint response, EContactEditor *editor) +categories_response (GtkDialog *dialog, + gint response, + EContactEditor *editor) { const gchar *categories; GtkWidget *entry; @@ -3150,17 +3223,19 @@ categories_response (GtkDialog *dialog, gint response, EContactEditor *editor) } static gint -categories_editor_delete_event_cb (GtkWidget *widget, GdkEvent *event, gpointer data) +categories_editor_delete_event_cb (GtkWidget *widget, + GdkEvent *event, + gpointer data) { - if (widget) { - if (GTK_IS_WIDGET (widget)) - gtk_widget_destroy (widget); - } + if (GTK_IS_WIDGET (widget)) + gtk_widget_destroy (widget); + return TRUE; } static void -categories_clicked (GtkWidget *button, EContactEditor *editor) +categories_clicked (GtkWidget *button, + EContactEditor *editor) { gchar *categories = NULL; GtkDialog *dialog; @@ -3211,9 +3286,12 @@ image_selected (EContactEditor *editor) image_chooser = e_builder_get_widget (editor->builder, "image-chooser"); - g_signal_handlers_block_by_func (image_chooser, image_chooser_changed, editor); - e_image_chooser_set_from_file (E_IMAGE_CHOOSER (image_chooser), file_name); - g_signal_handlers_unblock_by_func (image_chooser, image_chooser_changed, editor); + g_signal_handlers_block_by_func ( + image_chooser, image_chooser_changed, editor); + e_image_chooser_set_from_file ( + E_IMAGE_CHOOSER (image_chooser), file_name); + g_signal_handlers_unblock_by_func ( + image_chooser, image_chooser_changed, editor); editor->image_set = TRUE; editor->image_changed = TRUE; @@ -3247,7 +3325,9 @@ image_cleared (EContactEditor *editor) } static void -file_chooser_response (GtkWidget *widget, gint response, EContactEditor *editor) +file_chooser_response (GtkWidget *widget, + gint response, + EContactEditor *editor) { if (response == GTK_RESPONSE_ACCEPT) image_selected (editor); @@ -3265,7 +3345,8 @@ file_selector_deleted (GtkWidget *widget) } static void -update_preview_cb (GtkFileChooser *file_chooser, gpointer data) +update_preview_cb (GtkFileChooser *file_chooser, + gpointer data) { GtkWidget *preview; gchar *filename = NULL; @@ -3296,7 +3377,8 @@ update_preview_cb (GtkFileChooser *file_chooser, gpointer data) } static void -image_clicked (GtkWidget *button, EContactEditor *editor) +image_clicked (GtkWidget *button, + EContactEditor *editor) { const gchar *title = _("Please select an image for this contact"); const gchar *no_image = _("_No image"); @@ -3348,7 +3430,9 @@ typedef struct { } EditorCloseStruct; static void -contact_removed_cb (GObject *source_object, GAsyncResult *result, gpointer user_data) +contact_removed_cb (GObject *source_object, + GAsyncResult *result, + gpointer user_data) { EBookClient *book_client = E_BOOK_CLIENT (source_object); EditorCloseStruct *ecs = user_data; @@ -3388,7 +3472,10 @@ contact_removed_cb (GObject *source_object, GAsyncResult *result, gpointer user_ } static void -contact_added_cb (EBookClient *book_client, const GError *error, const gchar *id, gpointer closure) +contact_added_cb (EBookClient *book_client, + const GError *error, + const gchar *id, + gpointer closure) { EditorCloseStruct *ecs = closure; EContactEditor *ce = ecs->ce; @@ -3425,7 +3512,9 @@ contact_added_cb (EBookClient *book_client, const GError *error, const gchar *id } static void -contact_modified_cb (EBookClient *book_client, const GError *error, gpointer closure) +contact_modified_cb (EBookClient *book_client, + const GError *error, + gpointer closure) { EditorCloseStruct *ecs = closure; EContactEditor *ce = ecs->ce; @@ -3451,7 +3540,9 @@ contact_modified_cb (EBookClient *book_client, const GError *error, gpointer clo } static void -contact_modified_ready_cb (GObject *source_object, GAsyncResult *result, gpointer user_data) +contact_modified_ready_cb (GObject *source_object, + GAsyncResult *result, + gpointer user_data) { EBookClient *book_client = E_BOOK_CLIENT (source_object); GError *error = NULL; @@ -3466,7 +3557,8 @@ contact_modified_ready_cb (GObject *source_object, GAsyncResult *result, gpointe /* Emits the signal to request saving a contact */ static void -real_save_contact (EContactEditor *ce, gboolean should_close) +real_save_contact (EContactEditor *ce, + gboolean should_close) { EditorCloseStruct *ecs; @@ -3501,10 +3593,13 @@ real_save_contact (EContactEditor *ce, gboolean should_close) } static void -save_contact (EContactEditor *ce, gboolean should_close) +save_contact (EContactEditor *ce, + gboolean should_close) { gchar *uid; - const gchar *name_entry_string, *file_as_entry_string, *company_name_string; + const gchar *name_entry_string; + const gchar *file_as_entry_string; + const gchar *company_name_string; GtkWidget *entry_fullname, *entry_file_as, *company_name; if (!ce->target_client) @@ -3528,9 +3623,13 @@ save_contact (EContactEditor *ce, gboolean should_close) if (strcmp (company_name_string , "")) { if (!strcmp (name_entry_string, "")) - gtk_entry_set_text (GTK_ENTRY (entry_fullname), company_name_string); + gtk_entry_set_text ( + GTK_ENTRY (entry_fullname), + company_name_string); if (!strcmp (file_as_entry_string, "")) - gtk_entry_set_text (GTK_ENTRY (entry_file_as), company_name_string); + gtk_entry_set_text ( + GTK_ENTRY (entry_file_as), + company_name_string); } extract_all (ce); @@ -3616,16 +3715,18 @@ e_contact_editor_is_valid (EABEditor *editor) widget = e_builder_get_widget (ce->builder, "dateedit-birthday"); if (!(e_date_edit_date_is_valid (E_DATE_EDIT (widget)))) { - g_string_append_printf (errmsg, _("'%s' has an invalid format"), - e_contact_pretty_name (E_CONTACT_BIRTH_DATE)); + g_string_append_printf ( + errmsg, _("'%s' has an invalid format"), + e_contact_pretty_name (E_CONTACT_BIRTH_DATE)); validation_error = TRUE; } widget = e_builder_get_widget (ce->builder, "dateedit-anniversary"); if (!(e_date_edit_date_is_valid (E_DATE_EDIT (widget)))) { - g_string_append_printf (errmsg, _("%s'%s' has an invalid format"), - validation_error ? ",\n" : "", - e_contact_pretty_name (E_CONTACT_ANNIVERSARY)); + g_string_append_printf ( + errmsg, _("%s'%s' has an invalid format"), + validation_error ? ",\n" : "", + e_contact_pretty_name (E_CONTACT_ANNIVERSARY)); validation_error = TRUE; } @@ -3635,20 +3736,24 @@ e_contact_editor_is_valid (EABEditor *editor) if (is_non_string_field (field_id)) { if (e_contact_get_const (ce->contact, field_id) == NULL) { - g_string_append_printf (errmsg, _("%s'%s' is empty"), - validation_error ? ",\n" : "", - e_contact_pretty_name (field_id)); + g_string_append_printf ( + errmsg, _("%s'%s' is empty"), + validation_error ? ",\n" : "", + e_contact_pretty_name (field_id)); validation_error = TRUE; break; } } else { - const gchar *text = e_contact_get_const (ce->contact, field_id); + const gchar *text; + + text = e_contact_get_const (ce->contact, field_id); if (STRING_IS_EMPTY (text)) { - g_string_append_printf (errmsg, _("%s'%s' is empty"), - validation_error ? ",\n" : "", - e_contact_pretty_name (field_id)); + g_string_append_printf ( + errmsg, _("%s'%s' is empty"), + validation_error ? ",\n" : "", + e_contact_pretty_name (field_id)); validation_error = TRUE; break; } @@ -3684,25 +3789,24 @@ e_contact_editor_get_window (EABEditor *editor) } static void -file_save_and_close_cb (GtkWidget *widget, gpointer data) +file_save_and_close_cb (GtkWidget *widget, + EContactEditor *ce) { - EContactEditor *ce; - - ce = E_CONTACT_EDITOR (data); save_contact (ce, TRUE); } static void -file_cancel_cb (GtkWidget *widget, gpointer data) +file_cancel_cb (GtkWidget *widget, + EContactEditor *ce) { - EContactEditor *ce = E_CONTACT_EDITOR (data); - eab_editor_close (EAB_EDITOR (ce)); } /* Callback used when the dialog box is destroyed */ static gint -app_delete_event_cb (GtkWidget *widget, GdkEvent *event, gpointer data) +app_delete_event_cb (GtkWidget *widget, + GdkEvent *event, + gpointer data) { EContactEditor *ce; @@ -3833,7 +3937,8 @@ expand_phone_toggle (EContactEditor *ce) { GtkWidget *phone_ext_table; - phone_ext_table = e_builder_get_widget (ce->builder, "table-phone-extended"); + phone_ext_table = e_builder_get_widget ( + ce->builder, "table-phone-extended"); expand_phone (ce, !gtk_widget_get_visible (phone_ext_table)); } @@ -3879,7 +3984,8 @@ e_contact_editor_init (EContactEditor *e_contact_editor) setup_tab_order (builder); - e_contact_editor->app = e_builder_get_widget (builder, "contact editor"); + e_contact_editor->app = + e_builder_get_widget (builder, "contact editor"); widget = e_contact_editor->app; gtk_widget_ensure_style (widget); @@ -3948,11 +4054,13 @@ e_contact_editor_init (EContactEditor *e_contact_editor) widget, "clicked", G_CALLBACK (expand_mail_toggle), e_contact_editor); - widget = e_builder_get_widget (e_contact_editor->builder, "entry-fullname"); + widget = e_builder_get_widget ( + e_contact_editor->builder, "entry-fullname"); if (widget) gtk_widget_grab_focus (widget); - widget = e_builder_get_widget (e_contact_editor->builder, "entry-categories"); + widget = e_builder_get_widget ( + e_contact_editor->builder, "entry-categories"); completion = e_category_completion_new (); gtk_entry_set_completion (GTK_ENTRY (widget), completion); g_object_unref (completion); @@ -3964,7 +4072,8 @@ e_contact_editor_init (EContactEditor *e_contact_editor) G_CALLBACK (app_delete_event_cb), e_contact_editor); /* set the icon */ - gtk_window_set_icon_name (GTK_WINDOW (e_contact_editor->app), "contact-editor"); + gtk_window_set_icon_name ( + GTK_WINDOW (e_contact_editor->app), "contact-editor"); /* show window */ gtk_widget_show (e_contact_editor->app); @@ -3983,13 +4092,17 @@ e_contact_editor_dispose (GObject *object) } if (e_contact_editor->writable_fields) { - e_client_util_free_string_slist (e_contact_editor->writable_fields); + e_client_util_free_string_slist ( + e_contact_editor->writable_fields); e_contact_editor->writable_fields = NULL; } + if (e_contact_editor->required_fields) { - e_client_util_free_string_slist (e_contact_editor->required_fields); + e_client_util_free_string_slist ( + e_contact_editor->required_fields); e_contact_editor->required_fields = NULL; } + if (e_contact_editor->contact) { g_object_unref (e_contact_editor->contact); e_contact_editor->contact = NULL; @@ -4028,19 +4141,27 @@ e_contact_editor_dispose (GObject *object) } static void -supported_fields_cb (GObject *source_object, GAsyncResult *result, gpointer user_data) +supported_fields_cb (GObject *source_object, + GAsyncResult *result, + gpointer user_data) { EBookClient *book_client = E_BOOK_CLIENT (source_object); EContactEditor *ce = user_data; gchar *prop_value = NULL; GSList *fields; + gboolean success; GError *error = NULL; - if (!e_client_get_backend_property_finish (E_CLIENT (book_client), result, &prop_value, &error)) + success = e_client_get_backend_property_finish ( + E_CLIENT (book_client), result, &prop_value, &error); + + if (!success) prop_value = NULL; - if (error) { - g_debug ("%s: Failed to get supported fields: %s", G_STRFUNC, error->message); + if (error != NULL) { + g_warning ( + "%s: Failed to get supported fields: %s", + G_STRFUNC, error->message); g_error_free (error); } @@ -4065,19 +4186,27 @@ supported_fields_cb (GObject *source_object, GAsyncResult *result, gpointer user } static void -required_fields_cb (GObject *source_object, GAsyncResult *result, gpointer user_data) +required_fields_cb (GObject *source_object, + GAsyncResult *result, + gpointer user_data) { EBookClient *book_client = E_BOOK_CLIENT (source_object); EContactEditor *ce = user_data; gchar *prop_value = NULL; GSList *fields; + gboolean success; GError *error = NULL; - if (!e_client_get_backend_property_finish (E_CLIENT (book_client), result, &prop_value, &error)) + success = e_client_get_backend_property_finish ( + E_CLIENT (book_client), result, &prop_value, &error); + + if (!success) prop_value = NULL; - if (error) { - g_debug ("%s: Failed to get supported fields: %s", G_STRFUNC, error->message); + if (error != NULL) { + g_warning ( + "%s: Failed to get supported fields: %s", + G_STRFUNC, error->message); g_error_free (error); } @@ -4175,8 +4304,15 @@ e_contact_editor_set_property (GObject *object, editor->target_client, "notify::readonly", G_CALLBACK (notify_readonly_cb), editor); - e_client_get_backend_property (E_CLIENT (editor->target_client), BOOK_BACKEND_PROPERTY_SUPPORTED_FIELDS, NULL, supported_fields_cb, editor); - e_client_get_backend_property (E_CLIENT (editor->target_client), BOOK_BACKEND_PROPERTY_REQUIRED_FIELDS, NULL, required_fields_cb, editor); + e_client_get_backend_property ( + E_CLIENT (editor->target_client), + BOOK_BACKEND_PROPERTY_SUPPORTED_FIELDS, + NULL, supported_fields_cb, editor); + + e_client_get_backend_property ( + E_CLIENT (editor->target_client), + BOOK_BACKEND_PROPERTY_REQUIRED_FIELDS, + NULL, required_fields_cb, editor); } writable = !e_client_is_readonly (E_CLIENT (editor->target_client)); @@ -4202,7 +4338,9 @@ e_contact_editor_set_property (GObject *object, break; if (editor->target_client) { - g_signal_handler_disconnect (editor->target_client, editor->target_editable_id); + g_signal_handler_disconnect ( + editor->target_client, + editor->target_editable_id); g_object_unref (editor->target_client); } @@ -4213,8 +4351,15 @@ e_contact_editor_set_property (GObject *object, editor->target_client, "notify::readonly", G_CALLBACK (notify_readonly_cb), editor); - e_client_get_backend_property (E_CLIENT (editor->target_client), BOOK_BACKEND_PROPERTY_SUPPORTED_FIELDS, NULL, supported_fields_cb, editor); - e_client_get_backend_property (E_CLIENT (editor->target_client), BOOK_BACKEND_PROPERTY_REQUIRED_FIELDS, NULL, required_fields_cb, editor); + e_client_get_backend_property ( + E_CLIENT (editor->target_client), + BOOK_BACKEND_PROPERTY_SUPPORTED_FIELDS, + NULL, supported_fields_cb, editor); + + e_client_get_backend_property ( + E_CLIENT (editor->target_client), + BOOK_BACKEND_PROPERTY_REQUIRED_FIELDS, + NULL, required_fields_cb, editor); if (!editor->is_new_contact) editor->changed = TRUE; @@ -4235,7 +4380,8 @@ e_contact_editor_set_property (GObject *object, case PROP_CONTACT: if (editor->contact) g_object_unref (editor->contact); - editor->contact = e_contact_duplicate (E_CONTACT (g_value_get_object (value))); + editor->contact = e_contact_duplicate ( + E_CONTACT (g_value_get_object (value))); fill_in_all (editor); editor->changed = FALSE; break; @@ -4269,14 +4415,18 @@ e_contact_editor_set_property (GObject *object, if (editor->writable_fields) e_client_util_free_string_slist (editor->writable_fields); - editor->writable_fields = e_client_util_copy_string_slist (NULL, g_value_get_pointer (value)); + editor->writable_fields = + e_client_util_copy_string_slist ( + NULL, g_value_get_pointer (value)); sensitize_all (editor); break; case PROP_REQUIRED_FIELDS: if (editor->required_fields) e_client_util_free_string_slist (editor->required_fields); - editor->required_fields = e_client_util_copy_string_slist (NULL, g_value_get_pointer (value)); + editor->required_fields = + e_client_util_copy_string_slist ( + NULL, g_value_get_pointer (value)); break; default: G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec); -- cgit v1.2.3 From fdd6d71ab45cb312053bd84213ada4f58c67f54c Mon Sep 17 00:00:00 2001 From: Milan Crha Date: Wed, 17 Aug 2011 08:57:32 +0200 Subject: Bug #656722 - Incorrect prototype of notify:: signal callback --- addressbook/gui/contact-editor/e-contact-editor.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'addressbook/gui/contact-editor/e-contact-editor.c') diff --git a/addressbook/gui/contact-editor/e-contact-editor.c b/addressbook/gui/contact-editor/e-contact-editor.c index 3d76a401eb..5dd02b48e6 100644 --- a/addressbook/gui/contact-editor/e-contact-editor.c +++ b/addressbook/gui/contact-editor/e-contact-editor.c @@ -4253,7 +4253,7 @@ e_contact_editor_new (EShell *shell, } static void -notify_readonly_cb (EBookClient *book_client, EContactEditor *ce) +notify_readonly_cb (EBookClient *book_client, GParamSpec *pspec, EContactEditor *ce) { gint new_target_editable; gboolean changed = FALSE; -- cgit v1.2.3 From 777c1cbd40eb63365f2c28e38f6a93beb2d1c9d1 Mon Sep 17 00:00:00 2001 From: Matthew Barnes Date: Tue, 16 Aug 2011 11:25:56 -0400 Subject: Coding style and whitespace cleanup. --- addressbook/gui/contact-editor/e-contact-editor.c | 89 ++++++++++++++--------- 1 file changed, 56 insertions(+), 33 deletions(-) (limited to 'addressbook/gui/contact-editor/e-contact-editor.c') diff --git a/addressbook/gui/contact-editor/e-contact-editor.c b/addressbook/gui/contact-editor/e-contact-editor.c index 5dd02b48e6..6ce9524afc 100644 --- a/addressbook/gui/contact-editor/e-contact-editor.c +++ b/addressbook/gui/contact-editor/e-contact-editor.c @@ -76,11 +76,11 @@ enum { static void e_contact_editor_init (EContactEditor *editor); static void e_contact_editor_class_init (EContactEditorClass *klass); static void e_contact_editor_set_property (GObject *object, - guint prop_id, + guint property_id, const GValue *value, GParamSpec *pspec); static void e_contact_editor_get_property (GObject *object, - guint prop_id, + guint property_id, GValue *value, GParamSpec *pspec); static void e_contact_editor_dispose (GObject *object); @@ -488,7 +488,7 @@ name_to_style (const EContactName *name, string = g_strjoinv(" ", strings); break; case 2: - midstrptr=midstring; + midstrptr = midstring; if (name) { if (name->family && *name->family) *(midstrptr++) = name->family; @@ -567,7 +567,8 @@ file_as_get_style (EContactEditor *editor) } static void -file_as_set_style (EContactEditor *editor, gint style) +file_as_set_style (EContactEditor *editor, + gint style) { gchar *string; gint i; @@ -1008,7 +1009,8 @@ get_ui_slot (EVCardAttribute *attr) } static void -set_ui_slot (EVCardAttribute *attr, gint slot) +set_ui_slot (EVCardAttribute *attr, + gint slot) { EVCardAttributeParam *param; gchar *slot_str; @@ -1524,7 +1526,8 @@ extract_phone (EContactEditor *editor) } static void -init_phone_record_type (EContactEditor *editor, gint record) +init_phone_record_type (EContactEditor *editor, + gint record) { GtkWidget *phone_type_combo_box; GtkWidget *phone_entry; @@ -1945,7 +1948,8 @@ extract_im (EContactEditor *editor) } static void -sensitize_im_types (EContactEditor *editor, GtkWidget *combo_box) +sensitize_im_types (EContactEditor *editor, + GtkWidget *combo_box) { GtkTreeModel *model; GtkTreeIter iter; @@ -1971,7 +1975,9 @@ sensitize_im_types (EContactEditor *editor, GtkWidget *combo_box) } static void -sensitize_im_record (EContactEditor *editor, gint record, gboolean enabled) +sensitize_im_record (EContactEditor *editor, + gint record, + gboolean enabled) { GtkWidget *service_combo_box; #ifdef ENABLE_IM_LOCATION @@ -2038,7 +2044,8 @@ init_personal (EContactEditor *editor) } static void -init_address_textview (EContactEditor *editor, gint record) +init_address_textview (EContactEditor *editor, + gint record) { gchar *textview_name; GtkWidget *textview; @@ -2078,7 +2085,8 @@ init_address_field (EContactEditor *editor, } static void -init_address_record (EContactEditor *editor, gint record) +init_address_record (EContactEditor *editor, + gint record) { init_address_textview (editor, record); init_address_field (editor, record, "city"); @@ -2325,7 +2333,8 @@ set_address_label (EContact *contact, } static void -extract_address_record (EContactEditor *editor, gint record) +extract_address_record (EContactEditor *editor, + gint record) { EContactAddress *address; @@ -2411,7 +2420,9 @@ sensitize_address_field (EContactEditor *editor, } static void -sensitize_address_record (EContactEditor *editor, gint record, gboolean enabled) +sensitize_address_record (EContactEditor *editor, + gint record, + gboolean enabled) { sensitize_address_textview (editor, record, enabled); sensitize_address_field (editor, record, "city", enabled); @@ -2520,7 +2531,8 @@ static FieldMapping simple_field_map[] = { }; static void -init_simple_field (EContactEditor *editor, GtkWidget *widget) +init_simple_field (EContactEditor *editor, + GtkWidget *widget) { GObject *changed_object = NULL; @@ -2569,7 +2581,9 @@ init_simple_field (EContactEditor *editor, GtkWidget *widget) } static void -fill_in_simple_field (EContactEditor *editor, GtkWidget *widget, gint field_id) +fill_in_simple_field (EContactEditor *editor, + GtkWidget *widget, + gint field_id) { EContact *contact; @@ -2707,9 +2721,9 @@ extract_simple_field (EContactEditor *editor, EContactDate date; if (e_date_edit_get_date ( E_DATE_EDIT (widget), - (gint *)&date.year, - (gint *)&date.month, - (gint *)&date.day)) + (gint *) &date.year, + (gint *) &date.month, + (gint *) &date.day)) e_contact_set (contact, field_id, &date); else e_contact_set (contact, field_id, NULL); @@ -2809,7 +2823,8 @@ extract_simple_field (EContactEditor *editor, } static void -sensitize_simple_field (GtkWidget *widget, gboolean enabled) +sensitize_simple_field (GtkWidget *widget, + gboolean enabled) { if (GTK_IS_ENTRY (widget)) gtk_editable_set_editable (GTK_EDITABLE (widget), enabled); @@ -3258,7 +3273,7 @@ categories_clicked (GtkWidget *button, return; } - g_signal_connect(dialog, "response", + g_signal_connect (dialog, "response", G_CALLBACK (categories_response), editor); /* Close the category dialog if the editor is closed*/ @@ -3649,7 +3664,8 @@ save_contact (EContactEditor *ce, } static void -e_contact_editor_save_contact (EABEditor *editor, gboolean should_close) +e_contact_editor_save_contact (EABEditor *editor, + gboolean should_close) { save_contact (E_CONTACT_EDITOR (editor), should_close); } @@ -3782,7 +3798,7 @@ e_contact_editor_is_changed (EABEditor *editor) return E_CONTACT_EDITOR (editor)->changed; } -static GtkWindow* +static GtkWindow * e_contact_editor_get_window (EABEditor *editor) { return GTK_WINDOW (E_CONTACT_EDITOR (editor)->app); @@ -3837,14 +3853,17 @@ app_delete_event_cb (GtkWidget *widget, } static void -show_help_cb (GtkWidget *widget, gpointer data) +show_help_cb (GtkWidget *widget, + gpointer data) { /* FIXME Pass a proper parent window. */ e_display_help (NULL, "usage-contact-cards"); } static GList * -add_to_tab_order (GList *list, GtkBuilder *builder, const gchar *name) +add_to_tab_order (GList *list, + GtkBuilder *builder, + const gchar *name) { GtkWidget *widget = e_builder_get_widget (builder, name); return g_list_prepend (list, widget); @@ -3857,7 +3876,7 @@ setup_tab_order (GtkBuilder *builder) GList *list = NULL; /* container = e_builder_get_widget(builder, "table-contact-editor-general"); - + * if (container) { list = add_to_tab_order(list, builder, "entry-fullname"); list = add_to_tab_order(list, builder, "entry-jobtitle"); @@ -3867,7 +3886,7 @@ setup_tab_order (GtkBuilder *builder) list = add_to_tab_order(list, builder, "entry-phone-2"); list = add_to_tab_order(list, builder, "entry-phone-3"); list = add_to_tab_order(list, builder, "entry-phone-4"); - + * list = add_to_tab_order(list, builder, "entry-email1"); list = add_to_tab_order(list, builder, "alignment-htmlmail"); list = add_to_tab_order(list, builder, "entry-web"); @@ -4253,12 +4272,16 @@ e_contact_editor_new (EShell *shell, } static void -notify_readonly_cb (EBookClient *book_client, GParamSpec *pspec, EContactEditor *ce) +notify_readonly_cb (EBookClient *book_client, + GParamSpec *pspec, + EContactEditor *ce) { + EClient *client; gint new_target_editable; gboolean changed = FALSE; - new_target_editable = !e_client_is_readonly (E_CLIENT (ce->target_client)); + client = E_CLIENT (ce->target_client); + new_target_editable = !e_client_is_readonly (client); if (ce->target_editable != new_target_editable) changed = TRUE; @@ -4271,7 +4294,7 @@ notify_readonly_cb (EBookClient *book_client, GParamSpec *pspec, EContactEditor static void e_contact_editor_set_property (GObject *object, - guint prop_id, + guint property_id, const GValue *value, GParamSpec *pspec) { @@ -4279,7 +4302,7 @@ e_contact_editor_set_property (GObject *object, editor = E_CONTACT_EDITOR (object); - switch (prop_id) { + switch (property_id) { case PROP_SOURCE_CLIENT: { gboolean writable; gboolean changed = FALSE; @@ -4429,14 +4452,14 @@ e_contact_editor_set_property (GObject *object, NULL, g_value_get_pointer (value)); break; default: - G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec); + G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec); break; } } static void e_contact_editor_get_property (GObject *object, - guint prop_id, + guint property_id, GValue *value, GParamSpec *pspec) { @@ -4444,7 +4467,7 @@ e_contact_editor_get_property (GObject *object, e_contact_editor = E_CONTACT_EDITOR (object); - switch (prop_id) { + switch (property_id) { case PROP_SOURCE_CLIENT: g_value_set_object (value, e_contact_editor->source_client); break; @@ -4480,7 +4503,7 @@ e_contact_editor_get_property (GObject *object, g_value_set_pointer (value, e_contact_editor->required_fields); break; default: - G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec); + G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec); break; } } -- cgit v1.2.3 From 824f5db34a3b291bbaf1ce515e1e632b81dda0af Mon Sep 17 00:00:00 2001 From: Milan Crha Date: Mon, 26 Sep 2011 11:25:02 +0200 Subject: Bug #637673 - Make phone fields one row and auto-expand when needed --- addressbook/gui/contact-editor/e-contact-editor.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'addressbook/gui/contact-editor/e-contact-editor.c') diff --git a/addressbook/gui/contact-editor/e-contact-editor.c b/addressbook/gui/contact-editor/e-contact-editor.c index 6ce9524afc..ea696f88b8 100644 --- a/addressbook/gui/contact-editor/e-contact-editor.c +++ b/addressbook/gui/contact-editor/e-contact-editor.c @@ -1327,7 +1327,7 @@ expand_phone (EContactEditor *editor, gboolean expanded) { const gchar *names[] = { - "entry-phone-2", "combobox-phone-2", + "entry-phone-3", "combobox-phone-3", "entry-phone-4", "combobox-phone-4", "table-phone-extended", NULL }; @@ -1401,7 +1401,7 @@ fill_in_phone_record (EContactEditor *editor, phone_type >= 0 ? phone_type : phones_default[record - 1]); set_entry_text (editor, GTK_ENTRY (phone_entry), phone ? phone : ""); - if (phone && *phone && record >= 5) + if (phone && *phone && record >= 3) expand_phone (editor, TRUE); } -- cgit v1.2.3 From b436b8468346c384edc6bde0f24b2ac0ce657e00 Mon Sep 17 00:00:00 2001 From: Rodrigo Moya Date: Thu, 13 Oct 2011 17:00:14 +0200 Subject: Migrate Contact Editor to GSettings --- addressbook/gui/contact-editor/e-contact-editor.c | 18 ++++-------------- 1 file changed, 4 insertions(+), 14 deletions(-) (limited to 'addressbook/gui/contact-editor/e-contact-editor.c') diff --git a/addressbook/gui/contact-editor/e-contact-editor.c b/addressbook/gui/contact-editor/e-contact-editor.c index 28b5b636fe..9ad6fc0612 100644 --- a/addressbook/gui/contact-editor/e-contact-editor.c +++ b/addressbook/gui/contact-editor/e-contact-editor.c @@ -2302,26 +2302,16 @@ set_address_label (EContact *contact, { gchar *address_label = NULL; gboolean format_address; - GConfClient *client; - GConfValue *value; + GSettings *settings; if (!address) { e_contact_set (contact, field, NULL); return; } - - client = gconf_client_get_default (); - value = gconf_client_get (client, - "/apps/evolution/addressbook/display/address_formatting", NULL); - g_object_unref (client); - - if (value) { - format_address = gconf_value_get_bool (value); - gconf_value_free (value); - } else { - format_address = TRUE; - } + settings = g_settings_new ("org.gnome.evolution.addressbook"); + format_address = g_settings_get_boolean (settings, "address-formatting"); + g_object_unref (settings); if (format_address) { address_label = eab_format_address (contact, -- cgit v1.2.3