aboutsummaryrefslogtreecommitdiffstats
path: root/calendar/gui/gnome-cal.c
diff options
context:
space:
mode:
Diffstat (limited to 'calendar/gui/gnome-cal.c')
-rw-r--r--calendar/gui/gnome-cal.c1167
1 files changed, 157 insertions, 1010 deletions
diff --git a/calendar/gui/gnome-cal.c b/calendar/gui/gnome-cal.c
index e2fbd0f476..25b0336d16 100644
--- a/calendar/gui/gnome-cal.c
+++ b/calendar/gui/gnome-cal.c
@@ -53,7 +53,6 @@
#include "e-comp-editor-registry.h"
#include "dialogs/delete-error.h"
#include "dialogs/event-editor.h"
-#include "dialogs/task-editor.h"
#include "comp-util.h"
#include "e-cal-model-calendar.h"
#include "e-day-view.h"
@@ -65,11 +64,9 @@
#include "e-cal-list-view-config.h"
#include "e-mini-calendar-config.h"
#include "e-calendar-table-config.h"
-#include "e-memo-table-config.h"
#include "evolution-calendar.h"
#include "gnome-cal.h"
#include "calendar-component.h"
-#include "memos-component.h"
#include "cal-search-bar.h"
#include "calendar-commands.h"
#include "calendar-config.h"
@@ -77,11 +74,10 @@
#include "calendar-view-factory.h"
#include "tag-calendar.h"
#include "misc.h"
-#include "ea-calendar.h"
+#include "a11y/ea-calendar.h"
#include "common/authentication.h"
#include "e-cal-popup.h"
#include "e-cal-menu.h"
-#include "e-cal-model-tasks.h"
/* FIXME glib 2.4 and above has this */
#ifndef G_MAXINT32
@@ -97,9 +93,9 @@ static GHashTable *non_intrusive_error_table = NULL;
struct _GnomeCalendarPrivate {
/* The clients for display */
- GHashTable *clients[E_CAL_SOURCE_TYPE_LAST];
- GList *clients_list[E_CAL_SOURCE_TYPE_LAST];
- ECal *default_client[E_CAL_SOURCE_TYPE_LAST];
+ GHashTable *clients;
+ GList *clients_list;
+ ECal *default_client;
/*
* Fields for the calendar view
@@ -118,11 +114,6 @@ struct _GnomeCalendarPrivate {
ECalendar *date_navigator;
EMiniCalendarConfig *date_navigator_config;
- GtkWidget *todo;
- ECalendarTableConfig *todo_config;
-
- GtkWidget *memo;
- EMemoTableConfig *memo_config;
GtkWidget *day_view;
GtkWidget *work_week_view;
@@ -135,8 +126,6 @@ struct _GnomeCalendarPrivate {
/* plugin menu managers */
ECalMenu *calendar_menu;
- ECalMenu *taskpad_menu;
- ECalMenu *memopad_menu;
/* Calendar query for the date navigator */
GList *dn_queries; /* list of CalQueries */
@@ -167,10 +156,6 @@ struct _GnomeCalendarPrivate {
/* The signal handler id for our GtkCalendar "day_selected" handler. */
guint day_selected_id;
- /* View instance and menus for the control */
- GalViewInstance *view_instance;
- GalViewMenus *view_menus;
-
/* Our current week start */
gint week_start;
@@ -201,11 +186,6 @@ struct _GnomeCalendarPrivate {
enum {
DATES_SHOWN_CHANGED,
CALENDAR_SELECTION_CHANGED,
- TASKPAD_SELECTION_CHANGED,
- MEMOPAD_SELECTION_CHANGED,
- CALENDAR_FOCUS_CHANGE,
- TASKPAD_FOCUS_CHANGE,
- MEMOPAD_FOCUS_CHANGE,
GOTO_DATE,
SOURCE_ADDED,
SOURCE_REMOVED,
@@ -213,14 +193,6 @@ enum {
LAST_SIGNAL
};
-/* Used to indicate who has the focus within the calendar view */
-typedef enum {
- FOCUS_CALENDAR,
- FOCUS_TASKPAD,
- FOCUS_MEMOPAD,
- FOCUS_OTHER
-} FocusLocation;
-
static guint gnome_calendar_signals[LAST_SIGNAL];
@@ -317,55 +289,6 @@ gnome_calendar_class_init (GnomeCalendarClass *class)
g_cclosure_marshal_VOID__VOID,
G_TYPE_NONE, 0);
- gnome_calendar_signals[TASKPAD_SELECTION_CHANGED] =
- g_signal_new ("taskpad_selection_changed",
- G_TYPE_FROM_CLASS (object_class),
- G_SIGNAL_RUN_LAST,
- G_STRUCT_OFFSET (GnomeCalendarClass, taskpad_selection_changed),
- NULL, NULL,
- g_cclosure_marshal_VOID__VOID,
- G_TYPE_NONE, 0);
-
- gnome_calendar_signals[MEMOPAD_SELECTION_CHANGED] =
- g_signal_new ("memopad_selection_changed",
- G_TYPE_FROM_CLASS (object_class),
- G_SIGNAL_RUN_LAST,
- G_STRUCT_OFFSET (GnomeCalendarClass, memopad_selection_changed),
- NULL, NULL,
- g_cclosure_marshal_VOID__VOID,
- G_TYPE_NONE, 0);
-
-
- gnome_calendar_signals[CALENDAR_FOCUS_CHANGE] =
- g_signal_new ("calendar_focus_change",
- G_TYPE_FROM_CLASS (object_class),
- G_SIGNAL_RUN_FIRST,
- G_STRUCT_OFFSET (GnomeCalendarClass, calendar_focus_change),
- NULL, NULL,
- g_cclosure_marshal_VOID__BOOLEAN,
- G_TYPE_NONE, 1,
- G_TYPE_BOOLEAN);
-
- gnome_calendar_signals[TASKPAD_FOCUS_CHANGE] =
- g_signal_new ("taskpad_focus_change",
- G_TYPE_FROM_CLASS (object_class),
- G_SIGNAL_RUN_FIRST,
- G_STRUCT_OFFSET (GnomeCalendarClass, taskpad_focus_change),
- NULL, NULL,
- g_cclosure_marshal_VOID__BOOLEAN,
- G_TYPE_NONE, 1,
- G_TYPE_BOOLEAN);
-
- gnome_calendar_signals[MEMOPAD_FOCUS_CHANGE] =
- g_signal_new ("memopad_focus_change",
- G_TYPE_FROM_CLASS (object_class),
- G_SIGNAL_RUN_FIRST,
- G_STRUCT_OFFSET (GnomeCalendarClass, memopad_focus_change),
- NULL, NULL,
- g_cclosure_marshal_VOID__BOOLEAN,
- G_TYPE_NONE, 1,
- G_TYPE_BOOLEAN);
-
gnome_calendar_signals[SOURCE_ADDED] =
g_signal_new ("source_added",
G_TYPE_FROM_CLASS (object_class),
@@ -414,11 +337,6 @@ gnome_calendar_class_init (GnomeCalendarClass *class)
class->dates_shown_changed = NULL;
class->calendar_selection_changed = NULL;
- class->taskpad_selection_changed = NULL;
- class->memopad_selection_changed = NULL;
- class->calendar_focus_change = NULL;
- class->taskpad_focus_change = NULL;
- class->memopad_focus_change = NULL;
class->source_added = NULL;
class->source_removed = NULL;
class->goto_date = gnome_calendar_goto_date;
@@ -734,69 +652,6 @@ get_times_for_views (GnomeCalendar *gcal, GnomeCalendarViewType view_type, time_
}
}
-/* Gets the focus location based on who is the focused widget within the
- * calendar view.
- */
-static FocusLocation
-get_focus_location (GnomeCalendar *gcal)
-{
- GnomeCalendarPrivate *priv;
- ETable *etable, *m_etable;
-
- priv = gcal->priv;
-
- etable = e_calendar_table_get_table (E_CALENDAR_TABLE (priv->todo));
- m_etable = e_memo_table_get_table (E_MEMO_TABLE (priv->memo));
-
- if (GTK_WIDGET_HAS_FOCUS (etable->table_canvas))
- return FOCUS_TASKPAD;
- else if (GTK_WIDGET_HAS_FOCUS (m_etable->table_canvas))
- return FOCUS_MEMOPAD;
- else {
- GtkWidget *widget;
- EDayView *dv;
- EWeekView *wv;
- ECalListView *lv;
-
- widget = gnome_calendar_get_current_view_widget (gcal);
-
- switch (priv->current_view_type) {
- case GNOME_CAL_DAY_VIEW:
- case GNOME_CAL_WORK_WEEK_VIEW:
- dv = E_DAY_VIEW (widget);
-
- if (GTK_WIDGET_HAS_FOCUS (dv->top_canvas)
- || GNOME_CANVAS (dv->top_canvas)->focused_item != NULL
- || GTK_WIDGET_HAS_FOCUS (dv->main_canvas)
- || GNOME_CANVAS (dv->main_canvas)->focused_item != NULL)
- return FOCUS_CALENDAR;
- else
- return FOCUS_OTHER;
-
- case GNOME_CAL_WEEK_VIEW:
- case GNOME_CAL_MONTH_VIEW:
- wv = E_WEEK_VIEW (widget);
-
- if (GTK_WIDGET_HAS_FOCUS (wv->main_canvas)
- || GNOME_CANVAS (wv->main_canvas)->focused_item != NULL)
- return FOCUS_CALENDAR;
- else
- return FOCUS_OTHER;
-
- case GNOME_CAL_LIST_VIEW:
- lv = E_CAL_LIST_VIEW (widget);
-
- if (GTK_WIDGET_HAS_FOCUS (e_table_scrolled_get_table (lv->table_scrolled)))
- return FOCUS_CALENDAR;
- else
- return FOCUS_OTHER;
-
- default:
- g_return_val_if_reached (FOCUS_OTHER);
- }
- }
-}
-
/* Computes the range of time that the date navigator is showing */
static void
get_date_navigator_range (GnomeCalendar *gcal, time_t *start_time, time_t *end_time)
@@ -900,7 +755,7 @@ update_query_async (struct _date_query_msg *msg)
}
/* create queries for each loaded client */
- for (l = priv->clients_list[E_CAL_SOURCE_TYPE_EVENT]; l != NULL; l = l->next) {
+ for (l = priv->clients_list; l != NULL; l = l->next) {
GError *error = NULL;
gint tries = 0;
@@ -1070,8 +925,9 @@ search_bar_category_changed_cb (CalSearchBar *cal_search, const gchar *category,
category);
}
+ /* [KILL-BONOBO] Delete this when moved to ECalShellView.
model = e_calendar_table_get_model (E_CALENDAR_TABLE (priv->todo));
- e_cal_model_set_default_category (model, category);
+ e_cal_model_set_default_category (model, category); */
}
static void
@@ -1122,112 +978,6 @@ user_created_cb (GtkWidget *view, GnomeCalendar *gcal)
}
-/* Callback used when the taskpad receives a focus event. We emit the
- * corresponding signal so that parents can change the menus as appropriate.
- */
-static gint
-table_canvas_focus_change_cb (GtkWidget *widget, GdkEventFocus *event, gpointer data)
-{
- GnomeCalendar *gcal;
-
- gcal = GNOME_CALENDAR (data);
-
- g_signal_emit (gcal, gnome_calendar_signals [TASKPAD_FOCUS_CHANGE], 0,
- event->in ? TRUE : FALSE);
-
- return FALSE;
-}
-
-static gint
-memo_canvas_focus_change_cb (GtkWidget *widget, GdkEventFocus *event, gpointer data)
-{
- GnomeCalendar *gcal;
-
- gcal = GNOME_CALENDAR (data);
-
- g_signal_emit (gcal, gnome_calendar_signals [MEMOPAD_FOCUS_CHANGE], 0,
- event->in ? TRUE : FALSE);
-
- return FALSE;
-}
-
-static gint
-calendar_focus_change_cb (GtkWidget *widget, GdkEventFocus *event, gpointer data)
-{
- GnomeCalendar *gcal;
-
- gcal = GNOME_CALENDAR (data);
-
- g_signal_emit (gcal, gnome_calendar_signals [CALENDAR_FOCUS_CHANGE], 0,
- event->in ? TRUE : FALSE);
-
- return FALSE;
-}
-
-/* Connects to the focus change signals of a day view widget */
-static void
-connect_day_view_focus (GnomeCalendar *gcal, EDayView *dv)
-{
- g_signal_connect_after (dv->top_canvas, "focus_in_event",
- G_CALLBACK (calendar_focus_change_cb), gcal);
- g_signal_connect_after (dv->top_canvas, "focus_out_event",
- G_CALLBACK (calendar_focus_change_cb), gcal);
-
- g_signal_connect_after (dv->main_canvas, "focus_in_event",
- G_CALLBACK (calendar_focus_change_cb), gcal);
- g_signal_connect_after (dv->main_canvas, "focus_out_event",
- G_CALLBACK (calendar_focus_change_cb), gcal);
-}
-
-/* Connects to the focus change signals of a week view widget */
-static void
-connect_week_view_focus (GnomeCalendar *gcal, EWeekView *wv)
-{
- if (!E_IS_WEEK_VIEW (wv))
- return;
-
- g_signal_connect (wv->main_canvas, "focus_in_event",
- G_CALLBACK (calendar_focus_change_cb), gcal);
- g_signal_connect (wv->main_canvas, "focus_out_event",
- G_CALLBACK (calendar_focus_change_cb), gcal);
-}
-
-static void
-connect_list_view_focus (GnomeCalendar *gcal, ECalListView *lv)
-{
- ETable *etable;
-
- etable = e_table_scrolled_get_table (lv->table_scrolled);
-
- g_signal_connect (etable->table_canvas, "focus_in_event",
- G_CALLBACK (calendar_focus_change_cb), gcal);
- g_signal_connect (etable->table_canvas, "focus_out_event",
- G_CALLBACK (calendar_focus_change_cb), gcal);
-}
-
-/* Callback used when the selection in the taskpad table changes. We just proxy
- * the signal with our own one.
- */
-static void
-table_selection_change_cb (ETable *etable, gpointer data)
-{
- GnomeCalendar *gcal;
-
- gcal = GNOME_CALENDAR (data);
-
- g_signal_emit (gcal, gnome_calendar_signals[TASKPAD_SELECTION_CHANGED], 0);
-}
-
-static void
-memo_selection_change_cb (ETable *etable, gpointer data)
-{
- GnomeCalendar *gcal;
-
- gcal = GNOME_CALENDAR (data);
-
- g_signal_emit (gcal, gnome_calendar_signals[MEMOPAD_SELECTION_CHANGED], 0);
-}
-
static void
set_week_start (GnomeCalendar *calendar)
{
@@ -1280,27 +1030,18 @@ static void
set_timezone (GnomeCalendar *calendar)
{
GnomeCalendarPrivate *priv;
- gint i;
+ GList *l;
priv = calendar->priv;
priv->zone = calendar_config_get_icaltimezone ();
- for (i = 0; i < E_CAL_SOURCE_TYPE_LAST; i++) {
- GList *l;
-
- for (l = priv->clients_list[i]; l != NULL; l = l->next) {
- ECal *client = l->data;
-
- if (e_cal_get_load_state (client) == E_CAL_LOAD_LOADED)
- /* FIXME Error checking */
- e_cal_set_default_timezone (client, priv->zone, NULL);
- }
+ for (l = priv->clients_list; l != NULL; l = l->next) {
+ ECal *client = l->data;
- if (priv->default_client[i]
- && e_cal_get_load_state (priv->default_client[i]) == E_CAL_LOAD_LOADED)
+ if (e_cal_get_load_state (client) == E_CAL_LOAD_LOADED)
/* FIXME Error checking */
- e_cal_set_default_timezone (priv->default_client[i], priv->zone, NULL);
+ e_cal_set_default_timezone (client, priv->zone, NULL);
}
if (priv->views [priv->current_view_type])
@@ -1594,26 +1335,15 @@ categories_changed_cb (gpointer object, gpointer user_data)
static void
view_progress_cb (ECalModel *model, const gchar *message, gint percent, ECalSourceType type, GnomeCalendar *gcal)
{
- if (type == E_CAL_SOURCE_TYPE_EVENT) {
+ if (type == E_CAL_SOURCE_TYPE_EVENT)
e_calendar_view_set_status_message (E_CALENDAR_VIEW (gcal->priv->week_view), message, percent);
- } else if (type == E_CAL_SOURCE_TYPE_TODO) {
- e_calendar_table_set_status_message (E_CALENDAR_TABLE (gcal->priv->todo), message, percent);
- } else if (type == E_CAL_SOURCE_TYPE_JOURNAL) {
- e_memo_table_set_status_message (E_MEMO_TABLE (gcal->priv->memo), message);
- }
}
static void
view_done_cb (ECalModel *model, ECalendarStatus status, ECalSourceType type, GnomeCalendar *gcal)
{
- if (type == E_CAL_SOURCE_TYPE_EVENT) {
+ if (type == E_CAL_SOURCE_TYPE_EVENT)
e_calendar_view_set_status_message (E_CALENDAR_VIEW (gcal->priv->week_view), NULL, -1);
- } else if (type == E_CAL_SOURCE_TYPE_TODO) {
- e_calendar_table_set_status_message (E_CALENDAR_TABLE (gcal->priv->todo), NULL, -1);
- } else if (type == E_CAL_SOURCE_TYPE_JOURNAL) {
- e_memo_table_set_status_message (E_MEMO_TABLE (gcal->priv->memo), NULL);
- }
-
}
GtkWidget *
@@ -1718,36 +1448,11 @@ setup_widgets (GnomeCalendar *gcal)
g_free (tmp);
gtk_box_pack_start ((GtkBox *)vbox, label, FALSE, TRUE, 0);
- priv->todo = e_calendar_table_new ();
- priv->todo_config = e_calendar_table_config_new (E_CALENDAR_TABLE (priv->todo));
- gtk_paned_pack1 (GTK_PANED (priv->vpane), vbox, FALSE, FALSE);
- gtk_box_pack_end ((GtkBox *)vbox, priv->todo, TRUE, TRUE, 0);
-
- gtk_widget_show (priv->todo);
gtk_widget_show (label);
gtk_widget_show (vbox);
gtk_widget_show (sep);
- filename = g_build_filename (calendar_component_peek_config_directory (calendar_component_peek ()),
- "TaskPad", NULL);
- e_calendar_table_load_state (E_CALENDAR_TABLE (priv->todo), filename);
-
/* update_todo_view (gcal); */
- g_free (filename);
-
- etable = e_calendar_table_get_table (E_CALENDAR_TABLE (priv->todo));
- g_signal_connect (etable->table_canvas, "focus_in_event",
- G_CALLBACK (table_canvas_focus_change_cb), gcal);
- g_signal_connect (etable->table_canvas, "focus_out_event",
- G_CALLBACK (table_canvas_focus_change_cb), gcal);
-
- g_signal_connect (etable, "selection_change",
- G_CALLBACK (table_selection_change_cb), gcal);
-
- g_signal_connect (e_calendar_table_get_model ((ECalendarTable *)priv->todo), "cal_view_progress",
- G_CALLBACK (view_progress_cb), gcal);
- g_signal_connect (e_calendar_table_get_model ((ECalendarTable *)priv->todo), "cal_view_done",
- G_CALLBACK (view_done_cb), gcal);
/* Timeout check to hide completed items */
priv->update_timeout = g_timeout_add_full (G_PRIORITY_LOW, 60000, (GSourceFunc) update_todo_view_cb, gcal, NULL);
@@ -1762,7 +1467,6 @@ setup_widgets (GnomeCalendar *gcal)
e_calendar_view_set_timezone (E_CALENDAR_VIEW (priv->day_view), priv->zone);
g_signal_connect (priv->day_view, "selection_changed",
G_CALLBACK (view_selection_changed_cb), gcal);
- connect_day_view_focus (gcal, E_DAY_VIEW (priv->day_view));
/* The Work Week View. */
priv->work_week_view = e_day_view_new (cal_model);
@@ -1771,7 +1475,6 @@ setup_widgets (GnomeCalendar *gcal)
e_day_view_set_days_shown (E_DAY_VIEW (priv->work_week_view), 5);
e_calendar_view_set_calendar (E_CALENDAR_VIEW (priv->work_week_view), gcal);
e_calendar_view_set_timezone (E_CALENDAR_VIEW (priv->work_week_view), priv->zone);
- connect_day_view_focus (gcal, E_DAY_VIEW (priv->work_week_view));
/* The Marcus Bains line */
priv->update_marcus_bains_line_timeout = g_timeout_add_full (G_PRIORITY_LOW, 60000, (GSourceFunc) update_marcus_bains_line_cb, gcal, NULL);
@@ -1783,8 +1486,6 @@ setup_widgets (GnomeCalendar *gcal)
g_signal_connect (priv->week_view, "selection_changed",
G_CALLBACK (view_selection_changed_cb), gcal);
- connect_week_view_focus (gcal, E_WEEK_VIEW (priv->week_view));
-
adjustment = gtk_range_get_adjustment (GTK_RANGE (E_WEEK_VIEW (priv->week_view)->vscrollbar));
g_signal_connect (adjustment, "value_changed",
G_CALLBACK (week_view_adjustment_changed_cb),
@@ -1804,8 +1505,6 @@ setup_widgets (GnomeCalendar *gcal)
g_signal_connect (priv->month_view, "selection_changed",
G_CALLBACK (view_selection_changed_cb), gcal);
- connect_week_view_focus (gcal, E_WEEK_VIEW (priv->month_view));
-
adjustment = gtk_range_get_adjustment (GTK_RANGE (E_WEEK_VIEW (priv->month_view)->vscrollbar));
g_signal_connect (adjustment, "value_changed",
G_CALLBACK (month_view_adjustment_changed_cb),
@@ -1819,8 +1518,6 @@ setup_widgets (GnomeCalendar *gcal)
g_signal_connect (priv->list_view, "selection_changed",
G_CALLBACK (view_selection_changed_cb), gcal);
- connect_list_view_focus (gcal, E_CAL_LIST_VIEW (priv->list_view));
-
priv->views[GNOME_CAL_DAY_VIEW] = E_CALENDAR_VIEW (priv->day_view);
priv->configs[GNOME_CAL_DAY_VIEW] = G_OBJECT (e_day_view_config_new (E_DAY_VIEW (priv->views[GNOME_CAL_DAY_VIEW])));
priv->views[GNOME_CAL_WORK_WEEK_VIEW] = E_CALENDAR_VIEW (priv->work_week_view);
@@ -1849,38 +1546,14 @@ setup_widgets (GnomeCalendar *gcal)
gtk_label_set_markup ((GtkLabel *)label, tmp);
g_free (tmp);
gtk_box_pack_start ((GtkBox *)vbox, label, FALSE, TRUE, 0);
- priv->memo = e_memo_table_new ();
- priv->memo_config = e_memo_table_config_new (E_MEMO_TABLE (priv->memo));
- gtk_paned_pack2 (GTK_PANED (priv->vpane), vbox, TRUE, FALSE);
- gtk_box_pack_end ((GtkBox *)vbox, priv->memo, TRUE, TRUE, 0);
-
- gtk_widget_show (priv->memo);
gtk_widget_show (label);
gtk_widget_show (vbox);
- filename = g_build_filename (memos_component_peek_config_directory (memos_component_peek ()),
- "MemoPad", NULL);
- e_memo_table_load_state (E_MEMO_TABLE (priv->memo), filename);
+ e_cal_model_set_default_time_func (e_memo_table_get_model (E_MEMO_TABLE (priv->memo)), gc_get_default_time, gcal);
e_cal_model_set_default_time_func (e_memo_table_get_model (E_MEMO_TABLE (priv->memo)), gc_get_default_time, gcal);
update_memo_view (gcal);
- g_free (filename);
-
- etable = e_memo_table_get_table (E_MEMO_TABLE (priv->memo));
- g_signal_connect (etable->table_canvas, "focus_in_event",
- G_CALLBACK (memo_canvas_focus_change_cb), gcal);
- g_signal_connect (etable->table_canvas, "focus_out_event",
- G_CALLBACK (memo_canvas_focus_change_cb), gcal);
-
- g_signal_connect (etable, "selection_change",
- G_CALLBACK (memo_selection_change_cb), gcal);
-
- g_signal_connect (e_memo_table_get_model ((EMemoTable *)priv->memo), "cal_view_progress",
- G_CALLBACK (view_progress_cb), gcal);
- g_signal_connect (e_memo_table_get_model ((EMemoTable *)priv->memo), "cal_view_done",
- G_CALLBACK (view_done_cb), gcal);
-
}
/* Object initialization function for the gnome calendar */
@@ -1888,13 +1561,14 @@ static void
gnome_calendar_init (GnomeCalendar *gcal)
{
GnomeCalendarPrivate *priv;
- gint i;
priv = g_new0 (GnomeCalendarPrivate, 1);
gcal->priv = priv;
- for (i = 0; i < E_CAL_SOURCE_TYPE_LAST; i++)
- priv->clients[i] = g_hash_table_new_full (g_str_hash, g_str_equal, g_free, g_object_unref);
+ priv->clients = g_hash_table_new_full (g_str_hash, g_str_equal, g_free, g_object_unref);
+
+ if (non_intrusive_error_table == NULL)
+ non_intrusive_error_table = g_hash_table_new_full (g_str_hash, g_str_equal, g_free, g_object_unref);
if (non_intrusive_error_table == NULL)
non_intrusive_error_table = g_hash_table_new_full (g_str_hash, g_str_equal, g_free, g_object_unref);
@@ -1911,8 +1585,6 @@ gnome_calendar_init (GnomeCalendar *gcal)
setup_widgets (gcal);
priv->calendar_menu = e_cal_menu_new("org.gnome.evolution.calendar.view");
- priv->taskpad_menu = e_cal_menu_new("org.gnome.evolution.calendar.taskpad");
- priv->memopad_menu = e_cal_menu_new ("org.gnome.evolution.calendar.memopad");
priv->dn_queries = NULL;
priv->sexp = g_strdup ("#t"); /* Match all */
@@ -1920,7 +1592,6 @@ gnome_calendar_init (GnomeCalendar *gcal)
priv->memo_sexp = g_strdup ("#t");
priv->view_instance = NULL;
- priv->view_menus = NULL;
priv->visible_start = -1;
priv->visible_end = -1;
@@ -1948,37 +1619,24 @@ gnome_calendar_destroy (GtkObject *object)
e_categories_unregister_change_listener (G_CALLBACK (categories_changed_cb), gcal);
/* Clean up the clients */
- for (i = 0; i < E_CAL_SOURCE_TYPE_LAST; i++) {
- for (l = priv->clients_list[i]; l != NULL; l = l->next) {
- ESource *source = e_cal_get_source (l->data);
-
- g_signal_handlers_disconnect_matched (l->data, G_SIGNAL_MATCH_DATA,
- 0, 0, NULL, NULL, gcal);
-
- if (source)
- g_signal_handlers_disconnect_matched (source, G_SIGNAL_MATCH_DATA, 0, 0, NULL, NULL, gcal);
- }
-
- g_hash_table_destroy (priv->clients[i]);
- g_list_free (priv->clients_list[i]);
-
- priv->clients[i] = NULL;
- priv->clients_list[i] = NULL;
-
- if (priv->default_client[i]) {
- ESource *source = e_cal_get_source (priv->default_client[i]);
+ for (l = priv->clients_list; l != NULL; l = l->next) {
+ g_signal_handlers_disconnect_matched (l->data, G_SIGNAL_MATCH_DATA,
+ 0, 0, NULL, NULL, gcal);
+ }
- g_signal_handlers_disconnect_matched (priv->default_client[i],
- G_SIGNAL_MATCH_DATA,
- 0, 0, NULL, NULL, gcal);
+ g_hash_table_destroy (priv->clients);
+ g_list_free (priv->clients_list);
- if (source)
- g_signal_handlers_disconnect_matched (source, G_SIGNAL_MATCH_DATA, 0, 0, NULL, NULL, gcal);
+ priv->clients = NULL;
+ priv->clients_list = NULL;
- g_object_unref (priv->default_client[i]);
- }
- priv->default_client[i] = NULL;
+ if (priv->default_client) {
+ g_signal_handlers_disconnect_matched (priv->default_client,
+ G_SIGNAL_MATCH_DATA,
+ 0, 0, NULL, NULL, gcal);
+ g_object_unref (priv->default_client);
}
+ priv->default_client = NULL;
for (i = 0; i < GNOME_CAL_LAST_VIEW; i++) {
if (priv->configs[i])
@@ -1986,26 +1644,12 @@ gnome_calendar_destroy (GtkObject *object)
priv->configs[i] = NULL;
}
g_object_unref (priv->date_navigator_config);
- g_object_unref (priv->todo_config);
- g_object_unref (priv->memo_config);
for (l = priv->notifications; l; l = l->next)
calendar_config_remove_notification (GPOINTER_TO_UINT (l->data));
g_list_free (priv->notifications);
priv->notifications = NULL;
- /* Save the TaskPad layout. */
- filename = g_build_filename (calendar_component_peek_config_directory (calendar_component_peek ()),
- "TaskPad", NULL);
- e_calendar_table_save_state (E_CALENDAR_TABLE (priv->todo), filename);
- g_free (filename);
-
- /* Save the MemoPad layout. */
- filename = g_build_filename (memos_component_peek_config_directory (memos_component_peek ()),
- "MemoPad", NULL);
- e_memo_table_save_state (E_MEMO_TABLE (priv->memo), filename);
- g_free (filename);
-
if (priv->dn_queries) {
for (l = priv->dn_queries; l != NULL; l = l->next) {
g_signal_handlers_disconnect_matched ((ECalView *) l->data, G_SIGNAL_MATCH_DATA,
@@ -2027,50 +1671,21 @@ gnome_calendar_destroy (GtkObject *object)
priv->sexp = NULL;
}
- if (priv->todo_sexp) {
- g_free (priv->todo_sexp);
- priv->todo_sexp = NULL;
- }
-
- if (priv->memo_sexp) {
- g_free (priv->memo_sexp);
- priv->memo_sexp = NULL;
- }
-
if (priv->update_timeout) {
g_source_remove (priv->update_timeout);
priv->update_timeout = 0;
}
- if (priv->view_instance) {
- g_object_unref (priv->view_instance);
- priv->view_instance = NULL;
- }
-
if (priv->update_marcus_bains_line_timeout) {
g_source_remove (priv->update_marcus_bains_line_timeout);
priv->update_marcus_bains_line_timeout = 0;
}
- if (priv->view_menus) {
- g_object_unref (priv->view_menus);
- priv->view_menus = NULL;
- }
-
if (priv->calendar_menu) {
g_object_unref (priv->calendar_menu);
priv->calendar_menu = NULL;
}
- if (priv->taskpad_menu) {
- g_object_unref (priv->taskpad_menu);
- priv->taskpad_menu = NULL;
- }
-
- if (priv->memopad_menu) {
- g_object_unref (priv->memopad_menu);
- priv->memopad_menu = NULL;
- }
/* Disconnect all handlers */
cal_model = e_calendar_view_get_model ((ECalendarView *)priv->week_view);
g_signal_handlers_disconnect_by_func (cal_model,
@@ -2078,17 +1693,7 @@ gnome_calendar_destroy (GtkObject *object)
g_signal_handlers_disconnect_by_func (cal_model,
G_CALLBACK (view_done_cb), gcal);
- cal_model = e_calendar_table_get_model ((ECalendarTable *) priv->todo);
- g_signal_handlers_disconnect_by_func (cal_model,
- G_CALLBACK (view_progress_cb), gcal);
- g_signal_handlers_disconnect_by_func (cal_model,
- G_CALLBACK (view_done_cb), gcal);
-
- cal_model = e_memo_table_get_model ((EMemoTable *)priv->memo);
- g_signal_handlers_disconnect_by_func (cal_model,
- G_CALLBACK (view_progress_cb), gcal);
- g_signal_handlers_disconnect_by_func (cal_model,
- G_CALLBACK (view_done_cb), gcal);
+ g_mutex_free (priv->todo_update_lock);
g_mutex_free (priv->todo_update_lock);
@@ -2516,272 +2121,55 @@ display_view_cb (GalViewInstance *view_instance, GalView *view, gpointer data)
}
-/**
- * gnome_calendar_setup_view_menus:
- * @gcal: A calendar.
- * @uic: UI controller to use for the menus.
- *
- * Sets up the #GalView menus for a calendar. This function should be called
- * from the Bonobo control activation callback for this calendar. Also, the
- * menus should be discarded using gnome_calendar_discard_view_menus().
- **/
-void
-gnome_calendar_setup_view_menus (GnomeCalendar *gcal, BonoboUIComponent *uic)
+static void
+gnome_calendar_set_pane_positions (GnomeCalendar *gcal)
{
GnomeCalendarPrivate *priv;
- gchar *path0, *path1, *etspecfile;
- CalendarViewFactory *factory;
- GalViewFactory *gal_factory;
- static GalViewCollection *collection = NULL;
-
- g_return_if_fail (gcal != NULL);
- g_return_if_fail (GNOME_IS_CALENDAR (gcal));
- g_return_if_fail (uic != NULL);
- g_return_if_fail (BONOBO_IS_UI_COMPONENT (uic));
priv = gcal->priv;
- g_return_if_fail (priv->view_instance == NULL);
- g_return_if_fail (priv->view_menus == NULL);
-
- /* Create the view instance */
- if (collection == NULL) {
- ETableSpecification *spec;
-
- collection = gal_view_collection_new ();
-
- gal_view_collection_set_title (collection, _("Calendar"));
-
- path0 = g_build_filename (EVOLUTION_GALVIEWSDIR,
- "calendar",
- NULL);
- path1 = g_build_filename (calendar_component_peek_base_directory (calendar_component_peek ()),
- "views", NULL);
- gal_view_collection_set_storage_directories (collection,
- path0,
- path1);
- g_free (path1);
- g_free (path0);
-
- /* Create the views */
-
- factory = calendar_view_factory_new (GNOME_CAL_DAY_VIEW);
- gal_view_collection_add_factory (collection, GAL_VIEW_FACTORY (factory));
- g_object_unref (factory);
-
- factory = calendar_view_factory_new (GNOME_CAL_WORK_WEEK_VIEW);
- gal_view_collection_add_factory (collection, GAL_VIEW_FACTORY (factory));
- g_object_unref (factory);
-
- factory = calendar_view_factory_new (GNOME_CAL_WEEK_VIEW);
- gal_view_collection_add_factory (collection, GAL_VIEW_FACTORY (factory));
- g_object_unref (factory);
-
- factory = calendar_view_factory_new (GNOME_CAL_MONTH_VIEW);
- gal_view_collection_add_factory (collection, GAL_VIEW_FACTORY (factory));
- g_object_unref (factory);
-
- spec = e_table_specification_new ();
- etspecfile = g_build_filename (EVOLUTION_ETSPECDIR,
- "e-cal-list-view.etspec",
- NULL);
- if (!e_table_specification_load_from_file (spec, etspecfile))
- g_error ("Unable to load ETable specification file "
- "for calendar");
- g_free (etspecfile);
- gal_factory = gal_view_factory_etable_new (spec);
- g_object_unref (spec);
- gal_view_collection_add_factory (collection, GAL_VIEW_FACTORY (gal_factory));
- g_object_unref (gal_factory);
-
- /* Load the collection and create the menus */
-
- gal_view_collection_load (collection);
-
+ if (priv->current_view_type == GNOME_CAL_MONTH_VIEW && !priv->range_selected) {
+ gtk_paned_set_position (GTK_PANED (priv->hpane), priv->hpane_pos_month_view);
+ gtk_paned_set_position (GTK_PANED (priv->vpane), priv->vpane_pos_month_view);
+ } else {
+ gtk_paned_set_position (GTK_PANED (priv->hpane), priv->hpane_pos);
+ gtk_paned_set_position (GTK_PANED (priv->vpane), priv->vpane_pos);
}
-
- priv->view_instance = gal_view_instance_new (collection, NULL);
- priv->view_menus = gal_view_menus_new (priv->view_instance);
- gal_view_menus_apply (priv->view_menus, uic, NULL);
-
- g_signal_connect (priv->view_instance, "display_view", G_CALLBACK (display_view_cb), gcal);
- display_view_cb (priv->view_instance, gal_view_instance_get_current_view (priv->view_instance), gcal);
}
-/**
- * gnome_calendar_discard_view_menus:
- * @gcal: A calendar.
- *
- * Discards the #GalView menus used by a calendar. This function should be
- * called from the Bonobo control deactivation callback for this calendar. The
- * menus should have been set up with gnome_calendar_setup_view_menus().
- **/
-void
-gnome_calendar_discard_view_menus (GnomeCalendar *gcal)
-{
- GnomeCalendarPrivate *priv;
-
- g_return_if_fail (gcal != NULL);
-
- priv = gcal->priv;
-
- g_return_if_fail (priv->view_instance != NULL);
- g_return_if_fail (priv->view_menus != NULL);
-
- g_object_unref (priv->view_instance);
- priv->view_instance = NULL;
-
- g_object_unref (priv->view_menus);
- priv->view_menus = NULL;
-}
-
-/* This is copied/moved from gal-view-instance, only the calendar uses this for a popup menu */
-static void
-gc_set_view(EPopup *ep, EPopupItem *pitem, gpointer data)
-{
- GnomeCalendar *gcal = data;
-
- if (pitem->type & E_POPUP_ACTIVE)
- gal_view_instance_set_current_view_id(gcal->priv->view_instance, (gchar *)pitem->user_data);
-}
-
-static void
-gc_save_custom_view(EPopup *ep, EPopupItem *pitem, gpointer data)
-{
- GnomeCalendar *gcal = data;
-
- gal_view_instance_save_as(gcal->priv->view_instance);
-}
-
-static void
-gc_define_views_response(GtkWidget *d, gint id, GnomeCalendar *gcal)
-{
- if (id == GTK_RESPONSE_OK)
- gal_view_collection_save(gcal->priv->view_instance->collection);
-
- gtk_widget_destroy(d);
-}
-
-static void
-gc_define_views(EPopup *ep, EPopupItem *pitem, gpointer data)
-{
- GnomeCalendar *gcal = data;
- GtkWidget *dialog = gal_define_views_dialog_new(gcal->priv->view_instance->collection);
-
- g_signal_connect(dialog, "response", G_CALLBACK(gc_define_views_response), data);
- gtk_widget_show(dialog);
-}
-
-static EPopupItem gc_popups[] = {
- /* Code generates the path to fit */
- { E_POPUP_BAR, NULL },
- { E_POPUP_RADIO|E_POPUP_ACTIVE, NULL, (gchar *) N_("_Custom View"), },
- { E_POPUP_ITEM, NULL, (gchar *) N_("_Save Custom View"), gc_save_custom_view },
-
- /* index == 3, when we have non-custom view */
-
- { E_POPUP_BAR, NULL },
- { E_POPUP_ITEM, NULL, (gchar *) N_("_Define Views..."), gc_define_views },
+struct _mclient_msg {
+ Message header;
+ ECalModel *model;
+ ECal *client;
};
static void
-gc_popup_free (EPopup *ep, GSList *list, gpointer data)
+add_mclient_async (struct _mclient_msg *msg)
{
- while (list) {
- GSList *n = list->next;
- EPopupItem *pitem = list->data;
-
- g_free(pitem->path);
- g_free(pitem->label);
- g_free(pitem->user_data);
- g_free(pitem);
- g_slist_free_1(list);
- list = n;
- }
-}
+ e_cal_model_add_client (msg->model, msg->client);
-static void
-gc_popup_free_static (EPopup *ep, GSList *list, gpointer data)
-{
- while (list) {
- GSList *n = list->next;
- EPopupItem *pitem = list->data;
-
- g_free(pitem->path);
- g_free(pitem);
- g_slist_free_1(list);
- list = n;
- }
+ g_object_unref (msg->client);
+ g_object_unref (msg->model);
+ g_slice_free (struct _mclient_msg, msg);
}
-void
-gnome_calendar_view_popup_factory (GnomeCalendar *gcal, EPopup *ep, const gchar *prefix)
+static void
+add_mclient (ECalModel *model, ECal *client)
{
- GnomeCalendarPrivate *priv;
- gint length;
- gint i;
- gboolean found = FALSE;
- gchar *id;
- GSList *menus = NULL;
- EPopupItem *pitem;
-
- g_return_if_fail (gcal != NULL);
- g_return_if_fail (GNOME_IS_CALENDAR (gcal));
- g_return_if_fail (prefix != NULL);
-
- priv = gcal->priv;
-
- g_return_if_fail (priv->view_instance != NULL);
-
- length = gal_view_collection_get_count(priv->view_instance->collection);
- id = gal_view_instance_get_current_view_id (priv->view_instance);
-
- for (i = 0; i < length; i++) {
- GalViewCollectionItem *item = gal_view_collection_get_view_item(priv->view_instance->collection, i);
-
- pitem = g_malloc0(sizeof(*pitem));
- pitem->type = E_POPUP_RADIO;
- pitem->path = g_strdup_printf("%s/%02d.item", prefix, i);
- pitem->label = g_strdup(item->title);
- pitem->activate = gc_set_view;
- pitem->user_data = g_strdup(item->id);
-
- if (!found && id && !strcmp (id, item->id)) {
- found = TRUE;
- pitem->type |= E_POPUP_ACTIVE;
- }
-
- menus = g_slist_prepend(menus, pitem);
- }
-
- if (menus)
- e_popup_add_items(ep, menus, NULL, gc_popup_free, gcal);
+ struct _mclient_msg *msg;
- menus = NULL;
- for (i = found?3:0; i<sizeof(gc_popups)/sizeof(gc_popups[0]);i++) {
- pitem = g_malloc0(sizeof(*pitem));
- memcpy(pitem, &gc_popups[i], sizeof(*pitem));
- pitem->path = g_strdup_printf("%s/%02d.item", prefix, i+length);
- menus = g_slist_prepend(menus, pitem);
- }
+ msg = g_slice_new0 (struct _mclient_msg);
+ msg->header.func = (MessageFunc) add_mclient_async;
+ msg->model = g_object_ref (model);
+ msg->client = g_object_ref (client);
- e_popup_add_items(ep, menus, NULL, gc_popup_free_static, gcal);
+ message_push ((Message *) msg);
}
static void
-gnome_calendar_set_pane_positions (GnomeCalendar *gcal)
+non_intrusive_error_remove(GtkWidget *w, gpointer data)
{
- GnomeCalendarPrivate *priv;
-
- priv = gcal->priv;
-
- if (priv->current_view_type == GNOME_CAL_MONTH_VIEW && !priv->range_selected) {
- gtk_paned_set_position (GTK_PANED (priv->hpane), priv->hpane_pos_month_view);
- gtk_paned_set_position (GTK_PANED (priv->vpane), priv->vpane_pos_month_view);
- } else {
- gtk_paned_set_position (GTK_PANED (priv->hpane), priv->hpane_pos);
- gtk_paned_set_position (GTK_PANED (priv->vpane), priv->vpane_pos);
- }
+ g_hash_table_remove(non_intrusive_error_table, data);
}
struct _mclient_msg {
@@ -2823,7 +2211,6 @@ static void
client_cal_opened_cb (ECal *ecal, ECalendarStatus status, GnomeCalendar *gcal)
{
GnomeCalendarPrivate *priv;
- ECalSourceType source_type;
ESource *source;
ECalModel *model;
ECalLoadState state;
@@ -2833,23 +2220,9 @@ client_cal_opened_cb (ECal *ecal, ECalendarStatus status, GnomeCalendar *gcal)
priv = gcal->priv;
- source_type = e_cal_get_source_type (ecal);
source = e_cal_get_source (ecal);
state = e_cal_get_load_state (ecal);
- switch (source_type) {
- case E_CAL_SOURCE_TYPE_EVENT:
- e_calendar_view_set_status_message (E_CALENDAR_VIEW (priv->week_view), NULL, -1);
- break;
- case E_CAL_SOURCE_TYPE_TODO:
- e_calendar_table_set_status_message (E_CALENDAR_TABLE (priv->todo), NULL, -1);
- break;
- case E_CAL_SOURCE_TYPE_JOURNAL:
- e_memo_table_set_status_message (E_MEMO_TABLE (priv->memo), NULL);
- default:
- break;
- }
-
if (status == E_CALENDAR_STATUS_AUTHENTICATION_FAILED || status == E_CALENDAR_STATUS_AUTHENTICATION_REQUIRED)
auth_cal_forget_password (ecal);
@@ -2881,32 +2254,27 @@ client_cal_opened_cb (ECal *ecal, ECalendarStatus status, GnomeCalendar *gcal)
e_cal_open_async (ecal, FALSE);
return;
case E_CALENDAR_STATUS_REPOSITORY_OFFLINE:
- if (source_type == E_CAL_SOURCE_TYPE_EVENT)
- {
- /* check to see if we have dialog already running for this operation */
- id = g_strdup ("calendar:unable-to-load-the-calendar");
-
- if (g_hash_table_lookup(non_intrusive_error_table, id)) {
- /* We already have it */
- g_message("Error occurred while existing dialog active:\n");
- return;
- }
+ /* check to see if we have dialog already running for this operation */
+ id = g_strdup ("calendar:unable-to-load-the-calendar");
- w = e_error_new(GTK_WINDOW (gtk_widget_get_toplevel (GTK_WIDGET (gcal))), "calendar:unable-to-load-the-calendar", e_cal_get_error_message (status), NULL);
- e_calendar_utils_show_error_silent (w);
- g_hash_table_insert (non_intrusive_error_table, id, g_object_ref(w));
- g_signal_connect(w, "destroy", G_CALLBACK(non_intrusive_error_remove), id);
+ if (g_hash_table_lookup(non_intrusive_error_table, id)) {
+ /* We already have it */
+ g_message("Error occurred while existing dialog active:\n");
+ return;
}
+
+ w = e_error_new(GTK_WINDOW (gtk_widget_get_toplevel (GTK_WIDGET (gcal))), "calendar:unable-to-load-the-calendar", e_cal_get_error_message (status), NULL);
+ e_calendar_utils_show_error_silent (w);
+ g_hash_table_insert (non_intrusive_error_table, id, g_object_ref(w));
+ g_signal_connect(w, "destroy", G_CALLBACK(non_intrusive_error_remove), id);
default:
/* Make sure the source doesn't disappear on us */
g_object_ref (source);
- g_signal_handlers_disconnect_matched (ecal, G_SIGNAL_MATCH_DATA, 0, 0, NULL, NULL, gcal);
-
- priv->clients_list[source_type] = g_list_remove (priv->clients_list[source_type], ecal);
- g_hash_table_remove (priv->clients[source_type], e_source_peek_uid (source));
+ priv->clients_list = g_list_remove (priv->clients_list, ecal);
+ g_hash_table_remove (priv->clients, e_source_peek_uid (source));
- g_signal_emit (gcal, gnome_calendar_signals[SOURCE_REMOVED], 0, source_type, source);
+ g_signal_emit (gcal, gnome_calendar_signals[SOURCE_REMOVED], 0, source);
g_object_unref (source);
g_warning ("Unable to load the calendar %s \n", e_cal_get_error_message (status));
@@ -2916,74 +2284,35 @@ client_cal_opened_cb (ECal *ecal, ECalendarStatus status, GnomeCalendar *gcal)
g_signal_handlers_disconnect_matched (ecal, G_SIGNAL_MATCH_FUNC, 0, 0, NULL, client_cal_opened_cb, NULL);
- switch (source_type) {
- case E_CAL_SOURCE_TYPE_EVENT :
- msg = g_strdup_printf (_("Loading appointments at %s"), e_cal_get_uri (ecal));
- e_calendar_view_set_status_message (E_CALENDAR_VIEW (priv->week_view), msg, -1);
- g_free (msg);
-
- /* add client to the views */
- model = e_calendar_view_get_model (priv->views[priv->current_view_type]);
- add_mclient (model, ecal);
-
- /* update date navigator query */
- update_query (gcal);
-
- e_calendar_view_set_status_message (E_CALENDAR_VIEW (priv->week_view), NULL, -1);
- break;
+ msg = g_strdup_printf (_("Loading appointments at %s"), e_cal_get_uri (ecal));
+ e_calendar_view_set_status_message (E_CALENDAR_VIEW (priv->week_view), msg, -1);
+ g_free (msg);
- case E_CAL_SOURCE_TYPE_TODO :
- msg = g_strdup_printf (_("Loading tasks at %s"), e_cal_get_uri (ecal));
- e_calendar_table_set_status_message (E_CALENDAR_TABLE (priv->todo), msg, -1);
- g_free (msg);
+ /* add client to the views */
+ model = e_calendar_view_get_model (priv->views[priv->current_view_type]);
+ add_mclient (model, ecal);
- e_cal_model_add_client (e_calendar_table_get_model (E_CALENDAR_TABLE (priv->todo)), ecal);
+ /* update date navigator query */
+ update_query (gcal);
- e_calendar_table_set_status_message (E_CALENDAR_TABLE (priv->todo), NULL, -1);
- break;
- case E_CAL_SOURCE_TYPE_JOURNAL:
- msg = g_strdup_printf (_("Loading memos at %s"), e_cal_get_uri (ecal));
- e_memo_table_set_status_message (E_MEMO_TABLE (priv->memo), msg);
- g_free (msg);
- e_cal_model_add_client (e_memo_table_get_model (E_MEMO_TABLE (priv->memo)), ecal);
- e_memo_table_set_status_message (E_MEMO_TABLE (priv->memo), NULL);
- break;
- default:
- g_return_if_reached ();
- }
+ e_calendar_view_set_status_message (E_CALENDAR_VIEW (priv->week_view), NULL, -1);
}
static void
default_client_cal_opened_cb (ECal *ecal, ECalendarStatus status, GnomeCalendar *gcal)
{
GnomeCalendarPrivate *priv;
- ECalSourceType source_type;
ESource *source;
ECalLoadState state;
priv = gcal->priv;
- source_type = e_cal_get_source_type (ecal);
source = e_cal_get_source (ecal);
state = e_cal_get_load_state (ecal);
if (status == E_CALENDAR_STATUS_AUTHENTICATION_FAILED || status == E_CALENDAR_STATUS_AUTHENTICATION_REQUIRED)
auth_cal_forget_password (ecal);
- switch (source_type) {
- case E_CAL_SOURCE_TYPE_EVENT:
- e_calendar_view_set_status_message (E_CALENDAR_VIEW (priv->week_view), NULL, -1);
- break;
- case E_CAL_SOURCE_TYPE_TODO:
- e_calendar_table_set_status_message (E_CALENDAR_TABLE (priv->todo), NULL, -1);
- break;
- case E_CAL_SOURCE_TYPE_JOURNAL:
- e_memo_table_set_status_message (E_MEMO_TABLE (priv->memo), NULL);
- break;
- default:
- break;
- }
-
switch (status) {
case E_CALENDAR_STATUS_OK:
break;
@@ -3004,15 +2333,15 @@ default_client_cal_opened_cb (ECal *ecal, ECalendarStatus status, GnomeCalendar
g_signal_handlers_disconnect_matched (ecal, G_SIGNAL_MATCH_DATA, 0, 0, NULL, NULL, gcal);
/* FIXME should we do this to prevent multiple error dialogs? */
- priv->clients_list[source_type] = g_list_remove (priv->clients_list[source_type], ecal);
- g_hash_table_remove (priv->clients[source_type], e_source_peek_uid (source));
+ priv->clients_list = g_list_remove (priv->clients_list, ecal);
+ g_hash_table_remove (priv->clients, e_source_peek_uid (source));
/* FIXME Is there a better way to handle this? */
- if (priv->default_client[source_type])
- g_object_unref (priv->default_client[source_type]);
- priv->default_client[source_type] = NULL;
+ if (priv->default_client)
+ g_object_unref (priv->default_client);
+ priv->default_client = NULL;
- g_signal_emit (gcal, gnome_calendar_signals[SOURCE_REMOVED], 0, source_type, source);
+ g_signal_emit (gcal, gnome_calendar_signals[SOURCE_REMOVED], 0, source);
g_object_unref (source);
g_warning ("Unable to load the calendar %s \n", e_cal_get_error_message (status));
@@ -3022,22 +2351,10 @@ default_client_cal_opened_cb (ECal *ecal, ECalendarStatus status, GnomeCalendar
g_signal_handlers_disconnect_matched (ecal, G_SIGNAL_MATCH_FUNC, 0, 0, NULL, default_client_cal_opened_cb, NULL);
- switch (source_type) {
- case E_CAL_SOURCE_TYPE_EVENT:
- e_cal_model_set_default_client (
- e_calendar_view_get_model (E_CALENDAR_VIEW (priv->views[priv->current_view_type])),
- ecal);
- break;
-
- case E_CAL_SOURCE_TYPE_TODO:
- e_cal_model_set_default_client (e_calendar_table_get_model (E_CALENDAR_TABLE (priv->todo)), ecal);
- break;
- case E_CAL_SOURCE_TYPE_JOURNAL:
- e_cal_model_set_default_client (e_memo_table_get_model (E_MEMO_TABLE (priv->memo)), ecal);
- break;
- default:
- break;
- }
+ e_cal_model_set_default_client (
+ e_calendar_view_get_model (
+ E_CALENDAR_VIEW (priv->views[priv->current_view_type])),
+ ecal);
}
typedef void (*open_func) (ECal *, ECalendarStatus, GnomeCalendar *);
@@ -3055,20 +2372,7 @@ open_ecal (GnomeCalendar *gcal, ECal *cal, gboolean only_if_exists, open_func of
e_cal_set_default_timezone (cal, zone, NULL);
msg = g_strdup_printf (_("Opening %s"), e_cal_get_uri (cal));
- switch (e_cal_get_source_type (cal)) {
- case E_CAL_SOURCE_TYPE_EVENT :
- e_calendar_view_set_status_message (E_CALENDAR_VIEW (priv->week_view), msg, -1);
- break;
- case E_CAL_SOURCE_TYPE_TODO :
- e_calendar_table_set_status_message (E_CALENDAR_TABLE (priv->todo), msg, -1);
- break;
- case E_CAL_SOURCE_TYPE_JOURNAL:
- e_memo_table_set_status_message (E_MEMO_TABLE (priv->memo), msg);
- break;
- default:
- g_free (msg);
- g_return_val_if_reached (FALSE);
- }
+ e_calendar_view_set_status_message (E_CALENDAR_VIEW (priv->week_view), msg, -1);
g_free (msg);
@@ -3113,7 +2417,6 @@ backend_died_cb (ECal *ecal, gpointer data)
{
GnomeCalendar *gcal;
GnomeCalendarPrivate *priv;
- ECalSourceType source_type;
ESource *source;
const gchar *id;
GtkWidget *w = NULL;
@@ -3124,39 +2427,16 @@ backend_died_cb (ECal *ecal, gpointer data)
/* FIXME What about default sources? */
/* Make sure the source doesn't go away on us since we use it below */
- source_type = e_cal_get_source_type (ecal);
source = g_object_ref (e_cal_get_source (ecal));
- priv->clients_list[source_type] = g_list_remove (priv->clients_list[source_type], ecal);
- g_hash_table_remove (priv->clients[source_type], e_source_peek_uid (source));
-
- switch (source_type) {
- case E_CAL_SOURCE_TYPE_EVENT:
- id = g_strdup ("calendar:calendar-crashed");
-
- e_calendar_view_set_status_message (E_CALENDAR_VIEW (priv->week_view), NULL, -1);
-
- g_signal_emit (gcal, gnome_calendar_signals[SOURCE_REMOVED], 0, source_type, source);
- break;
-
- case E_CAL_SOURCE_TYPE_TODO:
- id = g_strdup ("calendar:calendar-crashed");
+ priv->clients_list = g_list_remove (priv->clients_list, ecal);
+ g_hash_table_remove (priv->clients, e_source_peek_uid (source));
- e_calendar_table_set_status_message (E_CALENDAR_TABLE (priv->todo), NULL, -1);
+ id = g_strdup ("calendar:calendar-crashed");
- g_signal_emit (gcal, gnome_calendar_signals[SOURCE_REMOVED], 0, source_type, source);
- break;
-
- case E_CAL_SOURCE_TYPE_JOURNAL:
- id = g_strdup ("calendar:calendar-crashed");
-
- e_memo_table_set_status_message (E_MEMO_TABLE (priv->memo), NULL);
+ e_calendar_view_set_status_message (E_CALENDAR_VIEW (priv->week_view), NULL, -1);
- g_signal_emit (gcal, gnome_calendar_signals[SOURCE_REMOVED], 0, source_type, source);
- break;
- default:
- g_return_if_reached ();
- }
+ g_signal_emit (gcal, gnome_calendar_signals[SOURCE_REMOVED], 0, source);
g_object_unref (source);
@@ -3201,35 +2481,6 @@ gnome_calendar_new (void)
return GTK_WIDGET (gcal);
}
-void
-gnome_calendar_set_activity_handler (GnomeCalendar *cal, EActivityHandler *activity_handler)
-{
- GnomeCalendarPrivate *priv;
- gint i;
-
- g_return_if_fail (cal != NULL);
- g_return_if_fail (GNOME_IS_CALENDAR (cal));
-
- priv = cal->priv;
-
- priv->activity_handler = activity_handler;
-
- for (i = 0; i < GNOME_CAL_LAST_VIEW; i++)
- e_calendar_view_set_activity_handler (priv->views[i], activity_handler);
-
- e_calendar_table_set_activity_handler (E_CALENDAR_TABLE (priv->todo), activity_handler);
-}
-
-void
-gnome_calendar_set_ui_component (GnomeCalendar *gcal,
- BonoboUIComponent *ui_component)
-{
- g_return_if_fail (GNOME_IS_CALENDAR (gcal));
- g_return_if_fail (ui_component == NULL || BONOBO_IS_UI_COMPONENT (ui_component));
-
- e_search_bar_set_ui_component (E_SEARCH_BAR (gcal->priv->search_bar), ui_component);
-}
-
/**
* gnome_calendar_get_calendar_model:
* @gcal: A calendar view.
@@ -3277,7 +2528,7 @@ gnome_calendar_get_default_client (GnomeCalendar *gcal)
* Returns: TRUE if successful, FALSE if error.
*/
gboolean
-gnome_calendar_add_source (GnomeCalendar *gcal, ECalSourceType source_type, ESource *source)
+gnome_calendar_add_source (GnomeCalendar *gcal, ESource *source)
{
GnomeCalendarPrivate *priv;
ECal *client;
@@ -3288,7 +2539,7 @@ gnome_calendar_add_source (GnomeCalendar *gcal, ECalSourceType source_type, ESou
priv = gcal->priv;
- client = g_hash_table_lookup (priv->clients[source_type], e_source_peek_uid (source));
+ client = g_hash_table_lookup (priv->clients, e_source_peek_uid (source));
if (client) {
/* We already have it */
@@ -3296,18 +2547,18 @@ gnome_calendar_add_source (GnomeCalendar *gcal, ECalSourceType source_type, ESou
} else {
ESource *default_source;
- if (priv->default_client[source_type]) {
- default_source = e_cal_get_source (priv->default_client[source_type]);
+ if (priv->default_client) {
+ default_source = e_cal_get_source (priv->default_client);
g_message ("Check if default client matches (%s %s)", e_source_peek_uid (default_source), e_source_peek_uid (source));
/* We don't have it but the default client is it */
if (!strcmp (e_source_peek_uid (default_source), e_source_peek_uid (source)))
- client = g_object_ref (priv->default_client[source_type]);
+ client = g_object_ref (priv->default_client);
}
/* Create a new one */
if (!client) {
- client = auth_new_cal_from_source (source, source_type);
+ client = auth_new_cal_from_source (source, E_CAL_SOURCE_TYPE_EVENT);
if (!client)
return FALSE;
}
@@ -3317,10 +2568,10 @@ gnome_calendar_add_source (GnomeCalendar *gcal, ECalSourceType source_type, ESou
g_signal_connect (G_OBJECT (client), "backend_died", G_CALLBACK (backend_died_cb), gcal);
/* add the client to internal structure */
- g_hash_table_insert (priv->clients[source_type], g_strdup (e_source_peek_uid (source)), client);
- priv->clients_list[source_type] = g_list_prepend (priv->clients_list[source_type], client);
+ g_hash_table_insert (priv->clients, g_strdup (e_source_peek_uid (source)), client);
+ priv->clients_list = g_list_prepend (priv->clients_list, client);
- g_signal_emit (gcal, gnome_calendar_signals[SOURCE_ADDED], 0, source_type, source);
+ g_signal_emit (gcal, gnome_calendar_signals[SOURCE_ADDED], 0, source);
open_ecal (gcal, client, FALSE, client_cal_opened_cb);
@@ -3338,7 +2589,7 @@ gnome_calendar_add_source (GnomeCalendar *gcal, ECalSourceType source_type, ESou
* Returns: TRUE if successful, FALSE otherwise.
*/
gboolean
-gnome_calendar_remove_source (GnomeCalendar *gcal, ECalSourceType source_type, ESource *source)
+gnome_calendar_remove_source (GnomeCalendar *gcal, ESource *source)
{
gboolean result;
@@ -3346,15 +2597,15 @@ gnome_calendar_remove_source (GnomeCalendar *gcal, ECalSourceType source_type, E
g_return_val_if_fail (GNOME_IS_CALENDAR (gcal), FALSE);
g_return_val_if_fail (E_IS_SOURCE (source), FALSE);
- result = gnome_calendar_remove_source_by_uid (gcal, source_type, e_source_peek_uid (source));
+ result = gnome_calendar_remove_source_by_uid (gcal, e_source_peek_uid (source));
if (result)
- g_signal_emit (gcal, gnome_calendar_signals[SOURCE_REMOVED], 0, source_type, source);
+ g_signal_emit (gcal, gnome_calendar_signals[SOURCE_REMOVED], 0, source);
return result;
}
gboolean
-gnome_calendar_remove_source_by_uid (GnomeCalendar *gcal, ECalSourceType source_type, const gchar *uid)
+gnome_calendar_remove_source_by_uid (GnomeCalendar *gcal, const gchar *uid)
{
GnomeCalendarPrivate *priv;
ECal *client;
@@ -3367,51 +2618,34 @@ gnome_calendar_remove_source_by_uid (GnomeCalendar *gcal, ECalSourceType source_
priv = gcal->priv;
- client = g_hash_table_lookup (priv->clients[source_type], uid);
+ client = g_hash_table_lookup (priv->clients, uid);
if (!client)
return TRUE;
- priv->clients_list[source_type] = g_list_remove (priv->clients_list[source_type], client);
+ priv->clients_list = g_list_remove (priv->clients_list, client);
g_signal_handlers_disconnect_matched (client, G_SIGNAL_MATCH_DATA,
0, 0, NULL, NULL, gcal);
- switch (source_type) {
- case E_CAL_SOURCE_TYPE_EVENT:
- /* remove the query for this client */
- for (l = priv->dn_queries; l != NULL; l = l->next) {
- ECalView *query = l->data;
+ /* remove the query for this client */
+ for (l = priv->dn_queries; l != NULL; l = l->next) {
+ ECalView *query = l->data;
- if (query && (client == e_cal_view_get_client (query))) {
- g_signal_handlers_disconnect_matched (query, G_SIGNAL_MATCH_DATA,
- 0, 0, NULL, NULL, gcal);
- priv->dn_queries = g_list_remove (priv->dn_queries, query);
- g_object_unref (query);
- break;
- }
+ if (query && (client == e_cal_view_get_client (query))) {
+ g_signal_handlers_disconnect_matched (query, G_SIGNAL_MATCH_DATA,
+ 0, 0, NULL, NULL, gcal);
+ priv->dn_queries = g_list_remove (priv->dn_queries, query);
+ g_object_unref (query);
+ break;
}
+ }
- model = e_calendar_view_get_model (priv->views[priv->current_view_type]);
- e_cal_model_remove_client (model, client);
-
- /* update date navigator query */
- update_query (gcal);
- break;
-
- case E_CAL_SOURCE_TYPE_TODO:
- model = e_calendar_table_get_model (E_CALENDAR_TABLE (priv->todo));
- e_cal_model_remove_client (model, client);
- break;
-
- case E_CAL_SOURCE_TYPE_JOURNAL:
- model = e_memo_table_get_model (E_MEMO_TABLE (priv->memo));
- e_cal_model_remove_client (model, client);
- break;
+ model = e_calendar_view_get_model (priv->views[priv->current_view_type]);
+ e_cal_model_remove_client (model, client);
- default:
- g_return_val_if_reached (TRUE);
- }
+ /* update date navigator query */
+ update_query (gcal);
- g_hash_table_remove (priv->clients[source_type], uid);
+ g_hash_table_remove (priv->clients, uid);
return TRUE;
}
@@ -3429,7 +2663,7 @@ gnome_calendar_remove_source_by_uid (GnomeCalendar *gcal, ECalSourceType source_
* otherwise
**/
gboolean
-gnome_calendar_set_default_source (GnomeCalendar *gcal, ECalSourceType source_type, ESource *source)
+gnome_calendar_set_default_source (GnomeCalendar *gcal, ESource *source)
{
GnomeCalendarPrivate *priv;
ECal *client;
@@ -3440,21 +2674,21 @@ gnome_calendar_set_default_source (GnomeCalendar *gcal, ECalSourceType source_ty
priv = gcal->priv;
- client = g_hash_table_lookup (priv->clients[source_type], e_source_peek_uid (source));
+ client = g_hash_table_lookup (priv->clients, e_source_peek_uid (source));
- if (priv->default_client[source_type])
- g_object_unref (priv->default_client[source_type]);
+ if (priv->default_client)
+ g_object_unref (priv->default_client);
if (client) {
- priv->default_client[source_type] = g_object_ref (client);
+ priv->default_client = g_object_ref (client);
} else {
- priv->default_client[source_type] = auth_new_cal_from_source (source, source_type);
- if (!priv->default_client[source_type])
+ priv->default_client = auth_new_cal_from_source (source, E_CAL_SOURCE_TYPE_EVENT);
+ if (!priv->default_client)
return FALSE;
}
- open_ecal (gcal, priv->default_client[source_type], FALSE, default_client_cal_opened_cb);
+ open_ecal (gcal, priv->default_client, FALSE, default_client_cal_opened_cb);
return TRUE;
}
@@ -3817,55 +3051,34 @@ gnome_calendar_vpane_resized (GtkWidget *w, GdkEventButton *e, GnomeCalendar *gc
void
gnome_calendar_cut_clipboard (GnomeCalendar *gcal)
{
- GnomeCalendarPrivate *priv;
- FocusLocation location;
-
- priv = gcal->priv;
+ GtkWidget *widget;
- location = get_focus_location (gcal);
+ g_return_if_fail (GNOME_IS_CALENDAR (gcal));
- if (location == FOCUS_CALENDAR) {
- e_calendar_view_cut_clipboard (E_CALENDAR_VIEW (gnome_calendar_get_current_view_widget (gcal)));
- } else if (location == FOCUS_TASKPAD)
- e_calendar_table_cut_clipboard (E_CALENDAR_TABLE (priv->todo));
- else if (location == FOCUS_MEMOPAD)
- e_memo_table_cut_clipboard (E_MEMO_TABLE (priv->memo));
+ widget = gnome_calendar_get_current_view_widget (gcal);
+ e_calendar_view_cut_clipboard (E_CALENDAR_VIEW (widget));
}
void
gnome_calendar_copy_clipboard (GnomeCalendar *gcal)
{
- GnomeCalendarPrivate *priv;
- FocusLocation location;
-
- priv = gcal->priv;
+ GtkWidget *widget;
- location = get_focus_location (gcal);
+ g_return_if_fail (GNOME_IS_CALENDAR (gcal));
- if (location == FOCUS_CALENDAR) {
- e_calendar_view_copy_clipboard (E_CALENDAR_VIEW (gnome_calendar_get_current_view_widget (gcal)));
- } else if (location == FOCUS_TASKPAD)
- e_calendar_table_copy_clipboard (E_CALENDAR_TABLE (priv->todo));
- else if (location == FOCUS_MEMOPAD)
- e_memo_table_copy_clipboard (E_MEMO_TABLE (priv->memo));
+ widget = gnome_calendar_get_current_view_widget (gcal);
+ e_calendar_view_copy_clipboard (E_CALENDAR_VIEW (widget));
}
void
gnome_calendar_paste_clipboard (GnomeCalendar *gcal)
{
- GnomeCalendarPrivate *priv;
- FocusLocation location;
+ GtkWidget *widget;
- priv = gcal->priv;
-
- location = get_focus_location (gcal);
+ g_return_if_fail (GNOME_IS_CALENDAR (gcal));
- if (location == FOCUS_CALENDAR) {
- e_calendar_view_paste_clipboard (E_CALENDAR_VIEW (gnome_calendar_get_current_view_widget (gcal)));
- } else if (location == FOCUS_TASKPAD)
- e_calendar_table_paste_clipboard (E_CALENDAR_TABLE (priv->todo));
- else if (location == FOCUS_MEMOPAD)
- e_memo_table_paste_clipboard (E_MEMO_TABLE (priv->memo));
+ widget = gnome_calendar_get_current_view_widget (gcal);
+ e_calendar_view_paste_clipboard (E_CALENDAR_VIEW (widget));
}
@@ -3927,69 +3140,26 @@ gnome_calendar_get_num_events_selected (GnomeCalendar *gcal)
return retval;
}
-/**
- * gnome_calendar_get_num_tasks_selected:
- * @gcal: A calendar view.
- *
- * Queries the number of tasks that are currently selected in the task pad of a
- * calendar view.
- *
- * Return value: Number of selected tasks.
- **/
-gint
-gnome_calendar_get_num_tasks_selected (GnomeCalendar *gcal)
-{
- GnomeCalendarPrivate *priv;
- ETable *etable;
-
- g_return_val_if_fail (gcal != NULL, -1);
- g_return_val_if_fail (GNOME_IS_CALENDAR (gcal), -1);
-
- priv = gcal->priv;
-
- etable = e_calendar_table_get_table (E_CALENDAR_TABLE (priv->todo));
- return e_table_selected_count (etable);
-}
-
-
void
-gnome_calendar_delete_selection (GnomeCalendar *gcal)
+gnome_calendar_delete_selection (GnomeCalendar *gcal)
{
- GnomeCalendarPrivate *priv;
- FocusLocation location;
- GtkWidget *view;
+ GtkWidget *widget;
g_return_if_fail (GNOME_IS_CALENDAR (gcal));
- priv = gcal->priv;
-
- location = get_focus_location (gcal);
-
- if (location == FOCUS_CALENDAR) {
- view = gnome_calendar_get_current_view_widget (gcal);
-
- e_calendar_view_delete_selected_events (E_CALENDAR_VIEW (view));
- } else if (location == FOCUS_TASKPAD)
- e_calendar_table_delete_selected (E_CALENDAR_TABLE (priv->todo));
- else if (location == FOCUS_MEMOPAD)
- e_memo_table_delete_selected (E_MEMO_TABLE (priv->memo));
+ widget = gnome_calendar_get_current_view_widget (gcal);
+ e_calendar_view_delete_selected_events (E_CALENDAR_VIEW (widget));
}
void
gnome_calendar_delete_selected_occurrence (GnomeCalendar *gcal)
{
- FocusLocation location;
- GtkWidget *view;
+ GtkWidget *widget;
g_return_if_fail (GNOME_IS_CALENDAR (gcal));
- location = get_focus_location (gcal);
-
- if (location == FOCUS_CALENDAR) {
-
- view = gnome_calendar_get_current_view_widget (gcal);
- e_calendar_view_delete_selected_occurrence (E_CALENDAR_VIEW (view));
- }
+ widget = gnome_calendar_get_current_view_widget (gcal);
+ e_calendar_view_delete_selected_occurrence (E_CALENDAR_VIEW (widget));
}
static gboolean
@@ -4088,14 +3258,6 @@ gnome_calendar_purge (GnomeCalendar *gcal, time_t older_than)
}
-ECalendarTable*
-gnome_calendar_get_task_pad (GnomeCalendar *gcal)
-{
- g_return_val_if_fail (GNOME_IS_CALENDAR (gcal), NULL);
-
- return E_CALENDAR_TABLE (gcal->priv->todo);
-}
-
GtkWidget *
gnome_calendar_get_e_calendar_widget (GnomeCalendar *gcal)
{
@@ -4120,13 +3282,6 @@ gnome_calendar_get_view_notebook_widget (GnomeCalendar *gcal)
return GTK_WIDGET(gcal->priv->notebook);
}
-ECalMenu *gnome_calendar_get_taskpad_menu (GnomeCalendar *gcal)
-{
- g_return_val_if_fail (GNOME_IS_CALENDAR (gcal), NULL);
-
- return gcal->priv->taskpad_menu;
-}
-
ECalMenu *gnome_calendar_get_calendar_menu (GnomeCalendar *gcal)
{
g_return_val_if_fail (GNOME_IS_CALENDAR (gcal), NULL);
@@ -4134,14 +3289,6 @@ ECalMenu *gnome_calendar_get_calendar_menu (GnomeCalendar *gcal)
return gcal->priv->calendar_menu;
}
-ECalMenu *gnome_calendar_get_memopad_menu (GnomeCalendar *gcal)
-{
- g_return_val_if_fail (GNOME_IS_CALENDAR (gcal), NULL);
-
- return gcal->priv->memopad_menu;
-}
-
-
void
gnome_calendar_edit_appointment (GnomeCalendar *gcal,
const gchar * src_uid,