aboutsummaryrefslogtreecommitdiffstats
path: root/addressbook/gui/contact-editor/e-contact-editor.c
diff options
context:
space:
mode:
Diffstat (limited to 'addressbook/gui/contact-editor/e-contact-editor.c')
-rw-r--r--addressbook/gui/contact-editor/e-contact-editor.c155
1 files changed, 15 insertions, 140 deletions
diff --git a/addressbook/gui/contact-editor/e-contact-editor.c b/addressbook/gui/contact-editor/e-contact-editor.c
index 3bd1780a05..aca452e78c 100644
--- a/addressbook/gui/contact-editor/e-contact-editor.c
+++ b/addressbook/gui/contact-editor/e-contact-editor.c
@@ -34,6 +34,7 @@
#include <gtk/gtkstock.h>
#include <gtk/gtkentry.h>
#include <gtk/gtklabel.h>
+#include <libgnomeui/gnome-popup-menu.h>
#include <libgnomeui/gnome-window-icon.h>
#include <libgnome/gnome-util.h>
#include <libgnome/gnome-i18n.h>
@@ -45,7 +46,6 @@
#include <gal/e-text/e-entry.h>
#include <libebook/e-address-western.h>
-#include <libedataserverui/e-source-option-menu.h>
#include <e-util/e-categories-master-list-wombat.h>
@@ -60,6 +60,7 @@
#include "widgets/misc/e-dateedit.h"
#include "widgets/misc/e-image-chooser.h"
#include "widgets/misc/e-url-entry.h"
+#include "widgets/misc/e-source-option-menu.h"
#include "shell/evolution-shell-component-utils.h"
#include "e-util/e-icon-factory.h"
@@ -119,8 +120,7 @@ enum {
PROP_IS_NEW_CONTACT,
PROP_EDITABLE,
PROP_CHANGED,
- PROP_WRITABLE_FIELDS,
- PROP_REQUIRED_FIELDS
+ PROP_WRITABLE_FIELDS
};
enum {
@@ -288,13 +288,6 @@ e_contact_editor_class_init (EContactEditorClass *klass)
E_TYPE_LIST,
G_PARAM_READWRITE));
- g_object_class_install_property (object_class, PROP_REQUIRED_FIELDS,
- g_param_spec_object ("required_fields",
- _("Required Fields"),
- /*_( */"XXX blurb" /*)*/,
- E_TYPE_LIST,
- G_PARAM_READWRITE));
-
g_object_class_install_property (object_class, PROP_EDITABLE,
g_param_spec_boolean ("editable",
_("Editable"),
@@ -2126,6 +2119,7 @@ extract_simple_field (EContactEditor *editor, GtkWidget *widget, gint field_id)
gtk_text_buffer_get_start_iter (buffer, &start);
gtk_text_buffer_get_end_iter (buffer, &end);
text = gtk_text_buffer_get_text (buffer, &start, &end, FALSE);
+
e_contact_set (contact, field_id, text);
g_free (text);
}
@@ -2741,29 +2735,17 @@ real_save_contact (EContactEditor *ce, gboolean should_close)
static void
save_contact (EContactEditor *ce, gboolean should_close)
{
- char *uid;
-
if (!ce->target_book)
return;
-
+
+ if (!e_contact_editor_is_valid (EAB_EDITOR (ce)))
+ return;
if (ce->target_editable && !e_book_is_writable (ce->source_book)) {
if (e_error_run (GTK_WINDOW (ce->app), "addressbook:prompt-move", NULL) == GTK_RESPONSE_NO)
return;
}
extract_all (ce);
-
- if (!e_contact_editor_is_valid (EAB_EDITOR (ce))) {
- uid = e_contact_get (ce->contact, E_CONTACT_UID);
- g_object_unref (ce->contact);
- ce->contact = e_contact_new ();
- if (uid) {
- e_contact_set (ce->contact, E_CONTACT_UID, uid);
- g_free (uid);
- }
- return;
- }
-
real_save_contact (ce, should_close);
}
@@ -2786,42 +2768,6 @@ e_contact_editor_close (EABEditor *editor)
}
}
-EContactField non_string_fields [] = {
- E_CONTACT_FULL_NAME,
- E_CONTACT_ADDRESS,
- E_CONTACT_ADDRESS_HOME,
- E_CONTACT_ADDRESS_WORK,
- E_CONTACT_ADDRESS_OTHER,
- E_CONTACT_EMAIL,
- E_CONTACT_IM_AIM,
- E_CONTACT_IM_GROUPWISE,
- E_CONTACT_IM_JABBER,
- E_CONTACT_IM_YAHOO,
- E_CONTACT_IM_MSN,
- E_CONTACT_IM_ICQ,
- E_CONTACT_PHOTO,
- E_CONTACT_LOGO,
- E_CONTACT_X509_CERT,
- E_CONTACT_CATEGORY_LIST,
- E_CONTACT_BIRTH_DATE,
- E_CONTACT_ANNIVERSARY
-
-
-};
-
-static gboolean
-is_non_string_field (EContactField id)
-{
- int count = sizeof (non_string_fields) / sizeof (EContactField);
- int i;
- for (i = 0; i < count; i++)
- if (id == non_string_fields[i])
- return TRUE;
- return FALSE;
-
-}
-
-
/* insert checks here (date format, for instance, etc.) */
static gboolean
e_contact_editor_is_valid (EABEditor *editor)
@@ -2829,7 +2775,6 @@ e_contact_editor_is_valid (EABEditor *editor)
EContactEditor *ce = E_CONTACT_EDITOR (editor);
GtkWidget *widget;
gboolean validation_error = FALSE;
- EIterator *iter;
GString *errmsg = g_string_new (_("The contact data is invalid:\n\n"));
widget = glade_xml_get_widget (ce->gui, "dateedit-birthday");
@@ -2847,38 +2792,14 @@ 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 char *field_name = e_iterator_get (iter);
- EContactField field_id = e_contact_field_id (field_name);
-
- 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));
- validation_error = TRUE;
- break;
- }
-
- } else {
-
- char *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));
- validation_error = TRUE;
- break;
- }
-
-
- }
+ widget = glade_xml_get_widget (ce->gui, "entry-file-as");
+ if (STRING_IS_EMPTY (gtk_entry_get_text (GTK_ENTRY (widget)))) {
+ g_string_append_printf (errmsg, "%s'%s' is empty",
+ validation_error ? ",\n" : "",
+ e_contact_pretty_name (E_CONTACT_FILE_AS));
+ validation_error = TRUE;
}
-
-
+
if (validation_error) {
g_string_append (errmsg, ".");
e_error_run (GTK_WINDOW (ce->app), "addressbook:generic-error",
@@ -3100,10 +3021,7 @@ e_contact_editor_dispose (GObject *object)
g_object_unref(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_contact_editor->required_fields = NULL;
- }
+
if (e_contact_editor->contact) {
g_object_unref(e_contact_editor->contact);
e_contact_editor->contact = NULL;
@@ -3155,24 +3073,6 @@ supported_fields_cb (EBook *book, EBookStatus status,
}
static void
-required_fields_cb (EBook *book, EBookStatus status,
- EList *fields, EContactEditor *ce)
-{
-
- if (!g_slist_find ((GSList*)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,
- "required_fields", fields,
- NULL);
-
-
-}
-
-
-static void
contact_editor_destroy_notify (void *data,
GObject *where_the_object_was)
{
@@ -3258,8 +3158,6 @@ e_contact_editor_set_property (GObject *object, guint prop_id, const GValue *val
e_book_async_get_supported_fields (editor->target_book,
(EBookEListCallback) supported_fields_cb, editor);
- e_book_async_get_required_fields (editor->target_book,
- (EBookEListCallback) required_fields_cb, editor);
}
writable = e_book_is_writable (editor->target_book);
@@ -3298,8 +3196,6 @@ e_contact_editor_set_property (GObject *object, guint prop_id, const GValue *val
e_book_async_get_supported_fields (editor->target_book,
(EBookEListCallback) supported_fields_cb, editor);
- e_book_async_get_required_fields (editor->target_book,
- (EBookEListCallback) required_fields_cb, editor);
if (!editor->is_new_contact)
editor->changed = TRUE;
@@ -3363,15 +3259,6 @@ e_contact_editor_set_property (GObject *object, guint prop_id, const GValue *val
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);
- break;
default:
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
break;
@@ -3417,12 +3304,6 @@ e_contact_editor_get_property (GObject *object, guint prop_id, GValue *value, GP
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));
- else
- g_value_set_object (value, NULL);
- break;
default:
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
break;
@@ -3487,12 +3368,6 @@ e_contact_editor_create_web(gchar *name,
gint int1, gint int2)
{
GtkWidget *widget = e_url_entry_new ();
- AtkObject *a11y = gtk_widget_get_accessible (e_url_entry_get_entry (widget));
-
- if (a11y != NULL) {
- atk_object_set_name (a11y, string1);
- }
-
gtk_widget_show (widget);
return widget;
}