aboutsummaryrefslogtreecommitdiffstats
path: root/calendar
diff options
context:
space:
mode:
Diffstat (limited to 'calendar')
-rw-r--r--calendar/modules/e-task-shell-backend.c167
-rw-r--r--calendar/modules/e-task-shell-backend.h6
-rw-r--r--calendar/modules/e-task-shell-migrate.c2
-rw-r--r--calendar/modules/e-task-shell-sidebar.c9
-rw-r--r--calendar/modules/e-task-shell-view-actions.c129
-rw-r--r--calendar/modules/e-task-shell-view-private.c16
-rw-r--r--calendar/modules/e-task-shell-view-private.h8
-rw-r--r--calendar/modules/e-task-shell-view.c42
-rw-r--r--calendar/modules/e-task-shell-view.h5
9 files changed, 229 insertions, 155 deletions
diff --git a/calendar/modules/e-task-shell-backend.c b/calendar/modules/e-task-shell-backend.c
index 1dba011c96..6a89a27938 100644
--- a/calendar/modules/e-task-shell-backend.c
+++ b/calendar/modules/e-task-shell-backend.c
@@ -19,6 +19,8 @@
*
*/
+#include "e-task-shell-backend.h"
+
#include <string.h>
#include <glib/gi18n.h>
#include <libecal/e-cal.h>
@@ -37,19 +39,31 @@
#include "calendar/gui/dialogs/calendar-setup.h"
#include "calendar/gui/dialogs/task-editor.h"
+#include "e-task-shell-migrate.h"
#include "e-task-shell-view.h"
-#include "e-task-shell-backend-migrate.h"
-#define MODULE_NAME "tasks"
-#define MODULE_ALIASES ""
-#define MODULE_SCHEMES "task"
-#define MODULE_SORT_ORDER 600
+#define E_TASK_SHELL_BACKEND_GET_PRIVATE(obj) \
+ (G_TYPE_INSTANCE_GET_PRIVATE \
+ ((obj), E_TYPE_TASK_SHELL_BACKEND, ETaskShellBackendPrivate))
#define WEB_BASE_URI "webcal://"
#define PERSONAL_RELATIVE_URI "system"
+struct _ETaskShellBackendPrivate {
+ ESourceList *source_list;
+};
+
+enum {
+ PROP_0,
+ PROP_SOURCE_LIST
+};
+
/* Module Entry Point */
-void e_shell_backend_init (GTypeModule *type_module);
+void e_module_load (GTypeModule *type_module);
+void e_module_unload (GTypeModule *type_module);
+
+GType e_task_shell_backend_type = 0;
+static gpointer parent_class;
static void
task_module_ensure_sources (EShellBackend *shell_backend)
@@ -484,32 +498,49 @@ task_module_window_created_cb (EShellBackend *shell_backend,
source_entries, G_N_ELEMENTS (source_entries));
}
-static EShellBackendInfo module_info = {
+static void
+task_shell_backend_get_property (GObject *object,
+ guint property_id,
+ GValue *value,
+ GParamSpec *pspec)
+{
+ switch (property_id) {
+ case PROP_SOURCE_LIST:
+ g_value_set_object (
+ value,
+ e_task_shell_backend_get_source_list (
+ E_TASK_SHELL_BACKEND (object)));
+ return;
+ }
- MODULE_NAME,
- MODULE_ALIASES,
- MODULE_SCHEMES,
- MODULE_SORT_ORDER,
+ G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
+}
- /* start */ NULL,
- /* is_busy */ NULL,
- /* shutdown */ NULL,
- e_task_shell_backend_migrate
-};
+static void
+task_shell_backend_dispose (GObject *object)
+{
+ ETaskShellBackendPrivate *priv;
-void
-e_shell_backend_init (GTypeModule *type_module)
+ priv = E_TASK_SHELL_BACKEND_GET_PRIVATE (object);
+
+ if (priv->source_list != NULL) {
+ g_object_unref (priv->source_list);
+ priv->source_list = NULL;
+ }
+
+ /* Chain up to parent's dispose() method. */
+ G_OBJECT_CLASS (parent_class)->dispose (object);
+}
+
+static void
+task_shell_backend_constructed (GObject *object)
{
EShell *shell;
EShellBackend *shell_backend;
- shell_backend = E_SHELL_BACKEND (type_module);
+ shell_backend = E_SHELL_BACKEND (object);
shell = e_shell_backend_get_shell (shell_backend);
- e_shell_backend_set_info (
- shell_backend, &module_info,
- e_task_shell_view_get_type (type_module));
-
task_module_ensure_sources (shell_backend);
g_signal_connect_swapped (
@@ -520,3 +551,93 @@ e_shell_backend_init (GTypeModule *type_module)
shell, "window-created",
G_CALLBACK (task_module_window_created_cb), shell_backend);
}
+
+static void
+task_shell_backend_class_init (ETaskShellBackendClass *class)
+{
+ GObjectClass *object_class;
+ EShellBackendClass *shell_backend_class;
+
+ parent_class = g_type_class_peek_parent (class);
+ g_type_class_add_private (class, sizeof (ETaskShellBackendPrivate));
+
+ object_class = G_OBJECT_CLASS (class);
+ object_class->get_property = task_shell_backend_get_property;
+ object_class->dispose = task_shell_backend_dispose;
+ object_class->constructed = task_shell_backend_constructed;
+
+ shell_backend_class = E_SHELL_BACKEND_CLASS (class);
+ 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;
+ shell_backend_class->migrate = e_task_shell_backend_migrate;
+
+ g_object_class_install_property (
+ object_class,
+ PROP_SOURCE_LIST,
+ g_param_spec_object (
+ "source-list",
+ _("Source List"),
+ _("The registry of task lists"),
+ E_TYPE_SOURCE_LIST,
+ G_PARAM_READABLE));
+}
+
+static void
+task_shell_backend_init (ETaskShellBackend *task_shell_backend)
+{
+ task_shell_backend->priv =
+ E_TASK_SHELL_BACKEND_GET_PRIVATE (task_shell_backend);
+}
+
+GType
+e_task_shell_backend_get_type (GTypeModule *type_module)
+{
+ if (e_task_shell_backend_type == 0) {
+ const GTypeInfo type_info = {
+ sizeof (ETaskShellBackendClass),
+ (GBaseInitFunc) NULL,
+ (GBaseFinalizeFunc) NULL,
+ (GClassInitFunc) task_shell_backend_class_init,
+ (GClassFinalizeFunc) NULL,
+ NULL, /* class_data */
+ sizeof (ETaskShellBackend),
+ 0, /* n_preallocs */
+ (GInstanceInitFunc) task_shell_backend_init,
+ NULL /* value_table */
+ };
+
+ e_task_shell_backend_type =
+ g_type_module_register_type (
+ type_module, E_TYPE_SHELL_BACKEND,
+ "ETaskShellBackend", &type_info, 0);
+ }
+
+ return e_task_shell_backend_type;
+}
+
+ESourceList *
+e_task_shell_backend_get_source_list (ETaskShellBackend *task_shell_backend)
+{
+ g_return_val_if_fail (
+ E_IS_TASK_SHELL_BACKEND (task_shell_backend), NULL);
+
+ return task_shell_backend->priv->source_list;
+}
+
+void
+e_module_load (GTypeModule *type_module)
+{
+ e_task_shell_backend_get_type (type_module);
+ e_task_shell_view_get_type (type_module);
+}
+
+void
+e_module_unload (GTypeModule *type_module)
+{
+}
diff --git a/calendar/modules/e-task-shell-backend.h b/calendar/modules/e-task-shell-backend.h
index d57eb12fd1..7326ea9f03 100644
--- a/calendar/modules/e-task-shell-backend.h
+++ b/calendar/modules/e-task-shell-backend.h
@@ -23,6 +23,7 @@
#define E_TASK_SHELL_BACKEND_H
#include <shell/e-shell-backend.h>
+#include <libedataserver/e-source-list.h>
/* Standard GObject macros */
#define E_TYPE_TASK_SHELL_BACKEND \
@@ -60,7 +61,10 @@ struct _ETaskShellBackendClass {
EShellBackendClass parent_class;
};
-GType e_task_shell_backend_get_type (GTypeModule *type_module);
+GType e_task_shell_backend_get_type
+ (GTypeModule *type_module);
+ESourceList * e_task_shell_backend_get_source_list
+ (ETaskShellBackend *task_shell_backend);
G_END_DECLS
diff --git a/calendar/modules/e-task-shell-migrate.c b/calendar/modules/e-task-shell-migrate.c
index 4658215f06..76e53f765c 100644
--- a/calendar/modules/e-task-shell-migrate.c
+++ b/calendar/modules/e-task-shell-migrate.c
@@ -19,7 +19,7 @@
*
*/
-#include "e-task-shell-backend-migrate.h"
+#include "e-task-shell-migrate.h"
#include <string.h>
#include <sys/types.h>
diff --git a/calendar/modules/e-task-shell-sidebar.c b/calendar/modules/e-task-shell-sidebar.c
index 9631321edb..df6ae4eadf 100644
--- a/calendar/modules/e-task-shell-sidebar.c
+++ b/calendar/modules/e-task-shell-sidebar.c
@@ -32,6 +32,7 @@
#include "calendar/gui/e-task-list-selector.h"
#include "calendar/gui/misc.h"
+#include "e-task-shell-backend.h"
#include "e-task-shell-view.h"
#define E_TASK_SHELL_SIDEBAR_GET_PRIVATE(obj) \
@@ -334,8 +335,8 @@ task_shell_sidebar_constructed (GObject *object)
{
ETaskShellSidebarPrivate *priv;
EShellView *shell_view;
+ EShellBackend *shell_backend;
EShellSidebar *shell_sidebar;
- ETaskShellView *task_shell_view;
ESourceSelector *selector;
ESourceList *source_list;
ESource *source;
@@ -353,8 +354,10 @@ task_shell_sidebar_constructed (GObject *object)
shell_sidebar = E_SHELL_SIDEBAR (object);
shell_view = e_shell_sidebar_get_shell_view (shell_sidebar);
- task_shell_view = E_TASK_SHELL_VIEW (shell_view);
- source_list = e_task_shell_view_get_source_list (task_shell_view);
+ shell_backend = e_shell_view_get_shell_backend (shell_view);
+
+ source_list = e_task_shell_backend_get_source_list (
+ E_TASK_SHELL_BACKEND (shell_backend));
container = GTK_CONTAINER (shell_sidebar);
diff --git a/calendar/modules/e-task-shell-view-actions.c b/calendar/modules/e-task-shell-view-actions.c
index d924043e5f..5de630e7d0 100644
--- a/calendar/modules/e-task-shell-view-actions.c
+++ b/calendar/modules/e-task-shell-view-actions.c
@@ -203,69 +203,72 @@ static void
action_task_list_delete_cb (GtkAction *action,
ETaskShellView *task_shell_view)
{
- ETaskShellContent *task_shell_content;
- ETaskShellSidebar *task_shell_sidebar;
- EShellWindow *shell_window;
- EShellView *shell_view;
- ECalendarTable *task_table;
- ECal *client;
- ECalModel *model;
- ESourceSelector *selector;
- ESourceGroup *source_group;
- ESourceList *source_list;
- ESource *source;
- gint response;
- gchar *uri;
- GError *error = NULL;
-
- shell_view = E_SHELL_VIEW (task_shell_view);
- shell_window = e_shell_view_get_shell_window (shell_view);
-
- task_shell_content = task_shell_view->priv->task_shell_content;
- task_table = e_task_shell_content_get_task_table (task_shell_content);
- model = e_calendar_table_get_model (task_table);
-
- task_shell_sidebar = task_shell_view->priv->task_shell_sidebar;
- selector = e_task_shell_sidebar_get_selector (task_shell_sidebar);
- source = e_source_selector_peek_primary_selection (selector);
- g_return_if_fail (E_IS_SOURCE (source));
-
- /* Ask for confirmation. */
- response = e_error_run (
- GTK_WINDOW (shell_window),
- "calendar:prompt-delete-task-list",
- e_source_peek_name (source));
- if (response != GTK_RESPONSE_YES)
- return;
-
- uri = e_source_get_uri (source);
- client = e_cal_model_get_client_for_uri (model, uri);
- if (client == NULL)
- client = e_cal_new_from_uri (uri, E_CAL_SOURCE_TYPE_JOURNAL);
- g_free (uri);
-
- g_return_if_fail (client != NULL);
-
- if (!e_cal_remove (client, &error)) {
- g_warning ("%s", error->message);
- g_error_free (error);
- return;
- }
-
- if (e_source_selector_source_is_selected (selector, source)) {
- e_task_shell_sidebar_remove_source (
- task_shell_sidebar, 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 = task_shell_view->priv->source_list;
- if (!e_source_list_sync (source_list, &error)) {
- g_warning ("%s", error->message);
- g_error_free (error);
- }
+ ETaskShellBackend *task_shell_backend;
+ ETaskShellContent *task_shell_content;
+ ETaskShellSidebar *task_shell_sidebar;
+ EShellWindow *shell_window;
+ EShellView *shell_view;
+ ECalendarTable *task_table;
+ ECal *client;
+ ECalModel *model;
+ ESourceSelector *selector;
+ ESourceGroup *source_group;
+ ESourceList *source_list;
+ ESource *source;
+ gint response;
+ gchar *uri;
+ GError *error = NULL;
+
+ shell_view = E_SHELL_VIEW (task_shell_view);
+ shell_window = e_shell_view_get_shell_window (shell_view);
+
+ task_shell_backend = task_shell_view->priv->task_shell_backend;
+ source_list = e_task_shell_backend_get_source_list (task_shell_backend);
+
+ task_shell_content = task_shell_view->priv->task_shell_content;
+ task_table = e_task_shell_content_get_task_table (task_shell_content);
+ model = e_calendar_table_get_model (task_table);
+
+ task_shell_sidebar = task_shell_view->priv->task_shell_sidebar;
+ selector = e_task_shell_sidebar_get_selector (task_shell_sidebar);
+ source = e_source_selector_peek_primary_selection (selector);
+ g_return_if_fail (E_IS_SOURCE (source));
+
+ /* Ask for confirmation. */
+ response = e_error_run (
+ GTK_WINDOW (shell_window),
+ "calendar:prompt-delete-task-list",
+ e_source_peek_name (source));
+ if (response != GTK_RESPONSE_YES)
+ return;
+
+ uri = e_source_get_uri (source);
+ client = e_cal_model_get_client_for_uri (model, uri);
+ if (client == NULL)
+ client = e_cal_new_from_uri (uri, E_CAL_SOURCE_TYPE_JOURNAL);
+ g_free (uri);
+
+ g_return_if_fail (client != NULL);
+
+ if (!e_cal_remove (client, &error)) {
+ g_warning ("%s", error->message);
+ g_error_free (error);
+ return;
+ }
+
+ if (e_source_selector_source_is_selected (selector, source)) {
+ e_task_shell_sidebar_remove_source (
+ task_shell_sidebar, source);
+ e_source_selector_unselect_source (selector, source);
+ }
+
+ source_group = e_source_peek_group (source);
+ e_source_group_remove_source (source_group, source);
+
+ if (!e_source_list_sync (source_list, &error)) {
+ g_warning ("%s", error->message);
+ g_error_free (error);
+ }
}
static void
diff --git a/calendar/modules/e-task-shell-view-private.c b/calendar/modules/e-task-shell-view-private.c
index bdafe6862c..926ace8aa6 100644
--- a/calendar/modules/e-task-shell-view-private.c
+++ b/calendar/modules/e-task-shell-view-private.c
@@ -214,16 +214,6 @@ void
e_task_shell_view_private_init (ETaskShellView *task_shell_view,
EShellViewClass *shell_view_class)
{
- ETaskShellViewPrivate *priv = task_shell_view->priv;
- ESourceList *source_list;
- GObject *object;
-
- object = G_OBJECT (shell_view_class->type_module);
- source_list = g_object_get_data (object, "source-list");
- g_return_if_fail (E_IS_SOURCE_LIST (source_list));
-
- priv->source_list = g_object_ref (source_list);
-
if (!gal_view_collection_loaded (shell_view_class->view_collection))
task_shell_view_load_view_collection (shell_view_class);
@@ -239,6 +229,7 @@ e_task_shell_view_private_constructed (ETaskShellView *task_shell_view)
ETaskShellContent *task_shell_content;
ETaskShellSidebar *task_shell_sidebar;
EShellView *shell_view;
+ EShellBackend *shell_backend;
EShellContent *shell_content;
EShellSidebar *shell_sidebar;
EShellWindow *shell_window;
@@ -249,6 +240,7 @@ e_task_shell_view_private_constructed (ETaskShellView *task_shell_view)
guint id;
shell_view = E_SHELL_VIEW (task_shell_view);
+ shell_backend = e_shell_view_get_shell_backend (shell_view);
shell_content = e_shell_view_get_shell_content (shell_view);
shell_sidebar = e_shell_view_get_shell_sidebar (shell_view);
shell_window = e_shell_view_get_shell_window (shell_view);
@@ -257,6 +249,7 @@ e_task_shell_view_private_constructed (ETaskShellView *task_shell_view)
e_shell_window_add_action_group (shell_window, "tasks-filter");
/* Cache these to avoid lots of awkward casting. */
+ priv->task_shell_backend = g_object_ref (shell_backend);
priv->task_shell_content = g_object_ref (shell_content);
priv->task_shell_sidebar = g_object_ref (shell_sidebar);
@@ -382,8 +375,7 @@ e_task_shell_view_private_dispose (ETaskShellView *task_shell_view)
ETaskShellViewPrivate *priv = task_shell_view->priv;
GList *iter;
- DISPOSE (priv->source_list);
-
+ DISPOSE (priv->task_shell_backend);
DISPOSE (priv->task_shell_content);
DISPOSE (priv->task_shell_sidebar);
diff --git a/calendar/modules/e-task-shell-view-private.h b/calendar/modules/e-task-shell-view-private.h
index 415363730a..c613e9e9fe 100644
--- a/calendar/modules/e-task-shell-view-private.h
+++ b/calendar/modules/e-task-shell-view-private.h
@@ -47,6 +47,7 @@
#include "calendar/gui/dialogs/copy-source-dialog.h"
#include "calendar/gui/dialogs/task-editor.h"
+#include "e-task-shell-backend.h"
#include "e-task-shell-content.h"
#include "e-task-shell-sidebar.h"
#include "e-task-shell-view-actions.h"
@@ -93,13 +94,8 @@ enum {
struct _ETaskShellViewPrivate {
- /*** Module Data ***/
-
- ESourceList *source_list;
-
- /*** Other Stuff ***/
-
/* These are just for convenience. */
+ ETaskShellBackend *task_shell_backend;
ETaskShellContent *task_shell_content;
ETaskShellSidebar *task_shell_sidebar;
diff --git a/calendar/modules/e-task-shell-view.c b/calendar/modules/e-task-shell-view.c
index 3bf84100cc..5869be7a96 100644
--- a/calendar/modules/e-task-shell-view.c
+++ b/calendar/modules/e-task-shell-view.c
@@ -21,32 +21,10 @@
#include "e-task-shell-view-private.h"
-enum {
- PROP_0,
- PROP_SOURCE_LIST
-};
-
GType e_task_shell_view_type = 0;
static gpointer parent_class;
static void
-task_shell_view_get_property (GObject *object,
- guint property_id,
- GValue *value,
- GParamSpec *pspec)
-{
- switch (property_id) {
- case PROP_SOURCE_LIST:
- g_value_set_object (
- value, e_task_shell_view_get_source_list (
- E_TASK_SHELL_VIEW (object)));
- return;
- }
-
- G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
-}
-
-static void
task_shell_view_dispose (GObject *object)
{
e_task_shell_view_private_dispose (E_TASK_SHELL_VIEW (object));
@@ -223,7 +201,6 @@ task_shell_view_class_init (ETaskShellViewClass *class,
g_type_class_add_private (class, sizeof (ETaskShellViewPrivate));
object_class = G_OBJECT_CLASS (class);
- object_class->get_property = task_shell_view_get_property;
object_class->dispose = task_shell_view_dispose;
object_class->finalize = task_shell_view_finalize;
object_class->constructed = task_shell_view_constructed;
@@ -235,20 +212,9 @@ task_shell_view_class_init (ETaskShellViewClass *class,
shell_view_class->ui_manager_id = "org.gnome.evolution.tasks";
shell_view_class->search_options = "/task-search-options";
shell_view_class->search_rules = "tasktypes.xml";
- shell_view_class->type_module = type_module;
shell_view_class->new_shell_content = e_task_shell_content_new;
shell_view_class->new_shell_sidebar = e_task_shell_sidebar_new;
shell_view_class->update_actions = task_shell_view_update_actions;
-
- g_object_class_install_property (
- object_class,
- PROP_SOURCE_LIST,
- g_param_spec_object (
- "source-list",
- _("Source List"),
- _("The registry of task lists"),
- E_TYPE_SOURCE_LIST,
- G_PARAM_READABLE));
}
static void
@@ -286,11 +252,3 @@ e_task_shell_view_get_type (GTypeModule *type_module)
return e_task_shell_view_type;
}
-
-ESourceList *
-e_task_shell_view_get_source_list (ETaskShellView *task_shell_view)
-{
- g_return_val_if_fail (E_IS_TASK_SHELL_VIEW (task_shell_view), NULL);
-
- return task_shell_view->priv->source_list;
-}
diff --git a/calendar/modules/e-task-shell-view.h b/calendar/modules/e-task-shell-view.h
index cc5b2350c1..c94864b4b9 100644
--- a/calendar/modules/e-task-shell-view.h
+++ b/calendar/modules/e-task-shell-view.h
@@ -61,10 +61,7 @@ struct _ETaskShellViewClass {
EShellViewClass parent_class;
};
-GType e_task_shell_view_get_type
- (GTypeModule *type_module);
-ESourceList * e_task_shell_view_get_source_list
- (ETaskShellView *task_shell_view);
+GType e_task_shell_view_get_type (GTypeModule *type_module);
G_END_DECLS