aboutsummaryrefslogtreecommitdiffstats
path: root/addressbook
diff options
context:
space:
mode:
authorHans Petter Jansson <hpj@ximian.com>2003-11-18 05:30:13 +0800
committerHans Petter <hansp@src.gnome.org>2003-11-18 05:30:13 +0800
commit9a1593d15ca3c4e0e171c4ac413a2ef33d251943 (patch)
treeb9554dfd6636bf468f6e4113df9ebce739500218 /addressbook
parentc6b3809b47d4c5166d5244754f28b03ec5d5d60b (diff)
downloadgsoc2013-evolution-9a1593d15ca3c4e0e171c4ac413a2ef33d251943.tar
gsoc2013-evolution-9a1593d15ca3c4e0e171c4ac413a2ef33d251943.tar.gz
gsoc2013-evolution-9a1593d15ca3c4e0e171c4ac413a2ef33d251943.tar.bz2
gsoc2013-evolution-9a1593d15ca3c4e0e171c4ac413a2ef33d251943.tar.lz
gsoc2013-evolution-9a1593d15ca3c4e0e171c4ac413a2ef33d251943.tar.xz
gsoc2013-evolution-9a1593d15ca3c4e0e171c4ac413a2ef33d251943.tar.zst
gsoc2013-evolution-9a1593d15ca3c4e0e171c4ac413a2ef33d251943.zip
Store a ref to the source selector. (impl_requestCreateItem): Implement.
2003-11-17 Hans Petter Jansson <hpj@ximian.com> * gui/component/addressbook-component.c (impl_createControls): Store a ref to the source selector. (impl_requestCreateItem): Implement. (impl_dispose): Unref the source selector. (addressbook_component_init): Set up default sources. * gui/widgets/e-addressbook-model.c (eab_model_set_property): If the 'book' property is set, and editability changes, emit a signal to that effect. svn path=/trunk/; revision=23404
Diffstat (limited to 'addressbook')
-rw-r--r--addressbook/ChangeLog12
-rw-r--r--addressbook/gui/component/addressbook-component.c96
-rw-r--r--addressbook/gui/widgets/e-addressbook-model.c7
3 files changed, 112 insertions, 3 deletions
diff --git a/addressbook/ChangeLog b/addressbook/ChangeLog
index 3932778070..91940f3224 100644
--- a/addressbook/ChangeLog
+++ b/addressbook/ChangeLog
@@ -1,3 +1,15 @@
+2003-11-17 Hans Petter Jansson <hpj@ximian.com>
+
+ * gui/component/addressbook-component.c (impl_createControls): Store
+ a ref to the source selector.
+ (impl_requestCreateItem): Implement.
+ (impl_dispose): Unref the source selector.
+ (addressbook_component_init): Set up default sources.
+
+ * gui/widgets/e-addressbook-model.c (eab_model_set_property): If
+ the 'book' property is set, and editability changes, emit a signal
+ to that effect.
+
2003-11-14 JP Rosevear <jpr@ximian.com>
* gui/component/new-addressbook.c: include e-source from e-d-s
diff --git a/addressbook/gui/component/addressbook-component.c b/addressbook/gui/component/addressbook-component.c
index 7de8d85022..97de5eeda4 100644
--- a/addressbook/gui/component/addressbook-component.c
+++ b/addressbook/gui/component/addressbook-component.c
@@ -31,7 +31,9 @@
#include "new-addressbook.h"
#include "widgets/misc/e-source-selector.h"
+#include "addressbook/gui/widgets/eab-gui-util.h"
+#include <string.h>
#include <bonobo/bonobo-i18n.h>
#include <gtk/gtkscrolledwindow.h>
#include <gtk/gtkmenu.h>
@@ -40,6 +42,7 @@
#include <gtk/gtkmessagedialog.h>
#include <gtk/gtkstock.h>
#include <gconf/gconf-client.h>
+#include <gal/util/e-util.h>
#define PARENT_TYPE bonobo_object_get_type ()
@@ -48,6 +51,7 @@ static BonoboObjectClass *parent_class = NULL;
struct _AddressbookComponentPrivate {
GConfClient *gconf_client;
ESourceList *source_list;
+ GtkWidget *source_selector;
};
@@ -141,6 +145,8 @@ impl_createControls (PortableServer_Servant servant,
e_source_selector_show_selection (E_SOURCE_SELECTOR (selector), FALSE);
gtk_widget_show (selector);
+ addressbook_component->priv->source_selector = selector;
+
selector_scrolled_window = gtk_scrolled_window_new (NULL, NULL);
gtk_scrolled_window_set_shadow_type (GTK_SCROLLED_WINDOW (selector_scrolled_window), GTK_SHADOW_IN);
gtk_scrolled_window_set_policy (GTK_SCROLLED_WINDOW (selector_scrolled_window),
@@ -197,9 +203,50 @@ impl_requestCreateItem (PortableServer_Servant servant,
const CORBA_char *item_type_name,
CORBA_Environment *ev)
{
- /* FIXME: fill me in */
+ AddressbookComponent *addressbook_component = ADDRESSBOOK_COMPONENT (bonobo_object_from_servant (servant));
+ AddressbookComponentPrivate *priv;
+ EBook *book;
+ EContact *contact = e_contact_new ();
+ ESource *selected_source;
+ gchar *uri;
+
+ priv = addressbook_component->priv;
+
+ selected_source = e_source_selector_peek_primary_selection (E_SOURCE_SELECTOR (priv->source_selector));
+ if (!selected_source) {
+ CORBA_exception_set (ev, CORBA_USER_EXCEPTION, ex_GNOME_Evolution_Component_Failed, NULL);
+ return;
+ }
+
+ uri = e_source_get_uri (selected_source);
+ if (!uri) {
+ CORBA_exception_set (ev, CORBA_USER_EXCEPTION, ex_GNOME_Evolution_Component_Failed, NULL);
+ return;
+ }
+
+ book = e_book_new ();
+ if (!e_book_load_uri (book, uri, TRUE, NULL)) {
+ CORBA_exception_set (ev, CORBA_USER_EXCEPTION, ex_GNOME_Evolution_Component_Failed, NULL);
+ g_object_unref (book);
+ g_free (uri);
+ return;
+ }
- CORBA_exception_set (ev, CORBA_USER_EXCEPTION, ex_GNOME_Evolution_Component_UnknownType, NULL);
+ contact = e_contact_new ();
+
+ if (!item_type_name) {
+ CORBA_exception_set (ev, CORBA_USER_EXCEPTION, ex_GNOME_Evolution_Component_UnknownType, NULL);
+ } else if (!strcmp (item_type_name, "contact")) {
+ eab_show_contact_editor (book, contact, TRUE, TRUE);
+ } else if (!strcmp (item_type_name, "contact_list")) {
+ eab_show_contact_list_editor (book, contact, TRUE, TRUE);
+ } else {
+ CORBA_exception_set (ev, CORBA_USER_EXCEPTION, ex_GNOME_Evolution_Component_UnknownType, NULL);
+ }
+
+ g_object_unref (book);
+ g_object_unref (contact);
+ g_free (uri);
}
@@ -210,6 +257,11 @@ impl_dispose (GObject *object)
{
AddressbookComponentPrivate *priv = ADDRESSBOOK_COMPONENT (object)->priv;
+ if (priv->source_selector != NULL) {
+ g_object_unref (priv->source_selector);
+ priv->source_selector = NULL;
+ }
+
if (priv->source_list != NULL) {
g_object_unref (priv->source_list);
priv->source_list = NULL;
@@ -256,6 +308,7 @@ static void
addressbook_component_init (AddressbookComponent *component)
{
AddressbookComponentPrivate *priv;
+ GSList *groups;
priv = g_new0 (AddressbookComponentPrivate, 1);
@@ -266,6 +319,45 @@ addressbook_component_init (AddressbookComponent *component)
priv->source_list = e_source_list_new_for_gconf (priv->gconf_client,
"/apps/evolution/addressbook/sources");
+ /* Create default addressbooks if there are no groups */
+ groups = e_source_list_peek_groups (priv->source_list);
+ if (!groups) {
+ ESourceGroup *group;
+ ESource *source;
+ char *base_uri, *base_uri_proto, *new_dir;
+
+ /* create the local source group */
+ base_uri = g_build_filename (g_get_home_dir (),
+ "/.evolution/addressbook/local/OnThisComputer/",
+ NULL);
+
+ base_uri_proto = g_strconcat ("file://", base_uri, NULL);
+
+ group = e_source_group_new (_("On This Computer"), base_uri_proto);
+ e_source_list_add_group (priv->source_list, group, -1);
+
+ g_free (base_uri_proto);
+
+ /* FIXME: Migrate addressbooks from older setup? */
+
+ /* Create default addressbooks */
+ new_dir = g_build_filename (base_uri, "Personal/", NULL);
+ if (!e_mkdir_hier (new_dir, 0700)) {
+ source = e_source_new (_("Personal"), "Personal");
+ e_source_group_add_source (group, source, -1);
+ }
+ g_free (new_dir);
+
+ new_dir = g_build_filename (base_uri, "Work/", NULL);
+ if (!e_mkdir_hier (new_dir, 0700)) {
+ source = e_source_new (_("Work"), "Work");
+ e_source_group_add_source (group, source, -1);
+ }
+ g_free (new_dir);
+
+ g_free (base_uri);
+ }
+
component->priv = priv;
}
diff --git a/addressbook/gui/widgets/e-addressbook-model.c b/addressbook/gui/widgets/e-addressbook-model.c
index e8a1e76a38..5a8088dc0a 100644
--- a/addressbook/gui/widgets/e-addressbook-model.c
+++ b/addressbook/gui/widgets/e-addressbook-model.c
@@ -550,8 +550,13 @@ eab_model_set_property (GObject *object, guint prop_id, const GValue *value, GPa
}
model->book = E_BOOK(g_value_get_object (value));
if (model->book) {
- if (!model->editable_set)
+ if (!model->editable_set) {
model->editable = e_book_is_writable (model->book);
+
+ g_signal_emit (model,
+ eab_model_signals [WRITABLE_STATUS], 0,
+ model->editable);
+ }
model->first_get_view = TRUE;
g_object_ref (model->book);
get_view (model);