aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--Makefile.am1
-rw-r--r--addressbook/gui/component/Makefile.am13
-rw-r--r--addressbook/gui/component/addressbook-component.c431
-rw-r--r--addressbook/gui/component/addressbook-view.c529
-rw-r--r--addressbook/gui/component/e-book-shell-module.c381
-rw-r--r--addressbook/gui/component/e-book-shell-view-actions.c494
-rw-r--r--addressbook/gui/component/e-book-shell-view-actions.h74
-rw-r--r--addressbook/gui/component/e-book-shell-view-private.c89
-rw-r--r--addressbook/gui/component/e-book-shell-view-private.h100
-rw-r--r--addressbook/gui/component/e-book-shell-view.c279
-rw-r--r--addressbook/gui/component/e-book-shell-view.h66
-rw-r--r--addressbook/gui/contact-editor/e-contact-editor.c1
-rw-r--r--addressbook/gui/contact-list-editor/e-contact-list-editor.c2
-rw-r--r--shell/Makefile.am4
-rw-r--r--shell/e-shell-module.c27
-rw-r--r--shell/e-shell-module.h4
-rw-r--r--shell/e-shell-view.c30
-rw-r--r--shell/e-shell-view.h8
-rw-r--r--shell/e-shell-window-actions.c11
-rw-r--r--shell/e-shell-window-private.c7
-rw-r--r--shell/e-shell-window.c52
-rw-r--r--shell/e-shell-window.h5
-rw-r--r--shell/e-shell.h2
-rw-r--r--shell/e-user-creatable-items-handler.c912
-rw-r--r--shell/e-user-creatable-items-handler.h70
-rw-r--r--shell/es-menu.c186
-rw-r--r--shell/es-menu.h96
-rw-r--r--shell/main.c2
-rw-r--r--shell/test/e-test-shell-module.c35
-rw-r--r--shell/test/e-test-shell-view.c18
-rw-r--r--shell/test/e-test-shell-view.h2
-rw-r--r--ui/Makefile.am1
-rw-r--r--ui/evolution-contacts.ui45
-rw-r--r--ui/evolution-shell.ui3
34 files changed, 1689 insertions, 2291 deletions
diff --git a/Makefile.am b/Makefile.am
index e9bf3c62e2..7f5097db82 100644
--- a/Makefile.am
+++ b/Makefile.am
@@ -61,6 +61,7 @@ SUBDIRS = \
a11y \
widgets \
shell \
+ addressbook \
art \
ui \
views \
diff --git a/addressbook/gui/component/Makefile.am b/addressbook/gui/component/Makefile.am
index 9eec272a0d..6726d2b050 100644
--- a/addressbook/gui/component/Makefile.am
+++ b/addressbook/gui/component/Makefile.am
@@ -23,8 +23,6 @@ INCLUDES = \
component_LTLIBRARIES = libevolution-addressbook.la
libevolution_addressbook_la_SOURCES = \
- addressbook-component.c \
- addressbook-component.h \
addressbook-config.c \
addressbook-config.h \
addressbook-migrate.c \
@@ -35,9 +33,14 @@ libevolution_addressbook_la_SOURCES = \
addressbook.h \
addressbook-view.c \
addressbook-view.h \
- component-factory.c
-
-# $(top_builddir)/addressbook/printing/libecontactprint.la
+ component-factory.c \
+ e-book-shell-module.c \
+ e-book-shell-view.c \
+ e-book-shell-view.h \
+ e-book-shell-view-actions.c \
+ e-book-shell-view-actions.h \
+ e-book-shell-view-private.c \
+ e-book-shell-view-private.h
if ENABLE_SMIME
SMIME_LIB=$(top_builddir)/smime/gui/libevolution-smime.la
diff --git a/addressbook/gui/component/addressbook-component.c b/addressbook/gui/component/addressbook-component.c
index cc4d2d9ffa..5c3ad0999f 100644
--- a/addressbook/gui/component/addressbook-component.c
+++ b/addressbook/gui/component/addressbook-component.c
@@ -54,350 +54,10 @@
#include "smime/gui/component.h"
#endif
-#define LDAP_BASE_URI "ldap://"
-#define PERSONAL_RELATIVE_URI "system"
-
-#define PARENT_TYPE bonobo_object_get_type ()
static BonoboObjectClass *parent_class = NULL;
-struct _AddressbookComponentPrivate {
- GConfClient *gconf_client;
- char *base_directory;
- GList *views;
-};
-
-static void
-ensure_sources (AddressbookComponent *component)
-{
- GSList *groups;
- ESourceList *source_list;
- ESourceGroup *group;
- ESourceGroup *on_this_computer;
- ESourceGroup *on_ldap_servers;
- ESource *personal_source;
- char *base_uri, *base_uri_proto;
- const gchar *base_dir;
-
- on_this_computer = NULL;
- on_ldap_servers = NULL;
- personal_source = NULL;
-
- if (!e_book_get_addressbooks (&source_list, NULL)) {
- g_warning ("Could not get addressbook source list from GConf!");
- return;
- }
-
- base_dir = addressbook_component_peek_base_directory (component);
- base_uri = g_build_filename (base_dir, "local", NULL);
-
- base_uri_proto = g_filename_to_uri (base_uri, NULL, NULL);
-
- groups = e_source_list_peek_groups (source_list);
- if (groups) {
- /* groups are already there, we need to search for things... */
- GSList *g;
-
- for (g = groups; g; g = g->next) {
-
- group = E_SOURCE_GROUP (g->data);
-
- /* compare only file:// part. If user home dir name changes we do not want to create
- one more group */
-
- if (!on_this_computer && !strncmp (base_uri_proto, e_source_group_peek_base_uri (group), 7))
- on_this_computer = group;
- else if (!on_ldap_servers && !strcmp (LDAP_BASE_URI, e_source_group_peek_base_uri (group)))
- on_ldap_servers = group;
- }
- }
-
- if (on_this_computer) {
- /* make sure "Personal" shows up as a source under
- this group */
- GSList *sources = e_source_group_peek_sources (on_this_computer);
- GSList *s;
- for (s = sources; s; s = s->next) {
- ESource *source = E_SOURCE (s->data);
- const gchar *relative_uri;
-
- relative_uri = e_source_peek_relative_uri (source);
- if (relative_uri == NULL)
- continue;
- if (!strcmp (PERSONAL_RELATIVE_URI, relative_uri)) {
- personal_source = source;
- break;
- }
- }
- /* Make sure we have the correct base uri. This can change when user's
- homedir name changes */
- if (strcmp (base_uri_proto, e_source_group_peek_base_uri (on_this_computer))) {
- e_source_group_set_base_uri (on_this_computer, base_uri_proto);
-
- /* *sigh* . We shouldn't need this sync call here as set_base_uri
- call results in synching to gconf, but that happens in idle loop
- and too late to prevent user seeing "Can not Open ... because of invalid uri" error.*/
- e_source_list_sync (source_list,NULL);
- }
- }
- else {
- /* create the local source group */
- group = e_source_group_new (_("On This Computer"), base_uri_proto);
- e_source_list_add_group (source_list, group, -1);
-
- on_this_computer = group;
- }
-
- if (!personal_source) {
- /* Create the default Person addressbook */
- ESource *source = e_source_new (_("Personal"), PERSONAL_RELATIVE_URI);
- e_source_group_add_source (on_this_computer, source, -1);
- g_object_unref (source);
-
- e_source_set_property (source, "completion", "true");
-
- personal_source = source;
- }
-
- if (!on_ldap_servers) {
- /* Create the LDAP source group */
- group = e_source_group_new (_("On LDAP Servers"), LDAP_BASE_URI);
- e_source_list_add_group (source_list, group, -1);
-
- on_ldap_servers = group;
- }
-
- g_free (base_uri_proto);
- g_free (base_uri);
-}
-
-static void
-view_destroyed_cb (gpointer data, GObject *where_the_object_was)
-{
- AddressbookComponent *addressbook_component = data;
- AddressbookComponentPrivate *priv;
- GList *l;
-
- priv = addressbook_component->priv;
-
- for (l = priv->views; l; l = l->next) {
- AddressbookView *view = l->data;
- if (G_OBJECT (view) == where_the_object_was) {
- priv->views = g_list_remove (priv->views, view);
- break;
- }
- }
-}
-
/* Evolution::Component CORBA methods. */
-static GNOME_Evolution_ComponentView
-impl_createView (PortableServer_Servant servant,
- GNOME_Evolution_ShellView parent,
- CORBA_boolean select_item,
- CORBA_Environment *ev)
-{
- AddressbookComponent *addressbook_component = ADDRESSBOOK_COMPONENT (bonobo_object_from_servant (servant));
- AddressbookComponentPrivate *priv = addressbook_component->priv;
- AddressbookView *view = addressbook_view_new ();
- EComponentView *component_view;
-
- g_object_weak_ref (G_OBJECT (view), view_destroyed_cb, addressbook_component);
- priv->views = g_list_append (priv->views, view);
-
- component_view = e_component_view_new_controls (parent, "contacts",
- bonobo_control_new (addressbook_view_peek_sidebar (view)),
- addressbook_view_peek_folder_view (view),
- bonobo_control_new (addressbook_view_peek_statusbar (view)));
-
- return BONOBO_OBJREF(component_view);
-
-}
-
-static GNOME_Evolution_CreatableItemTypeList *
-impl__get_userCreatableItems (PortableServer_Servant servant,
- CORBA_Environment *ev)
-{
- GNOME_Evolution_CreatableItemTypeList *list = GNOME_Evolution_CreatableItemTypeList__alloc ();
-
- list->_length = 3;
- list->_maximum = list->_length;
- list->_buffer = GNOME_Evolution_CreatableItemTypeList_allocbuf (list->_length);
-
- CORBA_sequence_set_release (list, FALSE);
-
- list->_buffer[0].id = "contact";
- list->_buffer[0].description = _("New Contact");
- list->_buffer[0].menuDescription = (char *) C_("New", "_Contact");
- list->_buffer[0].tooltip = _("Create a new contact");
- list->_buffer[0].menuShortcut = 'c';
- list->_buffer[0].iconName = "contact-new";
- list->_buffer[0].type = GNOME_Evolution_CREATABLE_OBJECT;
-
- list->_buffer[1].id = "contact_list";
- list->_buffer[1].description = _("New Contact List");
- list->_buffer[1].menuDescription = (char *) C_("New", "Contact _List");
- list->_buffer[1].tooltip = _("Create a new contact list");
- list->_buffer[1].menuShortcut = 'l';
- list->_buffer[1].iconName = "stock_contact-list";
- list->_buffer[1].type = GNOME_Evolution_CREATABLE_OBJECT;
-
- list->_buffer[2].id = "address_book";
- list->_buffer[2].description = _("New Address Book");
- list->_buffer[2].menuDescription = (char *) C_("New", "Address _Book");
- list->_buffer[2].tooltip = _("Create a new address book");
- list->_buffer[2].menuShortcut = '\0';
- list->_buffer[2].iconName = "address-book-new";
- list->_buffer[2].type = GNOME_Evolution_CREATABLE_FOLDER;
-
- return list;
-}
-
-static void
-book_loaded_cb (EBook *book, EBookStatus status, gpointer data)
-{
- EContact *contact;
- char *item_type_name = data;
-
- if (status != E_BOOK_ERROR_OK) {
- /* XXX we really need a dialog here, but we don't have
- access to the ESource so we can't use
- eab_load_error_dialog. fun! */
- return;
- }
-
- contact = e_contact_new ();
-
- 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);
- }
-
- g_object_unref (book);
- g_object_unref (contact);
-
- g_free (item_type_name);
-}
-
-static void
-impl_requestCreateItem (PortableServer_Servant servant,
- const CORBA_char *item_type_name,
- CORBA_Environment *ev)
-{
- EBook *book;
- GConfClient *gconf_client;
- ESourceList *source_list;
- char *uid;
-
- if (!item_type_name ||
- (strcmp (item_type_name, "address_book") &&
- strcmp (item_type_name, "contact") &&
- strcmp (item_type_name, "contact_list"))) {
- CORBA_exception_set (ev, CORBA_USER_EXCEPTION, ex_GNOME_Evolution_Component_UnknownType, NULL);
- return;
- }
-
- if (!strcmp (item_type_name, "address_book")) {
- addressbook_config_create_new_source (NULL);
- return;
- }
-
- gconf_client = gconf_client_get_default();
- uid = gconf_client_get_string (gconf_client, "/apps/evolution/addressbook/display/primary_addressbook",
- NULL);
- g_object_unref (gconf_client);
- if (!e_book_get_addressbooks (&source_list, NULL)) {
- g_warning ("Could not get addressbook source list from GConf!");
- g_free (uid);
- return;
- }
- if (uid) {
- ESource *source = e_source_list_peek_source_by_uid(source_list, uid);
- if (source) {
- book = e_book_new (source, NULL);
- }
- else {
- book = e_book_new_default_addressbook (NULL);
- }
- g_free (uid);
- }
- else {
- book = e_book_new_default_addressbook (NULL);
- }
-
- e_book_async_open (book, FALSE, book_loaded_cb, g_strdup (item_type_name));
-}
-
-static void
-impl_handleURI (PortableServer_Servant servant,
- const char* uri,
- CORBA_Environment *ev)
-{
- AddressbookComponent *addressbook_component = ADDRESSBOOK_COMPONENT (bonobo_object_from_servant (servant));
- AddressbookComponentPrivate *priv;
- AddressbookView *view = NULL;
-
- GList *l;
- char *src_uid = NULL;
- char *contact_uid = NULL;
-
- priv = addressbook_component->priv;
- l = g_list_last (priv->views);
- if (!l)
- return;
-
- view = l->data;
-
- if (!strncmp (uri, "contacts:", 9)) {
- EUri *euri = e_uri_new (uri);
- const char *p;
- char *header, *content;
- size_t len, clen;
-
- p = euri->query;
- if (p) {
- while (*p) {
- len = strcspn (p, "=&");
-
- /* If it's malformed, give up. */
- if (p[len] != '=')
- break;
-
- header = (char *) p;
- header[len] = '\0';
- p += len + 1;
-
- clen = strcspn (p, "&");
-
- content = g_strndup (p, clen);
-
- if (!g_ascii_strcasecmp (header, "source-uid")) {
- src_uid = g_strdup (content);
- } else if (!g_ascii_strcasecmp (header, "contact-uid")) {
- contact_uid = g_strdup (content);
- }
-
- g_free (content);
-
- p += clen;
- if (*p == '&') {
- p++;
- if (!strcmp (p, "amp;"))
- p += 4;
- }
- }
-
- addressbook_view_edit_contact (view, src_uid, contact_uid);
-
- g_free (src_uid);
- g_free (contact_uid);
- }
- e_uri_free (euri);
- }
-
-}
-
static void
impl_upgradeFromVersion (PortableServer_Servant servant, short major, short minor, short revision, CORBA_Environment *ev)
{
@@ -416,45 +76,6 @@ impl_upgradeFromVersion (PortableServer_Servant servant, short major, short mino
g_error_free(err);
}
-static CORBA_boolean
-impl_requestQuit (PortableServer_Servant servant, CORBA_Environment *ev)
-{
- return eab_editor_request_close_all ();
-}
-
-/* GObject methods. */
-
-static void
-impl_dispose (GObject *object)
-{
- AddressbookComponentPrivate *priv = ADDRESSBOOK_COMPONENT (object)->priv;
- GList *l;
-
- if (priv->gconf_client != NULL) {
- g_object_unref (priv->gconf_client);
- priv->gconf_client = NULL;
- }
-
- for (l = priv->views; l; l = l->next) {
- AddressbookView *view = l->data;
- g_object_weak_unref (G_OBJECT (view), view_destroyed_cb, ADDRESSBOOK_COMPONENT (object));
- }
- g_list_free (priv->views);
- priv->views = NULL;
- (* G_OBJECT_CLASS (parent_class)->dispose) (object);
-}
-
-static void
-impl_finalize (GObject *object)
-{
- AddressbookComponentPrivate *priv = ADDRESSBOOK_COMPONENT (object)->priv;
-
- g_free (priv);
-
- (* G_OBJECT_CLASS (parent_class)->finalize) (object);
-}
-
-
/* Initialization. */
static void
@@ -463,15 +84,7 @@ addressbook_component_class_init (AddressbookComponentClass *class)
POA_GNOME_Evolution_Component__epv *epv = &class->epv;
GObjectClass *object_class = G_OBJECT_CLASS (class);
- epv->createView = impl_createView;
- epv->_get_userCreatableItems = impl__get_userCreatableItems;
- epv->requestCreateItem = impl_requestCreateItem;
epv->upgradeFromVersion = impl_upgradeFromVersion;
- epv->requestQuit = impl_requestQuit;
- epv->handleURI = impl_handleURI;
-
- object_class->dispose = impl_dispose;
- object_class->finalize = impl_finalize;
parent_class = g_type_class_peek_parent (class);
}
@@ -479,20 +92,8 @@ addressbook_component_class_init (AddressbookComponentClass *class)
static void
addressbook_component_init (AddressbookComponent *component)
{
- AddressbookComponentPrivate *priv;
static int first = TRUE;
- priv = g_new0 (AddressbookComponentPrivate, 1);
-
- /* EPFIXME: Should use a custom one instead? */
- priv->gconf_client = gconf_client_get_default ();
-
- priv->base_directory = g_build_filename (e_get_user_data_dir (), "addressbook", NULL);
-
- component->priv = priv;
-
- ensure_sources (component);
-
#ifdef ENABLE_SMIME
smime_component_init ();
#endif
@@ -513,35 +114,3 @@ addressbook_component_init (AddressbookComponent *component)
e_import_class_add_importer(klass, evolution_csv_evolution_importer_peek(), NULL, NULL);
}
}
-
-
-/* Public API. */
-
-AddressbookComponent *
-addressbook_component_peek (void)
-{
- static AddressbookComponent *component = NULL;
-
- if (component == NULL)
- component = g_object_new (addressbook_component_get_type (), NULL);
-
- return component;
-}
-
-GConfClient*
-addressbook_component_peek_gconf_client (AddressbookComponent *component)
-{
- g_return_val_if_fail (ADDRESSBOOK_IS_COMPONENT (component), NULL);
-
- return component->priv->gconf_client;
-}
-
-const char *
-addressbook_component_peek_base_directory (AddressbookComponent *component)
-{
- g_return_val_if_fail (ADDRESSBOOK_IS_COMPONENT (component), NULL);
-
- return component->priv->base_directory;
-}
-
-BONOBO_TYPE_FUNC_FULL (AddressbookComponent, GNOME_Evolution_Component, PARENT_TYPE, addressbook_component)
diff --git a/addressbook/gui/component/addressbook-view.c b/addressbook/gui/component/addressbook-view.c
index cc8f195c98..b45329b37e 100644
--- a/addressbook/gui/component/addressbook-view.c
+++ b/addressbook/gui/component/addressbook-view.c
@@ -116,360 +116,6 @@ static void addressbook_view_dispose (GObject *object);
static ESource *find_first_source (ESourceList *source_list);
static ESource *get_primary_source (AddressbookView *view);
-typedef struct {
- GtkWidget *editor;
- char *uid;
- AddressbookView *view;
-} EditorUidClosure;
-
-static void
-editor_weak_notify (gpointer data, GObject *o)
-{
- EditorUidClosure *closure = data;
- AddressbookViewPrivate *priv = closure->view->priv;
-
- g_hash_table_remove (priv->uid_to_editor,
- closure->uid);
-}
-
-static EABView *
-get_current_view (AddressbookView *view)
-{
- AddressbookViewPrivate *priv = view->priv;
-
- return EAB_VIEW (gtk_notebook_get_nth_page (GTK_NOTEBOOK (priv->notebook),
- gtk_notebook_get_current_page (GTK_NOTEBOOK (priv->notebook))));
-}
-
-static void
-save_all_contacts_cb (BonoboUIComponent *uih, void *user_data, const char *path)
-{
- AddressbookView *view = (AddressbookView *) user_data;
- EABView *v = get_current_view (view);
-
- if (v)
- eab_view_save_as (v, TRUE);
-}
-
-static void
-save_contact_cb (BonoboUIComponent *uih, void *user_data, const char *path)
-{
- AddressbookView *view = (AddressbookView *) user_data;
- EABView *v = get_current_view (view);
- if (v)
- eab_view_save_as(v, FALSE);
-}
-
-static void
-view_contact_cb (BonoboUIComponent *uih, void *user_data, const char *path)
-{
- AddressbookView *view = (AddressbookView *) user_data;
- EABView *v = get_current_view (view);
- if (v)
- eab_view_view(v);
-}
-
-static void
-delete_contact_cb (BonoboUIComponent *uih, void *user_data, const char *path)
-{
- AddressbookView *view = (AddressbookView *) user_data;
- EABView *v = get_current_view (view);
- if (v)
- eab_view_delete_selection(v, TRUE);
-}
-
-static void
-print_cb (BonoboUIComponent *uih, void *user_data, const char *path)
-{
- AddressbookView *view = (AddressbookView *) user_data;
- EABView *v = get_current_view (view);
- if (v)
- eab_view_print (v, GTK_PRINT_OPERATION_ACTION_PRINT_DIALOG);
-}
-
-static void
-print_preview_cb (BonoboUIComponent *uih, void *user_data, const char *path)
-{
- AddressbookView *view = (AddressbookView *) user_data;
- EABView *v = get_current_view (view);
- if (v)
- eab_view_print (v, GTK_PRINT_OPERATION_ACTION_PREVIEW);
-}
-
-static void
-stop_loading_cb (BonoboUIComponent *uih, void *user_data, const char *path)
-{
- AddressbookView *view = (AddressbookView *) user_data;
- EABView *v = get_current_view (view);
- if (v)
- eab_view_stop(v);
-}
-
-static void
-cut_contacts_cb (BonoboUIComponent *uih, void *user_data, const char *path)
-{
- AddressbookView *view = (AddressbookView *) user_data;
- EABView *v = get_current_view (view);
- if (v)
- eab_view_cut(v);
-}
-
-static void
-copy_contacts_cb (BonoboUIComponent *uih, void *user_data, const char *path)
-{
- AddressbookView *view = (AddressbookView *) user_data;
- EABView *v = get_current_view (view);
- if (v)
- eab_view_copy(v);
-}
-
-static void
-paste_contacts_cb (BonoboUIComponent *uih, void *user_data, const char *path)
-{
- AddressbookView *view = (AddressbookView *) user_data;
- EABView *v = get_current_view (view);
- if (v)
- eab_view_paste(v);
-}
-
-static void
-select_all_contacts_cb (BonoboUIComponent *uih, void *user_data, const char *path)
-{
- AddressbookView *view = (AddressbookView *) user_data;
- EABView *v = get_current_view (view);
- if (v)
- eab_view_select_all (v);
-}
-
-static void
-send_contact_cb (BonoboUIComponent *uih, void *user_data, const char *path)
-{
- AddressbookView *view = (AddressbookView *) user_data;
- EABView *v = get_current_view (view);
- if (v)
- eab_view_send (v);
-}
-
-static void
-send_contact_to_cb (BonoboUIComponent *uih, void *user_data, const char *path)
-{
- AddressbookView *view = (AddressbookView *) user_data;
- EABView *v = get_current_view (view);
- if (v)
- eab_view_send_to (v);
-}
-
-static void
-copy_all_contacts_to_cb (BonoboUIComponent *uih, void *user_data, const char *path)
-{
- AddressbookView *view = (AddressbookView *) user_data;
- EABView *v = get_current_view (view);
-
- if (v)
- eab_view_copy_to_folder (v, TRUE);
-}
-
-static void
-copy_contact_to_cb (BonoboUIComponent *uih, void *user_data, const char *path)
-{
- AddressbookView *view = (AddressbookView *) user_data;
- EABView *v = get_current_view (view);
- if (v)
- eab_view_copy_to_folder (v, FALSE);
-}
-
-static void
-move_all_contacts_to_cb (BonoboUIComponent *uih, void *user_data, const char *path)
-{
- AddressbookView *view = (AddressbookView *) user_data;
- EABView *v = get_current_view (view);
- if (v)
- eab_view_move_to_folder (v, TRUE);
-}
-
-static void
-move_contact_to_cb (BonoboUIComponent *uih, void *user_data, const char *path)
-{
- AddressbookView *view = (AddressbookView *) user_data;
- EABView *v = get_current_view (view);
- if (v)
- eab_view_move_to_folder (v, FALSE);
-}
-
-static void
-forget_passwords_cb (BonoboUIComponent *uih, void *user_data, const char *path)
-{
- e_passwords_forget_passwords();
-}
-
-static void
-new_addressbook_folder (AddressbookView *view)
-{
- AddressbookViewPrivate *priv = view->priv;
- addressbook_config_create_new_source (gtk_widget_get_toplevel(priv->notebook));
-}
-
-static void
-new_folder_cb (BonoboUIComponent *uih, void *user_data, const char *path)
-{
- AddressbookView *view = (AddressbookView *) user_data;
- new_addressbook_folder (view);
-}
-
-static void
-delete_addressbook_folder (AddressbookView *view)
-{
- AddressbookViewPrivate *priv = view->priv;
- ESource *selected_source;
- EBook *book;
- GError *error = NULL;
- GtkWindow *toplevel;
-
- selected_source = e_source_selector_peek_primary_selection (E_SOURCE_SELECTOR (priv->selector));
- if (!selected_source)
- return;
- toplevel = (GtkWindow *) gtk_widget_get_toplevel (priv->notebook);
-
- if (e_error_run (toplevel, "addressbook:ask-delete-addressbook",
- e_source_peek_name(selected_source)) != GTK_RESPONSE_YES)
- return;
-
- /* Remove local data */
- book = e_book_new (selected_source, &error);
- if (book) {
- if (e_book_remove (book, NULL)) {
- if (e_source_selector_source_is_selected (E_SOURCE_SELECTOR (priv->selector),
- selected_source))
- e_source_selector_unselect_source (E_SOURCE_SELECTOR (priv->selector),
- selected_source);
-
- e_source_group_remove_source (e_source_peek_group (selected_source), selected_source);
-
- e_source_list_sync (priv->source_list, NULL);
- }
- else {
- e_error_run (toplevel, "addressbook:remove-addressbook", NULL);
- }
- g_object_unref (book);
- }
- else {
- g_warning ("error removing addressbook : %s", error->message);
- g_error_free (error);
- }
-}
-
-static void
-delete_folder_cb (BonoboUIComponent *uih, void *user_data, const char *path)
-{
- AddressbookView *view = (AddressbookView *) user_data;
- if (view)
- delete_addressbook_folder (view);
-
-}
-
-static void
-edit_addressbook_folder (AddressbookView *view)
-{
- AddressbookViewPrivate *priv = view->priv;
- ESource *selected_source;
- const char *uid;
- EditorUidClosure *closure;
-
- selected_source = e_source_selector_peek_primary_selection (E_SOURCE_SELECTOR (priv->selector));
- if (!selected_source)
- return;
-
- uid = e_source_peek_uid (selected_source);
-
- closure = g_hash_table_lookup (priv->uid_to_editor, uid);
- if (!closure) {
- char *uid_copy = g_strdup (uid);
-
- closure = g_new (EditorUidClosure, 1);
- closure->editor = addressbook_config_edit_source (gtk_widget_get_toplevel(priv->notebook), selected_source);
- closure->uid = uid_copy;
- closure->view = view;
-
- g_hash_table_insert (priv->uid_to_editor,
- uid_copy,
- closure);
-
- g_object_weak_ref (G_OBJECT (closure->editor),
- editor_weak_notify, closure);
- }
-
- gtk_window_present (GTK_WINDOW (closure->editor));
-
-}
-
-static void
-edit_folder_cb (BonoboUIComponent *uih, void *user_data, const char *path)
-{
- AddressbookView *view = (AddressbookView *) user_data;
- if (view)
- edit_addressbook_folder (view);
-
-}
-
-static void
-rename_addressbook_folder (AddressbookView *view)
-{
- AddressbookViewPrivate *priv = view->priv;
- ESource *source;
- const char *old_name;
- char *prompt, *new_name;
- gboolean done = FALSE;
-
- source = e_source_selector_peek_primary_selection (E_SOURCE_SELECTOR (priv->selector));
- old_name = e_source_peek_name(source);
- prompt = g_strdup_printf (_("Rename the \"%s\" folder to:"), old_name);
-
- while (!done) {
- new_name = e_request_string (NULL, _("Rename Folder"), prompt, old_name);
- if (new_name == NULL || !strcmp (old_name, new_name)) {
- done = TRUE;
- } else if (strchr(new_name, '/') != NULL) {
- e_error_run (NULL,
- "addressbook:no-rename-folder", old_name, new_name, _("Folder names cannot contain '/'"), NULL);
- done = TRUE;
- } else if (e_source_group_peek_source_by_name(e_source_peek_group(source), new_name)) {
- e_error_run (NULL, "addressbook:no-rename-folder-exists", old_name, new_name, NULL);
- } else {
- e_source_set_name (source, new_name);
- done = TRUE;
- }
- }
- g_free (new_name);
-
-}
-
-static void
-rename_folder_cb (BonoboUIComponent *uih, void *user_data, const char *path)
-{
- AddressbookView *view = (AddressbookView *) user_data;
- if (view)
- rename_addressbook_folder (view);
-}
-
-static gboolean
-folder_can_delete (AddressbookView *view)
-{
- AddressbookViewPrivate *priv = view->priv;
- ESource *source ;
- const char *source_uri;
-
- source = e_source_selector_peek_primary_selection (E_SOURCE_SELECTOR (priv->selector));
- if(source) {
- source_uri = e_source_peek_relative_uri (source);
- if (source_uri && !strcmp("system", source_uri))
- return 0;
- else
- return 1;
- }
- else
- return 0;
-}
-
static void
set_status_message (EABView *eav, const char *message, AddressbookView *view)
{
@@ -518,112 +164,6 @@ search_result (EABView *eav, EBookViewStatus status, AddressbookView *view)
}
static void
-update_command_state (EABView *eav, AddressbookView *view)
-{
- AddressbookViewPrivate *priv = view->priv;
- BonoboUIComponent *uic;
- EABMenuTargetSelect *target;
-
- if (eav != get_current_view (view))
- return;
-
- g_object_ref (view);
-
- target = eab_view_get_menu_target(eav, priv->menu);
- e_menu_update_target((EMenu *)priv->menu, target);
-
- uic = bonobo_control_get_ui_component (priv->folder_view_control);
-
- /* TODO: this stuff can mostly be made to use the target bits instead */
-
- if (bonobo_ui_component_get_container (uic) != CORBA_OBJECT_NIL) {
-#define SET_SENSITIVE(verb,f) \
- bonobo_ui_component_set_prop (uic, (verb), "sensitive", (f)(eav) ? "1" : "0", NULL)
-
- SET_SENSITIVE ("/commands/ContactsSaveAsVCard", eab_view_can_save_as);
- SET_SENSITIVE ("/commands/ContactsView", eab_view_can_view);
-
- /* Print Contact */
- SET_SENSITIVE ("/commands/ContactsPrint", eab_view_can_print);
- SET_SENSITIVE ("/commands/ContactsPrintPreview", eab_view_can_print);
-
- /* Delete Contact */
- SET_SENSITIVE ("/commands/ContactDelete", eab_view_can_delete);
- SET_SENSITIVE ("/commands/ContactsCut", eab_view_can_cut);
-
- SET_SENSITIVE ("/commands/ContactsCopy", eab_view_can_copy);
- SET_SENSITIVE ("/commands/ContactsPaste", eab_view_can_paste);
- SET_SENSITIVE ("/commands/ContactsSelectAll", eab_view_can_select_all);
- SET_SENSITIVE ("/commands/ContactsSendContactToOther", eab_view_can_send);
- SET_SENSITIVE ("/commands/ContactsSendMessageToContact", eab_view_can_send_to);
- SET_SENSITIVE ("/commands/ContactsMoveToFolder", eab_view_can_move_to_folder);
- SET_SENSITIVE ("/commands/ContactsCopyToFolder", eab_view_can_copy_to_folder);
-
- bonobo_ui_component_set_prop (uic, ("/commands/FolderDelete"), "sensitive", folder_can_delete(view) ? "1" : "0", NULL);
-
- /* Stop */
- SET_SENSITIVE ("/commands/ContactStop", eab_view_can_stop);
-#undef SET_SENSITIVE
- }
-
- g_object_unref (view);
-}
-
-static BonoboUIVerb verbs [] = {
- BONOBO_UI_UNSAFE_VERB ("ContactsPrint", print_cb),
- BONOBO_UI_UNSAFE_VERB ("ContactsPrintPreview", print_preview_cb),
- BONOBO_UI_UNSAFE_VERB ("ContactsSaveAsVCard", save_contact_cb),
- BONOBO_UI_UNSAFE_VERB ("ContactsView", view_contact_cb),
-
- BONOBO_UI_UNSAFE_VERB ("ContactDelete", delete_contact_cb),
- BONOBO_UI_UNSAFE_VERB ("ContactStop", stop_loading_cb),
-
- BONOBO_UI_UNSAFE_VERB ("ContactsCut", cut_contacts_cb),
- BONOBO_UI_UNSAFE_VERB ("ContactsCopy", copy_contacts_cb),
- BONOBO_UI_UNSAFE_VERB ("ContactsPaste", paste_contacts_cb),
- BONOBO_UI_UNSAFE_VERB ("ContactsSelectAll", select_all_contacts_cb),
-
- BONOBO_UI_UNSAFE_VERB ("ContactsSendContactToOther", send_contact_cb),
- BONOBO_UI_UNSAFE_VERB ("ContactsSendMessageToContact", send_contact_to_cb),
- BONOBO_UI_UNSAFE_VERB ("ContactsMoveToFolder", move_contact_to_cb),
- BONOBO_UI_UNSAFE_VERB ("ContactsCopyToFolder", copy_contact_to_cb),
- BONOBO_UI_UNSAFE_VERB ("ContactsForgetPasswords", forget_passwords_cb),
- /* ContactsViewPreview is a toggle */
-
- BONOBO_UI_UNSAFE_VERB ("FolderCreate", new_folder_cb),
- BONOBO_UI_UNSAFE_VERB ("FolderCopy", copy_all_contacts_to_cb),
- BONOBO_UI_UNSAFE_VERB ("FolderMove", move_all_contacts_to_cb),
- BONOBO_UI_UNSAFE_VERB ("FolderSave", save_all_contacts_cb),
- BONOBO_UI_UNSAFE_VERB ("FolderDelete", delete_folder_cb),
- BONOBO_UI_UNSAFE_VERB ("FolderRename", rename_folder_cb),
- BONOBO_UI_UNSAFE_VERB ("ChangeFolderProperties", edit_folder_cb),
-
- BONOBO_UI_VERB_END
-};
-
-static EPixmap pixmaps [] = {
- E_PIXMAP ("/commands/ChangeFolderProperties", "document-properties", E_ICON_SIZE_MENU),
- E_PIXMAP ("/commands/ContactDelete", "edit-delete", E_ICON_SIZE_MENU),
- E_PIXMAP ("/commands/ContactsCopy", "edit-copy", E_ICON_SIZE_MENU),
- E_PIXMAP ("/commands/ContactsCut", "edit-cut", E_ICON_SIZE_MENU),
- E_PIXMAP ("/commands/ContactsPaste", "edit-paste", E_ICON_SIZE_MENU),
- E_PIXMAP ("/commands/ContactsPrint", "document-print", E_ICON_SIZE_MENU),
- E_PIXMAP ("/commands/ContactsPrintPreview", "document-print-preview", E_ICON_SIZE_MENU),
- E_PIXMAP ("/commands/ContactsSaveAsVCard", "document-save-as", E_ICON_SIZE_MENU),
- E_PIXMAP ("/commands/ContactsSendContactToOther", "mail-forward", E_ICON_SIZE_MENU),
- E_PIXMAP ("/commands/ContactsSendMessageToContact", "mail-message-new", E_ICON_SIZE_MENU),
- E_PIXMAP ("/commands/FolderCopy", "edit-copy", E_ICON_SIZE_MENU),
- E_PIXMAP ("/commands/FolderDelete", "edit-delete", E_ICON_SIZE_MENU),
- E_PIXMAP ("/commands/FolderMove", "folder-move", E_ICON_SIZE_MENU),
- E_PIXMAP ("/commands/FolderSave", "document-save-as", E_ICON_SIZE_MENU),
-
- E_PIXMAP ("/Toolbar/ContactsPrint", "document-print", E_ICON_SIZE_LARGE_TOOLBAR),
- E_PIXMAP ("/Toolbar/ContactDelete", "edit-delete", E_ICON_SIZE_LARGE_TOOLBAR),
-
- E_PIXMAP_END
-};
-
-static void
control_activate (BonoboControl *control,
BonoboUIComponent *uic,
AddressbookView *view)
@@ -637,9 +177,6 @@ control_activate (BonoboControl *control,
bonobo_ui_component_set_container (uic, remote_ui_container, NULL);
bonobo_object_release_unref (remote_ui_container, NULL);
- bonobo_ui_component_add_verb_list_with_data (
- uic, verbs, view);
-
bonobo_ui_component_freeze (uic, NULL);
xmlfile = g_build_filename (EVOLUTION_UIDIR,
@@ -653,8 +190,6 @@ control_activate (BonoboControl *control,
if (v)
eab_view_setup_menus (v, uic);
- e_pixmaps_update (uic, pixmaps);
-
e_user_creatable_items_handler_activate (priv->creatable_items_handler, uic);
bonobo_ui_component_thaw (uic, NULL);
@@ -687,70 +222,6 @@ control_activate_cb (BonoboControl *control,
}
static void
-gather_uids_foreach (char *key,
- gpointer value,
- GList **list)
-{
- (*list) = g_list_prepend (*list, key);
-}
-
-static void
-source_list_changed_cb (ESourceList *source_list, AddressbookView *view)
-{
- AddressbookViewPrivate *priv = view->priv;
- GList *uids, *l;
- EABView *v;
-
- uids = NULL;
- g_hash_table_foreach (priv->uid_to_view, (GHFunc)gather_uids_foreach, &uids);
- for (l = uids; l; l = l->next) {
- char *uid = l->data;
- if (e_source_list_peek_source_by_uid (source_list, uid)) {
- /* the source still exists, do nothing */
- }
- else {
- /* the source no longer exists, remove its
- view remove it from our hash table. */
- v = g_hash_table_lookup (priv->uid_to_view,
- uid);
- gtk_notebook_remove_page (GTK_NOTEBOOK (priv->notebook),
- gtk_notebook_page_num (GTK_NOTEBOOK (priv->notebook),
- GTK_WIDGET (v)));
- g_hash_table_remove (priv->uid_to_view, uid);
- }
- }
- g_list_free (uids);
-
- uids = NULL;
- g_hash_table_foreach (priv->uid_to_editor, (GHFunc)gather_uids_foreach, &uids);
- for (l = uids; l; l = l->next) {
- char *uid = l->data;
- if (e_source_list_peek_source_by_uid (source_list, uid)) {
- /* the source still exists, do nothing */
- }
- else {
- /* the source no longer exists, remove its
- editor remove it from our hash table. */
- EditorUidClosure *closure = g_hash_table_lookup (priv->uid_to_editor,
- uid);
- g_object_weak_unref (G_OBJECT (closure->editor),
- editor_weak_notify, closure);
- gtk_widget_destroy (closure->editor);
- g_hash_table_remove (priv->uid_to_editor, uid);
- }
- }
- g_list_free (uids);
-
- /* make sure we've got the current view selected and updated
- properly */
- v = get_current_view (view);
- if (v) {
- eab_view_setup_menus (v, bonobo_control_get_ui_component (priv->folder_view_control));
- update_command_state (v, view);
- }
-}
-
-static void
load_uri_for_selection (ESourceSelector *selector,
AddressbookView *view,
gboolean force)
diff --git a/addressbook/gui/component/e-book-shell-module.c b/addressbook/gui/component/e-book-shell-module.c
new file mode 100644
index 0000000000..25693234ee
--- /dev/null
+++ b/addressbook/gui/component/e-book-shell-module.c
@@ -0,0 +1,381 @@
+/* -*- Mode: C; indent-tabs-mode: t; c-basic-offset: 8; tab-width: 8 -*- */
+/* e-book-shell-module.c
+ *
+ * Copyright (C) 1999-2008 Novell, Inc. (www.novell.com)
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of version 2 of the GNU General Public
+ * License as published by the Free Software Foundation.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public
+ * License along with this program; if not, write to the
+ * Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
+ * Boston, MA 02110-1301, USA.
+ */
+
+#include <e-shell.h>
+#include <e-shell-module.h>
+#include <e-shell-window.h>
+
+#include "e-book-shell-view.h"
+
+#define MODULE_NAME "addressbook"
+#define MODULE_ALIASES ""
+#define MODULE_SCHEMES ""
+#define MODULE_SORT_ORDER 300
+
+#define LDAP_BASE_URI "ldap://"
+#define PERSONAL_RELATIVE_URI "system"
+
+/* Module Entry Point */
+void e_shell_module_init (GTypeModule *type_module);
+
+static void
+book_module_ensure_sources (EShellModule *shell_module)
+{
+ ESourceList *source_list;
+ ESourceGroup *on_this_computer;
+ ESourceGroup *on_ldap_servers;
+ ESource *personal_source;
+ GSList *groups, *iter;
+ const gchar *base_dir;
+ gchar *base_uri;
+ gchar *base_uri_proto;
+
+ on_this_computer = NULL;
+ on_ldap_servers = NULL;
+ personal_source = NULL;
+
+ if (!e_book_get_addressbooks (&source_list, NULL)) {
+ g_warning ("Could not get addressbook sources from GConf!");
+ return;
+ }
+
+ base_dir = e_shell_module_get_data_dir (shell_module);
+ base_uri = g_build_filename (base_dir, "local", NULL);
+
+ base_uri_proto = g_filename_to_uri (base_uri, NULL, NULL);
+
+ groups = e_source_list_peek_groups (source_list);
+ for (iter = groups; iter != NULL; iter = iter->next) {
+ ESourceGroup *source_group = iter->data;
+ const gchar *group_base_uri;
+
+ group_base_uri = e_source_group_peek_base_uri (source_group);
+
+ /* Compare only "file://" part. if user home directory
+ * changes, we do not want to create one more group. */
+ if (on_this_computer == NULL &&
+ strncmp (base_uri_proto, group_base_uri, 7) == 0)
+ on_this_computer = source_group;
+
+ else if (on_ldap_servers == NULL &&
+ g_str_equal (LDAP_BASE_URI, group_base_uri))
+ on_ldap_servers = source_group;
+ }
+
+ if (on_this_computer != NULL) {
+ GSList *sources;
+ const gchar *group_base_uri;
+
+ sources = e_source_group_peek_sources (on_this_computer);
+ group_base_uri = e_source_group_peek_base_uri (on_this_computer);
+
+ /* Make this group includes a "Personal" source. */
+ for (iter = sources; iter != NULL; iter = iter->next) {
+ ESource *source = iter->data;
+ const gchar *relative_uri;
+
+ relative_uri = e_source_peek_relative_uri (source);
+ if (relative_uri == NULL)
+ continue;
+
+ if (g_str_equal (PERSONAL_RELATIVE_URI, relative_uri)) {
+ personal_source = source;
+ break;
+ }
+ }
+
+ /* Make sure we have the correct base URI. This can
+ * change when the user's home directory changes. */
+ if (!g_str_equal (base_uri_proto, group_base_uri)) {
+ e_source_group_set_base_uri (
+ on_this_computer, base_uri_proto);
+
+ /* XXX We shouldn't need this sync call here as
+ * set_base_uri() results in synching to GConf,
+ * but that happens in an idle loop and too late
+ * to prevent the user from seeing "Cannot
+ * Open ... because of invalid URI" error. */
+ e_source_list_sync (source_list, NULL);
+ }
+
+ } else {
+ ESourceGroup *source_group;
+ const gchar *name;
+
+ /* Create the local source group. */
+ name = _("On This Computer");
+ source_group = e_source_group_new (name, base_uri_proto);
+ e_source_list_add_group (source_list, source_group, -1);
+ }
+
+ if (personal_source == NULL) {
+ ESource *source;
+ const gchar *name;
+
+ /* Create the default Personal address book. */
+ name = _("Personal");
+ source = e_source_new (name, PERSONAL_RELATIVE_URI);
+ e_source_group_add_source (on_this_computer, source, -1);
+ e_source_set_property (source, "completion", "true");
+ g_object_unref (source);
+ }
+
+ if (on_ldap_servers == NULL) {
+ ESourceGroup *source_group;
+ const gchar *name;
+
+ /* Create the LDAP source group. */
+ name = _("On LDAP Servers");
+ source_group = e_source_group_new (name, LDAP_BASE_URI);
+ e_source_list_add_group (source_list, source_group, -1);
+ }
+
+ g_free (base_uri_proto);
+ g_free (base_uri);
+}
+
+static void
+book_module_book_loaded_cb (EBook *book,
+ EBookStatus status,
+ gpointer user_data)
+{
+ EContact *contact;
+ GtkAction *action;
+ const gchar *action_name;
+
+ if (status != E_BOOK_ERROR_OK) {
+ /* XXX We really need a dialog here, but we don't
+ * have access to the ESource so we can't use
+ * eab_load_error_dialog. Fun! */
+ return;
+ }
+
+ contact = e_contact_new ();
+ action = GTK_ACTION (user_data);
+ action_name = gtk_action_get_name (action);
+
+ if (g_str_equal (action_name, "contact-new"))
+ eab_show_contact_editor (book, contact, TRUE, TRUE);
+
+ if (g_str_equal (action_name, "contact-list-new") == 0)
+ eab_show_contact_list_editor (book, contact, TRUE, TRUE);
+
+ g_object_unref (contact);
+ g_object_unref (book);
+}
+
+static void
+action_contact_new_cb (GtkAction *action,
+ EShellWindow *shell_window)
+{
+ EBook *book;
+ GConfClient *client;
+ ESourceList *source_list;
+ const gchar *key;
+
+ /* This callback is used for both contacts and contact lists. */
+
+ if (!e_book_get_addressbooks (&source_list, NULL)) {
+ g_warning ("Could not get addressbook sources from GConf!");
+ return;
+ }
+
+ client = gconf_client_get_default ();
+ key = "/apps/evolution/addressbook/display/primary_addressbook";
+ uid = gconf_client_get_string (client, key, NULL);
+ g_object_unref (client);
+
+ if (uid != NULL) {
+ ESource *source;
+
+ source = e_source_list_peek_source_by_uid (source_list, uid);
+ if (source != NULL)
+ book = e_book_new (source, NULL);
+ g_free (uid);
+ }
+
+ if (book == NULL)
+ book = e_book_new_default_addressbook (NULL);
+
+ e_book_async_open (book, FALSE, book_module_book_loaded_cb, action);
+}
+
+static void
+action_address_book_new_cb (GtkAction *action,
+ EShellWindow *shell_window)
+{
+ addressbook_config_create_new_source (NULL);
+}
+
+static GtkActionEntry item_entries[] = {
+
+ { "contact-new",
+ "contact-new",
+ N_("_Contact"), /* XXX Need C_() here */
+ "<Control>c",
+ N_("Create a new contact"),
+ G_CALLBACK (action_contact_new_cb) },
+
+ { "contact-list-new",
+ "stock_contact-list",
+ N_("Contact _List"),
+ "<Control>l",
+ N_("Create a new contact list"),
+ G_CALLBACK (action_contact_new_cb) }
+};
+
+static GtkActionEntry source_entries[] = {
+
+ { "address-book-new",
+ "address-book-new",
+ N_("Address _Book"),
+ NULL,
+ N_("Create a new address book"),
+ G_CALLBACK (action_address_book_new_cb) }
+};
+
+static gboolean
+book_module_is_busy (EShellModule *shell_module)
+{
+ return !eab_editor_request_close_all ();
+}
+
+static gboolean
+book_module_shutdown (EShellModule *shell_module)
+{
+}
+
+static gboolean
+book_module_handle_uri (EShellModule *shell_module,
+ const gchar *uri)
+{
+ EUri *euri;
+ const gchar *cp;
+ gchar *source_uid = NULL;
+ gchar *contact_uid = NULL;
+
+ if (!g_str_has_prefix (uri, "contacts:"))
+ return FALSE;
+
+ euri = e_uri_new (uri);
+ cp = euri->query;
+
+ if (cp == NULL) {
+ e_uri_free (euri);
+ return FALSE;
+ }
+
+ while (*cp != NULL) {
+ gchar *header;
+ gchar *content;
+ gsize length;
+ gsize content_length;
+
+ length = strcspn (cp, "=&");
+
+ /* If it's malformed, give up. */
+ if (cp[length] != '=')
+ break;
+
+ header = (gchar *) cp;
+ header[length] = '\0';
+ cp += length + 1;
+
+ content_length = strcspn (cp, "&");
+ content = g_strndup (cp, content_length);
+
+ if (g_ascii_strcasecmp (header, "source-uid") == 0)
+ source_uid = g_strdup (content);
+
+ if (g_ascii_strcasecmp (header, "contact-uid") == 0)
+ contact_uid = g_strdup (content);
+
+ g_free (content);
+
+ cp += content_length;
+ if (*cp == '&') {
+ cp++;
+ if (strcmp (cp, "amp;"))
+ cp += 4;
+ }
+ }
+
+ /* FIXME */
+ /*addressbook_view_edit_contact (view, source_uid, contact_uid);*/
+
+ g_free (source_uid);
+ g_free (contact_uid);
+
+ e_uri_free (euri);
+
+ return TRUE;
+}
+
+static void
+book_module_window_created (EShellModule *shell_module,
+ EShellWindow *shell_window)
+{
+ const gchar *module_name;
+
+ module_name = G_TYPE_MODULE (shell_module)->name;
+
+ e_shell_window_register_new_item_actions (
+ shell_window, module_name,
+ item_entries, G_N_ELEMENTS (item_entries));
+
+ e_shell_window_register_new_source_actions (
+ shell_window, module_name,
+ source_entries, G_N_ELEMENTS (source_entries));
+}
+
+static EShellmoduleInfo module_info = {
+
+ MODULE_NAME,
+ MODULE_ALIASES,
+ MODULE_SCHEMES,
+ MODULE_SORT_ORDER,
+
+ /* Methods */
+ book_module_is_busy,
+ book_module_shutdown
+};
+
+void
+e_shell_module_init (GTypeModule *type_module)
+{
+ EShell *shell;
+ EShellModule *shell_module;
+
+ shell_module = E_SHELL_MODULE (type_module);
+ shell = e_shell_module_get_shell (shell_module);
+
+ e_book_shell_view_get_type (type_module);
+ e_shell_module_set_info (shell_module, &module_info);
+
+ book_module_ensure_sources (shell_module);
+
+ g_signal_connect_swapped (
+ shell, "handle-uri",
+ G_CALLBACK (book_module_handle_uri), shell_module);
+
+ g_signal_connect_swapped (
+ shell, "window-created",
+ G_CALLBACK (book_module_window_created), shell_module);
+}
diff --git a/addressbook/gui/component/e-book-shell-view-actions.c b/addressbook/gui/component/e-book-shell-view-actions.c
new file mode 100644
index 0000000000..8d2d1a7739
--- /dev/null
+++ b/addressbook/gui/component/e-book-shell-view-actions.c
@@ -0,0 +1,494 @@
+/* -*- Mode: C; indent-tabs-mode: t; c-basic-offset: 8; tab-width: 8 -*- */
+/* e-book-shell-view-actions.c
+ *
+ * Copyright (C) 1999-2008 Novell, Inc. (www.novell.com)
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of version 2 of the GNU General Public
+ * License as published by the Free Software Foundation.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public
+ * License along with this program; if not, write to the
+ * Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
+ * Boston, MA 02110-1301, USA.
+ */
+
+#include "e-book-shell-view-private.h"
+
+#include <e-util/e-util.h>
+
+static void
+action_address_book_copy_cb (GtkAction *action,
+ EBookShellView *book_shell_view)
+{
+ EABView *view;
+
+ view = e_book_shell_view_get_current_view (book_shell_view);
+ g_return_if_fail (view != NULL);
+ eab_view_copy_to_folder (view, TRUE);
+}
+
+static void
+action_address_book_delete_cb (GtkAction *action,
+ EBookShellView *book_shell_view)
+{
+ EShellView *shell_view;
+ EShellWindow *shell_window;
+ ESource *source;
+ ESourceSelector *selector;
+ ESourceGroup *source_group;
+ ESourceList *source_list;
+ EBook *book;
+ gint response;
+ GError *error = NULL;
+
+ shell_view = E_SHELL_VIEW (book_shell_view);
+ shell_window = e_shell_view_get_window (shell_view);
+
+ selector = E_SOURCE_SELECTOR (book_shell_view->priv->selector);
+ source = e_source_selector_peek_primary_selection (selector);
+ g_return_if_fail (source != NULL);
+
+ response = e_error_run (
+ GTK_WINDOW (shell_window),
+ "addressbook:ask-delete-addressbook",
+ e_source_peek_name (source));
+
+ if (response != GTK_RESPONSE_YES)
+ return;
+
+ book = e_book_new (source, &error);
+ if (error != NULL) {
+ g_warning ("Error removing addressbook: %s", error->message);
+ g_error_free (error);
+ return;
+ }
+
+ if (!e_book_remove (book, NULL)) {
+ e_error_run (
+ GTK_WINDOW (shell_window),
+ "addressbook:remove-addressbook", NULL);
+ g_object_unref (book);
+ return;
+ }
+
+ if (e_source_selector_source_is_selected (selector, source))
+ e_source_selector_unselect_source (selector, source);
+
+ source_group = e_source_peek_group (source);
+ e_source_group_remove_source (source_group, source);
+
+ source_list = book_shell_view->priv->source_list;
+ e_source_list_sync (source_list, NULL);
+
+ g_object_unref (book);
+}
+
+static void
+action_address_book_move_cb (GtkAction *action,
+ EBookShellView *book_shell_view)
+{
+ EABView *view;
+
+ view = e_book_shell_view_get_current_view (book_shell_view);
+ g_return_if_fail (view != NULL);
+ eab_view_move_to_folder (view, TRUE);
+}
+
+static void
+action_address_book_properties_cb (GtkAction *action,
+ EBookShellView *book_shell_view)
+{
+ EShellView *shell_view;
+ EShellWindow *shell_window;
+ ESource *source;
+ ESourceSelector *selector;
+ EditorUidClosure *closure;
+ GHashTable *uid_to_editor;
+ const gchar *uid;
+
+ shell_view = E_SHELL_VIEW (book_shell_view);
+ shell_window = e_shell_view_get_window (shell_view);
+
+ selector = E_SOURCE_SELECTOR (book_shell_view->priv->selector);
+ source = e_source_selector_peek_primary_selection (selector);
+ g_return_if_fail (source != NULL);
+
+ uid = e_source_peek_uid (source);
+ uid_to_editor = book_shell_view->priv->uid_to_editor;
+
+ closure = g_hash_table_lookup (uid_to_editor, uid);
+ if (closure == NULL) {
+ GtkWidget *editor;
+
+ editor = addressbook_config_edit_source (
+ GTK_WINDOW (shell_window), source);
+
+ closure = g_new (EditorUidClosure, 1);
+ closure->editor = editor;
+ closure->uid = g_strdup (uid);
+ closure->view = book_shell_view;
+
+ g_hash_table_insert (uid_to_editor, closure->uid, closure);
+
+ g_object_weak_ref (
+ G_OBJECT (closure->editor), (GWeakNotify)
+ e_book_shell_view_editor_weak_notify, closure);
+ }
+
+ gtk_window_present (GTK_WINDOW (closure->editor));
+}
+
+static void
+action_address_book_save_as_cb (GtkAction *action,
+ EBookShellView *book_shell_view)
+{
+ EABView *view;
+
+ view = e_book_shell_view_get_current_view (book_shell_view);
+ g_return_if_fail (view != NULL);
+ eab_view_save_as (view, TRUE);
+}
+
+static void
+action_address_book_stop_cb (GtkAction *action,
+ EBookShellView *book_shell_view)
+{
+ EABView *view;
+
+ view = e_book_shell_view_get_current_view (book_shell_view);
+ g_return_if_fail (view != NULL);
+ eab_view_stop (view);
+}
+
+static void
+action_contact_clipboard_copy_cb (GtkAction *action,
+ EBookShellView *book_shell_view)
+{
+ EABView *view;
+
+ view = e_book_shell_view_get_current_view (book_shell_view);
+ g_return_if_fail (view != NULL);
+ eab_view_copy (view);
+}
+
+static void
+action_contact_clipboard_cut_cb (GtkAction *action,
+ EBookShellView *book_shell_view)
+{
+ EABView *view;
+
+ view = e_book_shell_view_get_current_view (book_shell_view);
+ g_return_if_fail (view != NULL);
+ eab_view_cut (view);
+}
+
+static void
+action_contact_clipboard_paste_cb (GtkAction *action,
+ EBookShellView *book_shell_view)
+{
+ EABView *view;
+
+ view = e_book_shell_view_get_current_view (book_shell_view);
+ g_return_if_fail (view != NULL);
+ eab_view_paste (view);
+}
+
+static void
+action_contact_copy_cb (GtkAction *action,
+ EBookShellView *book_shell_view)
+{
+ EABView *view;
+
+ view = e_book_shell_view_get_current_view (book_shell_view);
+ g_return_if_fail (view != NULL);
+ eab_view_copy_to_folder (view, FALSE);
+}
+
+static void
+action_contact_delete_cb (GtkAction *action,
+ EBookShellView *book_shell_view)
+{
+ EABView *view;
+
+ view = e_book_shell_view_get_current_view (book_shell_view);
+ g_return_if_fail (view != NULL);
+ eab_view_delete_selection (view, TRUE);
+}
+
+static void
+action_contact_forward_cb (GtkAction *action,
+ EBookShellView *book_shell_view)
+{
+ EABView *view;
+
+ view = e_book_shell_view_get_current_view (book_shell_view);
+ g_return_if_fail (view != NULL);
+ eab_view_send (view);
+}
+
+static void
+action_contact_move_cb (GtkAction *action,
+ EBookShellView *book_shell_view)
+{
+ EABView *view;
+
+ view = e_book_shell_view_get_current_view (book_shell_view);
+ g_return_if_fail (view != NULL);
+ eab_view_move_to_folder (view, FALSE);
+}
+
+static void
+action_contact_open_cb (GtkAction *action,
+ EBookShellView *book_shell_view)
+{
+ EABView *view;
+
+ view = e_book_shell_view_get_current_view (book_shell_view);
+ g_return_if_fail (view != NULL);
+ eab_view_view (view);
+}
+
+static void
+action_contact_preview_cb (GtkToggleAction *action,
+ EBookShellView *book_shell_view)
+{
+ gboolean active;
+
+ active = gtk_toggle_action_get_active (action);
+ /* FIXME Unfinished. */
+}
+
+static void
+action_contact_print_cb (GtkAction *action,
+ EBookShellView *book_shell_view)
+{
+ EABView *view;
+
+ view = e_book_shell_view_get_current_view (book_shell_view);
+ g_return_if_fail (view != NULL);
+ eab_view_print (view, GTK_PRINT_OPERATION_ACTION_PRINT_DIALOG);
+}
+
+static void
+action_contact_print_preview_cb (GtkAction *action,
+ EBookShellView *book_shell_view)
+{
+ EABView *view;
+
+ view = e_book_shell_view_get_current_view (book_shell_view);
+ g_return_if_fail (view != NULL);
+ eab_view_print (view, GTK_PRINT_OPERATION_ACTION_PREVIEW);
+}
+
+static void
+action_contact_save_as_cb (GtkAction *action,
+ EBookShellView *book_shell_view)
+{
+ EABView *view;
+
+ view = e_book_shell_view_get_current_view (book_shell_view);
+ g_return_if_fail (view != NULL);
+ eab_view_save_as (view, FALSE);
+}
+
+static void
+action_contact_select_all_cb (GtkAction *action,
+ EBookShellView *book_shell_view)
+{
+ EABView *view;
+
+ view = e_book_shell_view_get_current_view (book_shell_view);
+ g_return_if_fail (view != NULL);
+ eab_view_select_all (view);
+}
+
+static void
+action_contact_send_message_cb (GtkAction *action,
+ EBookShellView *book_shell_view)
+{
+ EABView *view;
+
+ view = e_book_shell_view_get_current_view (book_shell_view);
+ g_return_if_fail (view != NULL);
+ eab_view_send_to (view);
+}
+
+static GtkActionEntry contact_entries[] = {
+
+ { "address-book-copy",
+ GTK_STOCK_COPY,
+ N_("Co_py All Contacts To..."),
+ NULL,
+ N_("Copy the contacts of the selected address book to another"),
+ G_CALLBACK (action_address_book_copy_cb) },
+
+ { "address-book-delete",
+ GTK_STOCK_DELETE,
+ N_("Del_ete Address Book"),
+ NULL,
+ N_("Delete the selected address book"),
+ G_CALLBACK (action_address_book_delete_cb) },
+
+ { "address-book-move",
+ "folder-move",
+ N_("Mo_ve All Contacts To..."),
+ NULL,
+ N_("Move the contacts of the selected address book to another"),
+ G_CALLBACK (action_address_book_move_cb) },
+
+ { "address-book-properties",
+ GTK_STOCK_PROPERTIES,
+ N_("Address _Book Properties"),
+ NULL,
+ N_("Change the properties of the selected address book"),
+ G_CALLBACK (action_address_book_properties_cb) },
+
+ { "address-book-save-as",
+ GTK_STOCK_SAVE_AS,
+ N_("S_ave Address Book as VCard"),
+ NULL,
+ N_("Save the contacts of the selected address book as a VCard"),
+ G_CALLBACK (action_address_book_save_as) },
+
+ { "address-book-stop",
+ GTK_STOCK_STOP,
+ NULL,
+ NULL,
+ N_("Stop loading"),
+ G_CALLBACK (action_address_book_stop_cb) },
+
+ { "contact-clipboard-copy",
+ GTK_STOCK_COPY,
+ NULL,
+ NULL,
+ N_("Copy the selection"),
+ G_CALLBACK (action_contact_clipboard_copy_cb) },
+
+ { "contact-clipboard-cut",
+ GTK_STOCK_CUT,
+ NULL,
+ NULL,
+ N_("Cut the selection"),
+ G_CALLBACK (action_contact_clipboard_cut_cb) },
+
+ { "contact-clipboard-paste",
+ GTK_STOCK_PASTE,
+ NULL,
+ NULL,
+ N_("Paste the clipboard"),
+ G_CALLBACK (action_contact_clipboard_paste_cb) },
+
+ { "contact-copy",
+ NULL,
+ N_("_Copy Contact To..."),
+ "<Control><Shift>y",
+ N_("Copy selected contacts to another address book"),
+ G_CALLBACK (action_contact_copy_cb) },
+
+ { "contact-delete",
+ GTK_STOCK_DELETE,
+ N_("_Delete Contact"),
+ "<Control>d",
+ N_("Delete selected contacts"),
+ G_CALLBACK (action_contact_delete_cb) },
+
+ { "contact-forward",
+ "mail-forward",
+ N_("_Forward Contact..."),
+ NULL,
+ N_("Send selected contacts to another person"),
+ G_CALLBACK (action_contact_forward_cb) },
+
+ { "contact-move",
+ NULL,
+ N_("_Move Contact To..."),
+ "<Control><Shift>v",
+ N_("Move selected contacts to another address book"),
+ G_CALLBACK (action_contact_move_cb) },
+
+ { "contact-open",
+ NULL,
+ N_("_Open"),
+ "<Control>o",
+ N_("View the current contact"),
+ G_CALLBACK (action_contact_open_cb) },
+
+ { "contact-print",
+ GTK_STOCK_PRINT,
+ NULL,
+ NULL,
+ N_("Print selected contacts"),
+ G_CALLBACK (action_contact_print_cb) },
+
+ { "contact-print-preview",
+ GTK_STOCK_PRINT_PREVIEW,
+ NULL,
+ NULL,
+ N_("Preview the contacts to be printed"),
+ G_CALLBACK (action_contact_print_preview_cb) },
+
+ { "contact-save-as",
+ GTK_STOCK_SAVE_AS,
+ N_("Save as VCard..."),
+ NULL,
+ N_("Save selected contacts as a VCard"),
+ G_CALLBACK (action_contact_save_as_cb) },
+
+ { "contact-select-all",
+ GTK_STOCK_SELECT_ALL,
+ NULL,
+ NULL,
+ N_("Select all contacts"),
+ G_CALLBACK (action_contact_select_all_cb) },
+
+ { "contact-send-message",
+ "mail-message-new",
+ N_("_Send Message to Contact..."),
+ NULL,
+ N_("Send a message to the selected contacts"),
+ G_CALLBACK (action_contact_send_message_cb) }
+};
+
+static GtkToggleActionEntry contact_toggle_entries[] = {
+
+ { "contact-preview",
+ NULL,
+ N_("Contact _Preview"),
+ "<Control>m",
+ N_("Show contact preview window"),
+ G_CALLBACK (action_contact_preview_cb),
+ TRUE }
+};
+
+void
+e_book_shell_view_actions_init (EBookShellView *book_shell_view)
+{
+ EShellView *shell_view;
+ EShellWindow *shell_window;
+ GtkActionGroup *action_group;
+ GtkUIManager *manager;
+ const gchar *domain;
+
+ shell_view = E_SHELL_VIEW (book_shell_view);
+ shell_window = e_shell_view_get_window (shell_view);
+ manager = e_shell_window_get_ui_manager (shell_window);
+ domain = GETTEXT_PACKAGE;
+
+ e_load_ui_definition (manager, "evolution-contacts.ui");
+
+ action_group = book_shell_view->priv->contact_actions;
+ gtk_action_group_set_translation_domain (action_group, domain);
+ gtk_action_group_add_actions (
+ action_group, contact_entries,
+ G_N_ELEMENTS (contact_entries), book_shell_view);
+ gtk_action_group_add_toggle_actions (
+ action_group, contact_toggle_entries,
+ G_N_ELEMENTS (contact_toggle_entries), book_shell_view);
+ gtk_ui_manager_insert_action_group (manager, action_group, 0);
+}
diff --git a/addressbook/gui/component/e-book-shell-view-actions.h b/addressbook/gui/component/e-book-shell-view-actions.h
new file mode 100644
index 0000000000..cc54ca14c2
--- /dev/null
+++ b/addressbook/gui/component/e-book-shell-view-actions.h
@@ -0,0 +1,74 @@
+/* -*- Mode: C; indent-tabs-mode: t; c-basic-offset: 8; tab-width: 8 -*- */
+/* e-book-shell-view-actions.h
+ *
+ * Copyright (C) 1999-2008 Novell, Inc. (www.novell.com)
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of version 2 of the GNU General Public
+ * License as published by the Free Software Foundation.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public
+ * License along with this program; if not, write to the
+ * Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
+ * Boston, MA 02110-1301, USA.
+ */
+
+#ifndef E_BOOK_SHELL_VIEW_ACTIONS_H
+#define E_BOOK_SHELL_VIEW_ACTIONS_H
+
+#include <shell/e-shell-window-actions.h>
+
+/* Address Book Actions */
+#define E_SHELL_WINDOW_ACTION_ADDRESS_BOOK_COPY(window) \
+ E_SHELL_WINDOW_ACTION ((window), "address-book-copy")
+#define E_SHELL_WINDOW_ACTION_ADDRESS_BOOK_DELETE(window) \
+ E_SHELL_WINDOW_ACTION ((window), "address-book-delete")
+#define E_SHELL_WINDOW_ACTION_ADDRESS_BOOK_MOVE(window) \
+ E_SHELL_WINDOW_ACTION ((window), "address-book-move")
+#define E_SHELL_WINDOW_ACTION_ADDRESS_BOOK_PROPERTIES(window) \
+ E_SHELL_WINDOW_ACTION ((window), "address-book-properties")
+#define E_SHELL_WINDOW_ACTION_ADDRESS_BOOK_RENAME(window) \
+ E_SHELL_WINDOW_ACTION ((window), "address-book-rename")
+#define E_SHELL_WINDOW_ACTION_ADDRESS_BOOK_SAVE_AS(window) \
+ E_SHELL_WINDOW_ACTION ((window), "address-book-save-as")
+#define E_SHELL_WINDOW_ACTION_ADDRESS_BOOK_STOP(window) \
+ E_SHELL_WINDOW_ACTION ((window), "address-book-stop")
+
+/* Contact Actions */
+#define E_SHELL_WINDOW_ACTION_CONTACT_CLIPBOARD_COPY(window) \
+ E_SHELL_WINDOW_ACTION ((window), "contact-clipboard-copy")
+#define E_SHELL_WINDOW_ACTION_CONTACT_CLIPBOARD_CUT(window) \
+ E_SHELL_WINDOW_ACTION ((window), "contact-clipbard-cut")
+#define E_SHELL_WINDOW_ACTION_CONTACT_CLIPBOARD_PASTE(window) \
+ E_SHELL_WINDOW_ACTION ((window), "contact-clipboard-paste")
+#define E_SHELL_WINDOW_ACTION_CONTACT_COPY(window) \
+ E_SHELL_WINDOW_ACTION ((window), "contact-copy")
+#define E_SHELL_WINDOW_ACTION_CONTACT_DELETE(window) \
+ E_SHELL_WINDOW_ACTION ((window), "contact-delete")
+#define E_SHELL_WINDOW_ACTION_CONTACT_FORWARD(window) \
+ E_SHELL_WINDOW_ACTION ((window), "contact-forward")
+#define E_SHELL_WINDOW_ACTION_CONTACT_MOVE(window) \
+ E_SHELL_WINDOW_ACTION ((window), "contact-move")
+#define E_SHELL_WINDOW_ACTION_CONTACT_OPEN(window) \
+ E_SHELL_WINDOW_ACTION ((window), "contact-open")
+#define E_SHELL_WINDOW_ACTION_CONTACT_PRINT(window) \
+ E_SHELL_WINDOW_ACTION ((window), "contact-print")
+#define E_SHELL_WINDOW_ACTION_CONTACT_PRINT_PREVIEW(window) \
+ E_SHELL_WINDOW_ACTION ((window), "contact-print-preview")
+#define E_SHELL_WINDOW_ACTION_CONTACT_SAVE_AS(window) \
+ E_SHELL_WINDOW_ACTION ((window), "contact-save-as")
+#define E_SHELL_WINDOW_ACTION_CONTACT_SELECT_ALL(window) \
+ E_SHELL_WINDOW_ACTION ((window), "contact-select-all")
+#define E_SHELL_WINDOW_ACTION_CONTACT_SEND_MESSAGE(window) \
+ E_SHELL_WINDOW_ACTION ((window), "contact-send-message")
+
+/* Action Groups */
+#define E_SHELL_WINDOW_ACTION_GROUP_CONTACTS(window) \
+ E_SHELL_WINDOW_ACTION_GROUP ((window), "contacts")
+
+#endif /* E_BOOK_SHELL_VIEW_ACTIONS_H */
diff --git a/addressbook/gui/component/e-book-shell-view-private.c b/addressbook/gui/component/e-book-shell-view-private.c
new file mode 100644
index 0000000000..cfc12662f0
--- /dev/null
+++ b/addressbook/gui/component/e-book-shell-view-private.c
@@ -0,0 +1,89 @@
+/* -*- Mode: C; indent-tabs-mode: t; c-basic-offset: 8; tab-width: 8 -*- */
+/* e-book-shell-view-private.c
+ *
+ * Copyright (C) 1999-2008 Novell, Inc. (www.novell.com)
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of version 2 of the GNU General Public
+ * License as published by the Free Software Foundation.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public
+ * License along with this program; if not, write to the
+ * Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
+ * Boston, MA 02110-1301, USA.
+ */
+
+#include "e-book-shell-view-private.h"
+
+void
+e_book_shell_view_private_init (EBookShellView *book_shell_view)
+{
+ EBookShellViewPrivate *priv = book_shell_view->priv;
+ GHashTable *uid_to_view;
+ GHashTable *uid_to_editor;
+ GtkWidget *widget;
+
+ uid_to_view = g_hash_table_new_full (
+ g_str_hash, g_str_equal,
+ (GDestroyNotify) g_free,
+ (GDestroyNotify) g_object_unref);
+
+ uid_to_editor = g_hash_table_new_full (
+ g_str_hash, g_str_equal,
+ (GDestroyNotify) g_free,
+ (GDestroyNotify) g_free);
+
+ priv->contact_actions = gtk_action_group_new ("contacts");
+
+ e_book_shell_view_actions_init (book_shell_view);
+
+ widget = gtk_notebook_new ();
+ gtk_notebook_set_show_tabs (GTK_NOTEBOOK (widget), FALSE);
+ gtk_notebook_set_show_border (GTK_NOTEBOOK (widget), FALSE);
+ priv->notebook = g_object_ref_sink (widget);
+ gtk_widget_show (widget);
+
+ e_book_get_addressbooks (&priv->source_list, NULL);
+}
+
+void
+e_book_shell_view_private_dispose (EBookShellView *book_shell_view)
+{
+ EBookShellViewPrivate *priv = book_shell_view->priv;
+
+ DISPOSE (priv->notebook);
+ DISPOSE (priv->source_list);
+
+ g_hash_table_remove_all (priv->uid_to_view);
+ g_hash_table_remove_all (priv->uid_to_editor);
+}
+
+void
+e_book_shell_view_private_finalize (EBookShellView *book_shell_view)
+{
+ EBookShellViewPrivate *priv = book_shell_view->priv;
+
+ g_hash_table_destroy (priv->uid_to_view);
+ g_hash_table_destroy (priv->uid_to_editor);
+}
+
+EABView *
+e_book_shell_view_get_current_view (EBookShellView *book_shell_view)
+{
+ GtkNotebook *notebook;
+ GtkWidget *widget;
+ gint page_num;
+
+ g_return_val_if_fail (E_IS_BOOK_SHELL_VIEW (book_shell_view), NULL);
+
+ notebook = GTK_NOTEBOOK (book_shell_view->priv->notebook);
+ page_num = gtk_notebook_get_current_page (notebook);
+ widget = gtk_notebook_get_nth_page (notebook, page_num);
+
+ return EAB_VIEW (widget);
+}
diff --git a/addressbook/gui/component/e-book-shell-view-private.h b/addressbook/gui/component/e-book-shell-view-private.h
new file mode 100644
index 0000000000..025efd26fc
--- /dev/null
+++ b/addressbook/gui/component/e-book-shell-view-private.h
@@ -0,0 +1,100 @@
+/* -*- Mode: C; indent-tabs-mode: t; c-basic-offset: 8; tab-width: 8 -*- */
+/* e-book-shell-view-private.h
+ *
+ * Copyright (C) 1999-2008 Novell, Inc. (www.novell.com)
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of version 2 of the GNU General Public
+ * License as published by the Free Software Foundation.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public
+ * License along with this program; if not, write to the
+ * Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
+ * Boston, MA 02110-1301, USA.
+ */
+
+#ifndef E_BOOK_SHELL_VIEW_PRIVATE_H
+#define E_BOOK_SHELL_VIEW_PRIVATE_H
+
+#include "e-book-shell-view.h"
+
+#include <e-book-shell-view-actions.h>
+
+#define E_BOOK_SHELL_VIEW_GET_PRIVATE(obj) \
+ (G_TYPE_INSTANCE_GET_PRIVATE \
+ ((obj), E_TYPE_BOOK_SHELL_VIEW, EBookShellViewPrivate))
+
+/* Shorthand, requires a variable named "shell_window". */
+#define ACTION(name) \
+ (E_SHELL_WINDOW_ACTION_##name (shell_window))
+#define ACTION_GROUP(name) \
+ (E_SHELL_WINDOW_ACTION_GROUP_##name (shell_window))
+
+/* For use in dispose() methods. */
+#define DISPOSE(obj) \
+ G_STMT_START { \
+ if ((obj) != NULL) { g_object_unref (obj); (obj) = NULL; } \
+ } G_STMT_END
+
+G_BEGIN_DECLS
+
+typedef struct _EditorUidClosure EditorUidClosure;
+
+struct _EditorUidClosure {
+ GtkWidget *editor;
+ gchar *uid;
+ EBookShellView *view;
+};
+
+struct _EBookShellViewPrivate {
+
+ /*** UI Management ***/
+
+ GtkActionGroup *contact_actions;
+
+ /*** Other Stuff ***/
+
+ GtkWidget *notebook;
+ BonoboControl *folder_view_control;
+
+ GtkWidget *statusbar_widget;
+ EActivityHandler *activity_handler;
+
+ GtkWidget *info_widget;
+ GtkWidget *sidebar_widget;
+ GtkWidget *selector;
+
+ GHashTable *uid_to_view;
+ GHashTable *uid_to_editor;
+
+ EBook *book;
+ guint activity_id;
+ ESourceList *source_list;
+ gchar *password;
+ EUserCreatableItemsHandler *creatable_items_handler;
+
+ EABMenu *menu;
+};
+
+void e_book_shell_view_private_init
+ (EBookShellView *book_shell_view);
+void e_book_shell_view_private_dispose
+ (EBookShellView *book_shell_view);
+void e_book_shell_view_private_finalize
+ (EBookShellView *book_shell_view);
+
+/* Private Utilities */
+
+void e_book_shell_view_actions_init
+ (EBookShellView *book_shell_view);
+EABView * e_book_shell_view_get_current_view
+ (EBookShellView *book_shell_view);
+
+G_END_DECLS
+
+#endif /* E_BOOK_SHELL_VIEW_PRIVATE_H */
diff --git a/addressbook/gui/component/e-book-shell-view.c b/addressbook/gui/component/e-book-shell-view.c
new file mode 100644
index 0000000000..9a55cb0667
--- /dev/null
+++ b/addressbook/gui/component/e-book-shell-view.c
@@ -0,0 +1,279 @@
+/* -*- Mode: C; indent-tabs-mode: t; c-basic-offset: 8; tab-width: 8 -*- */
+/* e-book-shell-view.c
+ *
+ * Copyright (C) 1999-2008 Novell, Inc. (www.novell.com)
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of version 2 of the GNU General Public
+ * License as published by the Free Software Foundation.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public
+ * License along with this program; if not, write to the
+ * Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
+ * Boston, MA 02110-1301, USA.
+ */
+
+#include "e-book-shell-view-private.h"
+
+GType e_book_shell_view_type = 0;
+static gpointer parent_class;
+
+static void
+book_shell_view_update_actions (EBookShellView *book_shell_view,
+ EABView *view)
+{
+ EShellView *shell_view;
+ EShellWindow *shell_window;
+ ESource *source;
+ ESourceSelector *selector;
+ GtkAction *action;
+ gboolean sensitive;
+
+ if (e_book_shell_view_get_current_view (book_shell_view) != view)
+ return;
+
+ shell_view = E_SHELL_VIEW (book_shell_view);
+ shell_window = e_shell_view_get_window (shell_view);
+
+ selector = E_SOURCE_SELECTOR (book_shell_view->priv->selector);
+ source = e_source_selector_peek_primary_selection (selector);
+
+ action = ACTION (ADDRESS_BOOK_STOP);
+ sensitive = eab_view_can_stop (view);
+ gtk_action_set_sensitive (action, sensitive);
+
+ action = ACTION (CONTACT_CLIPBOARD_COPY);
+ sensitive = eab_view_can_copy (view);
+ gtk_action_set_sensitive (action, sensitive);
+
+ action = ACTION (CONTACT_CLIPBOARD_CUT);
+ sensitive = eab_view_can_cut (view);
+ gtk_action_set_sensitive (action, sensitive);
+
+ action = ACTION (CONTACT_CLIPBOARD_PASTE);
+ sensitive = eab_view_can_paste (view);
+ gtk_action_set_sensitive (action, sensitive);
+
+ action = ACTION (CONTACT_COPY);
+ sensitive = eab_view_can_copy_to_folder (view);
+ gtk_action_set_sensitive (action, sensitive);
+
+ action = ACTION (CONTACT_DELETE);
+ sensitive = eab_view_can_delete (view);
+ gtk_action_set_sensitive (action, sensitive);
+
+ action = ACTION (CONTACT_FORWARD);
+ sensitive = eab_view_can_send (view);
+ gtk_action_set_sensitive (action, sensitive);
+
+ action = ACTION (CONTACT_MOVE);
+ sensitive = eab_view_can_move_to_folder (view);
+ gtk_action_set_sensitive (action, sensitive);
+
+ action = ACTION (CONTACT_OPEN);
+ sensitive = eab_view_can_view (view);
+ gtk_action_set_sensitive (action, sensitive);
+
+ action = ACTION (CONTACT_PRINT);
+ sensitive = eab_view_can_print (view);
+ gtk_action_set_sensitive (action, sensitive);
+
+ action = ACTION (CONTACT_PRINT_PREVIEW);
+ sensitive = eab_view_can_print (view);
+ gtk_action_set_sensitive (action, sensitive);
+
+ action = ACTION (CONTACT_SAVE_AS);
+ sensitive = eab_view_can_save_as (view);
+ gtk_action_set_sensitive (action, sensitive);
+
+ action = ACTION (CONTACT_SELECT_ALL);
+ sensitive = eab_view_can_select_all (view);
+ gtk_action_set_sensitive (action, sensitive);
+
+ action = ACTION (CONTACT_SEND_MESSAGE);
+ sensitive = eab_view_can_send_to (view);
+ gtk_action_set_sensitive (action, sensitive);
+
+ action = ACTION (ADDRESS_BOOK_DELETE);
+ if (source != NULL) {
+ const gchar *uri;
+
+ uri = e_source_peek_relative_uri (source);
+ sensitive = (uri == NULL || strcmp ("system", uri) != 0);
+ } else
+ sensitive = FALSE;
+ gtk_action_set_sensitive (action, sensitive);
+}
+
+static void
+book_shell_view_editor_weak_notify (EditorUidClosure *closure,
+ GObject *where_the_object_was)
+{
+ GHashTable *hash_table;
+
+ hash_table = closure->view->priv->uid_to_editor;
+ g_hash_table_remove (hash_table, closure->uid);
+}
+
+static void
+book_shell_view_source_list_changed_cb (EBookShellView *book_shell_view,
+ ESourceList *source_list)
+{
+ EBookShellViewPrivate *priv = book_shell_view->priv;
+ GtkNotebook *notebook;
+ GList *keys, *iter;
+ EABView *view;
+
+ notebook = GTK_NOTEBOOK (priv->notebook);
+
+ keys = g_hash_table_get_keys (priv->uid_to_view);
+ for (iter = keys; iter != NULL; iter = iter->next) {
+ gchar *uid = iter->data;
+ GtkWidget *widget;
+ gint page_num;
+
+ /* If the source still exists, move on. */
+ if (e_source_list_peek_source_by_uid (source_list, uid))
+ continue;
+
+ /* Remove the view for the deleted source. */
+ widget = g_hash_table_lookup (priv->uid_to_view, uid);
+ page_num = gtk_notebook_page_num (notebook, widget);
+ gtk_notebook_remove_page (notebook, page_num);
+ g_hash_table_remove (priv->uid_to_view, uid);
+ }
+ g_list_free (keys);
+
+ keys = g_hash_table_get_keys (priv->uid_to_editor);
+ for (iter = keys; iter != NULL; iter = iter->next) {
+ gchar *uid = iter->data;
+ EditorUidClosure *closure;
+
+ /* If the source still exists, move on. */
+ if (e_source_list_peek_source_by_uid (source_list, uid))
+ continue;
+
+ /* Remove the editor for the deleted source. */
+ closure = g_hash_table_lookup (priv->uid_to_editor, uid);
+ g_object_weak_unref (
+ G_OBJECT (closure->editor), (GWeakNotify)
+ book_shell_view_editor_weak_notify, closure);
+ gtk_widget_destroy (closure->editor);
+ g_hash_table_remove (priv->uid_to_editor, uid);
+ }
+ g_list_free (keys);
+
+ /* Select and update the current view. */
+ view = e_book_shell_view_get_current_view (book_shell_view);
+ if (view != NULL) {
+#if 0
+ eab_view_setup_menus (view, bonobo_uic);
+ update_command_state (view, book_shell_view);
+#endif
+ }
+}
+
+static void
+book_shell_view_dispose (GObject *object)
+{
+ e_book_shell_view_private_dispose (E_BOOK_SHELL_VIEW (object));
+
+ /* Chain up to parent's dispose() method. */
+ G_OBJECT_CLASS (parent_class)->dispose (object);
+}
+
+static void
+book_shell_view_finalize (GObject *object)
+{
+ e_book_shell_view_private_finalize (E_BOOK_SHELL_VIEW (object));
+
+ /* Chain up to parent's finalize() method. */
+ G_OBJECT_CLASS (parent_class)->finalize (object);
+}
+
+static GtkWidget *
+book_shell_view_get_content_widget (EShellView *shell_view)
+{
+}
+
+static GtkWidget *
+book_shell_view_get_sidebar_widget (EShellView *shell_view)
+{
+}
+
+static GtkWidget *
+book_shell_view_get_status_widget (EShellView *shell_view)
+{
+}
+
+static void
+book_shell_view_class_init (EBookShellViewClass *class,
+ GTypeModule *type_module)
+{
+ GObjectClass *object_class;
+ EShellViewClass *shell_view_class;
+
+ parent_class = g_type_class_peek-parent (class);
+ g_type_class_add_private (class, sizeof (EBookShellViewPrivate));
+
+ object_class = G_OBJECT_CLASS (class);
+ object_class->dispose = book_shell_view_dispose;
+ object_class->finalize = book_shell_view_finalize;
+
+ shell_view_class = E_SHELL_VIEW_CLASS (class);
+ shell_view_class->label = N_("Contacts");
+ shell_view_class->icon_name = "x-office-address-book";
+ shell_view_class->type_module = type_module;
+
+ shell_view_class->get_content_widget =
+ book_shell_view_get_content_widget;
+ shell_view_class->get_sidebar_widget =
+ book_shell_view_get_sidebar_widget;
+ shell_view_class->get_status_widget =
+ book_shell_view_get_status_widget;
+}
+
+static void
+book_shell_view_init (EBookShellView *book_shell_view)
+{
+ book_shell_view->priv =
+ E_BOOK_SHELL_VIEW_GET_PRIVATE (book_shell_view);
+
+ e_book_shell_view_private_init (book_shell_view);
+
+ g_signal_connect_swapped (
+ priv->source_list, "changed",
+ G_CALLBACK (book_shell_view_source_list_changed_cb),
+ book_shell_view);
+}
+
+GType
+e_book_shell_view_get_type (GTypeModule *type_module)
+{
+ if (e_book_shell_view_type == 0) {
+ const GTypeInfo type_info = {
+ sizeof (EBookShellViewClass),
+ (GBaseInitFunc) NULL,
+ (GBaseFinalizeFunc) NULL,
+ (GClassInitFunc) book_shell_view_class_init,
+ (GClassFinalizeFunc) NULL,
+ type_module,
+ sizeof (EBookShellView),
+ 0, /* n_preallocs */
+ (GInstanceInitFunc) book_shell_view_init,
+ NULL /* value_table */
+ };
+
+ e_book_shell_view_type =
+ g_type_module_register_type (
+ type_module, E_TYPE_SHELL_VIEW,
+ "EBookShellView", &type_info, 0);
+ }
+
+ return e_book_shell_view_type;
+}
diff --git a/addressbook/gui/component/e-book-shell-view.h b/addressbook/gui/component/e-book-shell-view.h
new file mode 100644
index 0000000000..9071fc7ba4
--- /dev/null
+++ b/addressbook/gui/component/e-book-shell-view.h
@@ -0,0 +1,66 @@
+/* -*- Mode: C; indent-tabs-mode: t; c-basic-offset: 8; tab-width: 8 -*- */
+/* e-book-shell-view.h
+ *
+ * Copyright (C) 1999-2008 Novell, Inc. (www.novell.com)
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of version 2 of the GNU General Public
+ * License as published by the Free Software Foundation.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public
+ * License along with this program; if not, write to the
+ * Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
+ * Boston, MA 02110-1301, USA.
+ */
+
+#ifndef E_BOOK_SHELL_VIEW_H
+#define E_BOOK_SHELL_VIEW_H
+
+#include <e-shell-view.h>
+
+/* Standard GObject macros */
+#define E_TYPE_BOOK_SHELL_VIEW \
+ (e_book_shell_view_type)
+#define E_BOOK_SHELL_VIEW(obj) \
+ (G_TYPE_CHECK_INSTANCE_CAST \
+ ((obj), E_TYPE_BOOK_SHELL_VIEW, EBookShellView))
+#define E_BOOK_SHELL_VIEW_CLASS(cls) \
+ (G_TYPE_CHECK_CLASS_CAST \
+ ((cls), E_TYPE_BOOK_SHELL_VIEW, EBookShellViewClass))
+#define E_IS_BOOK_SHELL_VIEW(obj) \
+ (G_TYPE_CHECK_INSTANCE_TYPE \
+ ((obj), E_TYPE_BOOK_SHELL_VIEW))
+#define E_IS_BOOK_SHELL_VIEW_CLASS(cls) \
+ (G_TYPE_CHECK_CLASS_TYPE \
+ ((cls), E_TYPE_BOOK_SHELL_VIEW))
+#define E_BOOK_SHELL_VIEW_GET_CLASS(obj) \
+ (G_TYPE_INSTANCE_GET_CLASS \
+ ((obj), E_TYPE_BOOK_SHELL_VIEW, EBookShellViewClass))
+
+G_BEGIN_DECLS
+
+extern GType e_book_shell_view_type;
+
+typedef struct _EBookShellView EBookShellView;
+typedef struct _EBookShellViewClass EBookShellViewClass;
+typedef struct _EBookShellViewPrivate EBookShellViewPrivate;
+
+struct _EBookShellView {
+ EShellView parent;
+ EBookShellViewPrivate *priv;
+};
+
+struct _EBookShellViewClass {
+ EShellViewClass parent_class;
+};
+
+GType e_book_shell_view_get_type (GTypeModule *type_module);
+
+G_END_DECLS
+
+#endif /* E_BOOK_SHELL_VIEW_H */
diff --git a/addressbook/gui/contact-editor/e-contact-editor.c b/addressbook/gui/contact-editor/e-contact-editor.c
index a226cfe132..e629877eb0 100644
--- a/addressbook/gui/contact-editor/e-contact-editor.c
+++ b/addressbook/gui/contact-editor/e-contact-editor.c
@@ -48,7 +48,6 @@
#include "misc/e-dateedit.h"
#include "misc/e-image-chooser.h"
#include "misc/e-url-entry.h"
-#include "shell/evolution-shell-component-utils.h"
#include "e-util/e-icon-factory.h"
#include "e-util/e-util-private.h"
diff --git a/addressbook/gui/contact-list-editor/e-contact-list-editor.c b/addressbook/gui/contact-list-editor/e-contact-list-editor.c
index 7039bb5086..cac976ad70 100644
--- a/addressbook/gui/contact-list-editor/e-contact-list-editor.c
+++ b/addressbook/gui/contact-list-editor/e-contact-list-editor.c
@@ -32,8 +32,6 @@
#include <libedataserverui/e-source-combo-box.h>
-#include "shell/evolution-shell-component-utils.h"
-
#include "addressbook/gui/component/addressbook.h"
#include "addressbook/gui/widgets/eab-gui-util.h"
#include "addressbook/util/eab-book-util.h"
diff --git a/shell/Makefile.am b/shell/Makefile.am
index 55ff19f40a..0fc4fcab34 100644
--- a/shell/Makefile.am
+++ b/shell/Makefile.am
@@ -60,8 +60,7 @@ eshellinclude_HEADERS = \
e-shell-view.h \
e-shell-window.h \
e-shell-window-actions.h \
- es-event.h \
- es-menu.h
+ es-event.h
libeshell_la_SOURCES = \
$(IDL_GENERATED) \
@@ -98,7 +97,6 @@ evolution_SOURCES = \
e-sidebar.c \
e-sidebar.h \
es-event.c \
- es-menu.c \
main.c
evolution_LDADD = \
diff --git a/shell/e-shell-module.c b/shell/e-shell-module.c
index 6e44101cb3..ed8d2411f1 100644
--- a/shell/e-shell-module.c
+++ b/shell/e-shell-module.c
@@ -22,6 +22,7 @@
#include <gmodule.h>
#include <glib/gi18n.h>
+#include <e-util/e-util.h>
/* This is the symbol we look for when loading a module. */
#define INIT_SYMBOL "e_shell_module_init"
@@ -38,10 +39,12 @@ struct _EShellModulePrivate {
GModule *module;
gchar *filename;
+
EShell *shell;
+ gchar *data_dir;
- /* Initializes the loaded module. */
- void (*init) (GTypeModule *module);
+ /* Initializes the loaded type module. */
+ void (*init) (GTypeModule *type_module);
};
enum {
@@ -138,6 +141,7 @@ shell_module_finalize (GObject *object)
priv = E_SHELL_MODULE_GET_PRIVATE (object);
g_free (priv->filename);
+ g_free (priv->data_dir);
/* Chain up to parent's finalize() method. */
G_OBJECT_CLASS (parent_class)->finalize (object);
@@ -283,6 +287,15 @@ e_shell_module_compare (EShellModule *shell_module_a,
}
const gchar *
+e_shell_module_get_data_dir (EShellModule *shell_module)
+{
+ g_return_val_if_fail (E_IS_SHELL_MODULE (shell_module), NULL);
+ g_return_val_if_fail (shell_module->priv->data_dir != NULL, NULL);
+
+ return shell_module->priv->data_dir;
+}
+
+const gchar *
e_shell_module_get_filename (EShellModule *shell_module)
{
g_return_val_if_fail (E_IS_SHELL_MODULE (shell_module), NULL);
@@ -332,19 +345,19 @@ void
e_shell_module_set_info (EShellModule *shell_module,
const EShellModuleInfo *info)
{
- GTypeModule *module;
+ GTypeModule *type_module;
EShellModuleInfo *module_info;
g_return_if_fail (E_IS_SHELL_MODULE (shell_module));
g_return_if_fail (info != NULL);
- module = G_TYPE_MODULE (shell_module);
+ type_module = G_TYPE_MODULE (shell_module);
module_info = &shell_module->priv->info;
/* A module name is required. */
g_return_if_fail (info->name != NULL);
module_info->name = g_intern_string (info->name);
- g_type_module_set_name (module, module_info->name);
+ g_type_module_set_name (type_module, module_info->name);
module_info->aliases = g_intern_string (info->aliases);
module_info->schemes = g_intern_string (info->schemes);
@@ -352,4 +365,8 @@ e_shell_module_set_info (EShellModule *shell_module,
module_info->is_busy = info->is_busy;
module_info->shutdown = info->shutdown;
+
+ g_free (shell_module->priv->data_dir);
+ shell_module->priv->data_dir = g_build_filename (
+ e_get_user_data_dir (), module_info->name, NULL);
}
diff --git a/shell/e-shell-module.h b/shell/e-shell-module.h
index f92c849af7..d643d94527 100644
--- a/shell/e-shell-module.h
+++ b/shell/e-shell-module.h
@@ -21,8 +21,7 @@
#ifndef E_SHELL_MODULE_H
#define E_SHELL_MODULE_H
-#include "e-shell-common.h"
-#include "e-shell.h"
+#include <e-shell.h>
/* Standard GObject macros */
#define E_TYPE_SHELL_MODULE \
@@ -74,6 +73,7 @@ EShellModule * e_shell_module_new (EShell *shell,
const gchar *filename);
gint e_shell_module_compare (EShellModule *shell_module_a,
EShellModule *shell_module_b);
+const gchar * e_shell_module_get_data_dir (EShellModule *shell_module);
const gchar * e_shell_module_get_filename (EShellModule *shell_module);
EShell * e_shell_module_get_shell (EShellModule *shell_module);
gboolean e_shell_module_is_busy (EShellModule *shell_module);
diff --git a/shell/e-shell-view.c b/shell/e-shell-view.c
index 52f6479b18..5da8af55ff 100644
--- a/shell/e-shell-view.c
+++ b/shell/e-shell-view.c
@@ -20,6 +20,7 @@
#include "e-shell-view.h"
+#include <string.h>
#include <glib/gi18n.h>
#include "e-shell-window.h"
@@ -211,10 +212,10 @@ e_shell_view_get_name (EShellView *shell_view)
* module that registered the shell view subclass. */
class = E_SHELL_VIEW_GET_CLASS (shell_view);
- g_return_val_if_fail (class->module != NULL, NULL);
- g_return_val_if_fail (class->module->name != NULL, NULL);
+ g_return_val_if_fail (class->type_module != NULL, NULL);
+ g_return_val_if_fail (class->type_module->name != NULL, NULL);
- return class->module->name;
+ return class->type_module->name;
}
const gchar *
@@ -237,12 +238,31 @@ e_shell_view_set_title (EShellView *shell_view,
g_object_notify (G_OBJECT (shell_view), "title");
}
-GtkWidget *
+EShellWindow *
e_shell_view_get_window (EShellView *shell_view)
{
g_return_val_if_fail (E_IS_SHELL_VIEW (shell_view), NULL);
- return shell_view->priv->window;
+ return E_SHELL_WINDOW (shell_view->priv->window);
+}
+
+gboolean
+e_shell_view_is_selected (EShellView *shell_view)
+{
+ EShellViewClass *class;
+ EShellWindow *shell_window;
+ const gchar *curr_view_name;
+ const gchar *this_view_name;
+
+ g_return_val_if_fail (E_IS_SHELL_VIEW (shell_view), FALSE);
+
+ class = E_SHELL_VIEW_GET_CLASS (shell_view);
+ shell_window = e_shell_view_get_window (shell_view);
+ this_view_name = e_shell_view_get_name (shell_view);
+ curr_view_name = e_shell_window_get_current_view (shell_window);
+ g_return_val_if_fail (curr_view_name != NULL, FALSE);
+
+ return (strcmp (curr_view_name, this_view_name) == 0);
}
GtkWidget *
diff --git a/shell/e-shell-view.h b/shell/e-shell-view.h
index 433c02f01a..ed123773fe 100644
--- a/shell/e-shell-view.h
+++ b/shell/e-shell-view.h
@@ -21,7 +21,8 @@
#ifndef E_SHELL_VIEW_H
#define E_SHELL_VIEW_H
-#include "e-shell-common.h"
+#include <e-shell-common.h>
+#include <e-shell-window.h>
/* Standard GObject macros */
#define E_TYPE_SHELL_VIEW \
@@ -62,7 +63,7 @@ struct _EShellViewClass {
/* Subclasses should set this via the "class_data" field in
* the GTypeInfo they pass to g_type_module_register_type(). */
- GTypeModule *module;
+ GTypeModule *type_module;
GtkWidget * (*get_content_widget) (EShellView *shell_view);
GtkWidget * (*get_sidebar_widget) (EShellView *shell_view);
@@ -74,7 +75,8 @@ const gchar * e_shell_view_get_name (EShellView *shell_view);
const gchar * e_shell_view_get_title (EShellView *shell_view);
void e_shell_view_set_title (EShellView *shell_view,
const gchar *title);
-GtkWidget * e_shell_view_get_window (EShellView *shell_view);
+EShellWindow * e_shell_view_get_window (EShellView *shell_view);
+gboolean e_shell_view_is_selected (EShellView *shell_view);
GtkWidget * e_shell_view_get_content_widget (EShellView *shell_view);
GtkWidget * e_shell_view_get_sidebar_widget (EShellView *shell_view);
GtkWidget * e_shell_view_get_status_widget (EShellView *shell_view);
diff --git a/shell/e-shell-window-actions.c b/shell/e-shell-window-actions.c
index 24588b4931..61f95576cd 100644
--- a/shell/e-shell-window-actions.c
+++ b/shell/e-shell-window-actions.c
@@ -22,9 +22,6 @@
#include <string.h>
-#include <e-shell.h>
-#include <e-shell-importer.h>
-
#include <e-util/e-dialog-utils.h>
#include <e-util/e-error.h>
#include <e-util/e-print.h>
@@ -32,6 +29,8 @@
#include <libedataserverui/e-passwords.h>
+#include "e-shell-importer.h"
+
#define EVOLUTION_COPYRIGHT \
"Copyright \xC2\xA9 1999 - 2008 Novell, Inc. and Others"
@@ -1286,6 +1285,8 @@ e_shell_window_actions_init (EShellWindow *shell_window)
manager = e_shell_window_get_ui_manager (shell_window);
domain = GETTEXT_PACKAGE;
+ e_load_ui_definition (manager, "evolution-shell.ui");
+
/* Shell Actions */
action_group = shell_window->priv->shell_actions;
gtk_action_group_set_translation_domain (action_group, domain);
@@ -1426,14 +1427,14 @@ e_shell_window_create_shell_view_actions (EShellWindow *shell_window)
continue;
}
- if (class->module == NULL) {
+ if (class->type_module == NULL) {
g_critical (
"Module member not set on %s",
G_OBJECT_CLASS_NAME (class));
continue;
}
- view_name = class->module->name;
+ view_name = class->type_module->name;
action_name = g_strdup_printf ("shell-view-%s", view_name);
tooltip = g_strdup_printf (_("Switch to %s"), class->label);
diff --git a/shell/e-shell-window-private.c b/shell/e-shell-window-private.c
index 5b4c1e40ba..1365238b60 100644
--- a/shell/e-shell-window-private.c
+++ b/shell/e-shell-window-private.c
@@ -29,6 +29,7 @@ shell_window_notify_current_view_cb (EShellWindow *shell_window)
{
GtkWidget *menu;
GtkWidget *widget;
+ EShellView *shell_view;
const gchar *path;
/* Update the "File -> New" submenu. */
@@ -205,8 +206,8 @@ e_shell_window_private_init (EShellWindow *shell_window)
gint height;
loaded_views = g_hash_table_new_full (
- g_direct_hash, g_direct_equal,
- (GDestroyNotify) NULL,
+ g_str_hash, g_str_equal,
+ (GDestroyNotify) g_free,
(GDestroyNotify) g_object_unref);
priv->manager = gtk_ui_manager_new ();
@@ -216,8 +217,6 @@ e_shell_window_private_init (EShellWindow *shell_window)
priv->shell_view_actions = gtk_action_group_new ("shell-view");
priv->loaded_views = loaded_views;
- e_load_ui_definition (priv->manager, "evolution-shell.ui");
-
e_shell_window_actions_init (shell_window);
gtk_window_add_accel_group (
diff --git a/shell/e-shell-window.c b/shell/e-shell-window.c
index c29f7d10e8..ed1e731922 100644
--- a/shell/e-shell-window.c
+++ b/shell/e-shell-window.c
@@ -26,7 +26,6 @@
#include <e-sidebar.h>
#include <es-event.h>
-#include <es-menu.h>
#include <e-util/e-plugin-ui.h>
#include <e-util/e-util-private.h>
@@ -254,6 +253,57 @@ e_shell_window_new (EShell *shell,
"shell", shell, "safe-mode", safe_mode, NULL);
}
+gpointer
+e_shell_window_get_view (EShellWindow *shell_window,
+ const gchar *view_name)
+{
+ GHashTable *loaded_views;
+ EShellView *shell_view;
+ GType *children;
+ guint n_children, ii;
+
+ g_return_val_if_fail (E_IS_SHELL_WINDOW (shell_window), NULL);
+ g_return_val_if_fail (view_name != NULL, NULL);
+
+ loaded_views = shell_window->priv->loaded_views;
+ shell_view = g_hash_table_lookup (loaded_views, view_name);
+
+ if (shell_view != NULL)
+ return shell_view;
+
+ children = g_type_children (E_TYPE_SHELL_VIEW, &n_children);
+
+ for (ii = 0; ii < n_children && shell_view == NULL; ii++) {
+ GType shell_view_type = children[ii];
+ EShellViewClass *class;
+
+ class = g_type_class_ref (shell_view_type);
+
+ if (class->type_module == NULL) {
+ g_critical (
+ "Module member not set on %s",
+ G_OBJECT_CLASS_NAME (class));
+ continue;
+ }
+
+ if (strcmp (view_name, class->type_module->name) == 0) {
+ shell_view = g_object_new (
+ shell_view_type, "title", class->label,
+ "window", shell_window, NULL);
+ g_hash_table_insert (
+ loaded_views,
+ g_strdup (view_name), shell_view);
+ }
+
+ g_type_class_unref (class);
+ }
+
+ if (shell_view == NULL)
+ g_critical ("Unknown shell view name: %s", view_name);
+
+ return shell_view;
+}
+
EShell *
e_shell_window_get_shell (EShellWindow *shell_window)
{
diff --git a/shell/e-shell-window.h b/shell/e-shell-window.h
index 0ec9b15e5f..1780675bb9 100644
--- a/shell/e-shell-window.h
+++ b/shell/e-shell-window.h
@@ -21,8 +21,7 @@
#ifndef E_SHELL_WINDOW_H
#define E_SHELL_WINDOW_H
-#include "e-shell-common.h"
-#include "e-shell.h"
+#include <e-shell.h>
/* Standard GObject macros */
#define E_TYPE_SHELL_WINDOW \
@@ -61,6 +60,8 @@ struct _EShellWindowClass {
GType e_shell_window_get_type (void);
GtkWidget * e_shell_window_new (EShell *shell,
gboolean safe_mode);
+gpointer e_shell_window_get_view (EShellWindow *shell_window,
+ const gchar *view_name);
EShell * e_shell_window_get_shell (EShellWindow *shell_window);
GtkUIManager * e_shell_window_get_ui_manager (EShellWindow *shell_window);
GtkAction * e_shell_window_get_action (EShellWindow *shell_window,
diff --git a/shell/e-shell.h b/shell/e-shell.h
index a0f037ea98..2a8f3251bd 100644
--- a/shell/e-shell.h
+++ b/shell/e-shell.h
@@ -21,7 +21,7 @@
#ifndef E_SHELL_H
#define E_SHELL_H
-#include "e-shell-common.h"
+#include <e-shell-common.h>
/* Standard GObject macros */
#define E_TYPE_SHELL \
diff --git a/shell/e-user-creatable-items-handler.c b/shell/e-user-creatable-items-handler.c
deleted file mode 100644
index 24ba4acd39..0000000000
--- a/shell/e-user-creatable-items-handler.c
+++ /dev/null
@@ -1,912 +0,0 @@
-/* -*- Mode: C; indent-tabs-mode: t; c-basic-offset: 8; tab-width: 8 -*- */
-/* e-user-creatable-items-handler.c
- *
- * Copyright (C) 1999-2008 Novell, Inc. (www.novell.com)
- *
- * This program is free software; you can redistribute it and/or
- * modify it under the terms of version 2 of the GNU General Public
- * License as published by the Free Software Foundation.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * General Public License for more details.
- *
- * You should have received a copy of the GNU General Public
- * License along with this program; if not, write to the
- * Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
- * Boston, MA 02110-1301, USA.
- *
- * Author: Ettore Perazzoli <ettore@ximian.com>
- */
-
-#ifdef HAVE_CONFIG_H
-#include <config.h>
-#endif
-
-#include "e-user-creatable-items-handler.h"
-#include <e-util/e-icon-factory.h>
-#include "Evolution.h"
-
-#include "e-util/e-corba-utils.h"
-#include "misc/e-combo-button.h"
-
-#include <bonobo/bonobo-ui-util.h>
-#include <bonobo/bonobo-exception.h>
-#include <bonobo/bonobo-control.h>
-
-#include <gtk/gtk.h>
-#include <glib/gi18n.h>
-
-#include <stdlib.h>
-#include <ctype.h>
-#include <string.h>
-
-#include <gconf/gconf-client.h>
-#include <libgnome/gnome-gconf.h>
-
-struct _Component {
- char *id, *alias;
- GNOME_Evolution_Component component;
- GNOME_Evolution_CreatableItemTypeList *type_list;
-};
-typedef struct _Component Component;
-
-/* Representation of a single menu item. */
-struct _MenuItem {
- const char *label;
- char shortcut;
- char *verb;
- char *tooltip;
- char *component;
- GdkPixbuf *icon;
- GdkPixbuf *icon_toolbar;
-};
-typedef struct _MenuItem MenuItem;
-
-struct _EUserCreatableItemsHandlerPrivate {
- /* This component's alias */
- char *this_component;
-
- /* For creating items on the view */
- EUserCreatableItemsHandlerCreate create_local;
- void *create_data;
-
- /* The components that register user creatable items. */
- GSList *components; /* Component */
-
- /* The "New ..." menu items. */
- GSList *objects; /* MenuItem */
- GSList *folders; /* MenuItem */
-
- /* The default item (the mailer's "message" item). To be used when the
- component in the view we are in doesn't provide a default user
- creatable type. This pointer always points to one of the menu items
- in ->objects. */
- const MenuItem *fallback_menu_item;
- const MenuItem *default_menu_item;
-
- char *menu_xml;
- GtkWidget *new_button, *new_menu;
- BonoboControl *new_control;
- GtkAccelGroup *accel_group;
-};
-
-enum {
- PROP_THIS_COMPONENT = 1,
- LAST_PROP
-};
-
-G_DEFINE_TYPE (EUserCreatableItemsHandler, e_user_creatable_items_handler, G_TYPE_OBJECT)
-
-/* Component struct handling. */
-
-static Component *
-component_new (const char *id,
- const char *component_alias,
- GNOME_Evolution_Component component)
-{
- CORBA_Environment ev;
- Component *new;
-
- CORBA_exception_init (&ev);
-
- new = g_new (Component, 1);
- new->id = g_strdup (id);
- new->alias = g_strdup (component_alias);
-
- new->type_list = GNOME_Evolution_Component__get_userCreatableItems (component, &ev);
- if (BONOBO_EX (&ev))
- new->type_list = NULL;
-
- new->component = component;
- Bonobo_Unknown_ref (new->component, &ev);
-
- if (ev._major != CORBA_NO_EXCEPTION)
- new->type_list = NULL;
-
- CORBA_exception_free (&ev);
-
- return new;
-}
-
-static void
-component_free (Component *component)
-{
- CORBA_Environment ev;
-
- CORBA_exception_init (&ev);
-
- Bonobo_Unknown_unref (component->component, &ev);
-
- g_free (component->id);
- g_free (component->alias);
-
- if (component->type_list != NULL)
- CORBA_free (component->type_list);
-
- CORBA_exception_free (&ev);
-
- g_free (component);
-}
-
-static const char *component_query =
- "repo_ids.has ('IDL:GNOME/Evolution/Component:" BASE_VERSION "')";
-
-static void
-get_components_from_bonobo (EUserCreatableItemsHandler *handler)
-{
- Bonobo_ServerInfoList *info_list;
- Bonobo_ActivationProperty *property;
- CORBA_Environment ev;
- char *iid, *alias;
- GNOME_Evolution_Component corba_component;
- Component *component;
- int i;
-
- CORBA_exception_init (&ev);
- info_list = bonobo_activation_query (component_query, NULL, &ev);
- if (BONOBO_EX (&ev)) {
- char *ex_text = bonobo_exception_get_text (&ev);
- g_warning ("Cannot query for components: %s\n", ex_text);
- g_free (ex_text);
- CORBA_exception_free (&ev);
- return;
- }
-
- for (i = 0; i < info_list->_length; i++) {
- iid = info_list->_buffer[i].iid;
- corba_component = bonobo_activation_activate_from_id (iid, Bonobo_ACTIVATION_FLAG_EXISTING_ONLY, NULL, &ev);
- if (BONOBO_EX (&ev)) {
- CORBA_exception_free (&ev);
- continue;
- }
-
- property = bonobo_server_info_prop_find (&info_list->_buffer[i],
- "evolution:component_alias");
- alias = property ? property->v._u.value_string : "unknown";
-
- component = component_new (iid, alias, corba_component);
- handler->priv->components = g_slist_prepend (handler->priv->components, component);
- }
-
- CORBA_free (info_list);
-}
-
-
-/* Helper functions. */
-
-static gboolean
-item_is_default (const MenuItem *item,
- const char *component)
-{
- if (component == NULL)
- return FALSE;
-
- if (strcmp (item->component, component) == 0)
- return TRUE;
- else
- return FALSE;
-}
-
-static char *
-create_verb (EUserCreatableItemsHandler *handler, int component_num, const char *comp, const char *type_id)
-{
- return g_strdup_printf ("EUserCreatableItemsHandler-%s:%d:%s", comp, component_num, type_id);
-}
-
-/* Setting up menu items for the "File -> New" submenu and the "New" toolbar
- button. */
-
-static void
-ensure_menu_items (EUserCreatableItemsHandler *handler)
-{
- EUserCreatableItemsHandlerPrivate *priv;
- GSList *objects, *folders;
- GSList *p;
- int component_num;
- const char *default_verb;
-
- priv = handler->priv;
- if (priv->objects != NULL)
- return;
-
- objects = folders = NULL;
- component_num = 0;
- default_verb = NULL;
- for (p = priv->components; p != NULL; p = p->next) {
- const Component *component;
- int i;
-
- component = (const Component *) p->data;
- if (component->type_list != NULL) {
- for (i = 0; i < component->type_list->_length; i ++) {
- const GNOME_Evolution_CreatableItemType *corba_item;
- MenuItem *item;
-
- corba_item = (const GNOME_Evolution_CreatableItemType *) component->type_list->_buffer + i;
-
- item = g_new (MenuItem, 1);
- item->label = corba_item->menuDescription;
- item->shortcut = corba_item->menuShortcut;
- item->verb = create_verb (handler, component_num, component->alias, corba_item->id);
- item->tooltip = corba_item->tooltip;
- item->component = g_strdup (component->alias);
-
- if (strcmp (item->component, "mail") == 0
- && strcmp (corba_item->id, "message") == 0)
- default_verb = item->verb;
-
- if (corba_item->iconName == NULL || *corba_item->iconName == '\0') {
- item->icon = NULL;
- item->icon_toolbar = NULL;
- } else {
- item->icon = e_icon_factory_get_icon (corba_item->iconName, E_ICON_SIZE_MENU);
- if (item_is_default (item, component->alias))
- item->icon_toolbar = e_icon_factory_get_icon (corba_item->iconName, E_ICON_SIZE_LARGE_TOOLBAR);
- else
- item->icon_toolbar = NULL;
- }
-
- if (corba_item->type == GNOME_Evolution_CREATABLE_OBJECT)
- objects = g_slist_prepend (objects, item);
- else
- folders = g_slist_prepend (folders, item);
- }
- }
-
- component_num ++;
- }
-
- priv->objects = g_slist_reverse (objects);
- priv->folders = g_slist_reverse (folders);
-
- priv->fallback_menu_item = NULL;
- if (default_verb != NULL) {
- for (p = priv->objects; p != NULL; p = p->next) {
- const MenuItem *item;
-
- item = (const MenuItem *) p->data;
- if (strcmp (item->verb, default_verb) == 0)
- priv->fallback_menu_item = item;
- }
- }
-}
-
-static void
-free_menu_items (GSList *menu_items)
-{
- GSList *p;
-
- if (menu_items == NULL)
- return;
-
- for (p = menu_items; p != NULL; p = p->next) {
- MenuItem *item;
-
- item = (MenuItem *) p->data;
- g_free (item->verb);
-
- if (item->icon != NULL)
- g_object_unref (item->icon);
-
- if (item->icon_toolbar != NULL)
- g_object_unref (item->icon_toolbar);
-
- g_free (item->component);
- g_free (item);
- }
-
- g_slist_free (menu_items);
-}
-
-static const MenuItem *
-get_default_action_for_view (EUserCreatableItemsHandler *handler)
-{
- EUserCreatableItemsHandlerPrivate *priv;
- const GSList *p;
-
- priv = handler->priv;
-
- for (p = priv->objects; p != NULL; p = p->next) {
- const MenuItem *item;
-
- item = (const MenuItem *) p->data;
- if (item_is_default (item, priv->this_component))
- return item;
- }
-
- return priv->fallback_menu_item;
-}
-
-
-/* Verb handling. */
-
-static void
-execute_verb (EUserCreatableItemsHandler *handler,
- const char *verb_name)
-{
- EUserCreatableItemsHandlerPrivate *priv;
- const Component *component;
- int component_number;
- const char *p;
- const char *id;
- GSList *component_list_item;
- int i;
-
- priv = handler->priv;
-
- p = strchr (verb_name, ':');
- g_return_if_fail (p != NULL);
- component_number = atoi (p + 1);
-
- p = strchr (p + 1, ':');
- g_return_if_fail (p != NULL);
- id = p + 1;
-
- component_list_item = g_slist_nth (priv->components, component_number);
- g_return_if_fail (component_list_item != NULL);
-
- component = (const Component *) component_list_item->data;
-
- if (component->type_list == NULL)
- return;
-
- /* TODO: why do we actually iterate this? Is it just to check we have it in the menu? The
- search isn't used otherwise */
- for (i = 0; i < component->type_list->_length; i ++) {
- if (strcmp (component->type_list->_buffer[i].id, id) == 0) {
- if (priv->create_local && priv->this_component && strcmp(priv->this_component, component->alias) == 0) {
- priv->create_local(handler, id, priv->create_data);
- } else {
- CORBA_Environment ev;
-
- CORBA_exception_init (&ev);
-
- GNOME_Evolution_Component_requestCreateItem (component->component, id, &ev);
-
- if (ev._major != CORBA_NO_EXCEPTION)
- g_warning ("Error in requestCreateItem -- %s", BONOBO_EX_REPOID (&ev));
-
- CORBA_exception_free (&ev);
- }
- return;
- }
- }
-}
-
-static void
-verb_fn (BonoboUIComponent *ui_component,
- void *data,
- const char *verb_name)
-{
- EUserCreatableItemsHandler *handler=
- E_USER_CREATABLE_ITEMS_HANDLER (data);
-
- execute_verb (handler, verb_name);
-}
-
-static void
-add_verbs (EUserCreatableItemsHandler *handler,
- BonoboUIComponent *ui_component)
-{
- EUserCreatableItemsHandlerPrivate *priv;
- int component_num;
- GSList *p;
-
- priv = handler->priv;
-
- component_num = 0;
- for (p = priv->components; p != NULL; p = p->next) {
- const Component *component;
- int i;
-
- component = (const Component *) p->data;
-
- if (component->type_list != NULL) {
- for (i = 0; i < component->type_list->_length; i ++) {
- char *verb_name;
-
- verb_name = create_verb (handler,
- component_num,
- component->alias,
- component->type_list->_buffer[i].id);
-
- bonobo_ui_component_add_verb (ui_component, verb_name, verb_fn, handler);
-
- g_free (verb_name);
- }
- }
-
- component_num ++;
- }
-}
-
-
-/* Generic menu construction code */
-
-static int
-item_types_sort_func (const void *a,
- const void *b)
-{
- const MenuItem *item_a;
- const MenuItem *item_b;
- const char *p1, *p2;
-
- item_a = (const MenuItem *) a;
- item_b = (const MenuItem *) b;
-
- p1 = item_a->label;
- p2 = item_b->label;
-
- while (*p1 != '\0' && *p2 != '\0') {
- if (*p1 == '_') {
- p1 ++;
- continue;
- }
-
- if (*p2 == '_') {
- p2 ++;
- continue;
- }
-
- if (toupper ((int) *p1) < toupper ((int) *p2))
- return -1;
- else if (toupper ((int) *p1) > toupper ((int) *p2))
- return +1;
-
- p1 ++, p2 ++;
- }
-
- if (*p1 == '\0') {
- if (*p2 == '\0')
- return 0;
- else
- return -1;
- } else {
- return +1;
- }
-}
-
-typedef void (*EUserCreatableItemsHandlerMenuItemFunc) (EUserCreatableItemsHandler *, gpointer, MenuItem *, gboolean);
-typedef void (*EUserCreatableItemsHandlerSeparatorFunc) (EUserCreatableItemsHandler *, gpointer, int);
-
-static void
-construct_menu (EUserCreatableItemsHandler *handler, gpointer menu,
- EUserCreatableItemsHandlerMenuItemFunc menu_item_func,
- EUserCreatableItemsHandlerSeparatorFunc separator_func)
-{
- EUserCreatableItemsHandlerPrivate *priv;
- MenuItem *item;
- GSList *p, *items;
- gboolean first = TRUE;
-
- priv = handler->priv;
-
- /* First add the current component's creatable objects */
- for (p = priv->objects; p != NULL; p = p->next) {
- item = p->data;
- if (item_is_default (item, priv->this_component)) {
- menu_item_func (handler, menu, item, first);
- first = FALSE;
- }
- }
-
- /* Then its creatable folders */
- for (p = priv->folders; p != NULL; p = p->next) {
- item = p->data;
- if (item_is_default (item, priv->this_component))
- menu_item_func (handler, menu, item, FALSE);
- }
-
- /* Then a separator */
- separator_func (handler, menu, 1);
-
- /* Then the objects from other components. */
- items = NULL;
- for (p = priv->objects; p != NULL; p = p->next) {
- item = p->data;
- if (! item_is_default (item, priv->this_component))
- items = g_slist_prepend (items, item);
- }
-
- items = g_slist_sort (items, item_types_sort_func);
- for (p = items; p != NULL; p = p->next)
- menu_item_func (handler, menu, p->data, FALSE);
- g_slist_free (items);
-
- /* Another separator */
- separator_func (handler, menu, 2);
-
- /* And finally the folders from other components */
- items = NULL;
- for (p = priv->folders; p != NULL; p = p->next) {
- item = p->data;
- if (! item_is_default (item, priv->this_component))
- items = g_slist_prepend (items, item);
- }
-
- items = g_slist_sort (items, item_types_sort_func);
- for (p = items; p != NULL; p = p->next)
- menu_item_func (handler, menu, p->data, FALSE);
- g_slist_free (items);
-}
-
-/* The XML description for "File -> New". */
-
-static void
-xml_menu_item_func (EUserCreatableItemsHandler *handler, gpointer menu,
- MenuItem *item, gboolean first)
-{
- GString *xml = menu;
- char *encoded_label;
- char *encoded_tooltip;
-
- encoded_label = bonobo_ui_util_encode_str (item->label);
- g_string_append_printf (xml, "<menuitem name=\"New:%s\" verb=\"%s\" label=\"%s\"",
- item->verb, item->verb, encoded_label);
-
- if (first)
- g_string_append_printf (xml, " accel=\"*Control*N\"");
- else if (item->shortcut != '\0')
- g_string_append_printf (xml, " accel=\"*Control**Shift*%c\"", item->shortcut);
-
- if (item->icon != NULL) {
- char *icon_xml;
-
- icon_xml = bonobo_ui_util_pixbuf_to_xml (item->icon);
- g_string_append_printf (xml, " pixtype=\"pixbuf\" pixname=\"%s\"", icon_xml);
- g_free (icon_xml);
- }
-
- encoded_tooltip = bonobo_ui_util_encode_str (item->tooltip);
- g_string_append_printf (xml, " tip=\"%s\"", encoded_tooltip);
-
- g_string_append (xml, "/> ");
-
- g_free (encoded_label);
- g_free (encoded_tooltip);
-}
-
-static void
-xml_separator_func (EUserCreatableItemsHandler *handler, gpointer menu, int nth)
-{
- GString *xml = menu;
-
- g_string_append_printf (xml, "<separator f=\"\" name=\"EUserCreatableItemsHandlerSeparator%d\"/>", nth);
-}
-
-static void
-create_menu_xml (EUserCreatableItemsHandler *handler)
-{
- GString *xml;
-
- xml = g_string_new ("<placeholder name=\"NewMenu\">");
- construct_menu (handler, xml, xml_menu_item_func, xml_separator_func);
- g_string_append (xml, "</placeholder>");
-
- handler->priv->menu_xml = xml->str;
- g_string_free (xml, FALSE);
-}
-
-
-/* The GtkMenu for the toolbar button. */
-
-static void
-menuitem_activate (GtkMenuItem *item, gpointer data)
-{
- EUserCreatableItemsHandler *handler = data;
- const char *verb;
-
- verb = g_object_get_data (G_OBJECT (item), "EUserCreatableItemsHandler:verb");
- execute_verb (handler, verb);
-}
-
-static void
-default_activate (EComboButton *combo_button, gpointer data)
-{
- EUserCreatableItemsHandler *handler = data;
-
- execute_verb (handler, handler->priv->default_menu_item->verb);
-}
-
-static void
-gtk_menu_item_func (EUserCreatableItemsHandler *handler, gpointer menu,
- MenuItem *item, gboolean first)
-{
- GtkWidget *menuitem, *icon;
-
- menuitem = gtk_image_menu_item_new_with_mnemonic (item->label);
-
- if (item->icon) {
- icon = gtk_image_new_from_pixbuf (item->icon);
- gtk_image_menu_item_set_image (GTK_IMAGE_MENU_ITEM (menuitem),
- icon);
- }
-
- if (first) {
- gtk_widget_add_accelerator (menuitem, "activate",
- handler->priv->accel_group,
- 'n', GDK_CONTROL_MASK,
- GTK_ACCEL_VISIBLE);
- } else if (item->shortcut != '\0') {
- gtk_widget_add_accelerator (menuitem, "activate",
- handler->priv->accel_group,
- item->shortcut,
- GDK_CONTROL_MASK | GDK_SHIFT_MASK,
- GTK_ACCEL_VISIBLE);
- }
-
- g_object_set_data (G_OBJECT (menuitem), "EUserCreatableItemsHandler:verb", item->verb);
- g_signal_connect (menuitem, "activate",
- G_CALLBACK (menuitem_activate), handler);
-
- gtk_menu_shell_append (menu, menuitem);
-}
-
-static void
-gtk_separator_func (EUserCreatableItemsHandler *handler, gpointer menu, int nth)
-{
- gtk_menu_shell_append (menu, gtk_separator_menu_item_new ());
-}
-
-static void
-set_combo_button_style (EComboButton *button, const gchar *style, GdkPixbuf *icon)
-{
- if(!g_ascii_strcasecmp (style,"both-horiz")){
- e_combo_button_pack_hbox (button);
- e_combo_button_set_label (button, _("New"));
- e_combo_button_set_icon (button, icon);
- }
- else if(!g_ascii_strcasecmp (style,"icons")){
- e_combo_button_pack_hbox (button);
- e_combo_button_set_icon (button, icon);
- e_combo_button_set_label (button, "");
- }
- else if(!g_ascii_strcasecmp(style,"text")){
- e_combo_button_pack_hbox (button);
- e_combo_button_set_label (button, _("New"));
- e_combo_button_set_icon (button, NULL);
- } else { /* Default to both */
- e_combo_button_pack_vbox (button);
- e_combo_button_set_icon (button, icon);
- e_combo_button_set_label (button, _("New"));
- }
-}
-
-static void
-new_button_change (GConfClient *gconf,
- unsigned int connection_id,
- GConfEntry *entry,
- EUserCreatableItemsHandler *handler)
-{
- EUserCreatableItemsHandlerPrivate *priv;
- char *val;
-
- priv = handler->priv;
- val = gconf_client_get_string (gconf, "/desktop/gnome/interface/toolbar_style", NULL);
-
- set_combo_button_style (E_COMBO_BUTTON (priv->new_button),
- val, priv->default_menu_item->icon_toolbar ? priv->default_menu_item->icon_toolbar : priv->default_menu_item->icon);
-
- g_free (val);
- gtk_widget_show (priv->new_button);
-}
-
-static void
-setup_toolbar_button (EUserCreatableItemsHandler *handler)
-{
- EUserCreatableItemsHandlerPrivate *priv;
- GConfClient *gconf = gconf_client_get_default ();
- char *val;
-
- priv = handler->priv;
- val = gconf_client_get_string (gconf, "/desktop/gnome/interface/toolbar_style", NULL);
-
- priv->new_button = e_combo_button_new ();
- priv->new_menu = gtk_menu_new ();
- priv->accel_group = gtk_accel_group_new ();
- construct_menu (handler, priv->new_menu,
- gtk_menu_item_func, gtk_separator_func);
- gtk_widget_show_all (priv->new_menu);
- e_combo_button_set_menu (E_COMBO_BUTTON (priv->new_button),
- GTK_MENU (priv->new_menu));
-
- g_signal_connect (priv->new_button, "activate_default",
- G_CALLBACK (default_activate), handler);
-
- priv->new_control = bonobo_control_new (priv->new_button);
-
- priv->default_menu_item = get_default_action_for_view (handler);
- if (!priv->default_menu_item) {
- gtk_widget_set_sensitive (priv->new_button, FALSE);
- g_object_unref (gconf);
- return;
- }
-
- gtk_widget_set_sensitive (priv->new_button, TRUE);
-
- set_combo_button_style (E_COMBO_BUTTON (priv->new_button),
- val, priv->default_menu_item->icon_toolbar ? priv->default_menu_item->icon_toolbar : priv->default_menu_item->icon);
-
- gconf_client_notify_add(gconf,"/desktop/gnome/interface/toolbar_style",
- (GConfClientNotifyFunc)new_button_change, handler, NULL, NULL);
-
- gtk_widget_set_tooltip_text (priv->new_button,
- priv->default_menu_item->tooltip);
- gtk_widget_show (priv->new_button);
-
- g_free (val);
- g_object_unref (gconf);
-}
-
-
-/* GObject methods. */
-
-static void
-impl_set_property (GObject *object, guint prop_id,
- const GValue *value, GParamSpec *pspec)
-{
- EUserCreatableItemsHandler *handler =
- E_USER_CREATABLE_ITEMS_HANDLER (object);
-
- switch (prop_id) {
- case PROP_THIS_COMPONENT:
- handler->priv->this_component = g_value_dup_string (value);
-
- get_components_from_bonobo (handler);
- ensure_menu_items (handler);
- break;
- default:
- break;
- }
-}
-
-static void
-impl_dispose (GObject *object)
-{
- EUserCreatableItemsHandler *handler;
- EUserCreatableItemsHandlerPrivate *priv;
- GSList *p;
-
- handler = E_USER_CREATABLE_ITEMS_HANDLER (object);
- priv = handler->priv;
-
- for (p = priv->components; p != NULL; p = p->next)
- component_free ((Component *) p->data);
-
- g_slist_free (priv->components);
- priv->components = NULL;
-
- if (priv->new_control) {
- bonobo_object_unref (priv->new_control);
- priv->new_control = NULL;
- }
-
- if (priv->accel_group) {
- g_object_unref (priv->accel_group);
- priv->accel_group = NULL;
- }
-
- (* G_OBJECT_CLASS (e_user_creatable_items_handler_parent_class)->dispose) (object);
-}
-
-static void
-impl_finalize (GObject *object)
-{
- EUserCreatableItemsHandler *handler;
- EUserCreatableItemsHandlerPrivate *priv;
-
- handler = E_USER_CREATABLE_ITEMS_HANDLER (object);
- priv = handler->priv;
-
- g_free (priv->this_component);
-
- free_menu_items (priv->objects);
- free_menu_items (priv->folders);
-
- g_free (priv->menu_xml);
-
- g_free (priv);
-
- (* G_OBJECT_CLASS (e_user_creatable_items_handler_parent_class)->finalize) (object);
-}
-
-
-static void
-e_user_creatable_items_handler_class_init (EUserCreatableItemsHandlerClass *klass)
-{
- GObjectClass *object_class;
-
- object_class = G_OBJECT_CLASS (klass);
- object_class->dispose = impl_dispose;
- object_class->finalize = impl_finalize;
- object_class->set_property = impl_set_property;
-
- g_object_class_install_property (
- object_class, PROP_THIS_COMPONENT,
- g_param_spec_string ("this_component", "Component alias",
- "The component_alias of this component",
- NULL,
- G_PARAM_WRITABLE | G_PARAM_CONSTRUCT_ONLY));
-}
-
-static void
-e_user_creatable_items_handler_init (EUserCreatableItemsHandler *handler)
-{
- EUserCreatableItemsHandlerPrivate *priv;
-
- priv = g_new0 (EUserCreatableItemsHandlerPrivate, 1);
-
- handler->priv = priv;
-}
-
-
-EUserCreatableItemsHandler *
-e_user_creatable_items_handler_new (const char *component_alias,
- EUserCreatableItemsHandlerCreate create_local, void *data)
-{
- EUserCreatableItemsHandler *handler;
-
- handler = g_object_new (e_user_creatable_items_handler_get_type (),
- "this_component", component_alias,
- NULL);
- handler->priv->create_local = create_local;
- handler->priv->create_data = data;
-
- return handler;
-}
-
-
-/**
- * e_user_creatable_items_handler_activate:
- * @handler: the #EUserCreatableItemsHandler
- * @ui_component: the #BonoboUIComponent to attach to
- *
- * Set up the menus and toolbar items for @ui_component.
- **/
-void
-e_user_creatable_items_handler_activate (EUserCreatableItemsHandler *handler,
- BonoboUIComponent *ui_component)
-{
- EUserCreatableItemsHandlerPrivate *priv;
-
- g_return_if_fail (E_IS_USER_CREATABLE_ITEMS_HANDLER (handler));
- g_return_if_fail (BONOBO_IS_UI_COMPONENT (ui_component));
-
- priv = handler->priv;
-
- if (!priv->menu_xml) {
- create_menu_xml (handler);
- setup_toolbar_button (handler);
- add_verbs (handler, ui_component);
- }
-
- bonobo_ui_component_set (ui_component, "/menu/File/New",
- priv->menu_xml, NULL);
-
- bonobo_ui_component_object_set (ui_component,
- "/Toolbar/NewComboButton",
- BONOBO_OBJREF (priv->new_control),
- NULL);
-}
diff --git a/shell/e-user-creatable-items-handler.h b/shell/e-user-creatable-items-handler.h
deleted file mode 100644
index e220e6c5a1..0000000000
--- a/shell/e-user-creatable-items-handler.h
+++ /dev/null
@@ -1,70 +0,0 @@
-/* -*- Mode: C; indent-tabs-mode: t; c-basic-offset: 8; tab-width: 8 -*- */
-/* e-user-creatable-items-handler.h
- *
- * Copyright (C) 1999-2008 Novell, Inc. (www.novell.com)
- *
- * This program is free software; you can redistribute it and/or
- * modify it under the terms of version 2 of the GNU General Public
- * License as published by the Free Software Foundation.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * General Public License for more details.
- *
- * You should have received a copy of the GNU General Public
- * License along with this program; if not, write to the
- * Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
- * Boston, MA 02110-1301, USA.
- *
- * Author: Ettore Perazzoli <ettore@ximian.com>
- */
-
-#ifndef _E_USER_CREATABLE_ITEMS_HANDLER_H_
-#define _E_USER_CREATABLE_ITEMS_HANDLER_H_
-
-#include <glib-object.h>
-#include <bonobo/bonobo-ui-component.h>
-#include <bonobo/bonobo-window.h>
-
-#ifdef __cplusplus
-extern "C" {
-#pragma }
-#endif /* __cplusplus */
-
-#define E_TYPE_USER_CREATABLE_ITEMS_HANDLER (e_user_creatable_items_handler_get_type ())
-#define E_USER_CREATABLE_ITEMS_HANDLER(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), E_TYPE_USER_CREATABLE_ITEMS_HANDLER, EUserCreatableItemsHandler))
-#define E_USER_CREATABLE_ITEMS_HANDLER_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), E_TYPE_USER_CREATABLE_ITEMS_HANDLER, EUserCreatableItemsHandlerClass))
-#define E_IS_USER_CREATABLE_ITEMS_HANDLER(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), E_TYPE_USER_CREATABLE_ITEMS_HANDLER))
-#define E_IS_USER_CREATABLE_ITEMS_HANDLER_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((obj), E_TYPE_USER_CREATABLE_ITEMS_HANDLER))
-
-
-typedef struct _EUserCreatableItemsHandler EUserCreatableItemsHandler;
-typedef struct _EUserCreatableItemsHandlerPrivate EUserCreatableItemsHandlerPrivate;
-typedef struct _EUserCreatableItemsHandlerClass EUserCreatableItemsHandlerClass;
-
-typedef void (*EUserCreatableItemsHandlerCreate)(EUserCreatableItemsHandler *handler, const char *item_type_name, void *data);
-
-struct _EUserCreatableItemsHandler {
- GObject parent;
-
- EUserCreatableItemsHandlerPrivate *priv;
-};
-
-struct _EUserCreatableItemsHandlerClass {
- GObjectClass parent_class;
-};
-
-
-GType e_user_creatable_items_handler_get_type (void);
-EUserCreatableItemsHandler *e_user_creatable_items_handler_new (const char *component_alias,
- EUserCreatableItemsHandlerCreate create_local, void *data);
-
-void e_user_creatable_items_handler_activate (EUserCreatableItemsHandler *handler,
- BonoboUIComponent *ui_component);
-
-#ifdef __cplusplus
-}
-#endif /* __cplusplus */
-
-#endif /* _E_USER_CREATABLE_ITEMS_HANDLER_H_ */
diff --git a/shell/es-menu.c b/shell/es-menu.c
deleted file mode 100644
index cd573a9642..0000000000
--- a/shell/es-menu.c
+++ /dev/null
@@ -1,186 +0,0 @@
-/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */
-/*
- * Authors: Michael Zucchi <notzed@ximian.com>
- *
- * Copyright (C) 1999-2008 Novell, Inc. (www.novell.com)
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 2 of the License, or
- * (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
- *
- */
-
-#ifdef HAVE_CONFIG_H
-#include <config.h>
-#endif
-
-#include <string.h>
-#include <stdlib.h>
-
-#include <glib.h>
-
-#include "es-menu.h"
-
-static GObjectClass *esm_parent;
-
-static void
-esm_init(GObject *o)
-{
- /*ESMenu *esm = (ESMenu *)o; */
-}
-
-static void
-esm_finalise(GObject *o)
-{
- ((GObjectClass *)esm_parent)->finalize(o);
-}
-
-static void
-esm_target_free(EMenu *ep, EMenuTarget *t)
-{
- switch (t->type) {
- case ES_MENU_TARGET_SHELL: {
- ESMenuTargetShell *s = (ESMenuTargetShell *)t;
-
- s = s;
- break; }
- }
-
- ((EMenuClass *)esm_parent)->target_free(ep, t);
-}
-
-static void
-esm_class_init(GObjectClass *klass)
-{
- klass->finalize = esm_finalise;
- ((EMenuClass *)klass)->target_free = esm_target_free;
-}
-
-GType
-es_menu_get_type(void)
-{
- static GType type = 0;
-
- if (type == 0) {
- static const GTypeInfo info = {
- sizeof(ESMenuClass),
- NULL, NULL,
- (GClassInitFunc)esm_class_init,
- NULL, NULL,
- sizeof(ESMenu), 0,
- (GInstanceInitFunc)esm_init
- };
- esm_parent = g_type_class_ref(e_menu_get_type());
- type = g_type_register_static(e_menu_get_type(), "ESMenu", &info, 0);
- }
-
- return type;
-}
-
-ESMenu *es_menu_new(const char *menuid)
-{
- ESMenu *esm = g_object_new(es_menu_get_type(), NULL);
-
- e_menu_construct(&esm->menu, menuid);
-
- return esm;
-}
-
-/**
- * es_menu_target_new_shell:
- * @esm:
- * @flags:
- *
- * Create a new menu target for the shell.
- *
- * Return value:
- **/
-ESMenuTargetShell *
-es_menu_target_new_shell(ESMenu *esm, guint32 flags)
-{
- ESMenuTargetShell *t = e_menu_target_new(&esm->menu, ES_MENU_TARGET_SHELL, sizeof(*t));
- guint32 mask = ~0;
-
- mask &= ~ flags;
- t->target.mask = mask;
-
- return t;
-}
-
-/* ********************************************************************** */
-
-
-static void *esph_parent_class;
-#define esph ((ESMenuHook *)eph)
-
-static const EMenuHookTargetMask esph_shell_masks[] = {
- { "online", ES_MENU_SHELL_ONLINE },
- { "offline", ES_MENU_SHELL_OFFLINE },
- { NULL }
-};
-
-static const EMenuHookTargetMap esph_targets[] = {
- { "shell", ES_MENU_TARGET_SHELL, esph_shell_masks },
- { NULL }
-};
-
-static void
-esph_finalise(GObject *o)
-{
- /*EPluginHook *eph = (EPluginHook *)o;*/
-
- ((GObjectClass *)esph_parent_class)->finalize(o);
-}
-
-static void
-esph_class_init(EPluginHookClass *klass)
-{
- int i;
-
- /** @HookClass: Shell Main Menu
- * @Id: org.gnome.evolution.shell.bonobomenu:1.0
- * @Target: ESMenuTargetShell
- *
- * A hook for the main menus from the shell component.
- *
- * These menu's will be available from all components, but
- * will have no context for the current component.
- **/
-
- ((GObjectClass *)klass)->finalize = esph_finalise;
- ((EPluginHookClass *)klass)->id = "org.gnome.evolution.shell.bonobomenu:1.0";
-
- for (i=0;esph_targets[i].type;i++)
- e_menu_hook_class_add_target_map((EMenuHookClass *)klass, &esph_targets[i]);
-
- /* FIXME: leaks parent set class? */
- ((EMenuHookClass *)klass)->menu_class = g_type_class_ref(es_menu_get_type());
-}
-
-GType
-es_menu_hook_get_type(void)
-{
- static GType type = 0;
-
- if (!type) {
- static const GTypeInfo info = {
- sizeof(ESMenuHookClass), NULL, NULL, (GClassInitFunc) esph_class_init, NULL, NULL,
- sizeof(ESMenuHook), 0, (GInstanceInitFunc) NULL,
- };
-
- esph_parent_class = g_type_class_ref(e_menu_hook_get_type());
- type = g_type_register_static(e_menu_hook_get_type(), "ESMenuHook", &info, 0);
- }
-
- return type;
-}
diff --git a/shell/es-menu.h b/shell/es-menu.h
deleted file mode 100644
index 7b9126d93b..0000000000
--- a/shell/es-menu.h
+++ /dev/null
@@ -1,96 +0,0 @@
-/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*-
- *
- * Authors: Michel Zucchi <notzed@ximian.com>
- *
- * Copyright (C) 1999-2008 Novell, Inc. (www.novell.com)
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 2 of the License, or
- * (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
- *
- */
-
-#ifndef __ES_MENU_H__
-#define __ES_MENU_H__
-
-#include <glib-object.h>
-
-#include "e-util/e-menu.h"
-
-#ifdef __cplusplus
-extern "C" {
-#pragma }
-#endif /* __cplusplus */
-
-typedef struct _ESMenu ESMenu;
-typedef struct _ESMenuClass ESMenuClass;
-
-/* Current target description */
-/* Types of popup tagets */
-enum _es_menu_target_t {
- ES_MENU_TARGET_SHELL,
-};
-
-/* Flags that describe a TARGET_SHELL */
-enum {
- ES_MENU_SHELL_ONLINE = 1<<0,
- ES_MENU_SHELL_OFFLINE = 1<<1,
-};
-
-typedef struct _ESMenuTargetShell ESMenuTargetShell;
-
-struct _ESMenuTargetShell {
- EMenuTarget target;
-
- /* current component?? */
-};
-
-typedef struct _EMenuItem ESMenuItem;
-
-/* The object */
-struct _ESMenu {
- EMenu menu;
-
- struct _ESMenuPrivate *priv;
-};
-
-struct _ESMenuClass {
- EMenuClass menu_class;
-};
-
-GType es_menu_get_type(void);
-
-ESMenu *es_menu_new(const char *menuid);
-
-ESMenuTargetShell *es_menu_target_new_shell(ESMenu *emp, guint32 flags);
-
-/* ********************************************************************** */
-
-typedef struct _ESMenuHook ESMenuHook;
-typedef struct _ESMenuHookClass ESMenuHookClass;
-
-struct _ESMenuHook {
- EMenuHook hook;
-};
-
-struct _ESMenuHookClass {
- EMenuHookClass hook_class;
-};
-
-GType es_menu_hook_get_type(void);
-
-#ifdef __cplusplus
-}
-#endif /* __cplusplus */
-
-#endif /* __ES_MENU_H__ */
diff --git a/shell/main.c b/shell/main.c
index 292b7f96cf..9f729a7bf9 100644
--- a/shell/main.c
+++ b/shell/main.c
@@ -40,7 +40,6 @@
#include "e-util/e-util.h"
#include "e-shell.h"
-#include "es-menu.h"
#include "es-event.h"
#include "e-util/e-util-private.h"
@@ -624,7 +623,6 @@ main (int argc, char **argv)
if (!disable_eplugin) {
e_plugin_register_type (e_plugin_lib_get_type ());
- e_plugin_hook_register_type (es_menu_hook_get_type ());
e_plugin_hook_register_type (es_event_hook_get_type ());
#ifdef ENABLE_PROFILING
e_plugin_hook_register_type (e_profile_event_hook_get_type ());
diff --git a/shell/test/e-test-shell-module.c b/shell/test/e-test-shell-module.c
index f7deaaca67..2aec01a444 100644
--- a/shell/test/e-test-shell-module.c
+++ b/shell/test/e-test-shell-module.c
@@ -1,5 +1,5 @@
/* -*- Mode: C; indent-tabs-mode: t; c-basic-offset: 8; tab-width: 8 -*- */
-/* e-test-module.c
+/* e-test-shell-module.c
*
* Copyright (C) 1999-2008 Novell, Inc. (www.novell.com)
*
@@ -32,17 +32,17 @@
#define MODULE_SORT_ORDER 100
/* Module Entry Point */
-void e_shell_module_init (GTypeModule *module);
+void e_shell_module_init (GTypeModule *type_module);
static void
-action_new_test_item_cb (GtkAction *action,
+action_test_item_new_cb (GtkAction *action,
EShellWindow *shell_window)
{
g_debug ("%s", G_STRFUNC);
}
static void
-action_new_test_source_cb (GtkAction *action,
+action_test_source_new_cb (GtkAction *action,
EShellWindow *shell_window)
{
g_debug ("%s", G_STRFUNC);
@@ -50,22 +50,22 @@ action_new_test_source_cb (GtkAction *action,
static GtkActionEntry item_entries[] = {
- { "new-test-item",
+ { "test-item-new",
"document-new",
N_("_Test Item"),
NULL,
N_("Create a new test item"),
- G_CALLBACK (action_new_test_item_cb) }
+ G_CALLBACK (action_test_item_new_cb) }
};
static GtkActionEntry source_entries[] = {
- { "new-test-source",
+ { "test-source-new",
"folder-new",
N_("Test _Source"),
NULL,
N_("Create a new test source"),
- G_CALLBACK (action_new_test_source_cb) }
+ G_CALLBACK (action_test_source_new_cb) }
};
static gboolean
@@ -139,27 +139,30 @@ static EShellModuleInfo module_info = {
};
void
-e_shell_module_init (GTypeModule *module)
+e_shell_module_init (GTypeModule *type_module)
{
EShell *shell;
+ EShellModule *shell_module;
- e_test_shell_view_get_type (module);
- shell = e_shell_module_get_shell (E_SHELL_MODULE (module));
- e_shell_module_set_info (E_SHELL_MODULE (module), &module_info);
+ shell_module = E_SHELL_MODULE (type_module);
+ shell = e_shell_module_get_shell (shell_module);
+
+ e_test_shell_view_get_type (type_module);
+ e_shell_module_set_info (shell_module, &module_info);
g_signal_connect_swapped (
shell, "handle-uri",
- G_CALLBACK (test_module_handle_uri), module);
+ G_CALLBACK (test_module_handle_uri), shell_module);
g_signal_connect_swapped (
shell, "send-receive",
- G_CALLBACK (test_module_send_receive), module);
+ G_CALLBACK (test_module_send_receive), shell_module);
g_signal_connect_swapped (
shell, "window-created",
- G_CALLBACK (test_module_window_created), module);
+ G_CALLBACK (test_module_window_created), shell_module);
g_signal_connect_swapped (
shell, "window-destroyed",
- G_CALLBACK (test_module_window_destroyed), module);
+ G_CALLBACK (test_module_window_destroyed), shell_module);
}
diff --git a/shell/test/e-test-shell-view.c b/shell/test/e-test-shell-view.c
index c76d459160..adba6ae3b8 100644
--- a/shell/test/e-test-shell-view.c
+++ b/shell/test/e-test-shell-view.c
@@ -35,7 +35,7 @@ static gpointer parent_class;
static void
test_shell_view_class_init (ETestShellViewClass *class,
- GTypeModule *module)
+ GTypeModule *type_module)
{
EShellViewClass *shell_view_class;
@@ -45,17 +45,17 @@ test_shell_view_class_init (ETestShellViewClass *class,
shell_view_class = E_SHELL_VIEW_CLASS (class);
shell_view_class->label = N_("Test");
shell_view_class->icon_name = "face-monkey";
- shell_view_class->module = module;
+ shell_view_class->type_module = type_module;
}
static void
-test_shell_view_init (ETestShellView *test_view)
+test_shell_view_init (ETestShellView *view)
{
- test_view->priv = E_TEST_SHELL_VIEW_GET_PRIVATE (test_view);
+ view->priv = E_TEST_SHELL_VIEW_GET_PRIVATE (view);
}
GType
-e_test_shell_view_get_type (GTypeModule *module)
+e_test_shell_view_get_type (GTypeModule *type_module)
{
if (e_test_shell_view_type == 0) {
const GTypeInfo type_info = {
@@ -64,16 +64,16 @@ e_test_shell_view_get_type (GTypeModule *module)
(GBaseFinalizeFunc) NULL,
(GClassInitFunc) test_shell_view_class_init,
(GClassFinalizeFunc) NULL,
- module, /* class_data */
+ type_module,
sizeof (ETestShellView),
- 0, /* n_preallocs */
+ 0, /* n_preallocs */
(GInstanceInitFunc) test_shell_view_init,
- NULL /* value_table */
+ NULL /* value_table */
};
e_test_shell_view_type =
g_type_module_register_type (
- module, E_TYPE_SHELL_VIEW,
+ type_module, E_TYPE_SHELL_VIEW,
"ETestShellView", &type_info, 0);
}
diff --git a/shell/test/e-test-shell-view.h b/shell/test/e-test-shell-view.h
index 036ebc3877..d349f63f0b 100644
--- a/shell/test/e-test-shell-view.h
+++ b/shell/test/e-test-shell-view.h
@@ -59,7 +59,7 @@ struct _ETestShellViewClass {
EShellViewClass parent_class;
};
-GType e_test_shell_view_get_type (GTypeModule *module);
+GType e_test_shell_view_get_type (GTypeModule *type_module);
G_END_DECLS
diff --git a/ui/Makefile.am b/ui/Makefile.am
index 00b8953101..5023d30148 100644
--- a/ui/Makefile.am
+++ b/ui/Makefile.am
@@ -10,6 +10,7 @@ XML_FILES = \
evolution-tasks.xml
UI_FILES = \
+ evolution-contacts.ui \
evolution-shell.ui
evolutionui_DATA = $(UI_FILES) $(XML_FILES)
diff --git a/ui/evolution-contacts.ui b/ui/evolution-contacts.ui
new file mode 100644
index 0000000000..18496acc42
--- /dev/null
+++ b/ui/evolution-contacts.ui
@@ -0,0 +1,45 @@
+<ui>
+ <menubar name='main-menu'>
+ <menu action='file-menu'>
+ <placeholder name='file-actions'>
+ <menuitem action='contact-open'/>
+ <menuitem action='contact-save-as'/>
+ <menuitem action='address-book-save-as'/>
+ </placeholder>
+ <placeholder name='print-actions'>
+ <menuitem action='contact-print-preview'/>
+ <menuitem action='contact-print'/>
+ </placeholder>
+ </menu>
+ <menu action='edit-menu'>
+ <placeholder name='edit-actions'>
+ <menuitem action='contact-select-all'/>
+ <separator/>
+ <menuitem action='contact-clipboard-cut'/>
+ <menuitem action='contact-clipboard-copy'/>
+ <menuitem action='contact-clipboard-paste'/>
+ <separator/>
+ <menuitem action='contact-delete'/>
+ <menuitem action='address-book-delete'/>
+ </placeholder>
+ </menu>
+ <menu action='view-menu'>
+ <menuitem action='contact-preview'/>
+ </menu>
+ <placeholder name='custom-menus'>
+ <menu action='action-menu'>
+ <menuitem action='contact-forward'/>
+ <menuitem action='contact-send-message'/>
+ <menuitem action='address-book-stop'/>
+ <separator/>
+ <menuitem action='contact-copy'/>
+ <menuitem action='contact-move'/>
+ <separator/>
+ <menuitem action='address-book-copy'/>
+ <menuitem action='address-book-move'/>
+ <separator/>
+ <menuitem action='address-book-properties'/>
+ </menu>
+ </placeholder>
+ </menubar>
+</ui>
diff --git a/ui/evolution-shell.ui b/ui/evolution-shell.ui
index 76e635ffe4..4cf5dbc428 100644
--- a/ui/evolution-shell.ui
+++ b/ui/evolution-shell.ui
@@ -5,6 +5,7 @@
<menuitem action='new-window'/>
<separator/>
<menuitem action='send-receive'/>
+ <placeholder name='file-actions'/>
<separator/>
<menuitem action='import'/>
<separator/>
@@ -18,6 +19,8 @@
<menuitem action='quit'/>
</menu>
<menu action='edit-menu'>
+ <placeholder name='edit-actions'/>
+ <separator/>
<menuitem action='sync-options'/>
<menuitem action='preferences'/>
</menu>