aboutsummaryrefslogtreecommitdiffstats
path: root/calendar/gui
diff options
context:
space:
mode:
Diffstat (limited to 'calendar/gui')
-rw-r--r--calendar/gui/e-tasks.c39
-rw-r--r--calendar/gui/e-tasks.h13
-rw-r--r--calendar/gui/tasks-component.c15
-rw-r--r--calendar/gui/tasks-control.c13
4 files changed, 50 insertions, 30 deletions
diff --git a/calendar/gui/e-tasks.c b/calendar/gui/e-tasks.c
index 7b5abba0c9..d4d88a70eb 100644
--- a/calendar/gui/e-tasks.c
+++ b/calendar/gui/e-tasks.c
@@ -789,27 +789,31 @@ e_tasks_new_task (ETasks *tasks)
}
gboolean
-e_tasks_add_todo_uri (ETasks *tasks, const char *str_uri)
+e_tasks_add_todo_source (ETasks *tasks, ESource *source)
{
ETasksPrivate *priv;
ECal *client;
ECalModel *model;
+ char *str_uri;
GError *error = NULL;
g_return_val_if_fail (tasks != NULL, FALSE);
g_return_val_if_fail (E_IS_TASKS (tasks), FALSE);
- g_return_val_if_fail (str_uri != NULL, FALSE);
+ g_return_val_if_fail (E_IS_SOURCE (source), FALSE);
priv = tasks->priv;
+ str_uri = e_source_get_uri (source);
client = g_hash_table_lookup (priv->clients, str_uri);
- if (client)
+ if (client) {
+ g_free (str_uri);
return TRUE;
+ }
set_status_message (tasks, _("Opening tasks at %s"), str_uri);
- client = auth_new_cal_from_uri (str_uri, E_CAL_SOURCE_TYPE_TODO);
- g_hash_table_insert (priv->clients, g_strdup (str_uri), client);
+ client = auth_new_cal_from_source (source, E_CAL_SOURCE_TYPE_TODO);
+ g_hash_table_insert (priv->clients, str_uri, client);
priv->clients_list = g_list_prepend (priv->clients_list, client);
g_signal_connect (G_OBJECT (client), "backend_error", G_CALLBACK (backend_error_cb), tasks);
@@ -830,6 +834,9 @@ e_tasks_add_todo_uri (ETasks *tasks, const char *str_uri)
g_signal_handlers_disconnect_matched (client, G_SIGNAL_MATCH_DATA,
0, 0, NULL, NULL, tasks);
+ g_free (str_uri);
+ g_object_unref (client);
+
gtk_dialog_run (GTK_DIALOG (dialog));
gtk_widget_destroy (dialog);
@@ -849,21 +856,24 @@ e_tasks_add_todo_uri (ETasks *tasks, const char *str_uri)
}
gboolean
-e_tasks_remove_todo_uri (ETasks *tasks, const char *str_uri)
+e_tasks_remove_todo_source (ETasks *tasks, ESource *source)
{
ETasksPrivate *priv;
ECal *client;
ECalModel *model;
+ char *str_uri, *orig_uri;
g_return_val_if_fail (tasks != NULL, FALSE);
g_return_val_if_fail (E_IS_TASKS (tasks), FALSE);
- g_return_val_if_fail (str_uri != NULL, FALSE);
+ g_return_val_if_fail (E_IS_SOURCE (source), FALSE);
priv = tasks->priv;
- client = g_hash_table_lookup (priv->clients, str_uri);
- if (!client)
+ str_uri = e_source_get_uri (source);
+ if (!g_hash_table_lookup_extended (priv->clients, str_uri, &orig_uri, &client)) {
+ g_free (str_uri);
return TRUE;
+ }
g_hash_table_remove (priv->clients, str_uri);
priv->clients_list = g_list_remove (priv->clients_list, client);
@@ -873,24 +883,31 @@ e_tasks_remove_todo_uri (ETasks *tasks, const char *str_uri)
model = e_calendar_table_get_model (E_CALENDAR_TABLE (priv->tasks_view));
e_cal_model_remove_client (model, client);
+ g_free (str_uri);
+ g_free (orig_uri);
+ g_object_unref (client);
+
return TRUE;
}
gboolean
-e_tasks_set_default_uri (ETasks *tasks, const char *str_uri)
+e_tasks_set_default_source (ETasks *tasks, ESource *source)
{
ETasksPrivate *priv;
ECal *ecal;
ECalModel *model;
+ char *str_uri;
g_return_val_if_fail (tasks != NULL, FALSE);
g_return_val_if_fail (E_IS_TASKS (tasks), FALSE);
- g_return_val_if_fail (str_uri != NULL, FALSE);
+ g_return_val_if_fail (E_IS_SOURCE (source), FALSE);
priv = tasks->priv;
+ str_uri = e_source_get_uri (source);
model = e_calendar_table_get_model (E_CALENDAR_TABLE (priv->tasks_view));
ecal = e_cal_model_get_client_for_uri (model, str_uri);
+ g_free (str_uri);
if (!ecal)
return FALSE;
diff --git a/calendar/gui/e-tasks.h b/calendar/gui/e-tasks.h
index 4b6f3a6b75..fc3b1ebcfe 100644
--- a/calendar/gui/e-tasks.h
+++ b/calendar/gui/e-tasks.h
@@ -27,6 +27,7 @@
#include <bonobo/bonobo-ui-component.h>
#include <gtk/gtktable.h>
+#include <libedataserver/e-source.h>
#include <libecal/e-cal.h>
#include "e-calendar-table.h"
@@ -61,13 +62,13 @@ GtkWidget *e_tasks_construct (ETasks *tasks);
GtkWidget *e_tasks_new (void);
-void e_tasks_set_ui_component (ETasks *tasks,
- BonoboUIComponent *ui_component);
+void e_tasks_set_ui_component (ETasks *tasks,
+ BonoboUIComponent *ui_component);
-gboolean e_tasks_add_todo_uri (ETasks *tasks, const char *str_uri);
-gboolean e_tasks_remove_todo_uri (ETasks *tasks, const char *str_uri);
-gboolean e_tasks_set_default_uri (ETasks *tasks, const char *str_uri);
-ECal *e_tasks_get_default_client (ETasks *tasks);
+gboolean e_tasks_add_todo_source (ETasks *tasks, ESource *source);
+gboolean e_tasks_remove_todo_source (ETasks *tasks, ESource *source);
+gboolean e_tasks_set_default_source (ETasks *tasks, ESource *source);
+ECal *e_tasks_get_default_client (ETasks *tasks);
void e_tasks_open_task (ETasks *tasks);
void e_tasks_new_task (ETasks *tasks);
diff --git a/calendar/gui/tasks-component.c b/calendar/gui/tasks-component.c
index a07095d571..d4de27f90c 100644
--- a/calendar/gui/tasks-component.c
+++ b/calendar/gui/tasks-component.c
@@ -84,19 +84,13 @@ struct _TasksComponentPrivate {
static void
add_uri_for_source (ESource *source, ETasks *tasks)
{
- char *uri = e_source_get_uri (source);
-
- e_tasks_add_todo_uri (tasks, uri);
- g_free (uri);
+ e_tasks_add_todo_source (tasks, source);
}
static void
remove_uri_for_source (ESource *source, ETasks *tasks)
{
- char *uri = e_source_get_uri (source);
-
- e_tasks_remove_todo_uri (tasks, uri);
- g_free (uri);
+ e_tasks_remove_todo_source (tasks, source);
}
static gboolean
@@ -186,7 +180,6 @@ update_uri_for_primary_selection (TasksComponent *component)
{
TasksComponentPrivate *priv;
ESource *source;
- char *uri;
ECalendarTable *cal_table;
ETable *etable;
@@ -197,9 +190,7 @@ update_uri_for_primary_selection (TasksComponent *component)
return;
/* Set the default */
- uri = e_source_get_uri (source);
- e_tasks_set_default_uri (priv->tasks, uri);
- g_free (uri);
+ e_tasks_set_default_source (priv->tasks, source);
cal_table = e_tasks_get_calendar_table (priv->tasks);
etable = e_calendar_table_get_table (cal_table);
diff --git a/calendar/gui/tasks-control.c b/calendar/gui/tasks-control.c
index f0064d0789..9e0d3fe286 100644
--- a/calendar/gui/tasks-control.c
+++ b/calendar/gui/tasks-control.c
@@ -192,13 +192,20 @@ tasks_control_set_property (BonoboPropertyBag *bag,
{
ETasks *tasks = user_data;
char *uri;
+ ESource *source;
+ ESourceGroup *group;
switch (arg_id) {
case TASKS_CONTROL_PROPERTY_URI_IDX:
/* FIXME Remove the old uri? */
uri = BONOBO_ARG_GET_STRING (arg);
- if (!e_tasks_add_todo_uri (tasks, uri)) {
+
+ group = e_source_group_new ("", uri);
+ source = e_source_new ("", "");
+ e_source_set_group (source, group);
+
+ if (!e_tasks_add_todo_source (tasks, source)) {
char *msg;
msg = g_strdup_printf (_("Could not load the tasks in `%s'"), uri);
@@ -207,6 +214,10 @@ tasks_control_set_property (BonoboPropertyBag *bag,
GTK_WINDOW (gtk_widget_get_toplevel (GTK_WIDGET (tasks))));
g_free (msg);
}
+
+ g_object_unref (source);
+ g_object_unref (group);
+
break;
default: