aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--addressbook/ChangeLog58
-rw-r--r--addressbook/contact-editor/e-contact-editor-address.c26
-rw-r--r--addressbook/contact-editor/e-contact-editor-address.h3
-rw-r--r--addressbook/contact-editor/e-contact-editor-fullname.c27
-rw-r--r--addressbook/contact-editor/e-contact-editor-fullname.h3
-rw-r--r--addressbook/contact-editor/e-contact-editor.c138
-rw-r--r--addressbook/contact-editor/e-contact-editor.h6
-rw-r--r--addressbook/contact-editor/e-contact-quick-add.c2
-rw-r--r--addressbook/contact-editor/test-editor.c4
-rw-r--r--addressbook/gui/component/addressbook.c2
-rw-r--r--addressbook/gui/component/select-names/e-select-names-text-model.c3
-rw-r--r--addressbook/gui/contact-editor/e-contact-editor-address.c26
-rw-r--r--addressbook/gui/contact-editor/e-contact-editor-address.h3
-rw-r--r--addressbook/gui/contact-editor/e-contact-editor-fullname.c27
-rw-r--r--addressbook/gui/contact-editor/e-contact-editor-fullname.h3
-rw-r--r--addressbook/gui/contact-editor/e-contact-editor.c138
-rw-r--r--addressbook/gui/contact-editor/e-contact-editor.h6
-rw-r--r--addressbook/gui/contact-editor/e-contact-quick-add.c2
-rw-r--r--addressbook/gui/contact-editor/test-editor.c4
-rw-r--r--addressbook/gui/widgets/e-addressbook-view.c2
-rw-r--r--addressbook/gui/widgets/e-minicard-view.c2
-rw-r--r--addressbook/gui/widgets/e-minicard.c2
22 files changed, 418 insertions, 69 deletions
diff --git a/addressbook/ChangeLog b/addressbook/ChangeLog
index 45873b7cb4..b3a1d72c94 100644
--- a/addressbook/ChangeLog
+++ b/addressbook/ChangeLog
@@ -1,3 +1,61 @@
+2001-03-12 Chris Toshok <toshok@ximian.com>
+
+ * gui/widgets/e-minicard.c (supported_fields_cb): add is_read_only
+ param.
+
+ * gui/widgets/e-minicard-view.c (supported_fields_cb): add
+ is_read_only param.
+
+ * gui/widgets/e-addressbook-view.c (supported_fields_cb): add
+ is_read_only param.
+
+ * gui/component/select-names/e-select-names-text-model.c
+ (e_select_names_text_model_activate_obj): add is_read_only param.
+ also, include a little policy here and make it TRUE, as the user
+ shouldn't be editting in this context anyway (imo).
+
+ * gui/component/addressbook.c (supported_fields_cb): add
+ is_read_only param.
+
+ * contact-editor/test-editor.c (main): add is_read_only param.
+
+ * contact-editor/e-contact-editor.c (set_read_only): new function,
+ that either enables or disables all the text fields, combo boxes,
+ and some buttons, depending on the state of is_read_only.
+ (e_contact_editor_class_init): add read/write arg "is_read_only".
+ (full_name_clicked): set the is_read_only of the fullname dialog
+ to the editor's.
+ (full_addr_clicked): same.
+ (e_contact_editor_new): add is_read_only param, that gets set
+ along with the other params.
+ (e_contact_editor_set_arg): add setter for is_read_only.
+ (e_contact_editor_get_arg): add getter for is_read_only.
+ (_phone_arrow_pressed): change TRUE to !editor->is_read_only for
+ entry.
+ (_email_arrow_pressed): same.
+ (_address_arrow_pressed): same.
+ (enable_writable_fields): same.
+
+ * contact-editor/e-contact-editor-fullname.c
+ (e_contact_editor_fullname_class_init): add read/write arg
+ "is_read_only".
+ (e_contact_editor_fullname_set_arg): add setter for is_read_only
+ that enables/disables all the entries/combos.
+ (e_contact_editor_fullname_get_arg): add getter for is_read_only.
+
+ * contact-editor/e-contact-editor-fullname.h (struct
+ _EContactEditorFullname): add is_read_only flag.
+
+ * contact-editor/e-contact-editor-address.c
+ (e_contact_editor_address_class_init): add read/write arg
+ "is_read_only".
+ (e_contact_editor_address_set_arg): add setter for is_read_only
+ that disables/enables all the entries/combos.
+ (e_contact_editor_address_get_arg): add getter for is_read_only.
+
+ * contact-editor/e-contact-editor-address.h (struct
+ _EContactEditorAddress): add is_read_only flag.
+
2001-03-13 Iain Holmes <iain@ximian.com>
* backend/ebook/Makefile.am: Change the importer includes around a bit.
diff --git a/addressbook/contact-editor/e-contact-editor-address.c b/addressbook/contact-editor/e-contact-editor-address.c
index 7df9cb8cb4..1df0462b7d 100644
--- a/addressbook/contact-editor/e-contact-editor-address.c
+++ b/addressbook/contact-editor/e-contact-editor-address.c
@@ -39,7 +39,8 @@ static GnomeDialogClass *parent_class = NULL;
/* The arguments we take */
enum {
ARG_0,
- ARG_ADDRESS
+ ARG_ADDRESS,
+ ARG_IS_READ_ONLY
};
GtkType
@@ -80,6 +81,8 @@ e_contact_editor_address_class_init (EContactEditorAddressClass *klass)
gtk_object_add_arg_type ("EContactEditorAddress::address", GTK_TYPE_POINTER,
GTK_ARG_READWRITE, ARG_ADDRESS);
+ gtk_object_add_arg_type ("EContactEditorAddress::is_read_only", GTK_TYPE_BOOL,
+ GTK_ARG_READWRITE, ARG_IS_READ_ONLY);
object_class->set_arg = e_contact_editor_address_set_arg;
object_class->get_arg = e_contact_editor_address_get_arg;
@@ -146,6 +149,24 @@ e_contact_editor_address_set_arg (GtkObject *o, GtkArg *arg, guint arg_id)
e_contact_editor_address->address = e_card_delivery_address_copy(GTK_VALUE_POINTER (*arg));
fill_in_info(e_contact_editor_address);
break;
+ case ARG_IS_READ_ONLY: {
+ int i;
+ char *entry_names[] = {
+ "entry-street",
+ "entry-city",
+ "entry-ext",
+ "entry-po",
+ "entry-region",
+ "combo-country",
+ "entry-code",
+ NULL
+ };
+ e_contact_editor_address->is_read_only = GTK_VALUE_BOOL (*arg) ? TRUE : FALSE;
+ for (i = 0; entry_names[i] != NULL; i ++) {
+ gtk_widget_set_sensitive (glade_xml_get_widget(e_contact_editor_address->gui, entry_names[i]), !e_contact_editor_address->is_read_only);
+ }
+ break;
+ }
}
}
@@ -161,6 +182,9 @@ e_contact_editor_address_get_arg (GtkObject *object, GtkArg *arg, guint arg_id)
extract_info(e_contact_editor_address);
GTK_VALUE_POINTER (*arg) = e_card_delivery_address_copy(e_contact_editor_address->address);
break;
+ case ARG_IS_READ_ONLY:
+ GTK_VALUE_BOOL (*arg) = e_contact_editor_address->is_read_only ? TRUE : FALSE;
+ break;
default:
arg->type = GTK_TYPE_INVALID;
break;
diff --git a/addressbook/contact-editor/e-contact-editor-address.h b/addressbook/contact-editor/e-contact-editor-address.h
index a74e1bd967..95fe8bf865 100644
--- a/addressbook/contact-editor/e-contact-editor-address.h
+++ b/addressbook/contact-editor/e-contact-editor-address.h
@@ -55,6 +55,9 @@ struct _EContactEditorAddress
/* item specific fields */
ECardDeliveryAddress *address;
+
+ guint is_read_only : 1;
+
GladeXML *gui;
};
diff --git a/addressbook/contact-editor/e-contact-editor-fullname.c b/addressbook/contact-editor/e-contact-editor-fullname.c
index 05e8d45702..0fb7fb57d0 100644
--- a/addressbook/contact-editor/e-contact-editor-fullname.c
+++ b/addressbook/contact-editor/e-contact-editor-fullname.c
@@ -39,7 +39,8 @@ static GnomeDialogClass *parent_class = NULL;
/* The arguments we take */
enum {
ARG_0,
- ARG_NAME
+ ARG_NAME,
+ ARG_IS_READ_ONLY
};
GtkType
@@ -80,6 +81,9 @@ e_contact_editor_fullname_class_init (EContactEditorFullnameClass *klass)
gtk_object_add_arg_type ("EContactEditorFullname::name", GTK_TYPE_POINTER,
GTK_ARG_READWRITE, ARG_NAME);
+
+ gtk_object_add_arg_type ("EContactEditorFullname::is_read_only", GTK_TYPE_BOOL,
+ GTK_ARG_READWRITE, ARG_IS_READ_ONLY);
object_class->set_arg = e_contact_editor_fullname_set_arg;
object_class->get_arg = e_contact_editor_fullname_get_arg;
@@ -145,6 +149,24 @@ e_contact_editor_fullname_set_arg (GtkObject *o, GtkArg *arg, guint arg_id)
e_contact_editor_fullname->name = e_card_name_copy(GTK_VALUE_POINTER (*arg));
fill_in_info(e_contact_editor_fullname);
break;
+ case ARG_IS_READ_ONLY: {
+ int i;
+ char *entry_names[] = {
+ "combo-title",
+ "combo-suffix",
+ "entry-first",
+ "entry-middle",
+ "entry-last",
+ NULL
+ };
+ e_contact_editor_fullname->is_read_only = GTK_VALUE_BOOL (*arg) ? TRUE : FALSE;
+ for (i = 0; entry_names[i] != NULL; i ++) {
+ gtk_widget_set_sensitive (glade_xml_get_widget(e_contact_editor_fullname->gui,
+ entry_names[i]),
+ !e_contact_editor_fullname->is_read_only);
+ }
+ break;
+ }
}
}
@@ -160,6 +182,9 @@ e_contact_editor_fullname_get_arg (GtkObject *object, GtkArg *arg, guint arg_id)
extract_info(e_contact_editor_fullname);
GTK_VALUE_POINTER (*arg) = e_card_name_copy(e_contact_editor_fullname->name);
break;
+ case ARG_IS_READ_ONLY:
+ GTK_VALUE_BOOL (*arg) = e_contact_editor_fullname->is_read_only ? TRUE : FALSE;
+ break;
default:
arg->type = GTK_TYPE_INVALID;
break;
diff --git a/addressbook/contact-editor/e-contact-editor-fullname.h b/addressbook/contact-editor/e-contact-editor-fullname.h
index bde6733976..b9138da324 100644
--- a/addressbook/contact-editor/e-contact-editor-fullname.h
+++ b/addressbook/contact-editor/e-contact-editor-fullname.h
@@ -56,6 +56,9 @@ struct _EContactEditorFullname
/* item specific fields */
ECardName *name;
GladeXML *gui;
+
+ /* Whether the dialog will accept modifications */
+ guint is_read_only : 1;
};
struct _EContactEditorFullnameClass
diff --git a/addressbook/contact-editor/e-contact-editor.c b/addressbook/contact-editor/e-contact-editor.c
index 7a3e485d05..2edee284f4 100644
--- a/addressbook/contact-editor/e-contact-editor.c
+++ b/addressbook/contact-editor/e-contact-editor.c
@@ -57,6 +57,7 @@ static void _email_arrow_pressed (GtkWidget *widget, GdkEventButton *button, ECo
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 set_read_only(EContactEditor *editor);
static void fill_in_info(EContactEditor *editor);
static void extract_info(EContactEditor *editor);
static void set_fields(EContactEditor *editor);
@@ -72,6 +73,7 @@ enum {
ARG_0,
ARG_CARD,
ARG_IS_NEW_CARD,
+ ARG_IS_READ_ONLY,
ARG_WRITABLE_FIELDS
};
@@ -121,6 +123,8 @@ e_contact_editor_class_init (EContactEditorClass *klass)
GTK_ARG_READWRITE, ARG_IS_NEW_CARD);
gtk_object_add_arg_type ("EContactEditor::writable_fields", GTK_TYPE_POINTER,
GTK_ARG_READWRITE, ARG_WRITABLE_FIELDS);
+ gtk_object_add_arg_type ("EContactEditor::is_read_only", GTK_TYPE_BOOL,
+ GTK_ARG_READWRITE, ARG_IS_READ_ONLY);
contact_editor_signals[ADD_CARD] =
gtk_signal_new ("add_card",
@@ -493,8 +497,13 @@ full_name_clicked(GtkWidget *button, EContactEditor *editor)
{
GnomeDialog *dialog = GNOME_DIALOG(e_contact_editor_fullname_new(editor->name));
int result;
+
+ gtk_object_set (GTK_OBJECT (dialog),
+ "is_read_only", editor->is_read_only,
+ NULL);
gtk_widget_show(GTK_WIDGET(dialog));
result = gnome_dialog_run (dialog);
+
if (result == 0) {
ECardName *name;
GtkWidget *fname_widget;
@@ -531,6 +540,9 @@ full_addr_clicked(GtkWidget *button, EContactEditor *editor)
address = e_card_simple_get_delivery_address(editor->simple, editor->address_choice);
dialog = GNOME_DIALOG(e_contact_editor_address_new(address));
+ gtk_object_set (GTK_OBJECT (dialog),
+ "is_read_only", editor->is_read_only,
+ NULL);
gtk_widget_show(GTK_WIDGET(dialog));
result = gnome_dialog_run (dialog);
@@ -1025,7 +1037,10 @@ e_contact_editor_destroy (GtkObject *object) {
}
EContactEditor *
-e_contact_editor_new (ECard *card, gboolean is_new_card, EList *fields)
+e_contact_editor_new (ECard *card,
+ gboolean is_new_card,
+ EList *fields,
+ gboolean is_read_only)
{
EContactEditor *ce;
@@ -1035,6 +1050,7 @@ e_contact_editor_new (ECard *card, gboolean is_new_card, EList *fields)
"card", card,
"is_new_card", is_new_card,
"writable_fields", fields,
+ "is_read_only", is_read_only,
NULL);
gtk_widget_show (ce->app);
@@ -1063,6 +1079,16 @@ e_contact_editor_set_arg (GtkObject *o, GtkArg *arg, guint arg_id)
editor->is_new_card = GTK_VALUE_BOOL (*arg) ? TRUE : FALSE;
break;
+ case ARG_IS_READ_ONLY: {
+ gboolean new_value = GTK_VALUE_BOOL (*arg) ? TRUE : FALSE;
+ gboolean changed = (editor->is_read_only != new_value);
+
+ editor->is_read_only = new_value;
+
+ if (changed)
+ set_read_only (editor);
+ break;
+ }
case ARG_WRITABLE_FIELDS:
if (editor->writable_fields)
gtk_object_unref(GTK_OBJECT(editor->writable_fields));
@@ -1094,6 +1120,16 @@ e_contact_editor_get_arg (GtkObject *object, GtkArg *arg, guint arg_id)
GTK_VALUE_BOOL (*arg) = e_contact_editor->is_new_card ? TRUE : FALSE;
break;
+ case ARG_IS_READ_ONLY:
+ GTK_VALUE_BOOL (*arg) = e_contact_editor->is_read_only ? TRUE : FALSE;
+ break;
+
+ case ARG_WRITABLE_FIELDS:
+ if (e_contact_editor->writable_fields)
+ GTK_VALUE_POINTER (*arg) = e_list_duplicate (e_contact_editor->writable_fields);
+ else
+ GTK_VALUE_POINTER (*arg) = NULL;
+ break;
default:
arg->type = GTK_TYPE_INVALID;
break;
@@ -1402,7 +1438,7 @@ _phone_arrow_pressed (GtkWidget *widget, GdkEventButton *button, EContactEditor
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);
+ gtk_widget_set_sensitive (glade_xml_get_widget (editor->gui, entry), !editor->is_read_only);
}
g_free(label);
@@ -1435,8 +1471,8 @@ _email_arrow_pressed (GtkWidget *widget, GdkEventButton *button, EContactEditor
/* 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);
+ gtk_widget_set_sensitive (glade_xml_get_widget (editor->gui, "entry-email1"), !editor->is_read_only);
+ gtk_widget_set_sensitive (glade_xml_get_widget (editor->gui, "checkbutton-htmlmail"), !editor->is_read_only);
}
}
@@ -1465,8 +1501,8 @@ _address_arrow_pressed (GtkWidget *widget, GdkEventButton *button, EContactEdito
/* 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);
+ gtk_widget_set_sensitive (glade_xml_get_widget (editor->gui, "button-fulladdr"), !editor->is_read_only);
+ gtk_widget_set_sensitive (glade_xml_get_widget (editor->gui, "text-address"), !editor->is_read_only);
}
}
@@ -1665,52 +1701,56 @@ disable_widget_foreach (char *key, GtkWidget *widget, gpointer closure)
static struct {
char *widget_name;
ECardSimpleField field_id;
+ gboolean desensitize_for_read_only;
} widget_field_mappings[] = {
- { "entry-web", E_CARD_SIMPLE_FIELD_URL },
+ { "entry-web", E_CARD_SIMPLE_FIELD_URL, TRUE },
{ "accellabel-web", E_CARD_SIMPLE_FIELD_URL },
- { "entry-jobtitle", E_CARD_SIMPLE_FIELD_TITLE },
+ { "entry-jobtitle", E_CARD_SIMPLE_FIELD_TITLE, TRUE },
{ "label-jobtitle", E_CARD_SIMPLE_FIELD_TITLE },
- { "entry-company", E_CARD_SIMPLE_FIELD_ORG },
+ { "entry-company", E_CARD_SIMPLE_FIELD_ORG, TRUE },
{ "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 },
+ { "combo-file-as", E_CARD_SIMPLE_FIELD_FILE_AS, TRUE },
+ { "entry-file-as", E_CARD_SIMPLE_FIELD_FILE_AS, TRUE },
{ "accellabel-fileas", E_CARD_SIMPLE_FIELD_FILE_AS },
{ "label-department", E_CARD_SIMPLE_FIELD_ORG_UNIT },
- { "entry-department", E_CARD_SIMPLE_FIELD_ORG_UNIT },
+ { "entry-department", E_CARD_SIMPLE_FIELD_ORG_UNIT, TRUE },
{ "label-office", E_CARD_SIMPLE_FIELD_OFFICE },
- { "entry-office", E_CARD_SIMPLE_FIELD_OFFICE },
+ { "entry-office", E_CARD_SIMPLE_FIELD_OFFICE, TRUE },
{ "label-profession", E_CARD_SIMPLE_FIELD_ROLE },
- { "entry-profession", E_CARD_SIMPLE_FIELD_ROLE },
+ { "entry-profession", E_CARD_SIMPLE_FIELD_ROLE, TRUE },
{ "label-manager", E_CARD_SIMPLE_FIELD_MANAGER },
- { "entry-manager", E_CARD_SIMPLE_FIELD_MANAGER },
+ { "entry-manager", E_CARD_SIMPLE_FIELD_MANAGER, TRUE },
{ "label-assistant", E_CARD_SIMPLE_FIELD_ASSISTANT },
- { "entry-assistant", E_CARD_SIMPLE_FIELD_ASSISTANT },
+ { "entry-assistant", E_CARD_SIMPLE_FIELD_ASSISTANT, TRUE },
{ "label-nickname", E_CARD_SIMPLE_FIELD_NICKNAME },
- { "entry-nickname", E_CARD_SIMPLE_FIELD_NICKNAME },
+ { "entry-nickname", E_CARD_SIMPLE_FIELD_NICKNAME, TRUE },
{ "label-spouse", E_CARD_SIMPLE_FIELD_SPOUSE },
- { "entry-spouse", E_CARD_SIMPLE_FIELD_SPOUSE },
+ { "entry-spouse", E_CARD_SIMPLE_FIELD_SPOUSE, TRUE },
{ "label-birthday", E_CARD_SIMPLE_FIELD_BIRTH_DATE },
- { "dateedit-birthday", E_CARD_SIMPLE_FIELD_BIRTH_DATE },
+ { "dateedit-birthday", E_CARD_SIMPLE_FIELD_BIRTH_DATE, TRUE },
{ "label-anniversary", E_CARD_SIMPLE_FIELD_ANNIVERSARY },
- { "dateedit-anniversary", E_CARD_SIMPLE_FIELD_ANNIVERSARY },
+ { "dateedit-anniversary", E_CARD_SIMPLE_FIELD_ANNIVERSARY, TRUE },
{ "label-comments", E_CARD_SIMPLE_FIELD_NOTE },
- { "text-comments", E_CARD_SIMPLE_FIELD_NOTE },
+ { "text-comments", E_CARD_SIMPLE_FIELD_NOTE, TRUE },
{ "button-fullname", E_CARD_SIMPLE_FIELD_FULL_NAME },
- { "entry-fullname", E_CARD_SIMPLE_FIELD_FULL_NAME }
+ { "entry-fullname", E_CARD_SIMPLE_FIELD_FULL_NAME, TRUE },
+
+ { "button-categories", E_CARD_SIMPLE_FIELD_CATEGORIES, TRUE },
+ { "entry-categories", E_CARD_SIMPLE_FIELD_CATEGORIES, TRUE }
};
static int num_widget_field_mappings = sizeof(widget_field_mappings) / sizeof (widget_field_mappings[0]);
@@ -1792,13 +1832,13 @@ enable_writable_fields(EContactEditor *editor)
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, "entry-email1"), !editor->is_read_only);
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);
+ gtk_widget_set_sensitive (glade_xml_get_widget (editor->gui, "button-fulladdr"), !editor->is_read_only);
+ gtk_widget_set_sensitive (glade_xml_get_widget (editor->gui, "text-address"), !editor->is_read_only);
}
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])))) {
@@ -1806,7 +1846,7 @@ enable_writable_fields(EContactEditor *editor)
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);
+ gtk_widget_set_sensitive (glade_xml_get_widget (editor->gui, widget_name), !editor->is_read_only);
g_free (widget_name);
}
}
@@ -1821,6 +1861,52 @@ enable_writable_fields(EContactEditor *editor)
gtk_widget_set_sensitive (glade_xml_get_widget(editor->gui,
widget_field_mappings[i].widget_name), enabled);
}
+
+ g_hash_table_destroy (dropdown_hash);
+ g_hash_table_destroy (supported_hash);
+}
+
+static void
+set_read_only (EContactEditor *editor)
+{
+ int i;
+ char *label, *entry;
+ /* set the sensitivity of all the non-dropdown entry/texts/dateedits */
+ for (i = 0; i < num_widget_field_mappings; i ++) {
+ if (widget_field_mappings[i].desensitize_for_read_only)
+ gtk_widget_set_sensitive (glade_xml_get_widget(editor->gui,
+ widget_field_mappings[i].widget_name), !editor->is_read_only);
+ }
+
+ /* handle the phone dropdown entries */
+ for (i = 0; i < 4; i ++) {
+ label = g_strdup_printf ("label-phone%d", i+1);
+ entry = g_strdup_printf ("entry-phone%d", i+1);
+
+ if (GTK_WIDGET_IS_SENSITIVE (glade_xml_get_widget (editor->gui, label)))
+ gtk_widget_set_sensitive (glade_xml_get_widget(editor->gui,
+ entry), !editor->is_read_only);
+
+ g_free (label);
+ g_free (entry);
+ }
+
+ /* handle the email dropdown entry */
+ label = "label-email1";
+ entry = "entry-email1";
+ if (GTK_WIDGET_IS_SENSITIVE (glade_xml_get_widget (editor->gui, label))) {
+ gtk_widget_set_sensitive (glade_xml_get_widget(editor->gui,
+ entry), !editor->is_read_only);
+ gtk_widget_set_sensitive (glade_xml_get_widget(editor->gui,
+ "checkbutton-htmlmail"), !editor->is_read_only);
+ }
+
+ /* handle the address dropdown entry */
+ label = "label-address";
+ entry = "text-address";
+ if (GTK_WIDGET_IS_SENSITIVE (glade_xml_get_widget (editor->gui, label)))
+ gtk_widget_set_sensitive (glade_xml_get_widget(editor->gui,
+ entry), !editor->is_read_only);
}
static void
diff --git a/addressbook/contact-editor/e-contact-editor.h b/addressbook/contact-editor/e-contact-editor.h
index ef2b1238df..184829b64c 100644
--- a/addressbook/contact-editor/e-contact-editor.h
+++ b/addressbook/contact-editor/e-contact-editor.h
@@ -86,6 +86,9 @@ struct _EContactEditor
/* Whether we are editing a new card or an existing one */
guint is_new_card : 1;
+ /* Whether the contact editor will accept modifications */
+ guint is_read_only : 1;
+
EList *writable_fields;
};
@@ -103,7 +106,8 @@ struct _EContactEditorClass
EContactEditor *e_contact_editor_new (ECard *card,
gboolean is_new_card,
- EList *writable_fields);
+ EList *writable_fields,
+ gboolean is_read_only);
GtkType e_contact_editor_get_type (void);
void e_contact_editor_raise (EContactEditor *editor);
diff --git a/addressbook/contact-editor/e-contact-quick-add.c b/addressbook/contact-editor/e-contact-quick-add.c
index 2592f797a5..d398719a65 100644
--- a/addressbook/contact-editor/e-contact-quick-add.c
+++ b/addressbook/contact-editor/e-contact-quick-add.c
@@ -124,7 +124,7 @@ ce_book_found_fields (EBook *book, EBookStatus status, EList *fields, gpointer u
return;
}
- contact_editor = e_contact_editor_new (card, TRUE, fields);
+ contact_editor = e_contact_editor_new (card, TRUE, fields, FALSE /* XXX */);
gtk_signal_connect (GTK_OBJECT (contact_editor),
"add_card",
diff --git a/addressbook/contact-editor/test-editor.c b/addressbook/contact-editor/test-editor.c
index e9060b3e25..8a6920107b 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, NULL);
+ ce = e_contact_editor_new (e_card_new (cardstr), TRUE, NULL, FALSE);
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, NULL);
+ ce = e_contact_editor_new (e_card_new (cardstr), TRUE, NULL, FALSE);
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 1208923d35..0679f68598 100644
--- a/addressbook/gui/component/addressbook.c
+++ b/addressbook/gui/component/addressbook.c
@@ -105,7 +105,7 @@ supported_fields_cb (EBook *book, EBookStatus status, EList *fields, gpointer cl
card = e_card_new("");
- ce = e_contact_editor_new (card, TRUE, fields);
+ ce = e_contact_editor_new (card, TRUE, fields, FALSE);
gtk_signal_connect (GTK_OBJECT (ce), "add_card",
GTK_SIGNAL_FUNC (add_card_cb), book);
diff --git a/addressbook/gui/component/select-names/e-select-names-text-model.c b/addressbook/gui/component/select-names/e-select-names-text-model.c
index 0e4d5eeb32..1a1bd06b60 100644
--- a/addressbook/gui/component/select-names/e-select-names-text-model.c
+++ b/addressbook/gui/component/select-names/e-select-names-text-model.c
@@ -712,7 +712,8 @@ e_select_names_text_model_activate_obj (ETextModel *model, gint n)
card = e_select_names_model_get_card (source, i);
g_return_if_fail (card);
- contact_editor = e_contact_editor_new ((ECard *) card, FALSE, NULL);
+ /* present read-only contact editor when someone double clicks from here */
+ contact_editor = e_contact_editor_new ((ECard *) card, FALSE, NULL, TRUE);
e_contact_editor_raise (contact_editor);
}
diff --git a/addressbook/gui/contact-editor/e-contact-editor-address.c b/addressbook/gui/contact-editor/e-contact-editor-address.c
index 7df9cb8cb4..1df0462b7d 100644
--- a/addressbook/gui/contact-editor/e-contact-editor-address.c
+++ b/addressbook/gui/contact-editor/e-contact-editor-address.c
@@ -39,7 +39,8 @@ static GnomeDialogClass *parent_class = NULL;
/* The arguments we take */
enum {
ARG_0,
- ARG_ADDRESS
+ ARG_ADDRESS,
+ ARG_IS_READ_ONLY
};
GtkType
@@ -80,6 +81,8 @@ e_contact_editor_address_class_init (EContactEditorAddressClass *klass)
gtk_object_add_arg_type ("EContactEditorAddress::address", GTK_TYPE_POINTER,
GTK_ARG_READWRITE, ARG_ADDRESS);
+ gtk_object_add_arg_type ("EContactEditorAddress::is_read_only", GTK_TYPE_BOOL,
+ GTK_ARG_READWRITE, ARG_IS_READ_ONLY);
object_class->set_arg = e_contact_editor_address_set_arg;
object_class->get_arg = e_contact_editor_address_get_arg;
@@ -146,6 +149,24 @@ e_contact_editor_address_set_arg (GtkObject *o, GtkArg *arg, guint arg_id)
e_contact_editor_address->address = e_card_delivery_address_copy(GTK_VALUE_POINTER (*arg));
fill_in_info(e_contact_editor_address);
break;
+ case ARG_IS_READ_ONLY: {
+ int i;
+ char *entry_names[] = {
+ "entry-street",
+ "entry-city",
+ "entry-ext",
+ "entry-po",
+ "entry-region",
+ "combo-country",
+ "entry-code",
+ NULL
+ };
+ e_contact_editor_address->is_read_only = GTK_VALUE_BOOL (*arg) ? TRUE : FALSE;
+ for (i = 0; entry_names[i] != NULL; i ++) {
+ gtk_widget_set_sensitive (glade_xml_get_widget(e_contact_editor_address->gui, entry_names[i]), !e_contact_editor_address->is_read_only);
+ }
+ break;
+ }
}
}
@@ -161,6 +182,9 @@ e_contact_editor_address_get_arg (GtkObject *object, GtkArg *arg, guint arg_id)
extract_info(e_contact_editor_address);
GTK_VALUE_POINTER (*arg) = e_card_delivery_address_copy(e_contact_editor_address->address);
break;
+ case ARG_IS_READ_ONLY:
+ GTK_VALUE_BOOL (*arg) = e_contact_editor_address->is_read_only ? TRUE : FALSE;
+ break;
default:
arg->type = GTK_TYPE_INVALID;
break;
diff --git a/addressbook/gui/contact-editor/e-contact-editor-address.h b/addressbook/gui/contact-editor/e-contact-editor-address.h
index a74e1bd967..95fe8bf865 100644
--- a/addressbook/gui/contact-editor/e-contact-editor-address.h
+++ b/addressbook/gui/contact-editor/e-contact-editor-address.h
@@ -55,6 +55,9 @@ struct _EContactEditorAddress
/* item specific fields */
ECardDeliveryAddress *address;
+
+ guint is_read_only : 1;
+
GladeXML *gui;
};
diff --git a/addressbook/gui/contact-editor/e-contact-editor-fullname.c b/addressbook/gui/contact-editor/e-contact-editor-fullname.c
index 05e8d45702..0fb7fb57d0 100644
--- a/addressbook/gui/contact-editor/e-contact-editor-fullname.c
+++ b/addressbook/gui/contact-editor/e-contact-editor-fullname.c
@@ -39,7 +39,8 @@ static GnomeDialogClass *parent_class = NULL;
/* The arguments we take */
enum {
ARG_0,
- ARG_NAME
+ ARG_NAME,
+ ARG_IS_READ_ONLY
};
GtkType
@@ -80,6 +81,9 @@ e_contact_editor_fullname_class_init (EContactEditorFullnameClass *klass)
gtk_object_add_arg_type ("EContactEditorFullname::name", GTK_TYPE_POINTER,
GTK_ARG_READWRITE, ARG_NAME);
+
+ gtk_object_add_arg_type ("EContactEditorFullname::is_read_only", GTK_TYPE_BOOL,
+ GTK_ARG_READWRITE, ARG_IS_READ_ONLY);
object_class->set_arg = e_contact_editor_fullname_set_arg;
object_class->get_arg = e_contact_editor_fullname_get_arg;
@@ -145,6 +149,24 @@ e_contact_editor_fullname_set_arg (GtkObject *o, GtkArg *arg, guint arg_id)
e_contact_editor_fullname->name = e_card_name_copy(GTK_VALUE_POINTER (*arg));
fill_in_info(e_contact_editor_fullname);
break;
+ case ARG_IS_READ_ONLY: {
+ int i;
+ char *entry_names[] = {
+ "combo-title",
+ "combo-suffix",
+ "entry-first",
+ "entry-middle",
+ "entry-last",
+ NULL
+ };
+ e_contact_editor_fullname->is_read_only = GTK_VALUE_BOOL (*arg) ? TRUE : FALSE;
+ for (i = 0; entry_names[i] != NULL; i ++) {
+ gtk_widget_set_sensitive (glade_xml_get_widget(e_contact_editor_fullname->gui,
+ entry_names[i]),
+ !e_contact_editor_fullname->is_read_only);
+ }
+ break;
+ }
}
}
@@ -160,6 +182,9 @@ e_contact_editor_fullname_get_arg (GtkObject *object, GtkArg *arg, guint arg_id)
extract_info(e_contact_editor_fullname);
GTK_VALUE_POINTER (*arg) = e_card_name_copy(e_contact_editor_fullname->name);
break;
+ case ARG_IS_READ_ONLY:
+ GTK_VALUE_BOOL (*arg) = e_contact_editor_fullname->is_read_only ? TRUE : FALSE;
+ break;
default:
arg->type = GTK_TYPE_INVALID;
break;
diff --git a/addressbook/gui/contact-editor/e-contact-editor-fullname.h b/addressbook/gui/contact-editor/e-contact-editor-fullname.h
index bde6733976..b9138da324 100644
--- a/addressbook/gui/contact-editor/e-contact-editor-fullname.h
+++ b/addressbook/gui/contact-editor/e-contact-editor-fullname.h
@@ -56,6 +56,9 @@ struct _EContactEditorFullname
/* item specific fields */
ECardName *name;
GladeXML *gui;
+
+ /* Whether the dialog will accept modifications */
+ guint is_read_only : 1;
};
struct _EContactEditorFullnameClass
diff --git a/addressbook/gui/contact-editor/e-contact-editor.c b/addressbook/gui/contact-editor/e-contact-editor.c
index 7a3e485d05..2edee284f4 100644
--- a/addressbook/gui/contact-editor/e-contact-editor.c
+++ b/addressbook/gui/contact-editor/e-contact-editor.c
@@ -57,6 +57,7 @@ static void _email_arrow_pressed (GtkWidget *widget, GdkEventButton *button, ECo
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 set_read_only(EContactEditor *editor);
static void fill_in_info(EContactEditor *editor);
static void extract_info(EContactEditor *editor);
static void set_fields(EContactEditor *editor);
@@ -72,6 +73,7 @@ enum {
ARG_0,
ARG_CARD,
ARG_IS_NEW_CARD,
+ ARG_IS_READ_ONLY,
ARG_WRITABLE_FIELDS
};
@@ -121,6 +123,8 @@ e_contact_editor_class_init (EContactEditorClass *klass)
GTK_ARG_READWRITE, ARG_IS_NEW_CARD);
gtk_object_add_arg_type ("EContactEditor::writable_fields", GTK_TYPE_POINTER,
GTK_ARG_READWRITE, ARG_WRITABLE_FIELDS);
+ gtk_object_add_arg_type ("EContactEditor::is_read_only", GTK_TYPE_BOOL,
+ GTK_ARG_READWRITE, ARG_IS_READ_ONLY);
contact_editor_signals[ADD_CARD] =
gtk_signal_new ("add_card",
@@ -493,8 +497,13 @@ full_name_clicked(GtkWidget *button, EContactEditor *editor)
{
GnomeDialog *dialog = GNOME_DIALOG(e_contact_editor_fullname_new(editor->name));
int result;
+
+ gtk_object_set (GTK_OBJECT (dialog),
+ "is_read_only", editor->is_read_only,
+ NULL);
gtk_widget_show(GTK_WIDGET(dialog));
result = gnome_dialog_run (dialog);
+
if (result == 0) {
ECardName *name;
GtkWidget *fname_widget;
@@ -531,6 +540,9 @@ full_addr_clicked(GtkWidget *button, EContactEditor *editor)
address = e_card_simple_get_delivery_address(editor->simple, editor->address_choice);
dialog = GNOME_DIALOG(e_contact_editor_address_new(address));
+ gtk_object_set (GTK_OBJECT (dialog),
+ "is_read_only", editor->is_read_only,
+ NULL);
gtk_widget_show(GTK_WIDGET(dialog));
result = gnome_dialog_run (dialog);
@@ -1025,7 +1037,10 @@ e_contact_editor_destroy (GtkObject *object) {
}
EContactEditor *
-e_contact_editor_new (ECard *card, gboolean is_new_card, EList *fields)
+e_contact_editor_new (ECard *card,
+ gboolean is_new_card,
+ EList *fields,
+ gboolean is_read_only)
{
EContactEditor *ce;
@@ -1035,6 +1050,7 @@ e_contact_editor_new (ECard *card, gboolean is_new_card, EList *fields)
"card", card,
"is_new_card", is_new_card,
"writable_fields", fields,
+ "is_read_only", is_read_only,
NULL);
gtk_widget_show (ce->app);
@@ -1063,6 +1079,16 @@ e_contact_editor_set_arg (GtkObject *o, GtkArg *arg, guint arg_id)
editor->is_new_card = GTK_VALUE_BOOL (*arg) ? TRUE : FALSE;
break;
+ case ARG_IS_READ_ONLY: {
+ gboolean new_value = GTK_VALUE_BOOL (*arg) ? TRUE : FALSE;
+ gboolean changed = (editor->is_read_only != new_value);
+
+ editor->is_read_only = new_value;
+
+ if (changed)
+ set_read_only (editor);
+ break;
+ }
case ARG_WRITABLE_FIELDS:
if (editor->writable_fields)
gtk_object_unref(GTK_OBJECT(editor->writable_fields));
@@ -1094,6 +1120,16 @@ e_contact_editor_get_arg (GtkObject *object, GtkArg *arg, guint arg_id)
GTK_VALUE_BOOL (*arg) = e_contact_editor->is_new_card ? TRUE : FALSE;
break;
+ case ARG_IS_READ_ONLY:
+ GTK_VALUE_BOOL (*arg) = e_contact_editor->is_read_only ? TRUE : FALSE;
+ break;
+
+ case ARG_WRITABLE_FIELDS:
+ if (e_contact_editor->writable_fields)
+ GTK_VALUE_POINTER (*arg) = e_list_duplicate (e_contact_editor->writable_fields);
+ else
+ GTK_VALUE_POINTER (*arg) = NULL;
+ break;
default:
arg->type = GTK_TYPE_INVALID;
break;
@@ -1402,7 +1438,7 @@ _phone_arrow_pressed (GtkWidget *widget, GdkEventButton *button, EContactEditor
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);
+ gtk_widget_set_sensitive (glade_xml_get_widget (editor->gui, entry), !editor->is_read_only);
}
g_free(label);
@@ -1435,8 +1471,8 @@ _email_arrow_pressed (GtkWidget *widget, GdkEventButton *button, EContactEditor
/* 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);
+ gtk_widget_set_sensitive (glade_xml_get_widget (editor->gui, "entry-email1"), !editor->is_read_only);
+ gtk_widget_set_sensitive (glade_xml_get_widget (editor->gui, "checkbutton-htmlmail"), !editor->is_read_only);
}
}
@@ -1465,8 +1501,8 @@ _address_arrow_pressed (GtkWidget *widget, GdkEventButton *button, EContactEdito
/* 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);
+ gtk_widget_set_sensitive (glade_xml_get_widget (editor->gui, "button-fulladdr"), !editor->is_read_only);
+ gtk_widget_set_sensitive (glade_xml_get_widget (editor->gui, "text-address"), !editor->is_read_only);
}
}
@@ -1665,52 +1701,56 @@ disable_widget_foreach (char *key, GtkWidget *widget, gpointer closure)
static struct {
char *widget_name;
ECardSimpleField field_id;
+ gboolean desensitize_for_read_only;
} widget_field_mappings[] = {
- { "entry-web", E_CARD_SIMPLE_FIELD_URL },
+ { "entry-web", E_CARD_SIMPLE_FIELD_URL, TRUE },
{ "accellabel-web", E_CARD_SIMPLE_FIELD_URL },
- { "entry-jobtitle", E_CARD_SIMPLE_FIELD_TITLE },
+ { "entry-jobtitle", E_CARD_SIMPLE_FIELD_TITLE, TRUE },
{ "label-jobtitle", E_CARD_SIMPLE_FIELD_TITLE },
- { "entry-company", E_CARD_SIMPLE_FIELD_ORG },
+ { "entry-company", E_CARD_SIMPLE_FIELD_ORG, TRUE },
{ "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 },
+ { "combo-file-as", E_CARD_SIMPLE_FIELD_FILE_AS, TRUE },
+ { "entry-file-as", E_CARD_SIMPLE_FIELD_FILE_AS, TRUE },
{ "accellabel-fileas", E_CARD_SIMPLE_FIELD_FILE_AS },
{ "label-department", E_CARD_SIMPLE_FIELD_ORG_UNIT },
- { "entry-department", E_CARD_SIMPLE_FIELD_ORG_UNIT },
+ { "entry-department", E_CARD_SIMPLE_FIELD_ORG_UNIT, TRUE },
{ "label-office", E_CARD_SIMPLE_FIELD_OFFICE },
- { "entry-office", E_CARD_SIMPLE_FIELD_OFFICE },
+ { "entry-office", E_CARD_SIMPLE_FIELD_OFFICE, TRUE },
{ "label-profession", E_CARD_SIMPLE_FIELD_ROLE },
- { "entry-profession", E_CARD_SIMPLE_FIELD_ROLE },
+ { "entry-profession", E_CARD_SIMPLE_FIELD_ROLE, TRUE },
{ "label-manager", E_CARD_SIMPLE_FIELD_MANAGER },
- { "entry-manager", E_CARD_SIMPLE_FIELD_MANAGER },
+ { "entry-manager", E_CARD_SIMPLE_FIELD_MANAGER, TRUE },
{ "label-assistant", E_CARD_SIMPLE_FIELD_ASSISTANT },
- { "entry-assistant", E_CARD_SIMPLE_FIELD_ASSISTANT },
+ { "entry-assistant", E_CARD_SIMPLE_FIELD_ASSISTANT, TRUE },
{ "label-nickname", E_CARD_SIMPLE_FIELD_NICKNAME },
- { "entry-nickname", E_CARD_SIMPLE_FIELD_NICKNAME },
+ { "entry-nickname", E_CARD_SIMPLE_FIELD_NICKNAME, TRUE },
{ "label-spouse", E_CARD_SIMPLE_FIELD_SPOUSE },
- { "entry-spouse", E_CARD_SIMPLE_FIELD_SPOUSE },
+ { "entry-spouse", E_CARD_SIMPLE_FIELD_SPOUSE, TRUE },
{ "label-birthday", E_CARD_SIMPLE_FIELD_BIRTH_DATE },
- { "dateedit-birthday", E_CARD_SIMPLE_FIELD_BIRTH_DATE },
+ { "dateedit-birthday", E_CARD_SIMPLE_FIELD_BIRTH_DATE, TRUE },
{ "label-anniversary", E_CARD_SIMPLE_FIELD_ANNIVERSARY },
- { "dateedit-anniversary", E_CARD_SIMPLE_FIELD_ANNIVERSARY },
+ { "dateedit-anniversary", E_CARD_SIMPLE_FIELD_ANNIVERSARY, TRUE },
{ "label-comments", E_CARD_SIMPLE_FIELD_NOTE },
- { "text-comments", E_CARD_SIMPLE_FIELD_NOTE },
+ { "text-comments", E_CARD_SIMPLE_FIELD_NOTE, TRUE },
{ "button-fullname", E_CARD_SIMPLE_FIELD_FULL_NAME },
- { "entry-fullname", E_CARD_SIMPLE_FIELD_FULL_NAME }
+ { "entry-fullname", E_CARD_SIMPLE_FIELD_FULL_NAME, TRUE },
+
+ { "button-categories", E_CARD_SIMPLE_FIELD_CATEGORIES, TRUE },
+ { "entry-categories", E_CARD_SIMPLE_FIELD_CATEGORIES, TRUE }
};
static int num_widget_field_mappings = sizeof(widget_field_mappings) / sizeof (widget_field_mappings[0]);
@@ -1792,13 +1832,13 @@ enable_writable_fields(EContactEditor *editor)
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, "entry-email1"), !editor->is_read_only);
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);
+ gtk_widget_set_sensitive (glade_xml_get_widget (editor->gui, "button-fulladdr"), !editor->is_read_only);
+ gtk_widget_set_sensitive (glade_xml_get_widget (editor->gui, "text-address"), !editor->is_read_only);
}
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])))) {
@@ -1806,7 +1846,7 @@ enable_writable_fields(EContactEditor *editor)
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);
+ gtk_widget_set_sensitive (glade_xml_get_widget (editor->gui, widget_name), !editor->is_read_only);
g_free (widget_name);
}
}
@@ -1821,6 +1861,52 @@ enable_writable_fields(EContactEditor *editor)
gtk_widget_set_sensitive (glade_xml_get_widget(editor->gui,
widget_field_mappings[i].widget_name), enabled);
}
+
+ g_hash_table_destroy (dropdown_hash);
+ g_hash_table_destroy (supported_hash);
+}
+
+static void
+set_read_only (EContactEditor *editor)
+{
+ int i;
+ char *label, *entry;
+ /* set the sensitivity of all the non-dropdown entry/texts/dateedits */
+ for (i = 0; i < num_widget_field_mappings; i ++) {
+ if (widget_field_mappings[i].desensitize_for_read_only)
+ gtk_widget_set_sensitive (glade_xml_get_widget(editor->gui,
+ widget_field_mappings[i].widget_name), !editor->is_read_only);
+ }
+
+ /* handle the phone dropdown entries */
+ for (i = 0; i < 4; i ++) {
+ label = g_strdup_printf ("label-phone%d", i+1);
+ entry = g_strdup_printf ("entry-phone%d", i+1);
+
+ if (GTK_WIDGET_IS_SENSITIVE (glade_xml_get_widget (editor->gui, label)))
+ gtk_widget_set_sensitive (glade_xml_get_widget(editor->gui,
+ entry), !editor->is_read_only);
+
+ g_free (label);
+ g_free (entry);
+ }
+
+ /* handle the email dropdown entry */
+ label = "label-email1";
+ entry = "entry-email1";
+ if (GTK_WIDGET_IS_SENSITIVE (glade_xml_get_widget (editor->gui, label))) {
+ gtk_widget_set_sensitive (glade_xml_get_widget(editor->gui,
+ entry), !editor->is_read_only);
+ gtk_widget_set_sensitive (glade_xml_get_widget(editor->gui,
+ "checkbutton-htmlmail"), !editor->is_read_only);
+ }
+
+ /* handle the address dropdown entry */
+ label = "label-address";
+ entry = "text-address";
+ if (GTK_WIDGET_IS_SENSITIVE (glade_xml_get_widget (editor->gui, label)))
+ gtk_widget_set_sensitive (glade_xml_get_widget(editor->gui,
+ entry), !editor->is_read_only);
}
static void
diff --git a/addressbook/gui/contact-editor/e-contact-editor.h b/addressbook/gui/contact-editor/e-contact-editor.h
index ef2b1238df..184829b64c 100644
--- a/addressbook/gui/contact-editor/e-contact-editor.h
+++ b/addressbook/gui/contact-editor/e-contact-editor.h
@@ -86,6 +86,9 @@ struct _EContactEditor
/* Whether we are editing a new card or an existing one */
guint is_new_card : 1;
+ /* Whether the contact editor will accept modifications */
+ guint is_read_only : 1;
+
EList *writable_fields;
};
@@ -103,7 +106,8 @@ struct _EContactEditorClass
EContactEditor *e_contact_editor_new (ECard *card,
gboolean is_new_card,
- EList *writable_fields);
+ EList *writable_fields,
+ gboolean is_read_only);
GtkType e_contact_editor_get_type (void);
void e_contact_editor_raise (EContactEditor *editor);
diff --git a/addressbook/gui/contact-editor/e-contact-quick-add.c b/addressbook/gui/contact-editor/e-contact-quick-add.c
index 2592f797a5..d398719a65 100644
--- a/addressbook/gui/contact-editor/e-contact-quick-add.c
+++ b/addressbook/gui/contact-editor/e-contact-quick-add.c
@@ -124,7 +124,7 @@ ce_book_found_fields (EBook *book, EBookStatus status, EList *fields, gpointer u
return;
}
- contact_editor = e_contact_editor_new (card, TRUE, fields);
+ contact_editor = e_contact_editor_new (card, TRUE, fields, FALSE /* XXX */);
gtk_signal_connect (GTK_OBJECT (contact_editor),
"add_card",
diff --git a/addressbook/gui/contact-editor/test-editor.c b/addressbook/gui/contact-editor/test-editor.c
index e9060b3e25..8a6920107b 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, NULL);
+ ce = e_contact_editor_new (e_card_new (cardstr), TRUE, NULL, FALSE);
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, NULL);
+ ce = e_contact_editor_new (e_card_new (cardstr), TRUE, NULL, FALSE);
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 b19d185d93..1ecdec06f3 100644
--- a/addressbook/gui/widgets/e-addressbook-view.c
+++ b/addressbook/gui/widgets/e-addressbook-view.c
@@ -396,7 +396,7 @@ supported_fields_cb (EBook *book, EBookStatus status, EList *fields, ECard *card
{
EContactEditor *ce;
- ce = e_contact_editor_new (card, FALSE, fields);
+ ce = e_contact_editor_new (card, FALSE, fields, FALSE);
gtk_signal_connect (GTK_OBJECT (ce), "add_card",
GTK_SIGNAL_FUNC (add_card_cb), book);
diff --git a/addressbook/gui/widgets/e-minicard-view.c b/addressbook/gui/widgets/e-minicard-view.c
index e503d54d1f..7aac3e1641 100644
--- a/addressbook/gui/widgets/e-minicard-view.c
+++ b/addressbook/gui/widgets/e-minicard-view.c
@@ -409,7 +409,7 @@ supported_fields_cb (EBook *book, EBookStatus status, EList *fields, EMinicard *
card = e_card_new("");
- ce = e_contact_editor_new (card, TRUE, fields);
+ ce = e_contact_editor_new (card, TRUE, fields, FALSE);
gtk_signal_connect (GTK_OBJECT (ce), "add_card",
GTK_SIGNAL_FUNC (add_card_cb), book);
diff --git a/addressbook/gui/widgets/e-minicard.c b/addressbook/gui/widgets/e-minicard.c
index f55999e140..ec94d0fcb8 100644
--- a/addressbook/gui/widgets/e-minicard.c
+++ b/addressbook/gui/widgets/e-minicard.c
@@ -560,7 +560,7 @@ editor_closed_cb (EContactEditor *ce, gpointer data)
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);
+ e_minicard->editor = e_contact_editor_new (e_minicard->card, FALSE, fields, FALSE);
if (book != NULL) {
gtk_signal_connect (GTK_OBJECT (e_minicard->editor), "add_card",