aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorRodrigo Moya <rodrigo@ximian.com>2004-01-22 01:55:44 +0800
committerRodrigo Moya <rodrigo@src.gnome.org>2004-01-22 01:55:44 +0800
commit4e676f28fcd8bb7e5430c696bb6e6b711e18bf25 (patch)
treeb20fdca549b69f10c583e46d4fe5707664c14f6c
parent29ca7c6778a87c64230982432ee9364c95f5c614 (diff)
downloadgsoc2013-evolution-4e676f28fcd8bb7e5430c696bb6e6b711e18bf25.tar.gz
gsoc2013-evolution-4e676f28fcd8bb7e5430c696bb6e6b711e18bf25.tar.zst
gsoc2013-evolution-4e676f28fcd8bb7e5430c696bb6e6b711e18bf25.zip
renamed to _source and made them work with ESource's.
2004-01-21 Rodrigo Moya <rodrigo@ximian.com> * gui/e-tasks.[ch] (e_tasks_add_todo_uri, e_tasks_remove_todo_uri, e_tasks_get_default_uri): renamed to _source and made them work with ESource's. * gui/tasks-component.c (update_uri_for_primary_selection, add_uri_for_source, remove_uri_for_source): * gui/tasks-control.c (tasks_control_set_property): updated for changes in e-tasks.[ch]. svn path=/trunk/; revision=24354
-rw-r--r--calendar/ChangeLog11
-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
5 files changed, 61 insertions, 30 deletions
diff --git a/calendar/ChangeLog b/calendar/ChangeLog
index 409c1bc54c..f68f74af3a 100644
--- a/calendar/ChangeLog
+++ b/calendar/ChangeLog
@@ -1,5 +1,16 @@
2004-01-21 Rodrigo Moya <rodrigo@ximian.com>
+ * gui/e-tasks.[ch] (e_tasks_add_todo_uri, e_tasks_remove_todo_uri,
+ e_tasks_get_default_uri): renamed to _source and made them work
+ with ESource's.
+
+ * gui/tasks-component.c (update_uri_for_primary_selection,
+ add_uri_for_source, remove_uri_for_source):
+ * gui/tasks-control.c (tasks_control_set_property): updated for
+ changes in e-tasks.[ch].
+
+2004-01-21 Rodrigo Moya <rodrigo@ximian.com>
+
* gui/dialogs/calendar-setup.c (create_new_source_with_group):
added 'ECalSourceType' argument to be able to create the
ECal correctly. Added a call to e_cal_open with 'only_if_exists'
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: