aboutsummaryrefslogtreecommitdiffstats
path: root/addressbook
diff options
context:
space:
mode:
Diffstat (limited to 'addressbook')
-rw-r--r--addressbook/ChangeLog97
-rw-r--r--addressbook/backend/ebook/e-book-listener.c25
-rw-r--r--addressbook/backend/ebook/e-book-listener.h4
-rw-r--r--addressbook/backend/ebook/e-book.c21
-rw-r--r--addressbook/backend/ebook/e-book.h5
-rw-r--r--addressbook/backend/idl/addressbook.idl14
-rw-r--r--addressbook/backend/pas/pas-backend-file.c48
-rw-r--r--addressbook/backend/pas/pas-backend-ldap.c3
-rw-r--r--addressbook/backend/pas/pas-book.c22
-rw-r--r--addressbook/backend/pas/pas-book.h3
-rw-r--r--addressbook/gui/widgets/e-addressbook-model.c2
-rw-r--r--addressbook/gui/widgets/e-addressbook-view.c38
-rw-r--r--addressbook/gui/widgets/e-addressbook-view.h1
-rw-r--r--addressbook/gui/widgets/e-minicard-label.c12
-rw-r--r--addressbook/gui/widgets/e-minicard-label.h1
-rw-r--r--addressbook/gui/widgets/e-minicard-view-widget.c16
-rw-r--r--addressbook/gui/widgets/e-minicard-view-widget.h1
-rw-r--r--addressbook/gui/widgets/e-minicard-view.c27
-rw-r--r--addressbook/gui/widgets/e-minicard-view.h1
-rw-r--r--addressbook/gui/widgets/e-minicard.c20
-rw-r--r--addressbook/gui/widgets/e-minicard.h4
21 files changed, 334 insertions, 31 deletions
diff --git a/addressbook/ChangeLog b/addressbook/ChangeLog
index c364a884fe..5a8780b1d4 100644
--- a/addressbook/ChangeLog
+++ b/addressbook/ChangeLog
@@ -1,3 +1,100 @@
+2001-03-17 Chris Toshok <toshok@ximian.com>
+
+ * backend/ebook/e-book-listener.c
+ (e_book_listener_queue_writable_status): new function.
+ (impl_BookListener_report_writable): new function.
+ (e_book_listener_get_epv): fill in epv->notifyWritable.
+
+ * backend/ebook/e-book-listener.h: add writable status entries.
+
+ * backend/ebook/e-book.c (e_book_do_writable_event): new function.
+ (e_book_check_listener_queue): add WritableStatusEvent to the
+ switch.
+ (e_book_class_init): register writable_status signal.
+
+ * backend/ebook/e-book.h: add writable_status signal.
+
+ * backend/idl/addressbook.idl: add notifyWritable method to
+ BookListener.
+
+ * gui/widgets/e-minicard.c (e_minicard_class_init): add "editable"
+ arg.
+ (e_minicard_init): init editable.
+ (e_minicard_set_arg): loop over the minicard fields setting their
+ "editable".
+ (e_minicard_get_arg): add editable.
+ (supported_fields_cb): use editable when creating the
+ contact_editor.
+ (add_field): set "editable" when creatin the e_minicard.
+
+ * gui/widgets/e-minicard.h (struct _EMinicard): add "editable".
+
+ * gui/widgets/e-minicard-view.c (e_minicard_view_class_init): add
+ editable arg.
+ (e_minicard_view_init): init editable.
+ (create_card): pass editable to e_minicard canvas item.
+ (e_minicard_view_set_arg): bit of a hack - loop over all the
+ canvas items setting their "editable."
+ (e_minicard_view_get_arg): add editable.
+ (supported_fields_cb): use editable when creating the contact
+ editor.
+
+ * gui/widgets/e-minicard-view.h (struct _EMinicardView): add
+ "editable."
+
+ * gui/widgets/e-minicard-view-widget.c
+ (e_minicard_view_widget_class_init): add "editable" field.
+ (e_minicard_view_widget_init): init editable to FALSE.
+ (e_minicard_view_widget_set_arg): save editable, and pass it along
+ the e-minicard-view.
+ (e_minicard_view_widget_realize): same.
+ (e_minicard_view_widget_get_arg): add editable.
+
+ * gui/widgets/e-minicard-view-widget.h (struct
+ _EMinicardViewWidget): add "editable" field.
+
+ * gui/widgets/e-minicard-label.h (struct _EMinicardLabel): add
+ "editable" field.
+
+ * gui/widgets/e-minicard-label.c (e_minicard_label_class_init):
+ add "editable" arg.
+ (e_minicard_label_set_arg): editable, set it on the e_text too.
+ (e_minicard_label_get_arg): editable.
+ (e_minicard_label_construct): set the "editable" field when we
+ create the e_text cavas item
+
+ * gui/widgets/e-addressbook-view.c (e_addressbook_view_init):
+ default editable to FALSE.
+ (book_writable_cb): new function, set our editable field and
+ gtk_object_set it on the active view.
+ (e_addressbook_view_set_arg): set the active view's editable when
+ we set the view's book, and connect the "writable_status" signal
+ to book_writable_cb.
+ (change_view_type): same.
+ (supported_fields_cb): use our "editable" when creating the
+ contact editor.
+
+ * gui/widgets/e-addressbook-view.h (struct _EAddressbookView): add
+ editable field.
+
+ * gui/widgets/e-addressbook-model.c (e_addressbook_model_init):
+ change the default of editable to FALSE.
+
+ * backend/pas/pas-book.c (pas_book_report_writable): new function.
+
+ * backend/pas/pas-book.h: prototype for pas_book_report_writable.
+
+ * backend/pas/pas-backend-file.c (pas_backend_file_load_uri): if
+ we open the file O_RDWR (or create it) report it as writable. if
+ we can't open it as O_RDWR, try opening it read-only before we
+ attempt to create it.
+
+ * backend/pas/pas-backend-ldap.c
+ (pas_backend_ldap_process_authenticate_user): if we authenticate
+ successfully, grant write permissions (this is lacking but there's
+ really nothing we can do to determine the extent of the access
+ afforded a user.)
+
2001-03-15 Jon Trowbridge <trow@ximian.com>
* gui/component/e-address-widget.c: Added addressbook querying and
diff --git a/addressbook/backend/ebook/e-book-listener.c b/addressbook/backend/ebook/e-book-listener.c
index 0aaf5483a5..e1d47d70d2 100644
--- a/addressbook/backend/ebook/e-book-listener.c
+++ b/addressbook/backend/ebook/e-book-listener.c
@@ -188,6 +188,20 @@ e_book_listener_queue_link_status (EBookListener *listener,
}
static void
+e_book_listener_queue_writable_status (EBookListener *listener,
+ gboolean writable)
+{
+ EBookListenerResponse *resp;
+
+ resp = g_new0 (EBookListenerResponse, 1);
+
+ resp->op = WritableStatusEvent;
+ resp->writable = writable;
+
+ e_book_listener_queue_response (listener, resp);
+}
+
+static void
e_book_listener_queue_authentication_response (EBookListener *listener,
EBookStatus status)
{
@@ -394,6 +408,16 @@ impl_BookListener_report_connection_status (PortableServer_Servant servant,
listener, connected);
}
+static void
+impl_BookListener_report_writable (PortableServer_Servant servant,
+ const CORBA_boolean writable,
+ CORBA_Environment *ev)
+{
+ EBookListener *listener = E_BOOK_LISTENER (bonobo_object_from_servant (servant));
+
+ e_book_listener_queue_writable_status (listener, writable);
+}
+
/**
* e_book_listener_check_pending:
* @listener: the #EBookListener
@@ -627,6 +651,7 @@ e_book_listener_get_epv (void)
epv->notifyChangesRequested = impl_BookListener_respond_get_changes;
epv->notifyConnectionStatus = impl_BookListener_report_connection_status;
+ epv->notifyWritable = impl_BookListener_report_writable;
return epv;
}
diff --git a/addressbook/backend/ebook/e-book-listener.h b/addressbook/backend/ebook/e-book-listener.h
index 0390f7fcb2..84cdfecced 100644
--- a/addressbook/backend/ebook/e-book-listener.h
+++ b/addressbook/backend/ebook/e-book-listener.h
@@ -52,6 +52,7 @@ typedef enum {
/* Async events */
LinkStatusEvent,
+ WritableStatusEvent,
OpenProgressEvent,
} EBookListenerOperation;
@@ -80,6 +81,9 @@ typedef struct {
/* For LinkStatusEvent */
gboolean connected;
+ /* For WritableStatusEvent */
+ gboolean writable;
+
/* For Card[Added|Removed|Modified]Event */
char *id;
} EBookListenerResponse;
diff --git a/addressbook/backend/ebook/e-book.c b/addressbook/backend/ebook/e-book.c
index 2a02b78fbf..25fb42a37b 100644
--- a/addressbook/backend/ebook/e-book.c
+++ b/addressbook/backend/ebook/e-book.c
@@ -50,6 +50,7 @@ struct _EBookPrivate {
enum {
OPEN_PROGRESS,
+ WRITABLE_STATUS,
LINK_STATUS,
LAST_SIGNAL
};
@@ -336,6 +337,14 @@ e_book_do_link_event (EBook *book,
}
static void
+e_book_do_writable_event (EBook *book,
+ EBookListenerResponse *resp)
+{
+ gtk_signal_emit (GTK_OBJECT (book), e_book_signals [WRITABLE_STATUS],
+ resp->writable);
+}
+
+static void
e_book_do_response_get_supported_fields (EBook *book,
EBookListenerResponse *resp)
{
@@ -398,6 +407,9 @@ e_book_check_listener_queue (EBookListener *listener, EBook *book)
case LinkStatusEvent:
e_book_do_link_event (book, resp);
break;
+ case WritableStatusEvent:
+ e_book_do_writable_event (book, resp);
+ break;
default:
g_error ("EBook: Unknown operation %d in listener queue!\n",
resp->op);
@@ -1184,6 +1196,15 @@ e_book_class_init (EBookClass *klass)
GTK_TYPE_NONE, 1,
GTK_TYPE_BOOL);
+ e_book_signals [WRITABLE_STATUS] =
+ gtk_signal_new ("writable_status",
+ GTK_RUN_LAST,
+ object_class->type,
+ GTK_SIGNAL_OFFSET (EBookClass, writable_status),
+ gtk_marshal_NONE__BOOL,
+ GTK_TYPE_NONE, 1,
+ GTK_TYPE_BOOL);
+
gtk_object_class_add_signals (object_class, e_book_signals,
LAST_SIGNAL);
diff --git a/addressbook/backend/ebook/e-book.h b/addressbook/backend/ebook/e-book.h
index 0713bc6bdb..9e25c9d9a5 100644
--- a/addressbook/backend/ebook/e-book.h
+++ b/addressbook/backend/ebook/e-book.h
@@ -35,8 +35,9 @@ struct _EBookClass {
/*
* Signals.
*/
- void (* open_progress) (EBook *book, const char *msg, short percent);
- void (* link_status) (EBook *book, gboolean connected);
+ void (* open_progress) (EBook *book, const char *msg, short percent);
+ void (* link_status) (EBook *book, gboolean connected);
+ void (* writable_status) (EBook *book, gboolean writable);
};
/* Callbacks for asynchronous functions. */
diff --git a/addressbook/backend/idl/addressbook.idl b/addressbook/backend/idl/addressbook.idl
index 6d8da64163..877813e5d3 100644
--- a/addressbook/backend/idl/addressbook.idl
+++ b/addressbook/backend/idl/addressbook.idl
@@ -142,6 +142,20 @@ module Addressbook {
* being asked.
*/
void notifyConnectionStatus (in boolean connected);
+
+ /**
+ * notifyWritable:
+ *
+ * Used to report whether or not a backend can write
+ * to a given addressbook. All books default to
+ * read-only, so unless you receive a notification
+ * saying otherwise, treat the book as read-only. It
+ * is presumed that this notification will be sent
+ * early (just after a connection is opened, usually),
+ * but it may also be sent later, if/when the backend
+ * notices a change.
+ */
+ void notifyWritable (in boolean writable);
};
interface BookFactory : Bonobo::Unknown {
diff --git a/addressbook/backend/pas/pas-backend-file.c b/addressbook/backend/pas/pas-backend-file.c
index 74b8613d3d..a42a1fa499 100644
--- a/addressbook/backend/pas/pas-backend-file.c
+++ b/addressbook/backend/pas/pas-backend-file.c
@@ -1330,30 +1330,43 @@ pas_backend_file_load_uri (PASBackend *backend,
{
PASBackendFile *bf = PAS_BACKEND_FILE (backend);
char *filename;
+ gboolean writable = FALSE;
+ GList *l;
g_assert (bf->priv->loaded == FALSE);
filename = pas_backend_file_extract_path_from_uri (uri);
bf->priv->file_db = dbopen (filename, O_RDWR, 0666, DB_HASH, NULL);
- if (bf->priv->file_db == NULL) {
- bf->priv->file_db = dbopen (filename, O_RDWR | O_CREAT, 0666, DB_HASH, NULL);
+ if (bf->priv->file_db) {
+ writable = TRUE;
+ }
+ else {
+ /* try to open the file read-only */
+ bf->priv->file_db = dbopen (filename, O_RDONLY, 0666, DB_HASH, NULL);
- if (bf->priv->file_db) {
- char *create_initial_file;
- char *dir;
+ if (!bf->priv->file_db) {
+ /* lastly, try and create the file */
+ bf->priv->file_db = dbopen (filename, O_RDWR | O_CREAT, 0666, DB_HASH, NULL);
- dir = g_dirname(filename);
- create_initial_file = g_concat_dir_and_file(dir, "create-initial");
+ if (bf->priv->file_db) {
+ char *create_initial_file;
+ char *dir;
- if (g_file_exists(create_initial_file)) {
- char *id;
- id = do_create(backend, INITIAL_VCARD, NULL);
- g_free (id);
- }
+ dir = g_dirname(filename);
+ create_initial_file = g_concat_dir_and_file(dir, "create-initial");
+
+ if (g_file_exists(create_initial_file)) {
+ char *id;
+ id = do_create(backend, INITIAL_VCARD, NULL);
+ g_free (id);
+ }
- g_free(create_initial_file);
- g_free(dir);
+ g_free(create_initial_file);
+ g_free(dir);
+
+ writable = TRUE;
+ }
}
}
@@ -1369,6 +1382,13 @@ pas_backend_file_load_uri (PASBackend *backend,
} else
return FALSE;
+ /* report the writable status of the book to all its clients */
+ for (l = bf->priv->clients; l; l = g_list_next (l)) {
+ PASBook *book = l->data;
+
+ pas_book_report_writable (book, writable);
+ }
+
return TRUE;
}
diff --git a/addressbook/backend/pas/pas-backend-ldap.c b/addressbook/backend/pas/pas-backend-ldap.c
index 0478c59ece..0fb5347ca3 100644
--- a/addressbook/backend/pas/pas-backend-ldap.c
+++ b/addressbook/backend/pas/pas-backend-ldap.c
@@ -2036,6 +2036,9 @@ pas_backend_ldap_process_authenticate_user (PASBackend *backend,
pas_book_respond_authenticate_user (book,
ldap_error_to_response (ldap_error));
+ if (ldap_error == LDAP_SUCCESS)
+ pas_book_report_writable (book, TRUE);
+
if (!bl->priv->evolutionPersonChecked)
check_schema_support (bl);
}
diff --git a/addressbook/backend/pas/pas-book.c b/addressbook/backend/pas/pas-book.c
index 6add0987fc..d115e9062f 100644
--- a/addressbook/backend/pas/pas-book.c
+++ b/addressbook/backend/pas/pas-book.c
@@ -656,6 +656,28 @@ pas_book_report_connection (PASBook *book,
CORBA_exception_free (&ev);
}
+/**
+ * pas_book_report_writable:
+ */
+void
+pas_book_report_writable (PASBook *book,
+ gboolean writable)
+{
+ CORBA_Environment ev;
+
+ CORBA_exception_init (&ev);
+
+ GNOME_Evolution_Addressbook_BookListener_notifyWritable (
+ book->priv->listener, (CORBA_boolean) writable, &ev);
+
+ if (ev._major != CORBA_NO_EXCEPTION) {
+ g_warning ("pas_book_report_writable: Exception "
+ "responding to BookListener!\n");
+ }
+
+ CORBA_exception_free (&ev);
+}
+
static gboolean
pas_book_construct (PASBook *book,
PASBackend *backend,
diff --git a/addressbook/backend/pas/pas-book.h b/addressbook/backend/pas/pas-book.h
index 1d401d33a4..12c780e282 100644
--- a/addressbook/backend/pas/pas-book.h
+++ b/addressbook/backend/pas/pas-book.h
@@ -100,6 +100,9 @@ void pas_book_respond_get_changes (PASBook
void pas_book_report_connection (PASBook *book,
gboolean connected);
+void pas_book_report_writable (PASBook *book,
+ gboolean writable);
+
gboolean pas_book_can_write (PASBook *book);
gboolean pas_book_can_write_card (PASBook *book,
const char *id);
diff --git a/addressbook/gui/widgets/e-addressbook-model.c b/addressbook/gui/widgets/e-addressbook-model.c
index 31443a65b3..1716c0c498 100644
--- a/addressbook/gui/widgets/e-addressbook-model.c
+++ b/addressbook/gui/widgets/e-addressbook-model.c
@@ -311,7 +311,7 @@ e_addressbook_model_init (GtkObject *object)
model->status_message_id = 0;
model->data = NULL;
model->data_count = 0;
- model->editable = TRUE;
+ model->editable = FALSE;
model->first_get_view = TRUE;
}
diff --git a/addressbook/gui/widgets/e-addressbook-view.c b/addressbook/gui/widgets/e-addressbook-view.c
index 1ecdec06f3..e22228023f 100644
--- a/addressbook/gui/widgets/e-addressbook-view.c
+++ b/addressbook/gui/widgets/e-addressbook-view.c
@@ -140,6 +140,7 @@ e_addressbook_view_init (EAddressbookView *eav)
{
eav->view_type = E_ADDRESSBOOK_VIEW_NONE;
+ eav->editable = FALSE;
eav->book = NULL;
eav->query = g_strdup("(contains \"x-evolution-any-field\" \"\")");
@@ -168,6 +169,16 @@ e_addressbook_view_new (void)
}
static void
+book_writable_cb (EBook *book, gboolean writable, EAddressbookView *eav)
+{
+ eav->editable = writable;
+ if (eav->object)
+ gtk_object_set (GTK_OBJECT (eav->object),
+ "editable", eav->editable,
+ NULL);
+}
+
+static void
e_addressbook_view_set_arg (GtkObject *object, GtkArg *arg, guint arg_id)
{
EAddressbookView *eav = E_ADDRESSBOOK_VIEW(object);
@@ -180,13 +191,18 @@ e_addressbook_view_set_arg (GtkObject *object, GtkArg *arg, guint arg_id)
if (GTK_VALUE_OBJECT(*arg)) {
eav->book = E_BOOK(GTK_VALUE_OBJECT(*arg));
gtk_object_ref(GTK_OBJECT(eav->book));
+ gtk_signal_connect (GTK_OBJECT (eav->book),
+ "writable_status",
+ book_writable_cb, eav);
}
else
eav->book = NULL;
if (eav->object)
gtk_object_set(GTK_OBJECT(eav->object),
"book", eav->book,
+ "editable", eav->editable,
NULL);
+
break;
case ARG_QUERY:
g_free(eav->query);
@@ -391,12 +407,17 @@ editor_closed_cb (EContactEditor *ce, gpointer data)
gtk_object_unref (GTK_OBJECT (ce));
}
+typedef struct {
+ EAddressbookView *view;
+ ECard *card;
+} CardAndView;
+
static void
-supported_fields_cb (EBook *book, EBookStatus status, EList *fields, ECard *card)
+supported_fields_cb (EBook *book, EBookStatus status, EList *fields, CardAndView *card_and_view)
{
EContactEditor *ce;
- ce = e_contact_editor_new (card, FALSE, fields, FALSE);
+ ce = e_contact_editor_new (card_and_view->card, FALSE, fields, !card_and_view->view->editable);
gtk_signal_connect (GTK_OBJECT (ce), "add_card",
GTK_SIGNAL_FUNC (add_card_cb), book);
@@ -407,7 +428,9 @@ supported_fields_cb (EBook *book, EBookStatus status, EList *fields, ECard *card
gtk_signal_connect (GTK_OBJECT (ce), "editor_closed",
GTK_SIGNAL_FUNC (editor_closed_cb), NULL);
- gtk_object_unref(GTK_OBJECT(card));
+ gtk_object_unref(GTK_OBJECT(card_and_view->card));
+
+ g_free (card_and_view);
}
static void
@@ -417,14 +440,18 @@ table_double_click(ETableScrolled *table, gint row, EAddressbookView *view)
EAddressbookModel *model = E_ADDRESSBOOK_MODEL(view->object);
ECard *card = e_addressbook_model_get_card(model, row);
EBook *book;
-
+ CardAndView *card_and_view;
+
gtk_object_get(GTK_OBJECT(model),
"book", &book,
NULL);
g_assert (E_IS_BOOK (book));
- e_book_get_supported_fields (book, (EBookFieldsCallback)supported_fields_cb, card);
+ card_and_view = g_new (CardAndView, 1);
+ card_and_view->card = card;
+ card_and_view->view = view;
+ e_book_get_supported_fields (book, (EBookFieldsCallback)supported_fields_cb, card_and_view);
}
}
@@ -730,6 +757,7 @@ change_view_type (EAddressbookView *view, EAddressbookViewType view_type)
gtk_object_set(view->object,
"query", view->query,
"book", view->book,
+ "editable", view->editable,
NULL);
}
diff --git a/addressbook/gui/widgets/e-addressbook-view.h b/addressbook/gui/widgets/e-addressbook-view.h
index ca6cedf0b8..7197d237e5 100644
--- a/addressbook/gui/widgets/e-addressbook-view.h
+++ b/addressbook/gui/widgets/e-addressbook-view.h
@@ -63,6 +63,7 @@ struct _EAddressbookView
EBook *book;
char *query;
+ guint editable : 1;
GtkObject *object;
GtkWidget *widget;
diff --git a/addressbook/gui/widgets/e-minicard-label.c b/addressbook/gui/widgets/e-minicard-label.c
index 01fad008df..7e3a0e511c 100644
--- a/addressbook/gui/widgets/e-minicard-label.c
+++ b/addressbook/gui/widgets/e-minicard-label.c
@@ -51,6 +51,7 @@ enum {
ARG_FIELDNAME,
ARG_TEXT_MODEL,
ARG_MAX_FIELD_NAME_WIDTH,
+ ARG_EDITABLE
};
GtkType
@@ -103,6 +104,8 @@ e_minicard_label_class_init (EMinicardLabelClass *klass)
GTK_ARG_READWRITE, ARG_TEXT_MODEL);
gtk_object_add_arg_type ("EMinicardLabel::max_field_name_length", GTK_TYPE_DOUBLE,
GTK_ARG_READWRITE, ARG_MAX_FIELD_NAME_WIDTH);
+ gtk_object_add_arg_type ("EMinicardLabel::editable", GTK_TYPE_BOOL,
+ GTK_ARG_READWRITE, ARG_EDITABLE);
object_class->set_arg = e_minicard_label_set_arg;
object_class->get_arg = e_minicard_label_get_arg;
@@ -159,6 +162,10 @@ e_minicard_label_set_arg (GtkObject *o, GtkArg *arg, guint arg_id)
case ARG_MAX_FIELD_NAME_WIDTH:
e_minicard_label->max_field_name_length = GTK_VALUE_DOUBLE (*arg);
break;
+ case ARG_EDITABLE:
+ e_minicard_label->editable = GTK_VALUE_BOOL (*arg);
+ gtk_object_set (GTK_OBJECT (e_minicard_label->field), "editable", e_minicard_label->editable, NULL);
+ break;
}
}
@@ -196,6 +203,9 @@ e_minicard_label_get_arg (GtkObject *object, GtkArg *arg, guint arg_id)
case ARG_MAX_FIELD_NAME_WIDTH:
GTK_VALUE_DOUBLE (*arg) = e_minicard_label->max_field_name_length;
break;
+ case ARG_EDITABLE:
+ GTK_VALUE_BOOL (*arg) = e_minicard_label->editable;
+ break;
default:
arg->type = GTK_TYPE_INVALID;
break;
@@ -258,7 +268,7 @@ e_minicard_label_construct (GnomeCanvasItem *item)
"use_ellipsis", TRUE,
"font_gdk", font,
"fill_color", "black",
- "editable", TRUE,
+ "editable", e_minicard_label->editable,
"draw_background", FALSE,
NULL );
e_canvas_item_move_absolute(e_minicard_label->field, ( e_minicard_label->width / 2 + 2), 1);
diff --git a/addressbook/gui/widgets/e-minicard-label.h b/addressbook/gui/widgets/e-minicard-label.h
index 08eb51ee53..15d3a63105 100644
--- a/addressbook/gui/widgets/e-minicard-label.h
+++ b/addressbook/gui/widgets/e-minicard-label.h
@@ -58,6 +58,7 @@ struct _EMinicardLabel
double width;
double height;
double max_field_name_length;
+ guint editable : 1;
GnomeCanvasItem *fieldname;
GnomeCanvasItem *field;
GnomeCanvasItem *rect;
diff --git a/addressbook/gui/widgets/e-minicard-view-widget.c b/addressbook/gui/widgets/e-minicard-view-widget.c
index fbbcd6cf00..b3b326397f 100644
--- a/addressbook/gui/widgets/e-minicard-view-widget.c
+++ b/addressbook/gui/widgets/e-minicard-view-widget.c
@@ -39,7 +39,8 @@ static ECanvasClass *parent_class = NULL;
enum {
ARG_0,
ARG_BOOK,
- ARG_QUERY
+ ARG_QUERY,
+ ARG_EDITABLE
};
enum {
@@ -92,6 +93,8 @@ e_minicard_view_widget_class_init (EMinicardViewWidgetClass *klass)
GTK_ARG_READWRITE, ARG_BOOK);
gtk_object_add_arg_type ("EMinicardViewWidget::query", GTK_TYPE_STRING,
GTK_ARG_READWRITE, ARG_QUERY);
+ gtk_object_add_arg_type ("EMinicardViewWidget::editable", GTK_TYPE_BOOL,
+ GTK_ARG_READWRITE, ARG_EDITABLE);
e_minicard_view_widget_signals [STATUS_MESSAGE] =
gtk_signal_new ("status_message",
@@ -121,6 +124,7 @@ e_minicard_view_widget_init (EMinicardViewWidget *view)
view->book = NULL;
view->query = NULL;
+ view->editable = FALSE;
}
GtkWidget *
@@ -158,6 +162,12 @@ e_minicard_view_widget_set_arg (GtkObject *o, GtkArg *arg, guint arg_id)
"query", emvw->query,
NULL);
break;
+ case ARG_EDITABLE:
+ emvw->editable = GTK_VALUE_BOOL(*arg);
+ gtk_object_set (GTK_OBJECT(emvw->emv),
+ "editable", emvw->editable,
+ NULL);
+ break;
}
}
@@ -175,6 +185,9 @@ e_minicard_view_widget_get_arg (GtkObject *object, GtkArg *arg, guint arg_id)
case ARG_QUERY:
GTK_VALUE_STRING (*arg) = g_strdup(emvw->query);
break;
+ case ARG_EDITABLE:
+ GTK_VALUE_BOOL (*arg) = emvw->editable;
+ break;
default:
arg->type = GTK_TYPE_INVALID;
break;
@@ -233,6 +246,7 @@ e_minicard_view_widget_realize (GtkWidget *widget)
gtk_object_set(GTK_OBJECT(view->emv),
"book", view->book,
"query", view->query,
+ "editable", view->editable,
NULL);
if (GTK_WIDGET_CLASS(parent_class)->realize)
diff --git a/addressbook/gui/widgets/e-minicard-view-widget.h b/addressbook/gui/widgets/e-minicard-view-widget.h
index 0deb920ffa..b56a3d856e 100644
--- a/addressbook/gui/widgets/e-minicard-view-widget.h
+++ b/addressbook/gui/widgets/e-minicard-view-widget.h
@@ -50,6 +50,7 @@ struct _EMinicardViewWidget
EBook *book;
char *query;
+ guint editable : 1;
};
struct _EMinicardViewWidgetClass
diff --git a/addressbook/gui/widgets/e-minicard-view.c b/addressbook/gui/widgets/e-minicard-view.c
index 7aac3e1641..42284b02db 100644
--- a/addressbook/gui/widgets/e-minicard-view.c
+++ b/addressbook/gui/widgets/e-minicard-view.c
@@ -42,7 +42,8 @@ static EReflowSortedClass *parent_class = NULL;
enum {
ARG_0,
ARG_BOOK,
- ARG_QUERY
+ ARG_QUERY,
+ ARG_EDITABLE
};
enum {
@@ -92,6 +93,8 @@ e_minicard_view_class_init (EMinicardViewClass *klass)
GTK_ARG_READWRITE, ARG_BOOK);
gtk_object_add_arg_type ("EMinicardView::query", GTK_TYPE_STRING,
GTK_ARG_READWRITE, ARG_QUERY);
+ gtk_object_add_arg_type ("EMinicardView::editable", GTK_TYPE_BOOL,
+ GTK_ARG_READWRITE, ARG_EDITABLE);
e_minicard_view_signals [STATUS_MESSAGE] =
gtk_signal_new ("status_message",
@@ -123,6 +126,7 @@ e_minicard_view_init (EMinicardView *view)
{
view->book = NULL;
view->query = g_strdup("(contains \"x-evolution-any-field\" \"\")");
+ view->editable = FALSE;
view->book_view = NULL;
view->get_view_idle = 0;
view->create_card_id = 0;
@@ -173,6 +177,7 @@ create_card(EBookView *book_view, const GList *cards, EMinicardView *view)
GnomeCanvasItem *item = gnome_canvas_item_new(GNOME_CANVAS_GROUP(view),
e_minicard_get_type(),
"card", cards->data,
+ "editable", view->editable,
NULL);
gtk_signal_connect(GTK_OBJECT(item), "selected",
GTK_SIGNAL_FUNC(card_selected), view);
@@ -318,6 +323,17 @@ e_minicard_view_set_arg (GtkObject *o, GtkArg *arg, guint arg_id)
if (view->get_view_idle == 0)
view->get_view_idle = g_idle_add((GSourceFunc)get_view, view);
break;
+ case ARG_EDITABLE: {
+ GList *l;
+ view->editable = GTK_VALUE_BOOL (*arg);
+ /* bit of a hack */
+ for (l = E_REFLOW (view)->items; l; l = g_list_next(l)) {
+ gtk_object_set (GTK_OBJECT (l->data),
+ "editable", view->editable,
+ NULL);
+ }
+ break;
+ }
}
}
@@ -335,6 +351,9 @@ e_minicard_view_get_arg (GtkObject *object, GtkArg *arg, guint arg_id)
case ARG_QUERY:
GTK_VALUE_STRING (*arg) = g_strdup(e_minicard_view->query);
break;
+ case ARG_EDITABLE:
+ GTK_VALUE_BOOL (*arg) = e_minicard_view->editable;
+ break;
default:
arg->type = GTK_TYPE_INVALID;
break;
@@ -402,14 +421,14 @@ editor_closed_cb (EContactEditor *ce, gpointer data)
}
static void
-supported_fields_cb (EBook *book, EBookStatus status, EList *fields, EMinicard *e_minicard)
+supported_fields_cb (EBook *book, EBookStatus status, EList *fields, EMinicardView *view)
{
ECard *card;
EContactEditor *ce;
card = e_card_new("");
- ce = e_contact_editor_new (card, TRUE, fields, FALSE);
+ ce = e_contact_editor_new (card, TRUE, fields, !view->editable);
gtk_signal_connect (GTK_OBJECT (ce), "add_card",
GTK_SIGNAL_FUNC (add_card_cb), book);
@@ -440,7 +459,7 @@ e_minicard_view_event (GnomeCanvasItem *item, GdkEvent *event)
e_book_get_supported_fields (book,
(EBookFieldsCallback)supported_fields_cb,
- NULL);
+ view);
}
return TRUE;
default:
diff --git a/addressbook/gui/widgets/e-minicard-view.h b/addressbook/gui/widgets/e-minicard-view.h
index 2cfe74e993..fc52a4d864 100644
--- a/addressbook/gui/widgets/e-minicard-view.h
+++ b/addressbook/gui/widgets/e-minicard-view.h
@@ -67,6 +67,7 @@ struct _EMinicardView
/* item specific fields */
EBook *book;
char *query;
+ guint editable : 1;
EBookView *book_view;
ESelectionModelSimple *selection;
diff --git a/addressbook/gui/widgets/e-minicard.c b/addressbook/gui/widgets/e-minicard.c
index d6fa1a2068..871d8aa446 100644
--- a/addressbook/gui/widgets/e-minicard.c
+++ b/addressbook/gui/widgets/e-minicard.c
@@ -75,6 +75,7 @@ enum {
ARG_HEIGHT,
ARG_HAS_FOCUS,
ARG_SELECTED,
+ ARG_EDITABLE,
ARG_CARD
};
@@ -129,6 +130,8 @@ e_minicard_class_init (EMinicardClass *klass)
GTK_ARG_READWRITE, ARG_HAS_FOCUS);
gtk_object_add_arg_type ("EMinicard::selected", GTK_TYPE_BOOL,
GTK_ARG_READWRITE, ARG_SELECTED);
+ gtk_object_add_arg_type ("EMinicard::editable", GTK_TYPE_BOOL,
+ GTK_ARG_READWRITE, ARG_EDITABLE);
gtk_object_add_arg_type ("EMinicard::card", GTK_TYPE_OBJECT,
GTK_ARG_READWRITE, ARG_CARD);
@@ -165,7 +168,8 @@ e_minicard_init (EMinicard *minicard)
minicard->height = 10;
minicard->has_focus = FALSE;
minicard->selected = FALSE;
-
+ minicard->editable = FALSE;
+
minicard->card = NULL;
minicard->simple = e_card_simple_new(NULL);
@@ -210,6 +214,7 @@ e_minicard_set_arg (GtkObject *o, GtkArg *arg, guint arg_id)
{
GnomeCanvasItem *item;
EMinicard *e_minicard;
+ GList *l;
item = GNOME_CANVAS_ITEM (o);
e_minicard = E_MINICARD (o);
@@ -243,6 +248,13 @@ e_minicard_set_arg (GtkObject *o, GtkArg *arg, guint arg_id)
if (e_minicard->selected != GTK_VALUE_BOOL(*arg))
set_selected (e_minicard, GTK_VALUE_BOOL(*arg));
break;
+ case ARG_EDITABLE:
+ e_minicard->editable = GTK_VALUE_BOOL(*arg);
+ for (l = e_minicard->fields; l; l = l->next)
+ gtk_object_set (GTK_OBJECT (E_MINICARD_FIELD (l->data)->label),
+ "editable", e_minicard->editable,
+ NULL);
+ break;
case ARG_CARD:
if (e_minicard->card)
gtk_object_unref (GTK_OBJECT(e_minicard->card));
@@ -279,6 +291,9 @@ e_minicard_get_arg (GtkObject *object, GtkArg *arg, guint arg_id)
case ARG_SELECTED:
GTK_VALUE_BOOL (*arg) = e_minicard->selected;
break;
+ case ARG_EDITABLE:
+ GTK_VALUE_BOOL (*arg) = e_minicard->editable;
+ break;
case ARG_CARD:
e_card_simple_sync_card(e_minicard->simple);
GTK_VALUE_OBJECT (*arg) = GTK_OBJECT(e_minicard->card);
@@ -560,7 +575,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, FALSE);
+ e_minicard->editor = e_contact_editor_new (e_minicard->card, FALSE, fields, !e_minicard->editable);
if (book != NULL) {
gtk_signal_connect (GTK_OBJECT (e_minicard->editor), "add_card",
@@ -767,6 +782,7 @@ add_field (EMinicard *e_minicard, ECardSimpleField field, gdouble left_width)
"fieldname", name,
"field", string,
"max_field_name_length", left_width,
+ "editable", e_minicard->editable,
NULL );
gtk_signal_connect(GTK_OBJECT(E_MINICARD_LABEL(new_item)->field),
"changed", GTK_SIGNAL_FUNC(field_changed), e_minicard);
diff --git a/addressbook/gui/widgets/e-minicard.h b/addressbook/gui/widgets/e-minicard.h
index dbc914502c..34dbac0cc0 100644
--- a/addressbook/gui/widgets/e-minicard.h
+++ b/addressbook/gui/widgets/e-minicard.h
@@ -80,7 +80,9 @@ struct _EMinicard
guint selected : 1;
guint has_focus : 1;
-
+
+ guint editable : 1;
+
double width;
double height;
};