aboutsummaryrefslogtreecommitdiffstats
path: root/calendar/gui/e-tasks.c
diff options
context:
space:
mode:
authorFederico Mena Quintero <federico@ximian.com>2001-01-17 18:44:33 +0800
committerFederico Mena Quintero <federico@src.gnome.org>2001-01-17 18:44:33 +0800
commit0932fd7ec9d21e763371a043283384af8bc987fb (patch)
treedbfd7dcaf49fd667712a6408eae165bd201c3219 /calendar/gui/e-tasks.c
parentff6098b51168decc542245a215056dc6219ebd69 (diff)
downloadgsoc2013-evolution-0932fd7ec9d21e763371a043283384af8bc987fb.tar
gsoc2013-evolution-0932fd7ec9d21e763371a043283384af8bc987fb.tar.gz
gsoc2013-evolution-0932fd7ec9d21e763371a043283384af8bc987fb.tar.bz2
gsoc2013-evolution-0932fd7ec9d21e763371a043283384af8bc987fb.tar.lz
gsoc2013-evolution-0932fd7ec9d21e763371a043283384af8bc987fb.tar.xz
gsoc2013-evolution-0932fd7ec9d21e763371a043283384af8bc987fb.tar.zst
gsoc2013-evolution-0932fd7ec9d21e763371a043283384af8bc987fb.zip
Ximianified email addresses and copyrights.
2001-01-17 Federico Mena Quintero <federico@ximian.com> * */*: Ximianified email addresses and copyrights. * idl/evolution-calendar.idl (CalFactory::open): Renamed from ::load(), and added an only_if_exists argument. (CalFactory::create): Removed method. (Listener::OpenStatus): Removed the IN_USE error and replaced it with a NOT_FOUND one; renamed the enum from LoadStatus. (Listener::notifyCalOpened): Renamed from notifyCalLoaded(). * pcs/cal-backend.h (CalBackend): Removed the uri field. (CalBackendOpenStatus): Renamed from CalBackendLoadStatus and added a NOT_FOUND value. (CalBackendClass::open): Put in a slot for the open method. * pcs/cal-backend.c (cal_backend_create): Removed function. * pcs/cal-backend-file.c (cal_backend_file_open): Return the appropriate value when only_if_exists is TRUE. (create_cal): We are Ximian now, so set the PRODID property to the appropriate foo. * pcs/cal-factory.c (CalFactory_open): implemented, replacing CalFactory_load() and CalFactory_create(). (CalFactory_open): Moved the queue_load_create_job() stuff to here, since we now only need to contemplate the open case instead of load/create ones. (open_backend): Do everything here; replaces load_backend() and create_backend(). * cal-client/cal-listener.h (CalListenerClass::cal_opened): Renamed from cal_loaded. (CalListenerClass): Replaced the silly signals, which are gratuitous abstraction, by a set of function pointers in the instance structure. * cal-client/cal-listener.c (cal_listener_get_calendar): Removed unused function. (cal_listener_construct): Added the listener notification functions. (cal_listener_new): Ditto. (Listener_notifyCalOpened): Renamed to our new naming convention for servant implementations. (Listener_notifyObjUpdated): Ditto. (Listener_notifyObjRemoved): Ditto. * cal-client/cal-client.h (CalClientOpenStatus): Renamed from CalClientLoadStatus. (CalClientClass::cal_opened): Renamed from ::cal_loaded(). (CalClientLoadState): New enum; basically make LoadState public so that users of this code do not have to maintain their own states. * cal-client/cal-client.c (cal_client_create_calendar): Removed function. (cal_client_open_calendar): Moved the functionality over from load_or_create(); now we do everything here. (*): Use the CalClientLoadState enum values instead of the old LoadState values. (cal_client_get_load_state): Renamed from cal_client_is_loaded(), and return the appropriate value. (CalClientPrivate): Added an uri field. (cal_client_init): Initialize priv->uri. (cal_client_destroy): Free the priv->uri. (cal_opened_cb): Maintain the priv->uri. (cal_client_open_calendar): Fill in the priv->uri. (cal_client_get_uri): New function. * gui/calendar-model.c (calendar_model_set_new_comp_vtype): New function to configure the type of calendar components to create when doing click-to-add. This makes the model usable for something other than task lists. (calendar_model_get_new_comp_vtype): New function. * gui/e-calendar-table.c (e_calendar_table_get_model): New function. (e_calendar_table_destroy): Unref the subset_model. * gui/gnome-cal.h (GnomeCalendarOpenMode): Removed enum. * gui/gnome-cal.c (LoadState): Removed enum; we now use the CalClientLoadState from the client objects. (GnomeCalendarPrivate): Removed the loading_uri and task_pad_loading_uri fields as well as the load_state and task_pad_load_state fields, as we can now query them directly from the CalClient. (open_error): Renamed from load_error(). (create_error): Removed function. (gnome_calendar_open): Do not take in the mode parameter. (cal_opened_cb): Get rid of our beautifully-crafted state machine and replace it with simple code; all the loading smarts are in the Wombat now. (setup_widgets): Set the new component vtype of the table model to CAL_COMPONENT_TODO. * gui/Makefile.am (evolution_calendar_SOURCES): Removed gnome-month-item.[ch] from the list of sources. * gui/calendar-summary.c (CalSummary): Removed unused cal_loaded field. (create_summary_view): Do not check if the file exists; this is the job of the Wombat. (generate_html_summary): Fixed prototype. (alarm_fn): Fixed prototype. (property_dialog): Fixed prototype. Wonder if/how this ever worked. (create_summary_view): Cast the component and view as appropriate. Removed unused html variable. [Iain dude, are you compiling with -Wall?] * gui/e-itip-control.c (cal_opened_cb): Sigh, this function signature was *very* wrong. It was using CalClientGetStatus instead of CalClientOpenStatus. * gui/e-tasks.h (ETasksOpenMode): Removed enum. * gui/e-tasks.c (setup_widgets): Set the new component vtype of the table model to CAL_COMPONENT_TODO. (LoadState): Removed the state machine foo. (e_tasks_open): Removed the mode parameter. (initial_load): Removed function. (create_error): Removed function. (ETasksPrivate): Removed folder_uri field. (cal_opened_cb): Remove the state machine. * gui/component-factory.c: #include "tasks-control.h" * conduits/calendar/calendar-conduit.h (ECalConduitContext): Removed calendar_load_tried field. * conduits/calendar/calendar-conduit.c (start_calendar_server_cb): Sigh, fixed function prototype. * conduits/todo/todo-conduit.h (EToDoConduitContext): Removed calendar_load_tried field. * conduits/todo/todo-conduit.c (start_calendar_server_cb): Fixed function prototype. svn path=/trunk/; revision=7571
Diffstat (limited to 'calendar/gui/e-tasks.c')
-rw-r--r--calendar/gui/e-tasks.c184
1 files changed, 34 insertions, 150 deletions
diff --git a/calendar/gui/e-tasks.c b/calendar/gui/e-tasks.c
index 29c067783a..9e88a91513 100644
--- a/calendar/gui/e-tasks.c
+++ b/calendar/gui/e-tasks.c
@@ -2,6 +2,7 @@
/* e-tasks.c
*
* Copyright (C) 2001 Helix Code, Inc.
+ * Copyright (C) 2001 Ximian, Inc.
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License as
@@ -18,8 +19,8 @@
* Free Software Foundation, Inc., 59 Temple Place - Suite 330,
* Boston, MA 02111-1307, USA.
*
- * Authors: Federico Mena Quintero <federico@helixcode.com>
- * Damon Chaplin <damon@helixcode.com>
+ * Authors: Federico Mena Quintero <federico@ximian.com>
+ * Damon Chaplin <damon@ximian.com>
*/
#include <config.h>
@@ -28,32 +29,16 @@
#include <gal/e-table/e-table-scrolled.h>
#include "dialogs/task-editor.h"
#include "e-calendar-table.h"
-#include "alarm-notify.h"
#include "component-factory.h"
#include "e-tasks.h"
-/* States for the calendar loading and creation state machine */
-typedef enum {
- LOAD_STATE_NOT_LOADED,
- LOAD_STATE_WAIT_LOAD,
- LOAD_STATE_WAIT_LOAD_BEFORE_CREATE,
- LOAD_STATE_WAIT_CREATE,
- LOAD_STATE_LOADED
-} LoadState;
-
/* Private part of the GnomeCalendar structure */
struct _ETasksPrivate {
/* The calendar client object we monitor */
CalClient *client;
- /* Loading state; we can be loading or creating a calendar */
- LoadState load_state;
-
- /* URI of the folder being shown. */
- char *folder_uri;
-
/* The ECalendarTable showing the tasks. */
GtkWidget *tasks_view;
@@ -68,7 +53,7 @@ static void e_tasks_init (ETasks *tasks);
static void setup_widgets (ETasks *tasks);
static void e_tasks_destroy (GtkObject *object);
-static void cal_loaded_cb (CalClient *client, CalClientLoadStatus status, gpointer data);
+static void cal_opened_cb (CalClient *client, CalClientOpenStatus status, gpointer data);
static void obj_updated_cb (CalClient *client, const char *uid, gpointer data);
static void obj_removed_cb (CalClient *client, const char *uid, gpointer data);
@@ -115,8 +100,6 @@ e_tasks_init (ETasks *tasks)
priv = g_new0 (ETasksPrivate, 1);
tasks->priv = priv;
- priv->load_state = LOAD_STATE_NOT_LOADED;
-
setup_widgets (tasks);
}
@@ -138,6 +121,7 @@ setup_widgets (ETasks *tasks)
ETasksPrivate *priv;
ETable *etable;
GtkWidget *hbox, *menuitem, *categories_label;
+ CalendarModel *model;
priv = tasks->priv;
@@ -165,13 +149,17 @@ setup_widgets (ETasks *tasks)
priv->tasks_view = e_calendar_table_new ();
+ model = e_calendar_table_get_model (E_CALENDAR_TABLE (priv->tasks_view));
+ calendar_model_set_new_comp_vtype (model, CAL_COMPONENT_TODO);
etable = e_table_scrolled_get_table (E_TABLE_SCROLLED (E_CALENDAR_TABLE (priv->tasks_view)->etable));
e_table_set_state (etable, E_TASKS_TABLE_DEFAULT_STATE);
gtk_table_attach (GTK_TABLE (tasks), priv->tasks_view, 0, 1, 1, 2,
GTK_EXPAND | GTK_FILL, GTK_EXPAND | GTK_FILL, 0, 0);
gtk_widget_show (priv->tasks_view);
- gtk_signal_connect (GTK_OBJECT (E_CALENDAR_TABLE (priv->tasks_view)->model), "categories-changed", GTK_SIGNAL_FUNC (e_tasks_on_categories_changed), tasks);
+ gtk_signal_connect (GTK_OBJECT (E_CALENDAR_TABLE (priv->tasks_view)->model),
+ "categories-changed",
+ GTK_SIGNAL_FUNC (e_tasks_on_categories_changed), tasks);
}
@@ -189,14 +177,16 @@ e_tasks_construct (ETasks *tasks)
if (!priv->client)
return NULL;
- gtk_signal_connect (GTK_OBJECT (priv->client), "cal_loaded",
- GTK_SIGNAL_FUNC (cal_loaded_cb), tasks);
+ gtk_signal_connect (GTK_OBJECT (priv->client), "cal_opened",
+ GTK_SIGNAL_FUNC (cal_opened_cb), tasks);
gtk_signal_connect (GTK_OBJECT (priv->client), "obj_updated",
GTK_SIGNAL_FUNC (obj_updated_cb), tasks);
gtk_signal_connect (GTK_OBJECT (priv->client), "obj_removed",
GTK_SIGNAL_FUNC (obj_removed_cb), tasks);
+#if 0
alarm_notify_add_client (priv->client);
+#endif
e_calendar_table_set_cal_client (E_CALENDAR_TABLE (priv->tasks_view),
priv->client);
@@ -241,15 +231,10 @@ e_tasks_destroy (GtkObject *object)
config_filename);
g_free (config_filename);
- priv->load_state = LOAD_STATE_NOT_LOADED;
-
- if (priv->folder_uri) {
- g_free (priv->folder_uri);
- priv->folder_uri = NULL;
- }
-
if (priv->client) {
+#if 0
alarm_notify_remove_client (priv->client);
+#endif
gtk_object_unref (GTK_OBJECT (priv->client));
priv->client = NULL;
}
@@ -264,8 +249,7 @@ e_tasks_destroy (GtkObject *object)
gboolean
e_tasks_open (ETasks *tasks,
- char *file,
- ETasksOpenMode gcom)
+ char *file)
{
ETasksPrivate *priv;
char *config_filename;
@@ -275,21 +259,6 @@ e_tasks_open (ETasks *tasks,
g_return_val_if_fail (file != NULL, FALSE);
priv = tasks->priv;
- g_return_val_if_fail (priv->load_state == LOAD_STATE_NOT_LOADED,
- FALSE);
-
- g_assert (priv->folder_uri == NULL);
-
- priv->folder_uri = g_strdup (file);
-
- if (gcom == E_TASKS_OPEN)
- priv->load_state = LOAD_STATE_WAIT_LOAD;
- else if (gcom == E_TASKS_OPEN_OR_CREATE)
- priv->load_state = LOAD_STATE_WAIT_LOAD_BEFORE_CREATE;
- else {
- g_assert_not_reached ();
- return FALSE;
- }
config_filename = e_tasks_get_config_filename (tasks);
e_calendar_table_load_state (E_CALENDAR_TABLE (priv->tasks_view),
@@ -297,11 +266,7 @@ e_tasks_open (ETasks *tasks,
g_free (config_filename);
- if (!cal_client_load_calendar (priv->client, file)) {
- priv->load_state = LOAD_STATE_NOT_LOADED;
- g_free (priv->folder_uri);
- priv->folder_uri = NULL;
-
+ if (!cal_client_open_calendar (priv->client, file, FALSE)) {
g_message ("e_tasks_open(): Could not issue the request");
return FALSE;
}
@@ -310,19 +275,6 @@ e_tasks_open (ETasks *tasks,
}
-/* Loads the initial data into the calendar; this should be called right after
- * the cal_loaded signal from the client is invoked.
- */
-static void
-initial_load (ETasks *tasks)
-{
- ETasksPrivate *priv;
-
- priv = tasks->priv;
-
- /* FIXME: Do we need to do anything? */
-}
-
/* Displays an error to indicate that loading a calendar failed */
static void
load_error (ETasks *tasks,
@@ -335,19 +287,6 @@ load_error (ETasks *tasks,
g_free (msg);
}
-/* Displays an error to indicate that creating a calendar failed */
-static void
-create_error (ETasks *tasks,
- const char *uri)
-{
- char *msg;
-
- msg = g_strdup_printf (_("Could not create a tasks file in `%s'"),
- uri);
- gnome_error_dialog_parented (msg, GTK_WINDOW (gtk_widget_get_toplevel (GTK_WIDGET (tasks))));
- g_free (msg);
-}
-
/* Displays an error to indicate that the specified URI method is not supported */
static void
method_error (ETasks *tasks,
@@ -360,89 +299,34 @@ method_error (ETasks *tasks,
g_free (msg);
}
-/* Callback from the calendar client when a calendar is loaded */
+/* Callback from the calendar client when a calendar is opened */
static void
-cal_loaded_cb (CalClient *client,
- CalClientLoadStatus status,
+cal_opened_cb (CalClient *client,
+ CalClientOpenStatus status,
gpointer data)
{
ETasks *tasks;
ETasksPrivate *priv;
- gboolean free_uri;
tasks = E_TASKS (data);
priv = tasks->priv;
- g_assert (priv->load_state != LOAD_STATE_NOT_LOADED
- && priv->load_state != LOAD_STATE_LOADED);
- g_assert (priv->folder_uri != NULL);
-
- free_uri = TRUE;
-
- switch (priv->load_state) {
- case LOAD_STATE_WAIT_LOAD:
- if (status == CAL_CLIENT_LOAD_SUCCESS) {
- priv->load_state = LOAD_STATE_LOADED;
- initial_load (tasks);
- } else if (status == CAL_CLIENT_LOAD_ERROR) {
- priv->load_state = LOAD_STATE_NOT_LOADED;
- load_error (tasks, priv->folder_uri);
- } else if (status == CAL_CLIENT_LOAD_METHOD_NOT_SUPPORTED) {
- priv->load_state = LOAD_STATE_NOT_LOADED;
- method_error (tasks, priv->folder_uri);
- } else
- g_assert_not_reached ();
+ switch (status) {
+ case CAL_CLIENT_OPEN_SUCCESS:
+ /* Everything is OK */
+ return;
+ case CAL_CLIENT_OPEN_ERROR:
+ load_error (tasks, cal_client_get_uri (client));
break;
- case LOAD_STATE_WAIT_LOAD_BEFORE_CREATE:
- if (status == CAL_CLIENT_LOAD_SUCCESS) {
- priv->load_state = LOAD_STATE_LOADED;
- initial_load (tasks);
- } else if (status == CAL_CLIENT_LOAD_ERROR) {
- priv->load_state = LOAD_STATE_WAIT_CREATE;
- free_uri = FALSE;
-
- if (!cal_client_create_calendar (priv->client,
- priv->folder_uri)) {
- priv->load_state = LOAD_STATE_NOT_LOADED;
- free_uri = TRUE;
- g_message ("cal_loaded_cb(): Could not issue the create request");
- }
- } else if (status == CAL_CLIENT_LOAD_METHOD_NOT_SUPPORTED) {
- priv->load_state = LOAD_STATE_NOT_LOADED;
- method_error (tasks, priv->folder_uri);
- } else
- g_assert_not_reached ();
-
- break;
-
- case LOAD_STATE_WAIT_CREATE:
- if (status == CAL_CLIENT_LOAD_SUCCESS) {
- priv->load_state = LOAD_STATE_LOADED;
- initial_load (tasks);
- } else if (status == CAL_CLIENT_LOAD_ERROR) {
- priv->load_state = LOAD_STATE_NOT_LOADED;
- create_error (tasks, priv->folder_uri);
- } else if (status == CAL_CLIENT_LOAD_IN_USE) {
- /* Someone created the URI while we were issuing the
- * create request, so we just try to reload.
- */
- priv->load_state = LOAD_STATE_WAIT_LOAD;
- free_uri = FALSE;
-
- if (!cal_client_load_calendar (priv->client,
- priv->folder_uri)) {
- priv->load_state = LOAD_STATE_NOT_LOADED;
- free_uri = TRUE;
- g_message ("cal_loaded_cb(): Could not issue the load request");
- }
- } else if (status == CAL_CLIENT_LOAD_METHOD_NOT_SUPPORTED) {
- priv->load_state = LOAD_STATE_NOT_LOADED;
- method_error (tasks, priv->folder_uri);
- } else
- g_assert_not_reached ();
+ case CAL_CLIENT_OPEN_NOT_FOUND:
+ /* bullshit; we did not specify only_if_exists */
+ g_assert_not_reached ();
+ return;
+ case CAL_CLIENT_OPEN_METHOD_NOT_SUPPORTED:
+ method_error (tasks, cal_client_get_uri (client));
break;
default:
@@ -491,7 +375,7 @@ e_tasks_get_config_filename (ETasks *tasks)
priv = tasks->priv;
- url = g_strdup (priv->folder_uri);
+ url = g_strdup (cal_client_get_uri (priv->client));
/* This turns all funny characters into '_', in the string itself. */
e_filename_make_safe (url);