diff options
-rw-r--r-- | addressbook/gui/component/e-book-shell-backend.c | 2 | ||||
-rw-r--r-- | calendar/modules/e-cal-shell-backend.c | 8 | ||||
-rw-r--r-- | calendar/modules/e-memo-shell-backend.c | 4 | ||||
-rw-r--r-- | calendar/modules/e-task-shell-backend.c | 4 | ||||
-rw-r--r-- | configure.in | 2 | ||||
-rw-r--r-- | doc/reference/shell/eshell-sections.txt | 4 | ||||
-rw-r--r-- | doc/reference/shell/tmpl/e-shell-view.sgml | 1 | ||||
-rw-r--r-- | mail/e-mail-shell-backend.c | 4 | ||||
-rw-r--r-- | mail/e-mail-shell-sidebar.c | 2 | ||||
-rw-r--r-- | shell/e-shell-backend.c | 42 | ||||
-rw-r--r-- | shell/e-shell-backend.h | 5 | ||||
-rw-r--r-- | shell/e-shell-view.c | 63 | ||||
-rw-r--r-- | shell/e-shell-view.h | 3 | ||||
-rw-r--r-- | shell/e-shell-window-actions.c | 14 | ||||
-rw-r--r-- | shell/e-shell-window.c | 7 | ||||
-rw-r--r-- | shell/test/Makefile.am | 3 | ||||
-rw-r--r-- | shell/test/e-test-shell-backend.c | 255 | ||||
-rw-r--r-- | shell/test/e-test-shell-backend.h | 67 | ||||
-rw-r--r-- | shell/test/e-test-shell-module.c | 192 | ||||
-rw-r--r-- | shell/test/e-test-shell-view.c | 1 |
20 files changed, 411 insertions, 272 deletions
diff --git a/addressbook/gui/component/e-book-shell-backend.c b/addressbook/gui/component/e-book-shell-backend.c index d3bf07cd92..3e104c39f3 100644 --- a/addressbook/gui/component/e-book-shell-backend.c +++ b/addressbook/gui/component/e-book-shell-backend.c @@ -515,11 +515,11 @@ book_shell_backend_class_init (EBookShellBackendClass *class) object_class->constructed = book_shell_backend_constructed; shell_backend_class = E_SHELL_BACKEND_CLASS (class); + shell_backend_class->shell_view_type = E_TYPE_BOOK_SHELL_VIEW; shell_backend_class->name = "addressbook"; shell_backend_class->aliases = "contacts"; shell_backend_class->schemes = ""; shell_backend_class->sort_order = 300; - shell_backend_class->view_type = E_TYPE_BOOK_SHELL_VIEW; shell_backend_class->start = NULL; shell_backend_class->is_busy = book_shell_backend_is_busy; shell_backend_class->shutdown = book_shell_backend_shutdown; diff --git a/calendar/modules/e-cal-shell-backend.c b/calendar/modules/e-cal-shell-backend.c index d5b3ac7725..c6d84f0cf0 100644 --- a/calendar/modules/e-cal-shell-backend.c +++ b/calendar/modules/e-cal-shell-backend.c @@ -498,7 +498,7 @@ cal_shell_backend_init_preferences (EShell *shell) static gboolean cal_shell_backend_handle_uri_cb (EShellBackend *shell_backend, - const gchar *uri) + const gchar *uri) { /* FIXME */ return FALSE; @@ -506,14 +506,14 @@ cal_shell_backend_handle_uri_cb (EShellBackend *shell_backend, static void cal_shell_backend_window_created_cb (EShellBackend *shell_backend, - GtkWindow *window) + GtkWindow *window) { const gchar *backend_name; if (!E_IS_SHELL_WINDOW (window)) return; - backend_name = G_TYPE_MODULE (shell_backend)->name; + backend_name = E_SHELL_BACKEND_GET_CLASS (shell_backend)->name; e_shell_window_register_new_item_actions ( E_SHELL_WINDOW (window), backend_name, @@ -605,11 +605,11 @@ cal_shell_backend_class_init (ECalShellBackendClass *class) object_class->constructed = cal_shell_backend_constructed; shell_backend_class = E_SHELL_BACKEND_CLASS (class); + shell_backend_class->shell_view_type = E_TYPE_CAL_SHELL_VIEW; shell_backend_class->name = "calendar"; shell_backend_class->aliases = ""; shell_backend_class->schemes = "calendar"; shell_backend_class->sort_order = 400; - shell_backend_class->view_type = E_TYPE_CAL_SHELL_VIEW; shell_backend_class->start = NULL; shell_backend_class->is_busy = NULL; shell_backend_class->shutdown = NULL; diff --git a/calendar/modules/e-memo-shell-backend.c b/calendar/modules/e-memo-shell-backend.c index e91399af24..130b41839a 100644 --- a/calendar/modules/e-memo-shell-backend.c +++ b/calendar/modules/e-memo-shell-backend.c @@ -481,7 +481,7 @@ memo_module_window_created_cb (EShellBackend *shell_backend, if (!E_IS_SHELL_WINDOW (window)) return; - module_name = G_TYPE_MODULE (shell_backend)->name; + module_name = E_SHELL_BACKEND_GET_CLASS (shell_backend)->name; e_shell_window_register_new_item_actions ( E_SHELL_WINDOW (window), module_name, @@ -561,11 +561,11 @@ memo_shell_backend_class_init (EMemoShellBackendClass *class) object_class->constructed = memo_shell_backend_constructed; shell_backend_class = E_SHELL_BACKEND_CLASS (class); + shell_backend_class->shell_view_type = E_TYPE_MEMO_SHELL_VIEW; shell_backend_class->name = "memos"; shell_backend_class->aliases = ""; shell_backend_class->schemes = "memo"; shell_backend_class->sort_order = 500; - shell_backend_class->view_type = E_TYPE_MEMO_SHELL_VIEW; shell_backend_class->start = NULL; shell_backend_class->is_busy = NULL; shell_backend_class->shutdown = NULL; diff --git a/calendar/modules/e-task-shell-backend.c b/calendar/modules/e-task-shell-backend.c index 6a89a27938..3298764df3 100644 --- a/calendar/modules/e-task-shell-backend.c +++ b/calendar/modules/e-task-shell-backend.c @@ -487,7 +487,7 @@ task_module_window_created_cb (EShellBackend *shell_backend, if (!E_IS_SHELL_WINDOW (window)) return; - module_name = G_TYPE_MODULE (shell_backend)->name; + module_name = E_SHELL_BACKEND_GET_CLASS (shell_backend)->name; e_shell_window_register_new_item_actions ( E_SHELL_WINDOW (window), module_name, @@ -567,11 +567,11 @@ task_shell_backend_class_init (ETaskShellBackendClass *class) object_class->constructed = task_shell_backend_constructed; shell_backend_class = E_SHELL_BACKEND_CLASS (class); + shell_backend_class->shell_view_type = E_TYPE_TASK_SHELL_VIEW; shell_backend_class->name = "tasks"; shell_backend_class->aliases = ""; shell_backend_class->schemes = "task"; shell_backend_class->sort_order = 600; - shell_backend_class->view_type = E_TYPE_TASK_SHELL_VIEW; shell_backend_class->start = NULL; shell_backend_class->is_busy = NULL; shell_backend_class->shutdown = NULL; diff --git a/configure.in b/configure.in index 0defdde607..8ad2503e4c 100644 --- a/configure.in +++ b/configure.in @@ -1656,7 +1656,7 @@ fi dnl --- evolution-test flags -EVO_SET_COMPILE_FLAGS(EVOLUTION_TEST, gtk+-2.0 libxml-2.0 unique-1.0) +EVO_SET_COMPILE_FLAGS(EVOLUTION_TEST, gtk+-2.0 gconf-2.0 libxml-2.0 unique-1.0) AC_SUBST(EVOLUTION_TEST_CFLAGS) AC_SUBST(EVOLUTION_TEST_LIBS) diff --git a/doc/reference/shell/eshell-sections.txt b/doc/reference/shell/eshell-sections.txt index c3e3a3598a..c635f1c6bc 100644 --- a/doc/reference/shell/eshell-sections.txt +++ b/doc/reference/shell/eshell-sections.txt @@ -43,20 +43,16 @@ e_shell_migrate_error_quark <FILE>e-shell-backend</FILE> <TITLE>EShellBackend</TITLE> EShellBackend -EShellBackendInfo -e_shell_backend_new e_shell_backend_compare e_shell_backend_get_config_dir e_shell_backend_get_data_dir e_shell_backend_get_filename e_shell_backend_get_shell -e_shell_backend_get_shell_view_type e_shell_backend_add_activity e_shell_backend_start e_shell_backend_is_busy e_shell_backend_shutdown e_shell_backend_migrate -e_shell_backend_set_info <SUBSECTION Standard> E_SHELL_BACKEND E_IS_SHELL_BACKEND diff --git a/doc/reference/shell/tmpl/e-shell-view.sgml b/doc/reference/shell/tmpl/e-shell-view.sgml index 2119b2793e..15c6097c4f 100644 --- a/doc/reference/shell/tmpl/e-shell-view.sgml +++ b/doc/reference/shell/tmpl/e-shell-view.sgml @@ -95,6 +95,7 @@ EShellView @search_options: @search_rules: @view_collection: +@shell_backend: @new_shell_content: @new_shell_sidebar: @new_shell_taskbar: diff --git a/mail/e-mail-shell-backend.c b/mail/e-mail-shell-backend.c index 56f7422f5c..0d0521ebc0 100644 --- a/mail/e-mail-shell-backend.c +++ b/mail/e-mail-shell-backend.c @@ -829,7 +829,7 @@ mail_shell_backend_window_created_cb (EShell *shell, if (!E_IS_SHELL_WINDOW (window)) return; - backend_name = G_TYPE_MODULE (shell_backend)->name; + backend_name = E_SHELL_BACKEND_GET_CLASS (shell_backend)->name; e_shell_window_register_new_item_actions ( E_SHELL_WINDOW (window), backend_name, @@ -1012,11 +1012,11 @@ mail_shell_backend_class_init (EMailShellBackendClass *class) object_class->constructed = mail_shell_backend_constructed; shell_backend_class = E_SHELL_BACKEND_CLASS (class); + shell_backend_class->shell_view_type = E_TYPE_MAIL_SHELL_VIEW; shell_backend_class->name = BACKEND_NAME; shell_backend_class->aliases = ""; shell_backend_class->schemes = "mailto:email"; shell_backend_class->sort_order = 200; - shell_backend_class->view_type = E_TYPE_MAIL_SHELL_VIEW; shell_backend_class->start = mail_shell_backend_start; shell_backend_class->is_busy = NULL; shell_backend_class->shutdown = NULL; diff --git a/mail/e-mail-shell-sidebar.c b/mail/e-mail-shell-sidebar.c index d8d591e671..0429cdabf9 100644 --- a/mail/e-mail-shell-sidebar.c +++ b/mail/e-mail-shell-sidebar.c @@ -145,7 +145,7 @@ mail_shell_sidebar_constructed (GObject *object) shell_sidebar = E_SHELL_SIDEBAR (object); shell_view = e_shell_sidebar_get_shell_view (shell_sidebar); shell_backend = e_shell_view_get_shell_backend (shell_view); - mail_shell_backend = E_MAIL_SHELL_BACKEND (mail_shell_backend); + mail_shell_backend = E_MAIL_SHELL_BACKEND (shell_backend); /* Build sidebar widgets. */ diff --git a/shell/e-shell-backend.c b/shell/e-shell-backend.c index 03dfcdc6aa..e1b29aea00 100644 --- a/shell/e-shell-backend.c +++ b/shell/e-shell-backend.c @@ -23,9 +23,11 @@ #include <errno.h> #include <glib/gi18n.h> -#include <e-util/e-util.h> -#include <e-shell.h> +#include "e-util/e-util.h" + +#include "e-shell.h" +#include "e-shell-view.h" #define E_SHELL_BACKEND_GET_PRIVATE(obj) \ (G_TYPE_INSTANCE_GET_PRIVATE \ @@ -35,6 +37,12 @@ struct _EShellBackendPrivate { gpointer shell; /* weak pointer */ + /* We keep a reference to corresponding EShellView subclass + * since it keeps a reference back to us. This ensures the + * subclass is not finalized before we are, otherwise it + * would leak its EShellBackend reference. */ + EShellViewClass *shell_view_class; + gchar *config_dir; gchar *data_dir; @@ -56,7 +64,7 @@ static guint signals[LAST_SIGNAL]; static void shell_backend_set_shell (EShellBackend *shell_backend, - EShell *shell) + EShell *shell) { g_return_if_fail (shell_backend->priv->shell == NULL); @@ -102,6 +110,22 @@ shell_backend_get_property (GObject *object, } static void +shell_backend_dispose (GObject *object) +{ + EShellBackendPrivate *priv; + + priv = E_SHELL_BACKEND_GET_PRIVATE (object); + + if (priv->shell_view_class != NULL) { + g_type_class_unref (priv->shell_view_class); + priv->shell_view_class = NULL; + } + + /* Chain up to parent's dispose() method. */ + G_OBJECT_CLASS (parent_class)->dispose (object); +} + +static void shell_backend_finalize (GObject *object) { EShellBackendPrivate *priv; @@ -125,6 +149,7 @@ shell_backend_class_init (EShellBackendClass *class) object_class = G_OBJECT_CLASS (class); object_class->set_property = shell_backend_set_property; object_class->get_property = shell_backend_get_property; + object_class->dispose = shell_backend_dispose; object_class->finalize = shell_backend_finalize; /** @@ -162,15 +187,22 @@ shell_backend_class_init (EShellBackendClass *class) static void shell_backend_init (EShellBackend *shell_backend, - EShellBackendClass *class) + EShellBackendClass *class) { + EShellViewClass *shell_view_class; gchar *dirname; shell_backend->priv = E_SHELL_BACKEND_GET_PRIVATE (shell_backend); + /* Install a reference to ourselves in the corresponding + * EShellViewClass structure, */ + shell_view_class = g_type_class_ref (class->shell_view_type); + shell_view_class->shell_backend = g_object_ref (shell_backend); + shell_backend->priv->shell_view_class = shell_view_class; + /* Determine the user data directory for this backend. */ shell_backend->priv->data_dir = g_build_filename ( - g_get_user_data_dir (), class->name, NULL); + e_get_user_data_dir (), class->name, NULL); /* Determine the user configuration directory for this backend. */ shell_backend->priv->config_dir = g_build_filename ( diff --git a/shell/e-shell-backend.h b/shell/e-shell-backend.h index 0dfab7a84b..570199c44e 100644 --- a/shell/e-shell-backend.h +++ b/shell/e-shell-backend.h @@ -84,7 +84,7 @@ struct _EShellBackend { * @sort_order: Used to determine the order of backends listed in * the main menu and in the switcher. See * e_shell_backend_compare(). - * @view_type: #GType for the corresponding #EShellView subclass. + * @shell_view_type: #GType for the corresponding #EShellView subclass. * @start: Method for notifying the backend to begin loading * data and running background tasks. This is called * just before the first instantiation of the @@ -110,11 +110,12 @@ struct _EShellBackend { struct _EShellBackendClass { GObjectClass parent_class; + GType shell_view_type; + const gchar *name; const gchar *aliases; const gchar *schemes; gint sort_order; - GType view_type; /* Methods */ void (*start) (EShellBackend *shell_backend); diff --git a/shell/e-shell-view.c b/shell/e-shell-view.c index 454e517f90..7c5332a8d0 100644 --- a/shell/e-shell-view.c +++ b/shell/e-shell-view.c @@ -35,7 +35,6 @@ struct _EShellViewPrivate { - gpointer shell_backend; /* weak pointer */ gpointer shell_window; /* weak pointer */ gchar *title; @@ -73,21 +72,17 @@ static gpointer parent_class; static gulong signals[LAST_SIGNAL]; static void -shell_view_init_view_collection (EShellView *shell_view) +shell_view_init_view_collection (EShellViewClass *class) { - EShellViewClass *view_class; - EShellBackendClass *backend_class; EShellBackend *shell_backend; const gchar *base_dir; const gchar *backend_name; gchar *system_dir; gchar *local_dir; - view_class = E_SHELL_VIEW_GET_CLASS (shell_view); - - shell_backend = e_shell_view_get_shell_backend (shell_view); - backend_class = E_SHELL_BACKEND_GET_CLASS (shell_backend); - backend_name = backend_class->name; + shell_backend = class->shell_backend; + g_return_if_fail (E_IS_SHELL_BACKEND (shell_backend)); + backend_name = E_SHELL_BACKEND_GET_CLASS (shell_backend)->name; base_dir = EVOLUTION_GALVIEWSDIR; system_dir = g_build_filename (base_dir, backend_name, NULL); @@ -96,13 +91,13 @@ shell_view_init_view_collection (EShellView *shell_view) local_dir = g_build_filename (base_dir, "views", NULL); /* The view collection is never destroyed. */ - view_class->view_collection = gal_view_collection_new (); + class->view_collection = gal_view_collection_new (); gal_view_collection_set_title ( - view_class->view_collection, view_class->label); + class->view_collection, class->label); gal_view_collection_set_storage_directories ( - view_class->view_collection, system_dir, local_dir); + class->view_collection, system_dir, local_dir); g_free (system_dir); g_free (local_dir); @@ -148,19 +143,6 @@ shell_view_set_action (EShellView *shell_view, } static void -shell_view_set_shell_backend (EShellView *shell_view, - EShellBackend *shell_backend) -{ - g_return_if_fail (shell_view->priv->shell_backend == NULL); - - shell_view->priv->shell_backend = shell_backend; - - g_object_add_weak_pointer ( - G_OBJECT (shell_backend), - &shell_view->priv->shell_backend); -} - -static void shell_view_set_shell_window (EShellView *shell_view, GtkWidget *shell_window) { @@ -198,12 +180,6 @@ shell_view_set_property (GObject *object, g_value_get_string (value)); return; - case PROP_SHELL_BACKEND: - shell_view_set_shell_backend ( - E_SHELL_VIEW (object), - g_value_get_object (value)); - return; - case PROP_SHELL_WINDOW: shell_view_set_shell_window ( E_SHELL_VIEW (object), @@ -291,12 +267,6 @@ shell_view_dispose (GObject *object) priv = E_SHELL_VIEW_GET_PRIVATE (object); - if (priv->shell_backend != NULL) { - g_object_remove_weak_pointer ( - G_OBJECT (priv->shell_backend), &priv->shell_backend); - priv->shell_backend = NULL; - } - if (priv->shell_window != NULL) { g_object_remove_weak_pointer ( G_OBJECT (priv->shell_window), &priv->shell_window); @@ -354,9 +324,6 @@ shell_view_constructed (GObject *object) shell_view = E_SHELL_VIEW (object); class = E_SHELL_VIEW_GET_CLASS (object); - if (class->view_collection == NULL) - shell_view_init_view_collection (shell_view); - shell_window = e_shell_view_get_shell_window (shell_view); ui_manager = e_shell_window_get_ui_manager (shell_window); id = class->ui_manager_id; @@ -491,8 +458,7 @@ shell_view_class_init (EShellViewClass *class) _("Shell Backend"), _("The EShellBackend for this shell view"), E_TYPE_SHELL_BACKEND, - G_PARAM_READWRITE | - G_PARAM_CONSTRUCT_ONLY)); + G_PARAM_READABLE)); /** * EShellView:shell-content @@ -621,10 +587,14 @@ shell_view_class_init (EShellViewClass *class) } static void -shell_view_init (EShellView *shell_view) +shell_view_init (EShellView *shell_view, + EShellViewClass *class) { GtkSizeGroup *size_group; + if (class->view_collection == NULL) + shell_view_init_view_collection (class); + size_group = gtk_size_group_new (GTK_SIZE_GROUP_VERTICAL); shell_view->priv = E_SHELL_VIEW_GET_PRIVATE (shell_view); @@ -903,9 +873,14 @@ e_shell_view_get_size_group (EShellView *shell_view) EShellBackend * e_shell_view_get_shell_backend (EShellView *shell_view) { + EShellViewClass *class; + g_return_val_if_fail (E_IS_SHELL_VIEW (shell_view), NULL); - return E_SHELL_BACKEND (shell_view->priv->shell_backend); + class = E_SHELL_VIEW_GET_CLASS (shell_view); + g_return_val_if_fail (class->shell_backend != NULL, NULL); + + return class->shell_backend; } /** diff --git a/shell/e-shell-view.h b/shell/e-shell-view.h index 66a72325fb..99730ef689 100644 --- a/shell/e-shell-view.h +++ b/shell/e-shell-view.h @@ -139,6 +139,9 @@ struct _EShellViewClass { /* A unique instance is created for each subclass. */ GalViewCollection *view_collection; + /* This is set by the corresponding EShellBackend. */ + EShellBackend *shell_backend; + /* Factory Methods */ GtkWidget * (*new_shell_content) (EShellView *shell_view); GtkWidget * (*new_shell_sidebar) (EShellView *shell_view); diff --git a/shell/e-shell-window-actions.c b/shell/e-shell-window-actions.c index 9c8c8d46df..846bb82d98 100644 --- a/shell/e-shell-window-actions.c +++ b/shell/e-shell-window-actions.c @@ -1965,26 +1965,28 @@ e_shell_window_create_switcher_actions (EShellWindow *shell_window) for (iter = list; iter != NULL; iter = iter->next) { EShellBackend *shell_backend = iter->data; + EShellBackendClass *backend_class; EShellViewClass *class; - GType type; + GType view_type; const gchar *view_name; gchar *accelerator; gchar *action_name; gchar *tooltip; /* The backend name is also the view name. */ - view_name = E_SHELL_BACKEND_GET_CLASS (shell_backend)->name; - type = E_SHELL_BACKEND_GET_CLASS (shell_backend)->view_type; + backend_class = E_SHELL_BACKEND_GET_CLASS (shell_backend); + view_type = backend_class->shell_view_type; + view_name = backend_class->name; - if (!g_type_is_a (type, E_TYPE_SHELL_VIEW)) { + if (!g_type_is_a (view_type, E_TYPE_SHELL_VIEW)) { g_critical ( "%s is not a subclass of %s", - g_type_name (type), + g_type_name (view_type), g_type_name (E_TYPE_SHELL_VIEW)); continue; } - class = g_type_class_ref (type); + class = g_type_class_ref (view_type); if (class->label == NULL) { g_critical ( diff --git a/shell/e-shell-window.c b/shell/e-shell-window.c index 5fdd2467bc..c39d856e32 100644 --- a/shell/e-shell-window.c +++ b/shell/e-shell-window.c @@ -52,7 +52,7 @@ shell_window_new_view (EShellBackend *shell_backend, GType type; name = E_SHELL_BACKEND_GET_CLASS (shell_backend)->name; - type = E_SHELL_BACKEND_GET_CLASS (shell_backend)->view_type; + type = E_SHELL_BACKEND_GET_CLASS (shell_backend)->shell_view_type; /* First off, start the shell backend. */ e_shell_backend_start (shell_backend); @@ -66,9 +66,8 @@ shell_window_new_view (EShellBackend *shell_backend, /* Create the shell view. */ shell_view = g_object_new ( - type, "action", action, "page-num", page_num, - "shell-backend", shell_backend, "shell-window", - shell_window, NULL); + type, "action", action, "page-num",page_num, + "shell-window", shell_window, NULL); /* Register the shell view. */ loaded_views = shell_window->priv->loaded_views; diff --git a/shell/test/Makefile.am b/shell/test/Makefile.am index 3656b5b782..3b98d1b9ce 100644 --- a/shell/test/Makefile.am +++ b/shell/test/Makefile.am @@ -10,7 +10,8 @@ INCLUDES = \ $(EVOLUTION_TEST_CFLAGS) libevolution_test_la_SOURCES = \ - e-test-shell-module.c \ + e-test-shell-backend.c \ + e-test-shell-backend.h \ e-test-shell-view.c \ e-test-shell-view.h diff --git a/shell/test/e-test-shell-backend.c b/shell/test/e-test-shell-backend.c new file mode 100644 index 0000000000..cdceb603d1 --- /dev/null +++ b/shell/test/e-test-shell-backend.c @@ -0,0 +1,255 @@ +/* + * e-test-shell-backend.c + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2 of the License, or (at your option) version 3. + * + * 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 + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with the program; if not, see <http://www.gnu.org/licenses/> + * + * + * Copyright (C) 1999-2008 Novell, Inc. (www.novell.com) + * + */ + +#include "e-test-shell-backend.h" + +#include <glib/gi18n.h> + +#include <e-shell.h> +#include <e-shell-window.h> + +#include "e-test-shell-view.h" + +#define E_TEST_SHELL_BACKEND_GET_PRIVATE(obj) \ + (G_TYPE_INSTANCE_GET_PRIVATE \ + ((obj), E_TYPE_TEST_SHELL_BACKEND, ETestShellBackendPrivate)) + +struct _ETestShellBackendPrivate { + gint placeholder; +}; + +/* Module Entry Point */ +void e_module_load (GTypeModule *type_module); +void e_module_unload (GTypeModule *type_module); + +GType e_test_shell_backend_type = 0; +static gpointer parent_class; + +static void +action_test_item_new_cb (GtkAction *action, + EShellWindow *shell_window) +{ + g_debug ("%s", G_STRFUNC); +} + +static void +action_test_source_new_cb (GtkAction *action, + EShellWindow *shell_window) +{ + g_debug ("%s", G_STRFUNC); +} + +static GtkActionEntry item_entries[] = { + + { "test-item-new", + "document-new", + NC_("New", "_Test Item"), + NULL, + N_("Create a new test item"), + G_CALLBACK (action_test_item_new_cb) } +}; + +static GtkActionEntry source_entries[] = { + + { "test-source-new", + "folder-new", + NC_("New", "Test _Source"), + NULL, + N_("Create a new test source"), + G_CALLBACK (action_test_source_new_cb) } +}; + +static void +test_shell_backend_start (EShellBackend *shell_backend) +{ + g_debug ("%s", G_STRFUNC); +} + +static gboolean +test_shell_backend_is_busy (EShellBackend *shell_backend) +{ + g_debug ("%s", G_STRFUNC); + + return FALSE; +} + +static gboolean +test_shell_backend_shutdown (EShellBackend *shell_backend) +{ + g_debug ("%s", G_STRFUNC); + + return TRUE; +} + +static gboolean +test_shell_backend_migrate (EShellBackend *shell_backend, + gint major, + gint minor, + gint micro, + GError **error) +{ + g_debug ("%s (from %d.%d.%d)", G_STRFUNC, major, minor, micro); + + return TRUE; +} + +static gboolean +test_shell_backend_handle_uri_cb (EShellBackend *shell_backend, + const gchar *uri) +{ + g_debug ("%s (uri=%s)", G_STRFUNC, uri); + + return FALSE; +} + +static void +test_shell_backend_send_receive_cb (EShellBackend *shell_backend, + GtkWindow *parent_window) +{ + g_debug ("%s (window=%p)", G_STRFUNC, parent_window); +} + +static void +test_shell_backend_window_created_cb (EShellBackend *shell_backend, + GtkWindow *window) +{ + const gchar *backend_name; + + g_debug ("%s (%s)", G_STRFUNC, G_OBJECT_TYPE_NAME (window)); + + if (!E_IS_SHELL_WINDOW (window)) + return; + + backend_name = E_SHELL_BACKEND_GET_CLASS (shell_backend)->name; + + e_shell_window_register_new_item_actions ( + E_SHELL_WINDOW (window), backend_name, + item_entries, G_N_ELEMENTS (item_entries)); + + e_shell_window_register_new_source_actions ( + E_SHELL_WINDOW (window), backend_name, + source_entries, G_N_ELEMENTS (source_entries)); +} + +static void +test_shell_backend_window_destroyed_cb (EShellBackend *shell_backend) +{ + g_debug ("%s", G_STRFUNC); +} + +void +test_shell_backend_constructed (GObject *object) +{ + EShell *shell; + EShellBackend *shell_backend; + + shell_backend = E_SHELL_BACKEND (object); + shell = e_shell_backend_get_shell (shell_backend); + + g_signal_connect_swapped ( + shell, "handle-uri", + G_CALLBACK (test_shell_backend_handle_uri_cb), + shell_backend); + + g_signal_connect_swapped ( + shell, "send-receive", + G_CALLBACK (test_shell_backend_send_receive_cb), + shell_backend); + + g_signal_connect_swapped ( + shell, "window-created", + G_CALLBACK (test_shell_backend_window_created_cb), + shell_backend); + + g_signal_connect_swapped ( + shell, "window-destroyed", + G_CALLBACK (test_shell_backend_window_destroyed_cb), + shell_backend); +} + +static void +test_shell_backend_class_init (ETestShellBackendClass *class) +{ + GObjectClass *object_class; + EShellBackendClass *shell_backend_class; + + parent_class = g_type_class_peek_parent (class); + g_type_class_add_private (class, sizeof (ETestShellBackendPrivate)); + + object_class = G_OBJECT_CLASS (class); + object_class->constructed = test_shell_backend_constructed; + + shell_backend_class = E_SHELL_BACKEND_CLASS (class); + shell_backend_class->shell_view_type = E_TYPE_TEST_SHELL_VIEW; + shell_backend_class->name = "test"; + shell_backend_class->aliases = "monkey"; + shell_backend_class->schemes = ""; + shell_backend_class->sort_order = 100; + shell_backend_class->start = test_shell_backend_start; + shell_backend_class->is_busy = test_shell_backend_is_busy; + shell_backend_class->shutdown = test_shell_backend_shutdown; + shell_backend_class->migrate = test_shell_backend_migrate; +} + +static void +test_shell_backend_init (ETestShellBackend *test_shell_backend) +{ + test_shell_backend->priv = + E_TEST_SHELL_BACKEND_GET_PRIVATE (test_shell_backend); +} + +GType +e_test_shell_backend_get_type (GTypeModule *type_module) +{ + if (e_test_shell_backend_type == 0) { + const GTypeInfo type_info = { + sizeof (ETestShellBackendClass), + (GBaseInitFunc) NULL, + (GBaseFinalizeFunc) NULL, + (GClassInitFunc) test_shell_backend_class_init, + (GClassFinalizeFunc) NULL, + NULL, /* class_data */ + sizeof (ETestShellBackend), + 0, /* n_preallocs */ + (GInstanceInitFunc) test_shell_backend_init, + NULL /* value_table */ + }; + + e_test_shell_backend_type = + g_type_module_register_type ( + type_module, E_TYPE_SHELL_BACKEND, + "ETestShellBackend", &type_info, 0); + } + + return e_test_shell_backend_type; +} + +void +e_module_load (GTypeModule *type_module) +{ + e_test_shell_backend_get_type (type_module); + e_test_shell_view_get_type (type_module); +} + +void +e_module_unload (GTypeModule *type_module) +{ +} diff --git a/shell/test/e-test-shell-backend.h b/shell/test/e-test-shell-backend.h new file mode 100644 index 0000000000..ccb04be7c2 --- /dev/null +++ b/shell/test/e-test-shell-backend.h @@ -0,0 +1,67 @@ +/* + * e-test-shell-backend.c + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2 of the License, or (at your option) version 3. + * + * 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 + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with the program; if not, see <http://www.gnu.org/licenses/> + * + * + * Copyright (C) 1999-2008 Novell, Inc. (www.novell.com) + * + */ + +#ifndef E_TEST_SHELL_BACKEND_H +#define E_TEST_SHELL_BACKEND_H + +#include <shell/e-shell-backend.h> + +/* Standard GObject macros */ +#define E_TYPE_TEST_SHELL_BACKEND \ + (e_test_shell_backend_type) +#define E_TEST_SHELL_BACKEND(obj) \ + (G_TYPE_CHECK_INSTANCE_CAST \ + ((obj), E_TYPE_TEST_SHELL_BACKEND, ETestShellBackend)) +#define E_TEST_SHELL_BACKEND_CLASS(cls) \ + (G_TYPE_CHECK_CLASS_CAST \ + ((cls), E_TYPE_TEST_SHELL_BACKEND, ETestShellBackendClass)) +#define E_IS_TEST_SHELL_BACKEND(obj) \ + (G_TYPE_CHECK_INSTANCE_TYPE \ + ((obj), E_TYPE_TEST_SHELL_BACKEND)) +#define E_IS_TEST_SHELL_BACKEND_CLASS(cls) \ + (G_TYPE_CHECK_CLASS_TYPE \ + ((cls), E_TYPE_TEST_SHELL_BACKEND)) +#define E_TEST_SHELL_BACKEND_GET_CLASS(obj) \ + (G_TYPE_INSTANCE_GET_CLASS \ + ((obj), E_TYPE_TEST_SHELL_BACKEND, ETestShellBackendClass)) + +G_BEGIN_DECLS + +extern GType e_test_shell_backend_type; + +typedef struct _ETestShellBackend ETestShellBackend; +typedef struct _ETestShellBackendClass ETestShellBackendClass; +typedef struct _ETestShellBackendPrivate ETestShellBackendPrivate; + +struct _ETestShellBackend { + EShellBackend parent; + ETestShellBackendPrivate *priv; +}; + +struct _ETestShellBackendClass { + EShellBackendClass parent_class; +}; + +GType e_test_shell_backend_get_type (GTypeModule *type_module); + +G_END_DECLS + +#endif /* E_TEST_SHELL_BACKEND_H */ diff --git a/shell/test/e-test-shell-module.c b/shell/test/e-test-shell-module.c deleted file mode 100644 index d579f46499..0000000000 --- a/shell/test/e-test-shell-module.c +++ /dev/null @@ -1,192 +0,0 @@ -/* - * e-test-shell-backend.c - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2 of the License, or (at your option) version 3. - * - * 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 - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with the program; if not, see <http://www.gnu.org/licenses/> - * - * - * Copyright (C) 1999-2008 Novell, Inc. (www.novell.com) - * - */ - -#include <glib/gi18n.h> - -#include <e-shell.h> -#include <e-shell-backend.h> -#include <e-shell-window.h> - -#include "e-test-shell-view.h" - -#define MODULE_NAME "test" -#define MODULE_ALIASES "monkey" -#define MODULE_SCHEMES "" -#define MODULE_SORT_ORDER 100 - -/* Module Entry Point */ -void e_shell_backend_init (GTypeModule *type_module); - -static void -action_test_item_new_cb (GtkAction *action, - EShellWindow *shell_window) -{ - g_debug ("%s", G_STRFUNC); -} - -static void -action_test_source_new_cb (GtkAction *action, - EShellWindow *shell_window) -{ - g_debug ("%s", G_STRFUNC); -} - -static GtkActionEntry item_entries[] = { - - { "test-item-new", - "document-new", - NC_("New", "_Test Item"), - NULL, - N_("Create a new test item"), - G_CALLBACK (action_test_item_new_cb) } -}; - -static GtkActionEntry source_entries[] = { - - { "test-source-new", - "folder-new", - NC_("New", "Test _Source"), - NULL, - N_("Create a new test source"), - G_CALLBACK (action_test_source_new_cb) } -}; - -static void -test_module_start (EShellBackend *shell_backend) -{ - g_debug ("%s", G_STRFUNC); -} - -static gboolean -test_module_is_busy (EShellBackend *shell_backend) -{ - g_debug ("%s", G_STRFUNC); - - return FALSE; -} - -static gboolean -test_module_shutdown (EShellBackend *shell_backend) -{ - g_debug ("%s", G_STRFUNC); - - return TRUE; -} - -static gboolean -test_module_migrate (EShellBackend *shell_backend, - gint major, - gint minor, - gint micro, - GError **error) -{ - g_debug ("%s (from %d.%d.%d)", G_STRFUNC, major, minor, micro); - - return TRUE; -} - -static gboolean -test_module_handle_uri_cb (EShellBackend *shell_backend, - const gchar *uri) -{ - g_debug ("%s (uri=%s)", G_STRFUNC, uri); - - return FALSE; -} - -static void -test_module_send_receive_cb (EShellBackend *shell_backend, - GtkWindow *parent_window) -{ - g_debug ("%s (window=%p)", G_STRFUNC, parent_window); -} - -static void -test_module_window_created_cb (EShellBackend *shell_backend, - GtkWindow *window) -{ - const gchar *module_name; - - g_debug ("%s (%s)", G_STRFUNC, G_OBJECT_TYPE_NAME (window)); - - if (!E_IS_SHELL_WINDOW (window)) - return; - - module_name = G_TYPE_MODULE (shell_backend)->name; - - e_shell_window_register_new_item_actions ( - E_SHELL_WINDOW (window), module_name, - item_entries, G_N_ELEMENTS (item_entries)); - - e_shell_window_register_new_source_actions ( - E_SHELL_WINDOW (window), module_name, - source_entries, G_N_ELEMENTS (source_entries)); -} - -static void -test_module_window_destroyed_cb (EShellBackend *shell_backend) -{ - g_debug ("%s", G_STRFUNC); -} - -static EShellBackendInfo module_info = { - - MODULE_NAME, - MODULE_ALIASES, - MODULE_SCHEMES, - MODULE_SORT_ORDER, - - /* Methods */ - test_module_start, - test_module_is_busy, - test_module_shutdown, - test_module_migrate -}; - -void -e_shell_backend_init (GTypeModule *type_module) -{ - EShell *shell; - EShellBackend *shell_backend; - - shell_backend = E_SHELL_BACKEND (type_module); - shell = e_shell_backend_get_shell (shell_backend); - - e_shell_backend_set_info ( - shell_backend, &module_info, - e_test_shell_view_get_type (type_module)); - - g_signal_connect_swapped ( - shell, "handle-uri", - G_CALLBACK (test_module_handle_uri_cb), shell_backend); - - g_signal_connect_swapped ( - shell, "send-receive", - G_CALLBACK (test_module_send_receive_cb), shell_backend); - - g_signal_connect_swapped ( - shell, "window-created", - G_CALLBACK (test_module_window_created_cb), shell_backend); - - g_signal_connect_swapped ( - shell, "window-destroyed", - G_CALLBACK (test_module_window_destroyed_cb), shell_backend); -} diff --git a/shell/test/e-test-shell-view.c b/shell/test/e-test-shell-view.c index de9d8f38ec..a7326af687 100644 --- a/shell/test/e-test-shell-view.c +++ b/shell/test/e-test-shell-view.c @@ -117,7 +117,6 @@ test_shell_view_class_init (ETestShellViewClass *class, shell_view_class = E_SHELL_VIEW_CLASS (class); shell_view_class->label = "Test"; shell_view_class->icon_name = "face-monkey"; - shell_view_class->type_module = type_module; shell_view_class->toggled = test_shell_view_toggled; } |