From 88f39730dd7b2615ab78dbc53f7218a2a15787e0 Mon Sep 17 00:00:00 2001 From: Chris Toshok Date: Wed, 18 Feb 2004 07:30:06 +0000 Subject: add image_set slot. 2004-02-17 Chris Toshok * gui/contact-list-editor/e-contact-list-editor.h (struct _EContactListEditor): add image_set slot. * gui/contact-list-editor/e-contact-list-editor.c (list_image_changed_cb): set image_set = TRUE. (e_contact_list_editor_init): init image_set = FALSE (extract_info): only set the LOGO attribute if image_set = TRUE. * gui/contact-editor/e-contact-editor.h (struct _EContactEditor): add image_set slot. * gui/contact-editor/e-contact-editor.c (extract_info): only set the PHOTO attribute if image_set == TRUE. (image_chooser_changed): new function, set image_set = TRUE and call widget_changed. (e_contact_editor_init): init image_set to FALSE. (_address_arrow_pressed): quiet compiler. svn path=/trunk/; revision=24771 --- addressbook/gui/contact-editor/e-contact-editor.c | 20 +++++++++++++++----- addressbook/gui/contact-editor/e-contact-editor.h | 3 +++ .../gui/contact-list-editor/e-contact-list-editor.c | 11 +++++++---- .../gui/contact-list-editor/e-contact-list-editor.h | 3 +++ 4 files changed, 28 insertions(+), 9 deletions(-) (limited to 'addressbook/gui') diff --git a/addressbook/gui/contact-editor/e-contact-editor.c b/addressbook/gui/contact-editor/e-contact-editor.c index 0e60e5dea5..07e5ffd30e 100644 --- a/addressbook/gui/contact-editor/e-contact-editor.c +++ b/addressbook/gui/contact-editor/e-contact-editor.c @@ -1206,6 +1206,14 @@ company_entry_changed (GtkWidget *widget, EContactEditor *editor) widget_changed (widget, editor); } +static void +image_chooser_changed (GtkWidget *widget, EContactEditor *editor) +{ + editor->image_set = TRUE; + + widget_changed (widget, editor); +} + static void field_changed (GtkWidget *widget, EContactEditor *editor) { @@ -1334,7 +1342,7 @@ set_entry_changed_signals(EContactEditor *editor) widget = glade_xml_get_widget (editor->gui, "image-chooser"); if (widget && E_IS_IMAGE_CHOOSER (widget)) { g_signal_connect (widget, "changed", - G_CALLBACK (widget_changed), editor); + G_CALLBACK (image_chooser_changed), editor); } } @@ -1952,6 +1960,7 @@ e_contact_editor_init (EContactEditor *e_contact_editor) e_contact_editor->contact = NULL; e_contact_editor->changed = FALSE; + e_contact_editor->image_set = FALSE; e_contact_editor->in_async_call = FALSE; e_contact_editor->source_editable = TRUE; e_contact_editor->target_editable = TRUE; @@ -2640,7 +2649,7 @@ _address_arrow_pressed (GtkWidget *widget, GdkEventButton *button, EContactEdito EContactAddress *address = e_contact_get (editor->contact, i); gboolean checked; - checked = address; + checked = (address != NULL); gtk_check_menu_item_set_active ( GTK_CHECK_MENU_ITEM (editor->address_info [i - E_CONTACT_FIRST_ADDRESS_ID].widget), checked); @@ -3372,9 +3381,10 @@ extract_info(EContactEditor *editor) char *image_data; gsize image_data_len; - if (e_image_chooser_get_image_data (E_IMAGE_CHOOSER (widget), - &image_data, - &image_data_len)) { + if (editor->image_set + && e_image_chooser_get_image_data (E_IMAGE_CHOOSER (widget), + &image_data, + &image_data_len)) { EContactPhoto photo; photo.data = image_data; diff --git a/addressbook/gui/contact-editor/e-contact-editor.h b/addressbook/gui/contact-editor/e-contact-editor.h index 069cc7d0cc..220e2cf421 100644 --- a/addressbook/gui/contact-editor/e-contact-editor.h +++ b/addressbook/gui/contact-editor/e-contact-editor.h @@ -89,6 +89,9 @@ struct _EContactEditor /* Whether we are editing a new contact or an existing one */ guint is_new_contact : 1; + /* Whether the image chooser widget has been changed. */ + guint image_set : 1; + /* Whether the contact has been changed since bringing up the contact editor */ guint changed : 1; diff --git a/addressbook/gui/contact-list-editor/e-contact-list-editor.c b/addressbook/gui/contact-list-editor/e-contact-list-editor.c index c8df169c70..84b6a769ea 100644 --- a/addressbook/gui/contact-list-editor/e-contact-list-editor.c +++ b/addressbook/gui/contact-list-editor/e-contact-list-editor.c @@ -9,7 +9,7 @@ * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * General Public License for more details. * * You should have received a copy of the GNU General Public @@ -220,6 +220,7 @@ e_contact_list_editor_init (EContactListEditor *editor) editor->contact = NULL; editor->changed = FALSE; + editor->image_set = FALSE; editor->editable = TRUE; editor->in_async_call = FALSE; editor->is_new_list = FALSE; @@ -775,6 +776,7 @@ list_name_changed_cb (GtkWidget *w, EContactListEditor *editor) static void list_image_changed_cb (GtkWidget *w, EContactListEditor *editor) { + editor->image_set = TRUE; editor->changed = TRUE; command_state_changed (editor); } @@ -970,9 +972,10 @@ extract_info(EContactListEditor *editor) g_list_foreach (email_list, (GFunc) g_free, NULL); g_list_free (email_list); - if (e_image_chooser_get_image_data (E_IMAGE_CHOOSER (editor->list_image), - &image_data, - &image_data_len)) { + if (editor->image_set + && e_image_chooser_get_image_data (E_IMAGE_CHOOSER (editor->list_image), + &image_data, + &image_data_len)) { EContactPhoto photo; photo.data = image_data; diff --git a/addressbook/gui/contact-list-editor/e-contact-list-editor.h b/addressbook/gui/contact-list-editor/e-contact-list-editor.h index f9293116b6..574f9a5b55 100644 --- a/addressbook/gui/contact-list-editor/e-contact-list-editor.h +++ b/addressbook/gui/contact-list-editor/e-contact-list-editor.h @@ -68,6 +68,9 @@ struct _EContactListEditor /* Whether we are editing a new contact or an existing one */ guint is_new_list : 1; + /* Whether the image chooser widget has been changed. */ + guint image_set : 1; + /* Whether the contact has been changed since bringing up the contact editor */ guint changed : 1; -- cgit v1.2.3