aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorChris Toshok <toshok@ximian.com>2001-03-02 19:02:33 +0800
committerChris Toshok <toshok@src.gnome.org>2001-03-02 19:02:33 +0800
commit0d345b68bf4ab7f2d21f3387f11e1c42c335e0b4 (patch)
treeb8ded202fd5216426089ddb3af49a0b73dd9a2d8
parent3e7e23772816efd672b314bcf507609cea821dd5 (diff)
downloadgsoc2013-evolution-0d345b68bf4ab7f2d21f3387f11e1c42c335e0b4.tar
gsoc2013-evolution-0d345b68bf4ab7f2d21f3387f11e1c42c335e0b4.tar.gz
gsoc2013-evolution-0d345b68bf4ab7f2d21f3387f11e1c42c335e0b4.tar.bz2
gsoc2013-evolution-0d345b68bf4ab7f2d21f3387f11e1c42c335e0b4.tar.lz
gsoc2013-evolution-0d345b68bf4ab7f2d21f3387f11e1c42c335e0b4.tar.xz
gsoc2013-evolution-0d345b68bf4ab7f2d21f3387f11e1c42c335e0b4.tar.zst
gsoc2013-evolution-0d345b68bf4ab7f2d21f3387f11e1c42c335e0b4.zip
new function. (e_minicard_view_event): split out the creation of the
2001-03-02 Chris Toshok <toshok@ximian.com> * gui/widgets/e-minicard-view.c (supported_fields_cb): new function. (e_minicard_view_event): split out the creation of the contact editor to the supported_fields callback. * gui/widgets/e-minicard.c (supported_fields_cb): new function. (e_minicard_event): split out the creation of the contact editor to the supported_fields callback. * gui/widgets/e-addressbook-view.c (table_double_click): split function into two functions, since e_book_get_supported_fields requires a callback now. (supported_fields_cb): new function. * gui/component/addressbook.c (new_contact_cb): split this into two functions, since e_book_get_supported_fields requires a callback now. (supported_fields_cb): new function. * contact-editor/test-editor.c (main): track change to e_contact_editor_new (pass NULL for the writable_fields arg.) * contact-editor/contact-editor.glade: fix several labels so they make better sense (since we look them up in e-contact-editor.c.) * contact-editor/e-contact-editor.h (struct _EContactEditor): add writable_fields. also, add it to e_contact_editor_new. * contact-editor/e-contact-editor.c (e_contact_editor_class_init): add writable_fields arg. (e_contact_editor_destroy): unref the writable_fields list. (e_contact_editor_new): pass @fields as the writable_fields arg. (e_contact_editor_set_arg): add writable_fields support. (enable_writable_fields): new (very hairy) function, to disable everything and reenable just the fields listed in the writable_fields list. (_email_arrow_pressed): set label-email1, entry-email1, and checkbutton-htmlmail to be sensitive since the only way to get here is to activate a writable field in the menu. (_address_arrow_pressed): set label-address, button-fulladdr, and text-address to be sensitive for the same reason. (_phone_arrow_pressed): sensitize the label and entry for the same reason. svn path=/trunk/; revision=8516
-rw-r--r--addressbook/ChangeLog46
-rw-r--r--addressbook/contact-editor/contact-editor.glade24
-rw-r--r--addressbook/contact-editor/e-contact-editor.c370
-rw-r--r--addressbook/contact-editor/e-contact-editor.h5
-rw-r--r--addressbook/contact-editor/test-editor.c4
-rw-r--r--addressbook/gui/component/addressbook.c29
-rw-r--r--addressbook/gui/contact-editor/contact-editor.glade24
-rw-r--r--addressbook/gui/contact-editor/e-contact-editor.c370
-rw-r--r--addressbook/gui/contact-editor/e-contact-editor.h5
-rw-r--r--addressbook/gui/contact-editor/test-editor.c4
-rw-r--r--addressbook/gui/widgets/e-addressbook-view.c33
-rw-r--r--addressbook/gui/widgets/e-minicard-view.c38
-rw-r--r--addressbook/gui/widgets/e-minicard.c31
13 files changed, 753 insertions, 230 deletions
diff --git a/addressbook/ChangeLog b/addressbook/ChangeLog
index 6e9a3b786e..05553b6f2b 100644
--- a/addressbook/ChangeLog
+++ b/addressbook/ChangeLog
@@ -1,5 +1,51 @@
2001-03-02 Chris Toshok <toshok@ximian.com>
+ * gui/widgets/e-minicard-view.c (supported_fields_cb): new
+ function.
+ (e_minicard_view_event): split out the creation of the contact
+ editor to the supported_fields callback.
+
+ * gui/widgets/e-minicard.c (supported_fields_cb): new function.
+ (e_minicard_event): split out the creation of the contact editor
+ to the supported_fields callback.
+
+ * gui/widgets/e-addressbook-view.c (table_double_click): split
+ function into two functions, since e_book_get_supported_fields
+ requires a callback now.
+ (supported_fields_cb): new function.
+
+ * gui/component/addressbook.c (new_contact_cb): split this into
+ two functions, since e_book_get_supported_fields requires a
+ callback now.
+ (supported_fields_cb): new function.
+
+ * contact-editor/test-editor.c (main): track change to
+ e_contact_editor_new (pass NULL for the writable_fields arg.)
+
+ * contact-editor/contact-editor.glade: fix several labels so they
+ make better sense (since we look them up in e-contact-editor.c.)
+
+ * contact-editor/e-contact-editor.h (struct _EContactEditor): add
+ writable_fields. also, add it to e_contact_editor_new.
+
+ * contact-editor/e-contact-editor.c (e_contact_editor_class_init):
+ add writable_fields arg.
+ (e_contact_editor_destroy): unref the writable_fields list.
+ (e_contact_editor_new): pass @fields as the writable_fields arg.
+ (e_contact_editor_set_arg): add writable_fields support.
+ (enable_writable_fields): new (very hairy) function, to disable
+ everything and reenable just the fields listed in the
+ writable_fields list.
+ (_email_arrow_pressed): set label-email1, entry-email1, and
+ checkbutton-htmlmail to be sensitive since the only way to get
+ here is to activate a writable field in the menu.
+ (_address_arrow_pressed): set label-address, button-fulladdr, and
+ text-address to be sensitive for the same reason.
+ (_phone_arrow_pressed): sensitize the label and entry for the same
+ reason.
+
+2001-03-02 Chris Toshok <toshok@ximian.com>
+
* backend/ebook/e-card-simple.c (field_data): add new entries for
phone enums, and fill in the ecard_field with (bogus in all but a
few cases) strings. these are the strings sent from wombat to
diff --git a/addressbook/contact-editor/contact-editor.glade b/addressbook/contact-editor/contact-editor.glade
index ddcc058ab2..30f7feb1a5 100644
--- a/addressbook/contact-editor/contact-editor.glade
+++ b/addressbook/contact-editor/contact-editor.glade
@@ -1494,7 +1494,7 @@
<widget>
<class>GtkLabel</class>
- <name>label34</name>
+ <name>label-jobtitle</name>
<cxx_use_heap>True</cxx_use_heap>
<label>_Job title:</label>
<justify>GTK_JUSTIFY_CENTER</justify>
@@ -1691,7 +1691,7 @@
<widget>
<class>GtkLabel</class>
- <name>label35</name>
+ <name>label-company</name>
<cxx_use_heap>True</cxx_use_heap>
<label>_Company:</label>
<justify>GTK_JUSTIFY_CENTER</justify>
@@ -1767,7 +1767,7 @@
<widget>
<class>GtkLabel</class>
- <name>label21</name>
+ <name>label-department</name>
<cxx_use_heap>True</cxx_use_heap>
<label>_Department:</label>
<justify>GTK_JUSTIFY_CENTER</justify>
@@ -1795,7 +1795,7 @@
<widget>
<class>GtkLabel</class>
- <name>label22</name>
+ <name>label-office</name>
<cxx_use_heap>True</cxx_use_heap>
<label>_Office:</label>
<justify>GTK_JUSTIFY_CENTER</justify>
@@ -1823,7 +1823,7 @@
<widget>
<class>GtkLabel</class>
- <name>label23</name>
+ <name>label-profession</name>
<cxx_use_heap>True</cxx_use_heap>
<label>_Profession:</label>
<justify>GTK_JUSTIFY_CENTER</justify>
@@ -1851,7 +1851,7 @@
<widget>
<class>GtkLabel</class>
- <name>label24</name>
+ <name>label-nickname</name>
<cxx_use_heap>True</cxx_use_heap>
<label>_Nickname:</label>
<justify>GTK_JUSTIFY_CENTER</justify>
@@ -1879,7 +1879,7 @@
<widget>
<class>GtkLabel</class>
- <name>label25</name>
+ <name>label-spouse</name>
<cxx_use_heap>True</cxx_use_heap>
<label>_Spouse:</label>
<justify>GTK_JUSTIFY_CENTER</justify>
@@ -1907,7 +1907,7 @@
<widget>
<class>GtkLabel</class>
- <name>label31</name>
+ <name>label-birthday</name>
<cxx_use_heap>True</cxx_use_heap>
<label>_Birthday:</label>
<justify>GTK_JUSTIFY_CENTER</justify>
@@ -1934,7 +1934,7 @@
<widget>
<class>GtkLabel</class>
- <name>label30</name>
+ <name>label-assistant</name>
<cxx_use_heap>True</cxx_use_heap>
<label>_Assistant's name:</label>
<justify>GTK_JUSTIFY_CENTER</justify>
@@ -1962,7 +1962,7 @@
<widget>
<class>GtkLabel</class>
- <name>label29</name>
+ <name>label-manager</name>
<cxx_use_heap>True</cxx_use_heap>
<label>_Manager's Name:</label>
<justify>GTK_JUSTIFY_CENTER</justify>
@@ -1990,7 +1990,7 @@
<widget>
<class>GtkLabel</class>
- <name>label32</name>
+ <name>label-anniversary</name>
<cxx_use_heap>True</cxx_use_heap>
<label>Anni_versary:</label>
<justify>GTK_JUSTIFY_CENTER</justify>
@@ -2262,7 +2262,7 @@
<widget>
<class>GtkLabel</class>
- <name>label33</name>
+ <name>label-comments</name>
<cxx_use_heap>True</cxx_use_heap>
<label>No_tes:</label>
<justify>GTK_JUSTIFY_CENTER</justify>
diff --git a/addressbook/contact-editor/e-contact-editor.c b/addressbook/contact-editor/e-contact-editor.c
index e65e9b9efb..006f1ba150 100644
--- a/addressbook/contact-editor/e-contact-editor.c
+++ b/addressbook/contact-editor/e-contact-editor.c
@@ -56,6 +56,7 @@ static GtkWidget *e_contact_editor_build_dialog(EContactEditor *editor, gchar *e
static void _email_arrow_pressed (GtkWidget *widget, GdkEventButton *button, EContactEditor *editor);
static void _phone_arrow_pressed (GtkWidget *widget, GdkEventButton *button, EContactEditor *editor);
static void _address_arrow_pressed (GtkWidget *widget, GdkEventButton *button, EContactEditor *editor);
+static void enable_writable_fields(EContactEditor *editor);
static void fill_in_info(EContactEditor *editor);
static void extract_info(EContactEditor *editor);
static void set_fields(EContactEditor *editor);
@@ -70,7 +71,8 @@ static guint contact_editor_signals[LAST_SIGNAL];
enum {
ARG_0,
ARG_CARD,
- ARG_IS_NEW_CARD
+ ARG_IS_NEW_CARD,
+ ARG_WRITABLE_FIELDS
};
enum {
@@ -117,6 +119,8 @@ e_contact_editor_class_init (EContactEditorClass *klass)
GTK_ARG_READWRITE, ARG_CARD);
gtk_object_add_arg_type ("EContactEditor::is_new_card", GTK_TYPE_BOOL,
GTK_ARG_READWRITE, ARG_IS_NEW_CARD);
+ gtk_object_add_arg_type ("EContactEditor::writable_fields", GTK_TYPE_POINTER,
+ GTK_ARG_READWRITE, ARG_WRITABLE_FIELDS);
contact_editor_signals[ADD_CARD] =
gtk_signal_new ("add_card",
@@ -972,7 +976,10 @@ e_contact_editor_init (EContactEditor *e_contact_editor)
void
e_contact_editor_destroy (GtkObject *object) {
EContactEditor *e_contact_editor = E_CONTACT_EDITOR(object);
-
+
+ if (e_contact_editor->writable_fields) {
+ gtk_object_unref(GTK_OBJECT(e_contact_editor->writable_fields));
+ }
if (e_contact_editor->email_list) {
g_list_foreach(e_contact_editor->email_list, (GFunc) g_free, NULL);
g_list_free(e_contact_editor->email_list);
@@ -1018,7 +1025,7 @@ e_contact_editor_destroy (GtkObject *object) {
}
EContactEditor *
-e_contact_editor_new (ECard *card, gboolean is_new_card)
+e_contact_editor_new (ECard *card, gboolean is_new_card, EList *fields)
{
EContactEditor *ce;
@@ -1027,6 +1034,7 @@ e_contact_editor_new (ECard *card, gboolean is_new_card)
gtk_object_set (GTK_OBJECT (ce),
"card", card,
"is_new_card", is_new_card,
+ "writable_fields", fields,
NULL);
gtk_widget_show (ce->app);
@@ -1054,6 +1062,12 @@ e_contact_editor_set_arg (GtkObject *o, GtkArg *arg, guint arg_id)
case ARG_IS_NEW_CARD:
editor->is_new_card = GTK_VALUE_BOOL (*arg) ? TRUE : FALSE;
break;
+
+ case ARG_WRITABLE_FIELDS:
+ editor->writable_fields = GTK_VALUE_POINTER (*arg);
+ gtk_object_ref (GTK_OBJECT (editor->writable_fields));
+ enable_writable_fields (editor);
+ break;
}
}
@@ -1164,6 +1178,99 @@ e_contact_editor_build_ui_info(GList *list, GnomeUIInfo **infop)
*infop = info;
}
+static void
+e_contact_editor_build_phone_ui (EContactEditor *editor)
+{
+ int i;
+
+ if (editor->phone_list == NULL) {
+ static char *info[] = {
+ N_("Assistant"),
+ N_("Business"),
+ N_("Business 2"),
+ N_("Business Fax"),
+ N_("Callback"),
+ N_("Car"),
+ N_("Company"),
+ N_("Home"),
+ N_("Home 2"),
+ N_("Home Fax"),
+ N_("ISDN"),
+ N_("Mobile"),
+ N_("Other"),
+ N_("Other Fax"),
+ N_("Pager"),
+ N_("Primary"),
+ N_("Radio"),
+ N_("Telex"),
+ N_("TTY/TDD")
+ };
+
+ for (i = 0; i < sizeof(info) / sizeof(info[0]); i++) {
+ editor->phone_list = g_list_append(editor->phone_list, g_strdup(info[i]));
+ }
+ }
+ if (editor->phone_info == NULL) {
+ e_contact_editor_build_ui_info(editor->phone_list, &editor->phone_info);
+
+ if ( editor->phone_popup )
+ gtk_widget_unref(editor->phone_popup);
+
+ editor->phone_popup = gnome_popup_menu_new(editor->phone_info);
+ }
+}
+
+static void
+e_contact_editor_build_email_ui (EContactEditor *editor)
+{
+ int i;
+
+ if (editor->email_list == NULL) {
+ static char *info[] = {
+ N_("Primary Email"),
+ N_("Email 2"),
+ N_("Email 3")
+ };
+
+ for (i = 0; i < sizeof(info) / sizeof(info[0]); i++) {
+ editor->email_list = g_list_append(editor->email_list, g_strdup(info[i]));
+ }
+ }
+ if (editor->email_info == NULL) {
+ e_contact_editor_build_ui_info(editor->email_list, &editor->email_info);
+
+ if ( editor->email_popup )
+ gtk_widget_unref(editor->email_popup);
+
+ editor->email_popup = gnome_popup_menu_new(editor->email_info);
+ }
+}
+
+static void
+e_contact_editor_build_address_ui (EContactEditor *editor)
+{
+ int i;
+
+ if (editor->address_list == NULL) {
+ static char *info[] = {
+ N_("Business"),
+ N_("Home"),
+ N_("Other")
+ };
+
+ for (i = 0; i < sizeof(info) / sizeof(info[0]); i++) {
+ editor->address_list = g_list_append(editor->address_list, g_strdup(info[i]));
+ }
+ }
+ if (editor->address_info == NULL) {
+ e_contact_editor_build_ui_info(editor->address_list, &editor->address_info);
+
+ if ( editor->address_popup )
+ gtk_widget_unref(editor->address_popup);
+
+ editor->address_popup = gnome_popup_menu_new(editor->address_info);
+ }
+}
#if 0
static void
_dialog_clicked(GtkWidget *dialog, gint button, EContactEditor *editor)
@@ -1272,41 +1379,7 @@ _phone_arrow_pressed (GtkWidget *widget, GdkEventButton *button, EContactEditor
label = g_strdup_printf("label-phone%d", which);
entry = g_strdup_printf("entry-phone%d", which);
- if (editor->phone_list == NULL) {
- static char *info[] = {
- N_("Assistant"),
- N_("Business"),
- N_("Business 2"),
- N_("Business Fax"),
- N_("Callback"),
- N_("Car"),
- N_("Company"),
- N_("Home"),
- N_("Home 2"),
- N_("Home Fax"),
- N_("ISDN"),
- N_("Mobile"),
- N_("Other"),
- N_("Other Fax"),
- N_("Pager"),
- N_("Primary"),
- N_("Radio"),
- N_("Telex"),
- N_("TTY/TDD")
- };
-
- for (i = 0; i < sizeof(info) / sizeof(info[0]); i++) {
- editor->phone_list = g_list_append(editor->phone_list, g_strdup(info[i]));
- }
- }
- if (editor->phone_info == NULL) {
- e_contact_editor_build_ui_info(editor->phone_list, &editor->phone_info);
-
- if ( editor->phone_popup )
- gtk_widget_unref(editor->phone_popup);
-
- editor->phone_popup = gnome_popup_menu_new(editor->phone_info);
- }
+ e_contact_editor_build_phone_ui (editor);
for(i = 0; i < E_CARD_SIMPLE_PHONE_ID_LAST; i++) {
const ECardPhone *phone = e_card_simple_get_phone(editor->simple, i);
@@ -1323,6 +1396,8 @@ _phone_arrow_pressed (GtkWidget *widget, GdkEventButton *button, EContactEditor
if (result != -1) {
editor->phone_choice[which - 1] = result;
set_fields(editor);
+ gtk_widget_set_sensitive (glade_xml_get_widget (editor->gui, label), TRUE);
+ gtk_widget_set_sensitive (glade_xml_get_widget (editor->gui, entry), TRUE);
}
g_free(label);
@@ -1334,26 +1409,9 @@ _email_arrow_pressed (GtkWidget *widget, GdkEventButton *button, EContactEditor
{
int i;
int result;
- if (editor->email_list == NULL) {
- static char *info[] = {
- N_("Primary Email"),
- N_("Email 2"),
- N_("Email 3")
- };
-
- for (i = 0; i < sizeof(info) / sizeof(info[0]); i++) {
- editor->email_list = g_list_append(editor->email_list, g_strdup(info[i]));
- }
- }
- if (editor->email_info == NULL) {
- e_contact_editor_build_ui_info(editor->email_list, &editor->email_info);
- if ( editor->email_popup )
- gtk_widget_unref(editor->email_popup);
-
- editor->email_popup = gnome_popup_menu_new(editor->email_info);
- }
-
+ e_contact_editor_build_email_ui (editor);
+
for(i = 0; i < E_CARD_SIMPLE_EMAIL_ID_LAST; i++) {
const char *string = e_card_simple_get_email(editor->simple, i);
gboolean checked;
@@ -1369,6 +1427,11 @@ _email_arrow_pressed (GtkWidget *widget, GdkEventButton *button, EContactEditor
if (result != -1) {
editor->email_choice = result;
set_fields(editor);
+
+ /* make sure the buttons/entry is/are sensitive */
+ gtk_widget_set_sensitive (glade_xml_get_widget (editor->gui, "label-email1"), TRUE);
+ gtk_widget_set_sensitive (glade_xml_get_widget (editor->gui, "entry-email1"), TRUE);
+ gtk_widget_set_sensitive (glade_xml_get_widget (editor->gui, "checkbutton-htmlmail"), TRUE);
}
}
@@ -1377,26 +1440,9 @@ _address_arrow_pressed (GtkWidget *widget, GdkEventButton *button, EContactEdito
{
int i;
int result;
- if (editor->address_list == NULL) {
- static char *info[] = {
- N_("Business"),
- N_("Home"),
- N_("Other")
- };
-
- for (i = 0; i < sizeof(info) / sizeof(info[0]); i++) {
- editor->address_list = g_list_append(editor->address_list, g_strdup(info[i]));
- }
- }
- if (editor->address_info == NULL) {
- e_contact_editor_build_ui_info(editor->address_list, &editor->address_info);
- if ( editor->address_popup )
- gtk_widget_unref(editor->address_popup);
-
- editor->address_popup = gnome_popup_menu_new(editor->address_info);
- }
-
+ e_contact_editor_build_address_ui (editor);
+
for(i = 0; i < E_CARD_SIMPLE_ADDRESS_ID_LAST; i++) {
const ECardAddrLabel *address = e_card_simple_get_address(editor->simple, i);
gboolean checked;
@@ -1411,6 +1457,11 @@ _address_arrow_pressed (GtkWidget *widget, GdkEventButton *button, EContactEdito
if (result != -1) {
set_address_field(editor, result);
+
+ /* make sure the buttons/entry is/are sensitive */
+ gtk_widget_set_sensitive (glade_xml_get_widget (editor->gui, "label-address"), TRUE);
+ gtk_widget_set_sensitive (glade_xml_get_widget (editor->gui, "button-fulladdr"), TRUE);
+ gtk_widget_set_sensitive (glade_xml_get_widget (editor->gui, "text-address"), TRUE);
}
}
@@ -1601,6 +1652,173 @@ fill_in_single_field(EContactEditor *editor, char *name)
}
static void
+disable_widget_foreach (char *key, GtkWidget *widget, gpointer closure)
+{
+ gtk_widget_set_sensitive (widget, FALSE);
+}
+
+static struct {
+ char *widget_name;
+ ECardSimpleField field_id;
+} widget_field_mappings[] = {
+ { "entry-web", E_CARD_SIMPLE_FIELD_URL },
+ { "accellabel-web", E_CARD_SIMPLE_FIELD_URL },
+
+ { "entry-jobtitle", E_CARD_SIMPLE_FIELD_TITLE },
+ { "label-jobtitle", E_CARD_SIMPLE_FIELD_TITLE },
+
+ { "entry-company", E_CARD_SIMPLE_FIELD_ORG },
+ { "label-company", E_CARD_SIMPLE_FIELD_ORG },
+
+ { "combo-file-as", E_CARD_SIMPLE_FIELD_FILE_AS },
+ { "entry-file-as", E_CARD_SIMPLE_FIELD_FILE_AS },
+ { "accellabel-fileas", E_CARD_SIMPLE_FIELD_FILE_AS },
+
+ { "label-department", E_CARD_SIMPLE_FIELD_ORG_UNIT },
+ { "entry-department", E_CARD_SIMPLE_FIELD_ORG_UNIT },
+
+ { "label-office", E_CARD_SIMPLE_FIELD_OFFICE },
+ { "entry-office", E_CARD_SIMPLE_FIELD_OFFICE },
+
+ { "label-profession", E_CARD_SIMPLE_FIELD_ROLE },
+ { "entry-profession", E_CARD_SIMPLE_FIELD_ROLE },
+
+ { "label-manager", E_CARD_SIMPLE_FIELD_MANAGER },
+ { "entry-manager", E_CARD_SIMPLE_FIELD_MANAGER },
+
+ { "label-assistant", E_CARD_SIMPLE_FIELD_ASSISTANT },
+ { "entry-assistant", E_CARD_SIMPLE_FIELD_ASSISTANT },
+
+ { "label-nickname", E_CARD_SIMPLE_FIELD_NICKNAME },
+ { "entry-nickname", E_CARD_SIMPLE_FIELD_NICKNAME },
+
+ { "label-spouse", E_CARD_SIMPLE_FIELD_SPOUSE },
+ { "entry-spouse", E_CARD_SIMPLE_FIELD_SPOUSE },
+
+ { "label-birthday", E_CARD_SIMPLE_FIELD_BIRTH_DATE },
+ { "dateedit-birthday", E_CARD_SIMPLE_FIELD_BIRTH_DATE },
+
+ { "label-anniversary", E_CARD_SIMPLE_FIELD_ANNIVERSARY },
+ { "dateedit-anniversary", E_CARD_SIMPLE_FIELD_ANNIVERSARY },
+
+ { "label-comments", E_CARD_SIMPLE_FIELD_NOTE },
+ { "text-comments", E_CARD_SIMPLE_FIELD_NOTE },
+
+ { "button-fullname", E_CARD_SIMPLE_FIELD_FULL_NAME },
+ { "entry-fullname", E_CARD_SIMPLE_FIELD_FULL_NAME }
+};
+static int num_widget_field_mappings = sizeof(widget_field_mappings) / sizeof (widget_field_mappings[0]);
+
+static void
+enable_writable_fields(EContactEditor *editor)
+{
+ EList *fields = editor->writable_fields;
+ EIterator *iter;
+ GHashTable *dropdown_hash, *supported_hash;
+ int i;
+ ECardSimple *card;
+ char *widget_name;
+
+ if (!fields)
+ return;
+
+ card = e_card_simple_new (e_card_new (""));
+
+ dropdown_hash = g_hash_table_new (g_str_hash, g_str_equal);
+ supported_hash = g_hash_table_new (g_str_hash, g_str_equal);
+
+ /* build our hashtable of the drop down menu items */
+ e_contact_editor_build_phone_ui (editor);
+ for (i = 0; i < E_CARD_SIMPLE_PHONE_ID_LAST; i ++)
+ g_hash_table_insert (dropdown_hash,
+ (char*)e_card_simple_get_ecard_field(card, e_card_simple_map_phone_to_field (i)),
+ editor->phone_info[i].widget);
+ e_contact_editor_build_email_ui (editor);
+ for (i = 0; i < E_CARD_SIMPLE_EMAIL_ID_LAST; i ++)
+ g_hash_table_insert (dropdown_hash,
+ (char*)e_card_simple_get_ecard_field(card, e_card_simple_map_email_to_field (i)),
+ editor->email_info[i].widget);
+ e_contact_editor_build_address_ui (editor);
+ for (i = 0; i < E_CARD_SIMPLE_ADDRESS_ID_LAST; i ++)
+ g_hash_table_insert (dropdown_hash,
+ (char*)e_card_simple_get_ecard_field(card, e_card_simple_map_address_to_field (i)),
+ editor->address_info[i].widget);
+
+ /* then disable them all */
+ g_hash_table_foreach (dropdown_hash, (GHFunc)disable_widget_foreach, NULL);
+
+ /* disable the label widgets for the dropdowns (4 phone, 1
+ email and the toggle button, and 1 address and one for
+ the full adress button */
+ for (i = 0; i < 4; i ++) {
+ widget_name = g_strdup_printf ("label-phone%d", i+1);
+ gtk_widget_set_sensitive (glade_xml_get_widget (editor->gui, widget_name), FALSE);
+ g_free (widget_name);
+ widget_name = g_strdup_printf ("entry-phone%d", i+1);
+ gtk_widget_set_sensitive (glade_xml_get_widget (editor->gui, widget_name), FALSE);
+ g_free (widget_name);
+ }
+ gtk_widget_set_sensitive (glade_xml_get_widget (editor->gui, "label-email1"), FALSE);
+ gtk_widget_set_sensitive (glade_xml_get_widget (editor->gui, "entry-email1"), FALSE);
+ gtk_widget_set_sensitive (glade_xml_get_widget (editor->gui, "checkbutton-htmlmail"), FALSE);
+ gtk_widget_set_sensitive (glade_xml_get_widget (editor->gui, "label-address"), FALSE);
+ gtk_widget_set_sensitive (glade_xml_get_widget (editor->gui, "button-fulladdr"), FALSE);
+ gtk_widget_set_sensitive (glade_xml_get_widget (editor->gui, "text-address"), FALSE);
+
+ /* enable widgets that map directly from a field to a widget (the drop down items) */
+ iter = e_list_get_iterator (fields);
+ for (; e_iterator_is_valid (iter); e_iterator_next (iter)) {
+ char *field = (char*)e_iterator_get (iter);
+ GtkWidget *widget = g_hash_table_lookup (dropdown_hash, field);
+
+ if (widget) {
+ gtk_widget_set_sensitive (widget, TRUE);
+ }
+ else {
+ /* if it's not a field that's handled by the
+ dropdown items, add it to the has to be
+ used in the second step */
+ g_hash_table_insert (supported_hash, field, field);
+ }
+
+ /* ugh - this is needed to make sure we don't have a
+ disabled label next to a drop down when the item in
+ the menu (the one reflected in the label) is
+ enabled. */
+ if (!strcmp (field, e_card_simple_get_ecard_field (card, e_card_simple_map_email_to_field(editor->email_choice)))) {
+ gtk_widget_set_sensitive (glade_xml_get_widget (editor->gui, "label-email1"), TRUE);
+ gtk_widget_set_sensitive (glade_xml_get_widget (editor->gui, "entry-email1"), TRUE);
+ gtk_widget_set_sensitive (glade_xml_get_widget (editor->gui, "checkbutton-htmlmail"), TRUE);
+ }
+ else if (!strcmp (field, e_card_simple_get_ecard_field (card, e_card_simple_map_address_to_field(editor->address_choice)))) {
+ gtk_widget_set_sensitive (glade_xml_get_widget (editor->gui, "label-address"), TRUE);
+ gtk_widget_set_sensitive (glade_xml_get_widget (editor->gui, "button-fulladdr"), TRUE);
+ gtk_widget_set_sensitive (glade_xml_get_widget (editor->gui, "text-address"), TRUE);
+ }
+ else for (i = 0; i < 4; i ++) {
+ if (!strcmp (field, e_card_simple_get_ecard_field (card, e_card_simple_map_phone_to_field(editor->phone_choice[i])))) {
+ widget_name = g_strdup_printf ("label-phone%d", i+1);
+ gtk_widget_set_sensitive (glade_xml_get_widget (editor->gui, widget_name), TRUE);
+ g_free (widget_name);
+ widget_name = g_strdup_printf ("entry-phone%d", i+1);
+ gtk_widget_set_sensitive (glade_xml_get_widget (editor->gui, widget_name), TRUE);
+ g_free (widget_name);
+ }
+ }
+ }
+
+ /* handle the label next to the dropdown widgets */
+
+ for (i = 0; i < num_widget_field_mappings; i ++) {
+ gboolean enabled = g_hash_table_lookup (supported_hash,
+ e_card_simple_get_ecard_field (card,
+ widget_field_mappings[i].field_id)) != NULL;
+ gtk_widget_set_sensitive (glade_xml_get_widget(editor->gui,
+ widget_field_mappings[i].widget_name), enabled);
+ }
+}
+
+static void
fill_in_info(EContactEditor *editor)
{
ECard *card = editor->card;
diff --git a/addressbook/contact-editor/e-contact-editor.h b/addressbook/contact-editor/e-contact-editor.h
index a2067b1a88..ef2b1238df 100644
--- a/addressbook/contact-editor/e-contact-editor.h
+++ b/addressbook/contact-editor/e-contact-editor.h
@@ -85,6 +85,8 @@ struct _EContactEditor
/* Whether we are editing a new card or an existing one */
guint is_new_card : 1;
+
+ EList *writable_fields;
};
struct _EContactEditorClass
@@ -100,7 +102,8 @@ struct _EContactEditorClass
};
EContactEditor *e_contact_editor_new (ECard *card,
- gboolean is_new_card);
+ gboolean is_new_card,
+ EList *writable_fields);
GtkType e_contact_editor_get_type (void);
void e_contact_editor_raise (EContactEditor *editor);
diff --git a/addressbook/contact-editor/test-editor.c b/addressbook/contact-editor/test-editor.c
index 80db2fe848..e9060b3e25 100644
--- a/addressbook/contact-editor/test-editor.c
+++ b/addressbook/contact-editor/test-editor.c
@@ -127,11 +127,11 @@ int main( int argc, char *argv[] )
if (cardstr == NULL)
cardstr = TEST_VCARD;
- ce = e_contact_editor_new (e_card_new (cardstr), TRUE);
+ ce = e_contact_editor_new (e_card_new (cardstr), TRUE, NULL);
gtk_signal_connect (GTK_OBJECT (ce), "editor_closed",
GTK_SIGNAL_FUNC (editor_closed_cb), NULL);
- ce = e_contact_editor_new (e_card_new (cardstr), TRUE);
+ ce = e_contact_editor_new (e_card_new (cardstr), TRUE, NULL);
gtk_signal_connect (GTK_OBJECT (ce), "editor_closed",
GTK_SIGNAL_FUNC (editor_closed_cb), NULL);
diff --git a/addressbook/gui/component/addressbook.c b/addressbook/gui/component/addressbook.c
index 1cea4c21f2..b80a2b80d7 100644
--- a/addressbook/gui/component/addressbook.c
+++ b/addressbook/gui/component/addressbook.c
@@ -98,22 +98,14 @@ editor_closed_cb (EContactEditor *ce, gpointer data)
}
static void
-new_contact_cb (BonoboUIComponent *uih, void *user_data, const char *path)
+supported_fields_cb (EBook *book, EBookStatus status, EList *fields, gpointer closure)
{
- ECard *card;
- EBook *book;
EContactEditor *ce;
- AddressbookView *view = (AddressbookView *) user_data;
+ ECard *card;
card = e_card_new("");
- gtk_object_get(GTK_OBJECT(view->view),
- "book", &book,
- NULL);
-
- g_assert (E_IS_BOOK (book));
-
- ce = e_contact_editor_new (card, TRUE);
+ ce = e_contact_editor_new (card, TRUE, fields);
gtk_signal_connect (GTK_OBJECT (ce), "add_card",
GTK_SIGNAL_FUNC (add_card_cb), book);
@@ -128,6 +120,21 @@ new_contact_cb (BonoboUIComponent *uih, void *user_data, const char *path)
}
static void
+new_contact_cb (BonoboUIComponent *uih, void *user_data, const char *path)
+{
+ EBook *book;
+ AddressbookView *view = (AddressbookView *) user_data;
+
+ gtk_object_get(GTK_OBJECT(view->view),
+ "book", &book,
+ NULL);
+
+ g_assert (E_IS_BOOK (book));
+
+ e_book_get_supported_fields (book, supported_fields_cb, view);
+}
+
+static void
config_cb (BonoboUIComponent *uih, void *user_data, const char *path)
{
addressbook_config (NULL /* XXX */);
diff --git a/addressbook/gui/contact-editor/contact-editor.glade b/addressbook/gui/contact-editor/contact-editor.glade
index ddcc058ab2..30f7feb1a5 100644
--- a/addressbook/gui/contact-editor/contact-editor.glade
+++ b/addressbook/gui/contact-editor/contact-editor.glade
@@ -1494,7 +1494,7 @@
<widget>
<class>GtkLabel</class>
- <name>label34</name>
+ <name>label-jobtitle</name>
<cxx_use_heap>True</cxx_use_heap>
<label>_Job title:</label>
<justify>GTK_JUSTIFY_CENTER</justify>
@@ -1691,7 +1691,7 @@
<widget>
<class>GtkLabel</class>
- <name>label35</name>
+ <name>label-company</name>
<cxx_use_heap>True</cxx_use_heap>
<label>_Company:</label>
<justify>GTK_JUSTIFY_CENTER</justify>
@@ -1767,7 +1767,7 @@
<widget>
<class>GtkLabel</class>
- <name>label21</name>
+ <name>label-department</name>
<cxx_use_heap>True</cxx_use_heap>
<label>_Department:</label>
<justify>GTK_JUSTIFY_CENTER</justify>
@@ -1795,7 +1795,7 @@
<widget>
<class>GtkLabel</class>
- <name>label22</name>
+ <name>label-office</name>
<cxx_use_heap>True</cxx_use_heap>
<label>_Office:</label>
<justify>GTK_JUSTIFY_CENTER</justify>
@@ -1823,7 +1823,7 @@
<widget>
<class>GtkLabel</class>
- <name>label23</name>
+ <name>label-profession</name>
<cxx_use_heap>True</cxx_use_heap>
<label>_Profession:</label>
<justify>GTK_JUSTIFY_CENTER</justify>
@@ -1851,7 +1851,7 @@
<widget>
<class>GtkLabel</class>
- <name>label24</name>
+ <name>label-nickname</name>
<cxx_use_heap>True</cxx_use_heap>
<label>_Nickname:</label>
<justify>GTK_JUSTIFY_CENTER</justify>
@@ -1879,7 +1879,7 @@
<widget>
<class>GtkLabel</class>
- <name>label25</name>
+ <name>label-spouse</name>
<cxx_use_heap>True</cxx_use_heap>
<label>_Spouse:</label>
<justify>GTK_JUSTIFY_CENTER</justify>
@@ -1907,7 +1907,7 @@
<widget>
<class>GtkLabel</class>
- <name>label31</name>
+ <name>label-birthday</name>
<cxx_use_heap>True</cxx_use_heap>
<label>_Birthday:</label>
<justify>GTK_JUSTIFY_CENTER</justify>
@@ -1934,7 +1934,7 @@
<widget>
<class>GtkLabel</class>
- <name>label30</name>
+ <name>label-assistant</name>
<cxx_use_heap>True</cxx_use_heap>
<label>_Assistant's name:</label>
<justify>GTK_JUSTIFY_CENTER</justify>
@@ -1962,7 +1962,7 @@
<widget>
<class>GtkLabel</class>
- <name>label29</name>
+ <name>label-manager</name>
<cxx_use_heap>True</cxx_use_heap>
<label>_Manager's Name:</label>
<justify>GTK_JUSTIFY_CENTER</justify>
@@ -1990,7 +1990,7 @@
<widget>
<class>GtkLabel</class>
- <name>label32</name>
+ <name>label-anniversary</name>
<cxx_use_heap>True</cxx_use_heap>
<label>Anni_versary:</label>
<justify>GTK_JUSTIFY_CENTER</justify>
@@ -2262,7 +2262,7 @@
<widget>
<class>GtkLabel</class>
- <name>label33</name>
+ <name>label-comments</name>
<cxx_use_heap>True</cxx_use_heap>
<label>No_tes:</label>
<justify>GTK_JUSTIFY_CENTER</justify>
diff --git a/addressbook/gui/contact-editor/e-contact-editor.c b/addressbook/gui/contact-editor/e-contact-editor.c
index e65e9b9efb..006f1ba150 100644
--- a/addressbook/gui/contact-editor/e-contact-editor.c
+++ b/addressbook/gui/contact-editor/e-contact-editor.c
@@ -56,6 +56,7 @@ static GtkWidget *e_contact_editor_build_dialog(EContactEditor *editor, gchar *e
static void _email_arrow_pressed (GtkWidget *widget, GdkEventButton *button, EContactEditor *editor);
static void _phone_arrow_pressed (GtkWidget *widget, GdkEventButton *button, EContactEditor *editor);
static void _address_arrow_pressed (GtkWidget *widget, GdkEventButton *button, EContactEditor *editor);
+static void enable_writable_fields(EContactEditor *editor);
static void fill_in_info(EContactEditor *editor);
static void extract_info(EContactEditor *editor);
static void set_fields(EContactEditor *editor);
@@ -70,7 +71,8 @@ static guint contact_editor_signals[LAST_SIGNAL];
enum {
ARG_0,
ARG_CARD,
- ARG_IS_NEW_CARD
+ ARG_IS_NEW_CARD,
+ ARG_WRITABLE_FIELDS
};
enum {
@@ -117,6 +119,8 @@ e_contact_editor_class_init (EContactEditorClass *klass)
GTK_ARG_READWRITE, ARG_CARD);
gtk_object_add_arg_type ("EContactEditor::is_new_card", GTK_TYPE_BOOL,
GTK_ARG_READWRITE, ARG_IS_NEW_CARD);
+ gtk_object_add_arg_type ("EContactEditor::writable_fields", GTK_TYPE_POINTER,
+ GTK_ARG_READWRITE, ARG_WRITABLE_FIELDS);
contact_editor_signals[ADD_CARD] =
gtk_signal_new ("add_card",
@@ -972,7 +976,10 @@ e_contact_editor_init (EContactEditor *e_contact_editor)
void
e_contact_editor_destroy (GtkObject *object) {
EContactEditor *e_contact_editor = E_CONTACT_EDITOR(object);
-
+
+ if (e_contact_editor->writable_fields) {
+ gtk_object_unref(GTK_OBJECT(e_contact_editor->writable_fields));
+ }
if (e_contact_editor->email_list) {
g_list_foreach(e_contact_editor->email_list, (GFunc) g_free, NULL);
g_list_free(e_contact_editor->email_list);
@@ -1018,7 +1025,7 @@ e_contact_editor_destroy (GtkObject *object) {
}
EContactEditor *
-e_contact_editor_new (ECard *card, gboolean is_new_card)
+e_contact_editor_new (ECard *card, gboolean is_new_card, EList *fields)
{
EContactEditor *ce;
@@ -1027,6 +1034,7 @@ e_contact_editor_new (ECard *card, gboolean is_new_card)
gtk_object_set (GTK_OBJECT (ce),
"card", card,
"is_new_card", is_new_card,
+ "writable_fields", fields,
NULL);
gtk_widget_show (ce->app);
@@ -1054,6 +1062,12 @@ e_contact_editor_set_arg (GtkObject *o, GtkArg *arg, guint arg_id)
case ARG_IS_NEW_CARD:
editor->is_new_card = GTK_VALUE_BOOL (*arg) ? TRUE : FALSE;
break;
+
+ case ARG_WRITABLE_FIELDS:
+ editor->writable_fields = GTK_VALUE_POINTER (*arg);
+ gtk_object_ref (GTK_OBJECT (editor->writable_fields));
+ enable_writable_fields (editor);
+ break;
}
}
@@ -1164,6 +1178,99 @@ e_contact_editor_build_ui_info(GList *list, GnomeUIInfo **infop)
*infop = info;
}
+static void
+e_contact_editor_build_phone_ui (EContactEditor *editor)
+{
+ int i;
+
+ if (editor->phone_list == NULL) {
+ static char *info[] = {
+ N_("Assistant"),
+ N_("Business"),
+ N_("Business 2"),
+ N_("Business Fax"),
+ N_("Callback"),
+ N_("Car"),
+ N_("Company"),
+ N_("Home"),
+ N_("Home 2"),
+ N_("Home Fax"),
+ N_("ISDN"),
+ N_("Mobile"),
+ N_("Other"),
+ N_("Other Fax"),
+ N_("Pager"),
+ N_("Primary"),
+ N_("Radio"),
+ N_("Telex"),
+ N_("TTY/TDD")
+ };
+
+ for (i = 0; i < sizeof(info) / sizeof(info[0]); i++) {
+ editor->phone_list = g_list_append(editor->phone_list, g_strdup(info[i]));
+ }
+ }
+ if (editor->phone_info == NULL) {
+ e_contact_editor_build_ui_info(editor->phone_list, &editor->phone_info);
+
+ if ( editor->phone_popup )
+ gtk_widget_unref(editor->phone_popup);
+
+ editor->phone_popup = gnome_popup_menu_new(editor->phone_info);
+ }
+}
+
+static void
+e_contact_editor_build_email_ui (EContactEditor *editor)
+{
+ int i;
+
+ if (editor->email_list == NULL) {
+ static char *info[] = {
+ N_("Primary Email"),
+ N_("Email 2"),
+ N_("Email 3")
+ };
+
+ for (i = 0; i < sizeof(info) / sizeof(info[0]); i++) {
+ editor->email_list = g_list_append(editor->email_list, g_strdup(info[i]));
+ }
+ }
+ if (editor->email_info == NULL) {
+ e_contact_editor_build_ui_info(editor->email_list, &editor->email_info);
+
+ if ( editor->email_popup )
+ gtk_widget_unref(editor->email_popup);
+
+ editor->email_popup = gnome_popup_menu_new(editor->email_info);
+ }
+}
+
+static void
+e_contact_editor_build_address_ui (EContactEditor *editor)
+{
+ int i;
+
+ if (editor->address_list == NULL) {
+ static char *info[] = {
+ N_("Business"),
+ N_("Home"),
+ N_("Other")
+ };
+
+ for (i = 0; i < sizeof(info) / sizeof(info[0]); i++) {
+ editor->address_list = g_list_append(editor->address_list, g_strdup(info[i]));
+ }
+ }
+ if (editor->address_info == NULL) {
+ e_contact_editor_build_ui_info(editor->address_list, &editor->address_info);
+
+ if ( editor->address_popup )
+ gtk_widget_unref(editor->address_popup);
+
+ editor->address_popup = gnome_popup_menu_new(editor->address_info);
+ }
+}
#if 0
static void
_dialog_clicked(GtkWidget *dialog, gint button, EContactEditor *editor)
@@ -1272,41 +1379,7 @@ _phone_arrow_pressed (GtkWidget *widget, GdkEventButton *button, EContactEditor
label = g_strdup_printf("label-phone%d", which);
entry = g_strdup_printf("entry-phone%d", which);
- if (editor->phone_list == NULL) {
- static char *info[] = {
- N_("Assistant"),
- N_("Business"),
- N_("Business 2"),
- N_("Business Fax"),
- N_("Callback"),
- N_("Car"),
- N_("Company"),
- N_("Home"),
- N_("Home 2"),
- N_("Home Fax"),
- N_("ISDN"),
- N_("Mobile"),
- N_("Other"),
- N_("Other Fax"),
- N_("Pager"),
- N_("Primary"),
- N_("Radio"),
- N_("Telex"),
- N_("TTY/TDD")
- };
-
- for (i = 0; i < sizeof(info) / sizeof(info[0]); i++) {
- editor->phone_list = g_list_append(editor->phone_list, g_strdup(info[i]));
- }
- }
- if (editor->phone_info == NULL) {
- e_contact_editor_build_ui_info(editor->phone_list, &editor->phone_info);
-
- if ( editor->phone_popup )
- gtk_widget_unref(editor->phone_popup);
-
- editor->phone_popup = gnome_popup_menu_new(editor->phone_info);
- }
+ e_contact_editor_build_phone_ui (editor);
for(i = 0; i < E_CARD_SIMPLE_PHONE_ID_LAST; i++) {
const ECardPhone *phone = e_card_simple_get_phone(editor->simple, i);
@@ -1323,6 +1396,8 @@ _phone_arrow_pressed (GtkWidget *widget, GdkEventButton *button, EContactEditor
if (result != -1) {
editor->phone_choice[which - 1] = result;
set_fields(editor);
+ gtk_widget_set_sensitive (glade_xml_get_widget (editor->gui, label), TRUE);
+ gtk_widget_set_sensitive (glade_xml_get_widget (editor->gui, entry), TRUE);
}
g_free(label);
@@ -1334,26 +1409,9 @@ _email_arrow_pressed (GtkWidget *widget, GdkEventButton *button, EContactEditor
{
int i;
int result;
- if (editor->email_list == NULL) {
- static char *info[] = {
- N_("Primary Email"),
- N_("Email 2"),
- N_("Email 3")
- };
-
- for (i = 0; i < sizeof(info) / sizeof(info[0]); i++) {
- editor->email_list = g_list_append(editor->email_list, g_strdup(info[i]));
- }
- }
- if (editor->email_info == NULL) {
- e_contact_editor_build_ui_info(editor->email_list, &editor->email_info);
- if ( editor->email_popup )
- gtk_widget_unref(editor->email_popup);
-
- editor->email_popup = gnome_popup_menu_new(editor->email_info);
- }
-
+ e_contact_editor_build_email_ui (editor);
+
for(i = 0; i < E_CARD_SIMPLE_EMAIL_ID_LAST; i++) {
const char *string = e_card_simple_get_email(editor->simple, i);
gboolean checked;
@@ -1369,6 +1427,11 @@ _email_arrow_pressed (GtkWidget *widget, GdkEventButton *button, EContactEditor
if (result != -1) {
editor->email_choice = result;
set_fields(editor);
+
+ /* make sure the buttons/entry is/are sensitive */
+ gtk_widget_set_sensitive (glade_xml_get_widget (editor->gui, "label-email1"), TRUE);
+ gtk_widget_set_sensitive (glade_xml_get_widget (editor->gui, "entry-email1"), TRUE);
+ gtk_widget_set_sensitive (glade_xml_get_widget (editor->gui, "checkbutton-htmlmail"), TRUE);
}
}
@@ -1377,26 +1440,9 @@ _address_arrow_pressed (GtkWidget *widget, GdkEventButton *button, EContactEdito
{
int i;
int result;
- if (editor->address_list == NULL) {
- static char *info[] = {
- N_("Business"),
- N_("Home"),
- N_("Other")
- };
-
- for (i = 0; i < sizeof(info) / sizeof(info[0]); i++) {
- editor->address_list = g_list_append(editor->address_list, g_strdup(info[i]));
- }
- }
- if (editor->address_info == NULL) {
- e_contact_editor_build_ui_info(editor->address_list, &editor->address_info);
- if ( editor->address_popup )
- gtk_widget_unref(editor->address_popup);
-
- editor->address_popup = gnome_popup_menu_new(editor->address_info);
- }
-
+ e_contact_editor_build_address_ui (editor);
+
for(i = 0; i < E_CARD_SIMPLE_ADDRESS_ID_LAST; i++) {
const ECardAddrLabel *address = e_card_simple_get_address(editor->simple, i);
gboolean checked;
@@ -1411,6 +1457,11 @@ _address_arrow_pressed (GtkWidget *widget, GdkEventButton *button, EContactEdito
if (result != -1) {
set_address_field(editor, result);
+
+ /* make sure the buttons/entry is/are sensitive */
+ gtk_widget_set_sensitive (glade_xml_get_widget (editor->gui, "label-address"), TRUE);
+ gtk_widget_set_sensitive (glade_xml_get_widget (editor->gui, "button-fulladdr"), TRUE);
+ gtk_widget_set_sensitive (glade_xml_get_widget (editor->gui, "text-address"), TRUE);
}
}
@@ -1601,6 +1652,173 @@ fill_in_single_field(EContactEditor *editor, char *name)
}
static void
+disable_widget_foreach (char *key, GtkWidget *widget, gpointer closure)
+{
+ gtk_widget_set_sensitive (widget, FALSE);
+}
+
+static struct {
+ char *widget_name;
+ ECardSimpleField field_id;
+} widget_field_mappings[] = {
+ { "entry-web", E_CARD_SIMPLE_FIELD_URL },
+ { "accellabel-web", E_CARD_SIMPLE_FIELD_URL },
+
+ { "entry-jobtitle", E_CARD_SIMPLE_FIELD_TITLE },
+ { "label-jobtitle", E_CARD_SIMPLE_FIELD_TITLE },
+
+ { "entry-company", E_CARD_SIMPLE_FIELD_ORG },
+ { "label-company", E_CARD_SIMPLE_FIELD_ORG },
+
+ { "combo-file-as", E_CARD_SIMPLE_FIELD_FILE_AS },
+ { "entry-file-as", E_CARD_SIMPLE_FIELD_FILE_AS },
+ { "accellabel-fileas", E_CARD_SIMPLE_FIELD_FILE_AS },
+
+ { "label-department", E_CARD_SIMPLE_FIELD_ORG_UNIT },
+ { "entry-department", E_CARD_SIMPLE_FIELD_ORG_UNIT },
+
+ { "label-office", E_CARD_SIMPLE_FIELD_OFFICE },
+ { "entry-office", E_CARD_SIMPLE_FIELD_OFFICE },
+
+ { "label-profession", E_CARD_SIMPLE_FIELD_ROLE },
+ { "entry-profession", E_CARD_SIMPLE_FIELD_ROLE },
+
+ { "label-manager", E_CARD_SIMPLE_FIELD_MANAGER },
+ { "entry-manager", E_CARD_SIMPLE_FIELD_MANAGER },
+
+ { "label-assistant", E_CARD_SIMPLE_FIELD_ASSISTANT },
+ { "entry-assistant", E_CARD_SIMPLE_FIELD_ASSISTANT },
+
+ { "label-nickname", E_CARD_SIMPLE_FIELD_NICKNAME },
+ { "entry-nickname", E_CARD_SIMPLE_FIELD_NICKNAME },
+
+ { "label-spouse", E_CARD_SIMPLE_FIELD_SPOUSE },
+ { "entry-spouse", E_CARD_SIMPLE_FIELD_SPOUSE },
+
+ { "label-birthday", E_CARD_SIMPLE_FIELD_BIRTH_DATE },
+ { "dateedit-birthday", E_CARD_SIMPLE_FIELD_BIRTH_DATE },
+
+ { "label-anniversary", E_CARD_SIMPLE_FIELD_ANNIVERSARY },
+ { "dateedit-anniversary", E_CARD_SIMPLE_FIELD_ANNIVERSARY },
+
+ { "label-comments", E_CARD_SIMPLE_FIELD_NOTE },
+ { "text-comments", E_CARD_SIMPLE_FIELD_NOTE },
+
+ { "button-fullname", E_CARD_SIMPLE_FIELD_FULL_NAME },
+ { "entry-fullname", E_CARD_SIMPLE_FIELD_FULL_NAME }
+};
+static int num_widget_field_mappings = sizeof(widget_field_mappings) / sizeof (widget_field_mappings[0]);
+
+static void
+enable_writable_fields(EContactEditor *editor)
+{
+ EList *fields = editor->writable_fields;
+ EIterator *iter;
+ GHashTable *dropdown_hash, *supported_hash;
+ int i;
+ ECardSimple *card;
+ char *widget_name;
+
+ if (!fields)
+ return;
+
+ card = e_card_simple_new (e_card_new (""));
+
+ dropdown_hash = g_hash_table_new (g_str_hash, g_str_equal);
+ supported_hash = g_hash_table_new (g_str_hash, g_str_equal);
+
+ /* build our hashtable of the drop down menu items */
+ e_contact_editor_build_phone_ui (editor);
+ for (i = 0; i < E_CARD_SIMPLE_PHONE_ID_LAST; i ++)
+ g_hash_table_insert (dropdown_hash,
+ (char*)e_card_simple_get_ecard_field(card, e_card_simple_map_phone_to_field (i)),
+ editor->phone_info[i].widget);
+ e_contact_editor_build_email_ui (editor);
+ for (i = 0; i < E_CARD_SIMPLE_EMAIL_ID_LAST; i ++)
+ g_hash_table_insert (dropdown_hash,
+ (char*)e_card_simple_get_ecard_field(card, e_card_simple_map_email_to_field (i)),
+ editor->email_info[i].widget);
+ e_contact_editor_build_address_ui (editor);
+ for (i = 0; i < E_CARD_SIMPLE_ADDRESS_ID_LAST; i ++)
+ g_hash_table_insert (dropdown_hash,
+ (char*)e_card_simple_get_ecard_field(card, e_card_simple_map_address_to_field (i)),
+ editor->address_info[i].widget);
+
+ /* then disable them all */
+ g_hash_table_foreach (dropdown_hash, (GHFunc)disable_widget_foreach, NULL);
+
+ /* disable the label widgets for the dropdowns (4 phone, 1
+ email and the toggle button, and 1 address and one for
+ the full adress button */
+ for (i = 0; i < 4; i ++) {
+ widget_name = g_strdup_printf ("label-phone%d", i+1);
+ gtk_widget_set_sensitive (glade_xml_get_widget (editor->gui, widget_name), FALSE);
+ g_free (widget_name);
+ widget_name = g_strdup_printf ("entry-phone%d", i+1);
+ gtk_widget_set_sensitive (glade_xml_get_widget (editor->gui, widget_name), FALSE);
+ g_free (widget_name);
+ }
+ gtk_widget_set_sensitive (glade_xml_get_widget (editor->gui, "label-email1"), FALSE);
+ gtk_widget_set_sensitive (glade_xml_get_widget (editor->gui, "entry-email1"), FALSE);
+ gtk_widget_set_sensitive (glade_xml_get_widget (editor->gui, "checkbutton-htmlmail"), FALSE);
+ gtk_widget_set_sensitive (glade_xml_get_widget (editor->gui, "label-address"), FALSE);
+ gtk_widget_set_sensitive (glade_xml_get_widget (editor->gui, "button-fulladdr"), FALSE);
+ gtk_widget_set_sensitive (glade_xml_get_widget (editor->gui, "text-address"), FALSE);
+
+ /* enable widgets that map directly from a field to a widget (the drop down items) */
+ iter = e_list_get_iterator (fields);
+ for (; e_iterator_is_valid (iter); e_iterator_next (iter)) {
+ char *field = (char*)e_iterator_get (iter);
+ GtkWidget *widget = g_hash_table_lookup (dropdown_hash, field);
+
+ if (widget) {
+ gtk_widget_set_sensitive (widget, TRUE);
+ }
+ else {
+ /* if it's not a field that's handled by the
+ dropdown items, add it to the has to be
+ used in the second step */
+ g_hash_table_insert (supported_hash, field, field);
+ }
+
+ /* ugh - this is needed to make sure we don't have a
+ disabled label next to a drop down when the item in
+ the menu (the one reflected in the label) is
+ enabled. */
+ if (!strcmp (field, e_card_simple_get_ecard_field (card, e_card_simple_map_email_to_field(editor->email_choice)))) {
+ gtk_widget_set_sensitive (glade_xml_get_widget (editor->gui, "label-email1"), TRUE);
+ gtk_widget_set_sensitive (glade_xml_get_widget (editor->gui, "entry-email1"), TRUE);
+ gtk_widget_set_sensitive (glade_xml_get_widget (editor->gui, "checkbutton-htmlmail"), TRUE);
+ }
+ else if (!strcmp (field, e_card_simple_get_ecard_field (card, e_card_simple_map_address_to_field(editor->address_choice)))) {
+ gtk_widget_set_sensitive (glade_xml_get_widget (editor->gui, "label-address"), TRUE);
+ gtk_widget_set_sensitive (glade_xml_get_widget (editor->gui, "button-fulladdr"), TRUE);
+ gtk_widget_set_sensitive (glade_xml_get_widget (editor->gui, "text-address"), TRUE);
+ }
+ else for (i = 0; i < 4; i ++) {
+ if (!strcmp (field, e_card_simple_get_ecard_field (card, e_card_simple_map_phone_to_field(editor->phone_choice[i])))) {
+ widget_name = g_strdup_printf ("label-phone%d", i+1);
+ gtk_widget_set_sensitive (glade_xml_get_widget (editor->gui, widget_name), TRUE);
+ g_free (widget_name);
+ widget_name = g_strdup_printf ("entry-phone%d", i+1);
+ gtk_widget_set_sensitive (glade_xml_get_widget (editor->gui, widget_name), TRUE);
+ g_free (widget_name);
+ }
+ }
+ }
+
+ /* handle the label next to the dropdown widgets */
+
+ for (i = 0; i < num_widget_field_mappings; i ++) {
+ gboolean enabled = g_hash_table_lookup (supported_hash,
+ e_card_simple_get_ecard_field (card,
+ widget_field_mappings[i].field_id)) != NULL;
+ gtk_widget_set_sensitive (glade_xml_get_widget(editor->gui,
+ widget_field_mappings[i].widget_name), enabled);
+ }
+}
+
+static void
fill_in_info(EContactEditor *editor)
{
ECard *card = editor->card;
diff --git a/addressbook/gui/contact-editor/e-contact-editor.h b/addressbook/gui/contact-editor/e-contact-editor.h
index a2067b1a88..ef2b1238df 100644
--- a/addressbook/gui/contact-editor/e-contact-editor.h
+++ b/addressbook/gui/contact-editor/e-contact-editor.h
@@ -85,6 +85,8 @@ struct _EContactEditor
/* Whether we are editing a new card or an existing one */
guint is_new_card : 1;
+
+ EList *writable_fields;
};
struct _EContactEditorClass
@@ -100,7 +102,8 @@ struct _EContactEditorClass
};
EContactEditor *e_contact_editor_new (ECard *card,
- gboolean is_new_card);
+ gboolean is_new_card,
+ EList *writable_fields);
GtkType e_contact_editor_get_type (void);
void e_contact_editor_raise (EContactEditor *editor);
diff --git a/addressbook/gui/contact-editor/test-editor.c b/addressbook/gui/contact-editor/test-editor.c
index 80db2fe848..e9060b3e25 100644
--- a/addressbook/gui/contact-editor/test-editor.c
+++ b/addressbook/gui/contact-editor/test-editor.c
@@ -127,11 +127,11 @@ int main( int argc, char *argv[] )
if (cardstr == NULL)
cardstr = TEST_VCARD;
- ce = e_contact_editor_new (e_card_new (cardstr), TRUE);
+ ce = e_contact_editor_new (e_card_new (cardstr), TRUE, NULL);
gtk_signal_connect (GTK_OBJECT (ce), "editor_closed",
GTK_SIGNAL_FUNC (editor_closed_cb), NULL);
- ce = e_contact_editor_new (e_card_new (cardstr), TRUE);
+ ce = e_contact_editor_new (e_card_new (cardstr), TRUE, NULL);
gtk_signal_connect (GTK_OBJECT (ce), "editor_closed",
GTK_SIGNAL_FUNC (editor_closed_cb), NULL);
diff --git a/addressbook/gui/widgets/e-addressbook-view.c b/addressbook/gui/widgets/e-addressbook-view.c
index 24070181f3..bc22ff65d6 100644
--- a/addressbook/gui/widgets/e-addressbook-view.c
+++ b/addressbook/gui/widgets/e-addressbook-view.c
@@ -392,13 +392,31 @@ editor_closed_cb (EContactEditor *ce, gpointer data)
}
static void
+supported_fields_cb (EBook *book, EBookStatus status, EList *fields, ECard *card)
+{
+ EContactEditor *ce;
+
+ ce = e_contact_editor_new (card, FALSE, fields);
+
+ gtk_signal_connect (GTK_OBJECT (ce), "add_card",
+ GTK_SIGNAL_FUNC (add_card_cb), book);
+ gtk_signal_connect (GTK_OBJECT (ce), "commit_card",
+ GTK_SIGNAL_FUNC (commit_card_cb), book);
+ gtk_signal_connect (GTK_OBJECT (ce), "delete_card",
+ GTK_SIGNAL_FUNC (delete_card_cb), book);
+ gtk_signal_connect (GTK_OBJECT (ce), "editor_closed",
+ GTK_SIGNAL_FUNC (editor_closed_cb), NULL);
+
+ gtk_object_unref(GTK_OBJECT(card));
+}
+
+static void
table_double_click(ETableScrolled *table, gint row, EAddressbookView *view)
{
if (E_IS_ADDRESSBOOK_MODEL(view->object)) {
EAddressbookModel *model = E_ADDRESSBOOK_MODEL(view->object);
ECard *card = e_addressbook_model_get_card(model, row);
EBook *book;
- EContactEditor *ce;
gtk_object_get(GTK_OBJECT(model),
"book", &book,
@@ -406,18 +424,7 @@ table_double_click(ETableScrolled *table, gint row, EAddressbookView *view)
g_assert (E_IS_BOOK (book));
- ce = e_contact_editor_new (card, FALSE);
-
- gtk_signal_connect (GTK_OBJECT (ce), "add_card",
- GTK_SIGNAL_FUNC (add_card_cb), book);
- gtk_signal_connect (GTK_OBJECT (ce), "commit_card",
- GTK_SIGNAL_FUNC (commit_card_cb), book);
- gtk_signal_connect (GTK_OBJECT (ce), "delete_card",
- GTK_SIGNAL_FUNC (delete_card_cb), book);
- gtk_signal_connect (GTK_OBJECT (ce), "editor_closed",
- GTK_SIGNAL_FUNC (editor_closed_cb), NULL);
-
- gtk_object_unref(GTK_OBJECT(card));
+ e_book_get_supported_fields (book, (EBookFieldsCallback)supported_fields_cb, card);
}
}
diff --git a/addressbook/gui/widgets/e-minicard-view.c b/addressbook/gui/widgets/e-minicard-view.c
index 3e3b1ceaf0..e503d54d1f 100644
--- a/addressbook/gui/widgets/e-minicard-view.c
+++ b/addressbook/gui/widgets/e-minicard-view.c
@@ -401,6 +401,26 @@ editor_closed_cb (EContactEditor *ce, gpointer data)
gtk_object_unref (GTK_OBJECT (ce));
}
+static void
+supported_fields_cb (EBook *book, EBookStatus status, EList *fields, EMinicard *e_minicard)
+{
+ ECard *card;
+ EContactEditor *ce;
+
+ card = e_card_new("");
+
+ ce = e_contact_editor_new (card, TRUE, fields);
+
+ gtk_signal_connect (GTK_OBJECT (ce), "add_card",
+ GTK_SIGNAL_FUNC (add_card_cb), book);
+ gtk_signal_connect (GTK_OBJECT (ce), "commit_card",
+ GTK_SIGNAL_FUNC (commit_card_cb), book);
+ gtk_signal_connect (GTK_OBJECT (ce), "editor_closed",
+ GTK_SIGNAL_FUNC (editor_closed_cb), NULL);
+
+ gtk_object_sink(GTK_OBJECT(card));
+}
+
static gboolean
e_minicard_view_event (GnomeCanvasItem *item, GdkEvent *event)
{
@@ -412,25 +432,15 @@ e_minicard_view_event (GnomeCanvasItem *item, GdkEvent *event)
case GDK_2BUTTON_PRESS:
if (((GdkEventButton *)event)->button == 1)
{
- ECard *card;
- EContactEditor *ce;
EBook *book;
- card = e_card_new("");
-
gtk_object_get(GTK_OBJECT(view), "book", &book, NULL);
- g_assert (E_IS_BOOK (book));
-
- ce = e_contact_editor_new (card, TRUE);
- gtk_signal_connect (GTK_OBJECT (ce), "add_card",
- GTK_SIGNAL_FUNC (add_card_cb), book);
- gtk_signal_connect (GTK_OBJECT (ce), "commit_card",
- GTK_SIGNAL_FUNC (commit_card_cb), book);
- gtk_signal_connect (GTK_OBJECT (ce), "editor_closed",
- GTK_SIGNAL_FUNC (editor_closed_cb), NULL);
+ g_assert (E_IS_BOOK (book));
- gtk_object_sink(GTK_OBJECT(card));
+ e_book_get_supported_fields (book,
+ (EBookFieldsCallback)supported_fields_cb,
+ NULL);
}
return TRUE;
default:
diff --git a/addressbook/gui/widgets/e-minicard.c b/addressbook/gui/widgets/e-minicard.c
index 6208f1f23f..22566ec749 100644
--- a/addressbook/gui/widgets/e-minicard.c
+++ b/addressbook/gui/widgets/e-minicard.c
@@ -557,6 +557,24 @@ editor_closed_cb (EContactEditor *ce, gpointer data)
minicard->editor = NULL;
}
+static void
+supported_fields_cb (EBook *book, EBookStatus status, EList *fields, EMinicard *e_minicard)
+{
+ e_minicard->editor = e_contact_editor_new (e_minicard->card, FALSE, fields);
+
+ if (book != NULL) {
+ gtk_signal_connect (GTK_OBJECT (e_minicard->editor), "add_card",
+ GTK_SIGNAL_FUNC (add_card_cb), book);
+ gtk_signal_connect (GTK_OBJECT (e_minicard->editor), "commit_card",
+ GTK_SIGNAL_FUNC (commit_card_cb), book);
+ gtk_signal_connect (GTK_OBJECT (e_minicard->editor), "delete_card",
+ GTK_SIGNAL_FUNC (delete_card_cb), book);
+ }
+
+ gtk_signal_connect (GTK_OBJECT (e_minicard->editor), "editor_closed",
+ GTK_SIGNAL_FUNC (editor_closed_cb), e_minicard);
+}
+
static gboolean
e_minicard_event (GnomeCanvasItem *item, GdkEvent *event)
{
@@ -641,19 +659,12 @@ e_minicard_event (GnomeCanvasItem *item, GdkEvent *event)
"book", &book,
NULL);
}
- e_minicard->editor = e_contact_editor_new (e_minicard->card, FALSE);
if (book != NULL) {
- gtk_signal_connect (GTK_OBJECT (e_minicard->editor), "add_card",
- GTK_SIGNAL_FUNC (add_card_cb), book);
- gtk_signal_connect (GTK_OBJECT (e_minicard->editor), "commit_card",
- GTK_SIGNAL_FUNC (commit_card_cb), book);
- gtk_signal_connect (GTK_OBJECT (e_minicard->editor), "delete_card",
- GTK_SIGNAL_FUNC (delete_card_cb), book);
+ e_book_get_supported_fields (book,
+ (EBookFieldsCallback)supported_fields_cb,
+ e_minicard);
}
-
- gtk_signal_connect (GTK_OBJECT (e_minicard->editor), "editor_closed",
- GTK_SIGNAL_FUNC (editor_closed_cb), e_minicard);
}
return TRUE;
}