aboutsummaryrefslogtreecommitdiffstats
path: root/calendar/gui
diff options
context:
space:
mode:
Diffstat (limited to 'calendar/gui')
-rw-r--r--calendar/gui/Makefile.am121
-rw-r--r--calendar/gui/alarm-notify/alarm-queue.c2
-rw-r--r--calendar/gui/apps_evolution_calendar.schemas.in22
-rw-r--r--calendar/gui/cal-search-bar.c920
-rw-r--r--calendar/gui/cal-search-bar.h91
-rw-r--r--calendar/gui/calendar-commands.c266
-rw-r--r--calendar/gui/calendar-component.c967
-rw-r--r--calendar/gui/calendar-component.h8
-rw-r--r--calendar/gui/calendar-config-keys.h8
-rw-r--r--calendar/gui/calendar-config.c210
-rw-r--r--calendar/gui/calendar-config.h31
-rw-r--r--calendar/gui/calendar-view-factory.c6
-rw-r--r--calendar/gui/calendar-view-factory.h4
-rw-r--r--calendar/gui/comp-editor-factory.c642
-rw-r--r--calendar/gui/comp-editor-factory.h62
-rw-r--r--calendar/gui/control-factory.c79
-rw-r--r--calendar/gui/dialogs/cal-prefs-dialog.c56
-rw-r--r--calendar/gui/dialogs/cal-prefs-dialog.h32
-rw-r--r--calendar/gui/dialogs/comp-editor.c206
-rw-r--r--calendar/gui/dialogs/comp-editor.h5
-rw-r--r--calendar/gui/dialogs/event-editor.c14
-rw-r--r--calendar/gui/dialogs/event-editor.h1
-rw-r--r--calendar/gui/dialogs/event-page.c113
-rw-r--r--calendar/gui/dialogs/memo-editor.c14
-rw-r--r--calendar/gui/dialogs/memo-editor.h1
-rw-r--r--calendar/gui/dialogs/memo-page.c10
-rw-r--r--calendar/gui/dialogs/memo-page.glade1
-rw-r--r--calendar/gui/dialogs/task-details-page.c7
-rw-r--r--calendar/gui/dialogs/task-details-page.glade190
-rw-r--r--calendar/gui/dialogs/task-editor.c14
-rw-r--r--calendar/gui/dialogs/task-editor.h1
-rw-r--r--calendar/gui/dialogs/task-page.c92
-rw-r--r--calendar/gui/e-cal-component-memo-preview.c365
-rw-r--r--calendar/gui/e-cal-component-memo-preview.h66
-rw-r--r--calendar/gui/e-cal-component-preview.c319
-rw-r--r--calendar/gui/e-cal-component-preview.h64
-rw-r--r--calendar/gui/e-cal-event.c25
-rw-r--r--calendar/gui/e-cal-event.h18
-rw-r--r--calendar/gui/e-cal-list-view.c7
-rw-r--r--calendar/gui/e-cal-model-memos.c2
-rw-r--r--calendar/gui/e-cal-model-memos.h4
-rw-r--r--calendar/gui/e-cal-model-tasks.c2
-rw-r--r--calendar/gui/e-cal-model-tasks.h2
-rw-r--r--calendar/gui/e-cal-model.c2
-rw-r--r--calendar/gui/e-calendar-selector.c226
-rw-r--r--calendar/gui/e-calendar-selector.h66
-rw-r--r--calendar/gui/e-calendar-table-config.c282
-rw-r--r--calendar/gui/e-calendar-table-config.h46
-rw-r--r--calendar/gui/e-calendar-table.c1290
-rw-r--r--calendar/gui/e-calendar-table.h119
-rw-r--r--calendar/gui/e-calendar-view.c280
-rw-r--r--calendar/gui/e-calendar-view.h62
-rw-r--r--calendar/gui/e-cell-date-edit-config.h2
-rw-r--r--calendar/gui/e-day-view-main-item.c4
-rw-r--r--calendar/gui/e-day-view.c16
-rw-r--r--calendar/gui/e-itip-control.c17
-rw-r--r--calendar/gui/e-meeting-time-sel.c11
-rw-r--r--calendar/gui/e-memo-list-selector.c287
-rw-r--r--calendar/gui/e-memo-list-selector.h71
-rw-r--r--calendar/gui/e-memo-table.c1249
-rw-r--r--calendar/gui/e-memo-table.h101
-rw-r--r--calendar/gui/e-memos.c848
-rw-r--r--calendar/gui/e-memos.h4
-rw-r--r--calendar/gui/e-month-view.c211
-rw-r--r--calendar/gui/e-month-view.h66
-rw-r--r--calendar/gui/e-task-list-selector.c288
-rw-r--r--calendar/gui/e-task-list-selector.h71
-rw-r--r--calendar/gui/e-tasks.c845
-rw-r--r--calendar/gui/e-tasks.h15
-rw-r--r--calendar/gui/e-week-view-config.c2
-rw-r--r--calendar/gui/e-week-view-main-item.c4
-rw-r--r--calendar/gui/e-week-view.c324
-rw-r--r--calendar/gui/e-week-view.h197
-rw-r--r--calendar/gui/ea-cal-view-event.c568
-rw-r--r--calendar/gui/ea-cal-view-event.h57
-rw-r--r--calendar/gui/ea-cal-view.c425
-rw-r--r--calendar/gui/ea-cal-view.h58
-rw-r--r--calendar/gui/ea-calendar-helpers.c156
-rw-r--r--calendar/gui/ea-calendar-helpers.h (renamed from calendar/gui/itip-bonobo-control.h)25
-rw-r--r--calendar/gui/ea-calendar.c203
-rw-r--r--calendar/gui/ea-calendar.h (renamed from calendar/gui/control-factory.h)18
-rw-r--r--calendar/gui/ea-day-view-cell.c395
-rw-r--r--calendar/gui/ea-day-view-cell.h85
-rw-r--r--calendar/gui/ea-day-view-main-item.c1288
-rw-r--r--calendar/gui/ea-day-view-main-item.h58
-rw-r--r--calendar/gui/ea-day-view.c276
-rw-r--r--calendar/gui/ea-day-view.h57
-rw-r--r--calendar/gui/ea-gnome-calendar.c313
-rw-r--r--calendar/gui/ea-gnome-calendar.h59
-rw-r--r--calendar/gui/ea-jump-button.c223
-rw-r--r--calendar/gui/ea-jump-button.h57
-rw-r--r--calendar/gui/ea-week-view-cell.c477
-rw-r--r--calendar/gui/ea-week-view-cell.h85
-rw-r--r--calendar/gui/ea-week-view-main-item.c1246
-rw-r--r--calendar/gui/ea-week-view-main-item.h59
-rw-r--r--calendar/gui/ea-week-view.c320
-rw-r--r--calendar/gui/ea-week-view.h58
-rw-r--r--calendar/gui/gnome-cal.c1506
-rw-r--r--calendar/gui/gnome-cal.h51
-rw-r--r--calendar/gui/goto.c9
-rw-r--r--calendar/gui/itip-bonobo-control.c264
-rw-r--r--calendar/gui/itip-utils.c3
-rw-r--r--calendar/gui/main.c193
-rw-r--r--calendar/gui/memos-component.c810
-rw-r--r--calendar/gui/memos-component.h4
-rw-r--r--calendar/gui/memos-control.c404
-rw-r--r--calendar/gui/memos-control.h36
-rw-r--r--calendar/gui/migration.c1243
-rw-r--r--calendar/gui/migration.h35
-rw-r--r--calendar/gui/print.c3
-rw-r--r--calendar/gui/print.h4
-rw-r--r--calendar/gui/tasks-component.c496
-rw-r--r--calendar/gui/tasks-component.h5
-rw-r--r--calendar/gui/tasks-control.c260
114 files changed, 10730 insertions, 13238 deletions
diff --git a/calendar/gui/Makefile.am b/calendar/gui/Makefile.am
index 6b515f442a..7bc52c9e15 100644
--- a/calendar/gui/Makefile.am
+++ b/calendar/gui/Makefile.am
@@ -1,31 +1,9 @@
if OS_WIN32
-WIN32_BOOTSTRAP_LIBS = $(top_builddir)/win32/libevolution-mail-shared.la
+WIN32_BOOTSTRAP_LIBS = $(top_builddir)/win32/libevolution-mail.la
endif
-## CORBA stuff
-
-IDLS = \
- $(top_srcdir)/calendar/idl/evolution-calendar.idl
-
-CALENDAR_IDL_GENERATED_H = \
- evolution-calendar.h
-CALENDAR_IDL_GENERATED_C = \
- evolution-calendar-common.c \
- evolution-calendar-skels.c \
- evolution-calendar-stubs.c
-CALENDAR_IDL_GENERATED = $(CALENDAR_IDL_GENERATED_C) $(CALENDAR_IDL_GENERATED_H)
-
-$(CALENDAR_IDL_GENERATED_H): $(IDLS)
- $(ORBIT_IDL) -I $(srcdir) $(IDL_INCLUDES) \
- $(top_srcdir)/calendar/idl/evolution-calendar.idl
-$(CALENDAR_IDL_GENERATED_C): $(CALENDAR_IDL_GENERATED_H)
-
-IDL_GENERATED = $(CALENDAR_IDL_GENERATED)
-
SUBDIRS = alarm-notify dialogs
-component_LTLIBRARIES = libevolution-calendar.la
-
ecalendarincludedir = $(privincludedir)/calendar/gui
ecalendarinclude_HEADERS = \
@@ -46,7 +24,6 @@ AM_CPPFLAGS = \
-I$(top_srcdir)/calendar \
-I$(top_srcdir)/widgets \
-I$(top_srcdir)/widgets/misc \
- -I$(top_srcdir)/a11y/calendar \
-DSEARCH_RULE_DIR=\"$(ruledir)\" \
-DEVOLUTION_GLADEDIR=\""$(gladedir)"\" \
-DEVOLUTION_ETSPECDIR=\""$(etspecdir)"\" \
@@ -67,35 +44,28 @@ etspec_DATA = \
e-cal-list-view.etspec \
e-memo-table.etspec
-libevolution_calendar_la_SOURCES = \
- $(IDL_GENERATED) \
+noinst_LTLIBRARIES = libcal-gui.la
+
+libcal_gui_la_SOURCES = \
e-attachment-handler-calendar.c \
e-attachment-handler-calendar.h \
- cal-search-bar.c \
- cal-search-bar.h \
+ e-calendar-view.c \
+ e-calendar-view.h \
+ e-calendar-table.c \
+ e-calendar-table.h \
calendar-config.c \
calendar-config.h \
calendar-config-keys.h \
- calendar-commands.c \
- calendar-commands.h \
- calendar-component.c \
- calendar-component.h \
calendar-view.c \
calendar-view.h \
calendar-view-factory.c \
calendar-view-factory.h \
- comp-editor-factory.c \
- comp-editor-factory.h \
comp-util.c \
comp-util.h \
- control-factory.c \
- control-factory.h \
e-alarm-list.c \
e-alarm-list.h \
e-cal-component-preview.c \
e-cal-component-preview.h \
- e-cal-component-memo-preview.c \
- e-cal-component-memo-preview.h \
e-cal-config.c \
e-cal-config.h \
e-cal-event.c \
@@ -111,18 +81,16 @@ libevolution_calendar_la_SOURCES = \
e-cal-model.h \
e-cal-popup.h \
e-cal-popup.c \
- e-calendar-view.c \
- e-calendar-view.h \
e-cal-list-view.c \
e-cal-list-view.h \
e-cal-list-view-config.c \
e-cal-list-view-config.h \
e-cal-model-memos.c \
e-cal-model-memos.h \
- e-calendar-table.c \
- e-calendar-table.h \
e-calendar-table-config.c \
e-calendar-table-config.h \
+ e-calendar-selector.c \
+ e-calendar-selector.h \
e-cell-date-edit-config.c \
e-cell-date-edit-config.h \
e-cell-date-edit-text.h \
@@ -160,18 +128,22 @@ libevolution_calendar_la_SOURCES = \
e-meeting-types.h \
e-meeting-utils.c \
e-meeting-utils.h \
+ e-memo-list-selector.c \
+ e-memo-list-selector.h \
e-memo-table.c \
e-memo-table.h \
e-memo-table-config.c \
e-memo-table-config.h \
- e-memos.c \
- e-memos.h \
e-mini-calendar-config.c \
e-mini-calendar-config.h \
+ e-month-view.c \
+ e-month-view.h \
e-select-names-editable.c \
e-select-names-editable.h \
e-select-names-renderer.c \
e-select-names-renderer.h \
+ e-task-list-selector.c \
+ e-task-list-selector.h \
e-week-view-config.c \
e-week-view-config.h \
e-week-view-event-item.c \
@@ -184,60 +156,67 @@ libevolution_calendar_la_SOURCES = \
e-week-view-titles-item.h \
e-week-view.c \
e-week-view.h \
- e-tasks.c \
- e-tasks.h \
e-timezone-entry.c \
e-timezone-entry.h \
- gnome-cal.c \
- gnome-cal.h \
goto.c \
goto.h \
- itip-bonobo-control.c \
- itip-bonobo-control.h \
+ gnome-cal.c \
+ gnome-cal.h \
itip-utils.c \
itip-utils.h \
- main.c \
- memos-component.c \
- memos-component.h \
- memos-control.c \
- memos-control.h \
- migration.c \
- migration.h \
misc.c \
misc.h \
print.c \
print.h \
tag-calendar.c \
tag-calendar.h \
- tasks-component.c \
- tasks-component.h \
- tasks-control.c \
- tasks-control.h \
weekday-picker.c \
- weekday-picker.h
+ weekday-picker.h \
+ ea-calendar.c \
+ ea-calendar.h \
+ ea-calendar-helpers.c \
+ ea-calendar-helpers.h \
+ ea-cal-view.c \
+ ea-cal-view.h \
+ ea-cal-view-event.c \
+ ea-cal-view-event.h \
+ ea-day-view.c \
+ ea-day-view.h \
+ ea-day-view-main-item.c \
+ ea-day-view-main-item.h \
+ ea-day-view-cell.c \
+ ea-day-view-cell.h \
+ ea-week-view.c \
+ ea-week-view.h \
+ ea-week-view-main-item.c \
+ ea-week-view-main-item.h \
+ ea-week-view-cell.c \
+ ea-week-view-cell.h \
+ ea-jump-button.c \
+ ea-jump-button.h \
+ ea-gnome-calendar.c \
+ ea-gnome-calendar.h
-libevolution_calendar_la_LIBADD = \
- $(WIN32_BOOTSTRAP_LIBS) \
+libcal_gui_la_LIBADD = \
+ $(top_builddir)/composer/libcomposer.la \
+ $(top_builddir)/addressbook/gui/contact-editor/libecontacteditor.la \
+ $(top_builddir)/addressbook/gui/contact-list-editor/libecontactlisteditor.la \
$(top_builddir)/widgets/menus/libmenus.la \
$(top_builddir)/shell/libeshell.la \
$(top_builddir)/calendar/common/libevolution-calendarprivate.la \
$(top_builddir)/calendar/gui/dialogs/libcal-dialogs.la \
$(top_builddir)/calendar/importers/libevolution-calendar-importers.la \
$(top_builddir)/widgets/e-timezone-dialog/libetimezonedialog.la \
- $(top_builddir)/widgets/misc/libefilterbar.la \
$(top_builddir)/widgets/misc/libemiscwidgets.la \
+ $(top_builddir)/widgets/table/libetable.la \
$(top_builddir)/filter/libfilter.la \
$(top_builddir)/e-util/libeutil.la \
- $(top_builddir)/a11y/calendar/libevolution-calendar-a11y.la \
$(LIBSOUP_LIBS) \
$(CAMEL_LIBS) \
$(EVOLUTION_CALENDAR_LIBS)
-libevolution_calendar_la_LDFLAGS = -avoid-version -module $(NO_UNDEFINED)
+libcal_gui_la_LDFLAGS = -avoid-version -module $(NO_UNDEFINED)
-server_in_files = GNOME_Evolution_Calendar.server.in.in
-server_DATA = $(server_in_files:.server.in.in=.server)
-@EVO_SERVER_RULE@
@INTLTOOL_SERVER_RULE@
# GConf schemas
@@ -252,10 +231,8 @@ EXTRA_DIST = \
$(glade_DATA) \
$(schema_in_files) \
$(etspec_DATA) \
- $(server_in_files) \
$(search_files)
-BUILT_SOURCES = $(IDL_GENERATED) $(server_DATA)
CLEANFILES = $(BUILT_SOURCES)
DISTCLEANFILES = $(schema_DATA)
diff --git a/calendar/gui/alarm-notify/alarm-queue.c b/calendar/gui/alarm-notify/alarm-queue.c
index 066f295a7d..e7fbdc7090 100644
--- a/calendar/gui/alarm-notify/alarm-queue.c
+++ b/calendar/gui/alarm-notify/alarm-queue.c
@@ -903,6 +903,7 @@ create_snooze (CompQueuedAlarms *cqa, gpointer alarm_id, gint snooze_mins)
static void
edit_component (ECal *client, ECalComponent *comp)
{
+#if 0 /* KILL-BONOBO */
const gchar *uid;
const gchar *uri;
ECalSourceType source_type;
@@ -946,6 +947,7 @@ edit_component (ECal *client, ECalComponent *comp)
/* Get rid of the factory */
bonobo_object_release_unref (factory, NULL);
+#endif
}
typedef struct {
diff --git a/calendar/gui/apps_evolution_calendar.schemas.in b/calendar/gui/apps_evolution_calendar.schemas.in
index 48c5100ad8..6e5e057c14 100644
--- a/calendar/gui/apps_evolution_calendar.schemas.in
+++ b/calendar/gui/apps_evolution_calendar.schemas.in
@@ -268,11 +268,11 @@
</locale>
</schema>
<schema>
- <key>/schemas/apps/evolution/calendar/display/tag_vpane_position</key>
- <applyto>/apps/evolution/calendar/display/tag_vpane_position</applyto>
+ <key>/schemas/apps/evolution/calendar/display/date_navigator_pane_position</key>
+ <applyto>/apps/evolution/calendar/display/date_navigator_pane_position</applyto>
<owner>evolution-calendar</owner>
- <type>float</type>
- <default>0.5</default>
+ <type>int</type>
+ <default>150</default>
<locale name="C">
<short>Month view vertical pane position </short>
<long>Position of the vertical pane, between the calendar lists and the date navigator calendar.</long>
@@ -293,13 +293,25 @@
</schema>
<schema>
+ <key>/schemas/apps/evolution/calendar/display/memo_vpane_position</key>
+ <applyto>/apps/evolution/calendar/display/memo_vpane_position</applyto>
+ <owner>evolution-calendar</owner>
+ <type>int</type>
+ <default>400</default>
+ <locale name="C">
+ <short>Memos vertical pane position</short>
+ <long>Position of the vertical pane, between the memo list and the memo preview pane, in pixels.</long>
+ </locale>
+ </schema>
+
+ <schema>
<key>/schemas/apps/evolution/calendar/display/task_vpane_position</key>
<applyto>/apps/evolution/calendar/display/task_vpane_position</applyto>
<owner>evolution-calendar</owner>
<type>int</type>
<default>400</default>
<locale name="C">
- <short>Tasks vertical pane position </short>
+ <short>Tasks vertical pane position</short>
<long>Position of the vertical pane, between the task list and the task preview pane, in pixels.</long>
</locale>
</schema>
diff --git a/calendar/gui/cal-search-bar.c b/calendar/gui/cal-search-bar.c
deleted file mode 100644
index 63fcb03497..0000000000
--- a/calendar/gui/cal-search-bar.c
+++ /dev/null
@@ -1,920 +0,0 @@
-/*
- * Evolution calendar - Search bar widget for calendar views
- *
- * This program is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 2 of the License, or (at your option) version 3.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with the program; if not, see <http://www.gnu.org/licenses/>
- *
- *
- * Authors:
- * Federico Mena-Quintero <federico@ximian.com>
- *
- * Copyright (C) 1999-2008 Novell, Inc. (www.novell.com)
- *
- */
-
-#ifdef HAVE_CONFIG_H
-#include <config.h>
-#endif
-
-#include <stdlib.h>
-#include <string.h>
-#include <gtk/gtk.h>
-#include <glib/gi18n.h>
-#include <libedataserver/e-categories.h>
-#include <libecal/e-cal-time-util.h>
-#include <libedataserver/e-categories.h>
-#include <filter/rule-editor.h>
-
-#include "cal-search-bar.h"
-#include "calendar-component.h"
-#include "memos-component.h"
-#include "tasks-component.h"
-
-#include "e-util/e-util.h"
-#include "e-util/e-error.h"
-#include "e-util/e-util-private.h"
-
-typedef struct CALSearchBarItem {
- ESearchBarItem search;
- const gchar *image;
-} CALSearchBarItem;
-
-static ESearchBarItem calendar_search_items[] = {
- E_FILTERBAR_ADVANCED,
- {NULL, 0, 0},
- E_FILTERBAR_SAVE,
- E_FILTERBAR_EDIT,
- {NULL, -1, 0}
-};
-
-/* IDs and option items for the ESearchBar */
-enum {
- SEARCH_SUMMARY_CONTAINS,
- SEARCH_DESCRIPTION_CONTAINS,
- SEARCH_ANY_FIELD_CONTAINS,
- SEARCH_CATEGORY_IS,
- SEARCH_COMMENT_CONTAINS,
- SEARCH_LOCATION_CONTAINS,
- SEARCH_ATTENDEE_CONTAINS
-
-};
-
-/* Comments are disabled because they are kind of useless right now, see bug 33247 */
-static ESearchBarItem search_option_items[] = {
- { (gchar *) N_("Summary contains"), SEARCH_SUMMARY_CONTAINS, ESB_ITEMTYPE_RADIO },
- { (gchar *) N_("Description contains"), SEARCH_DESCRIPTION_CONTAINS, ESB_ITEMTYPE_RADIO },
- { (gchar *) N_("Category is"), SEARCH_CATEGORY_IS, ESB_ITEMTYPE_RADIO },
- { (gchar *) N_("Comment contains"), SEARCH_COMMENT_CONTAINS, ESB_ITEMTYPE_RADIO },
- { (gchar *) N_("Location contains"), SEARCH_LOCATION_CONTAINS, ESB_ITEMTYPE_RADIO },
- { (gchar *) N_("Any field contains"), SEARCH_ANY_FIELD_CONTAINS, ESB_ITEMTYPE_RADIO },
-};
-
-/* IDs for the categories suboptions */
-
-typedef enum {
- CATEGORIES_ALL,
- CATEGORIES_UNMATCHED,
- LAST_FIELD
-} common_search_options;
-
-typedef enum {
- N_DAY_TASK = LAST_FIELD,
- ACTIVE_TASK,
- OVERDUE_TASK,
- COMPLETED_TASK,
- TASK_WITH_ATTACHMENT,
- TASK_LAST_FIELD
-} task_search_options;
-
-typedef enum {
- ACTIVE_APPONTMENT = LAST_FIELD,
- N_DAY_APPOINTMENT,
- CAL_LAST_FIELD
-} cal_search_options;
-
-/* We add 2 to the offset to include the separators used to differenciate the quick search queries. */
-#define CATEGORIES_TASKS_OFFSET (TASK_LAST_FIELD + 2)
-#define CATEGORIES_MEMOS_OFFSET (LAST_FIELD + 1)
-#define CATEGORIES_CALENDAR_OFFSET (CAL_LAST_FIELD + 2)
-
-/* Private part of the CalSearchBar structure */
-struct CalSearchBarPrivate {
- /* Array of categories */
- GPtrArray *categories;
-
- RuleContext *search_context;
- FilterRule *search_rule;
- guint32 view_flag;
-
- time_t start;
- time_t end;
-};
-
-static void cal_search_bar_destroy (GtkObject *object);
-
-static void cal_search_bar_search_activated (ESearchBar *search);
-
-/* Signal IDs */
-enum {
- SEXP_CHANGED,
- CATEGORY_CHANGED,
- LAST_SIGNAL
-};
-
-static guint cal_search_bar_signals[LAST_SIGNAL] = { 0 };
-
-G_DEFINE_TYPE (CalSearchBar, cal_search_bar, E_FILTER_BAR_TYPE)
-
-/* Class initialization function for the calendar search bar */
-static void
-cal_search_bar_class_init (CalSearchBarClass *klass)
-{
-
- GtkObjectClass *object_class = GTK_OBJECT_CLASS (klass);
- ESearchBarClass *search_bar_class = E_SEARCH_BAR_CLASS (klass);
-
- cal_search_bar_signals[SEXP_CHANGED] =
- g_signal_new ("sexp_changed",
- G_TYPE_FROM_CLASS (object_class),
- G_SIGNAL_RUN_FIRST,
- G_STRUCT_OFFSET (CalSearchBarClass, sexp_changed),
- NULL, NULL,
- g_cclosure_marshal_VOID__STRING,
- G_TYPE_NONE, 1,
- G_TYPE_STRING);
-
- cal_search_bar_signals[CATEGORY_CHANGED] =
- g_signal_new ("category_changed",
- G_TYPE_FROM_CLASS (object_class),
- G_SIGNAL_RUN_FIRST,
- G_STRUCT_OFFSET (CalSearchBarClass, category_changed),
- NULL, NULL,
- g_cclosure_marshal_VOID__STRING,
- G_TYPE_NONE, 1,
- G_TYPE_STRING);
-
- klass->sexp_changed = NULL;
- klass->category_changed = NULL;
-
- search_bar_class->search_activated = cal_search_bar_search_activated;
- object_class->destroy = cal_search_bar_destroy;
-}
-
-/* Object initialization function for the calendar search bar */
-static void
-cal_search_bar_init (CalSearchBar *cal_search)
-{
- CalSearchBarPrivate *priv;
-
- priv = g_new (CalSearchBarPrivate, 1);
- cal_search->priv = priv;
-
- priv->categories = g_ptr_array_new ();
- g_ptr_array_set_size (priv->categories, 0);
-
- priv->start = -1;
- priv->end = -1;
-}
-
-/* Frees an array of categories */
-static void
-free_categories (GPtrArray *categories)
-{
- gint i;
-
- for (i = 0; i < categories->len; i++) {
- if (categories->pdata[i] == NULL)
- continue;
- g_free (categories->pdata[i]);
- }
-
- g_ptr_array_free (categories, TRUE);
-}
-
-/* Destroy handler for the calendar search bar */
-static void
-cal_search_bar_destroy (GtkObject *object)
-{
- CalSearchBar *cal_search;
- CalSearchBarPrivate *priv;
-
- g_return_if_fail (object != NULL);
- g_return_if_fail (IS_CAL_SEARCH_BAR (object));
-
- cal_search = CAL_SEARCH_BAR (object);
- priv = cal_search->priv;
-
- if (priv) {
- if (priv->categories) {
- free_categories (priv->categories);
- priv->categories = NULL;
- }
-
- if (priv->search_rule) {
- g_object_unref (priv->search_rule);
- priv->search_rule = NULL;
- }
-
- /* FIXME
- if (priv->search_context) {
- g_object_unref (priv->search_context);
- priv->search_context = NULL;
- }*/
-
- g_free (priv);
- cal_search->priv = NULL;
- }
-
- if (GTK_OBJECT_CLASS (cal_search_bar_parent_class)->destroy)
- (* GTK_OBJECT_CLASS (cal_search_bar_parent_class)->destroy) (object);
-}
-
-
-
-/* Emits the "sexp_changed" signal for the calendar search bar */
-static void
-notify_sexp_changed (CalSearchBar *cal_search, const gchar *sexp)
-{
- g_signal_emit (GTK_OBJECT (cal_search), cal_search_bar_signals[SEXP_CHANGED], 0, sexp);
-}
-
-/* Returns the string of the currently selected category, NULL for "Unmatched" and "All
-*/
-static const gchar *
-get_current_category (CalSearchBar *cal_search)
-{
- CalSearchBarPrivate *priv;
- gint viewid, i = -1;
-
- priv = cal_search->priv;
-
- g_return_val_if_fail (priv->categories != NULL, NULL);
-
- viewid = e_search_bar_get_viewitem_id (E_SEARCH_BAR (cal_search));
-
- if (viewid == CATEGORIES_ALL || viewid == CATEGORIES_UNMATCHED)
- return NULL;
-
- if (priv->view_flag == CAL_SEARCH_TASKS_DEFAULT)
- i = viewid - CATEGORIES_TASKS_OFFSET;
- else if (priv->view_flag == CAL_SEARCH_MEMOS_DEFAULT)
- i = viewid - CATEGORIES_MEMOS_OFFSET;
- else if (priv->view_flag == CAL_SEARCH_CALENDAR_DEFAULT)
- i = viewid - CATEGORIES_CALENDAR_OFFSET;
-
- if (i >= 0 && i < priv->categories->len)
- return priv->categories->pdata[i];
- else
- return NULL;
-}
-
-/* Returns a sexp for the selected category in the drop-down menu. The "All"
- * option is returned as (const gchar *) 1, and the "Unfiled" option is returned
- * as NULL.
- */
-static gchar *
-get_show_option_sexp (CalSearchBar *cal_search)
-{
- CalSearchBarPrivate *priv;
- gint viewid;
- gchar *start, *end, *due, *ret = NULL;
- const gchar *category = NULL;
- time_t start_range, end_range;
-
- priv = cal_search->priv;
- viewid = e_search_bar_get_viewitem_id (E_SEARCH_BAR (cal_search));
-
- if (viewid == CATEGORIES_UNMATCHED)
- return g_strdup ("(has-categories? #f)"); /* Unfiled items */
- else if (viewid == CATEGORIES_ALL)
- return NULL; /* All items */
-
- switch (priv->view_flag) {
- case CAL_SEARCH_TASKS_DEFAULT:
- if (viewid == N_DAY_TASK) {
- start_range = time(NULL);
- end_range = time_add_day(start_range, 7);
- start = isodate_from_time_t (start_range);
- due = isodate_from_time_t (end_range);
-
- ret = g_strdup_printf ("(due-in-time-range? (make-time \"%s\")"
- " (make-time \"%s\"))",
- start, due);
-
- g_free (start);
- g_free (due);
-
- return ret;
- } else if (viewid == ACTIVE_TASK) {
- /* Shows the tasks due for an year from now which are not completed yet*/
- start_range = time(NULL);
- end_range = time_add_day(start_range, 365);
- start = isodate_from_time_t (start_range);
- due = isodate_from_time_t (end_range);
-
- ret = g_strdup_printf ("(and (due-in-time-range? (make-time \"%s\")"
- " (make-time \"%s\")) (not (is-completed?)))",
- start, due);
-
- g_free (start);
- g_free (due);
-
- return ret;
- } else if (viewid == OVERDUE_TASK) {
- /* Shows the tasks which are overdue from lower limit 1970 to the current time */
- start_range = 0;
- end_range = time (NULL);
- start = isodate_from_time_t (start_range);
- due = isodate_from_time_t (end_range);
-
- ret = g_strdup_printf ("(and (due-in-time-range? (make-time \"%s\")"
- " (make-time \"%s\")) (not (is-completed?)))",
- start, due);
-
- g_free (start);
- g_free (due);
-
- return ret;
- } else if (viewid == COMPLETED_TASK)
- return g_strdup ("(is-completed?)");
- else if (viewid == TASK_WITH_ATTACHMENT)
- return g_strdup ("(has-attachments?)");
- break;
- case CAL_SEARCH_CALENDAR_DEFAULT:
- if (viewid == ACTIVE_APPONTMENT) {
- /* Shows next one year's Appointments */
- start_range = time (NULL);
- end_range = time_add_day (start_range, 365);
- start = isodate_from_time_t (start_range);
- end = isodate_from_time_t (end_range);
-
- ret = g_strdup_printf ("(occur-in-time-range? (make-time \"%s\")"
- " (make-time \"%s\"))",
- start, end);
-
- cal_search->priv->start = start_range;
- cal_search->priv->end = end_range;
-
- g_free (start);
- g_free (end);
-
- return ret;
- } else if (viewid == N_DAY_APPOINTMENT) {
- start_range = time (NULL);
- end_range = time_add_day (start_range, 7);
- start = isodate_from_time_t (start_range);
- end = isodate_from_time_t (end_range);
-
- ret = g_strdup_printf ("(occur-in-time-range? (make-time \"%s\")"
- " (make-time \"%s\"))",
- start, end);
-
- cal_search->priv->start = start_range;
- cal_search->priv->end = end_range;
-
- g_free (start);
- g_free (end);
-
- return ret;
- }
- break;
- default:
- break;
- }
-
- category = get_current_category (cal_search);
-
- if (category != NULL)
- return g_strdup_printf ("(has-categories? \"%s\")", category);
- else
- return NULL;
-}
-
-/* Sets the query string to be (contains? "field" "text") */
-static void
-notify_e_cal_view_contains (CalSearchBar *cal_search, const gchar *field, const gchar *view)
-{
- gchar *text = NULL;
- gchar *sexp;
-
- text = e_search_bar_get_text (E_SEARCH_BAR (cal_search));
-
- if (!text)
- return; /* This is an error in the UTF8 conversion, not an empty string! */
-
- if (text && *text)
- sexp = g_strdup_printf ("(contains? \"%s\" \"%s\")", field, text);
- else
- sexp = g_strdup ("(contains? \"summary\" \"\")"); /* Show all */
-
- g_free (text);
-
- /* Apply the selected view on search */
- if (view && *view) {
- sexp = g_strconcat ("(and ",sexp, view, ")", NULL);
- }
-
- notify_sexp_changed (cal_search, sexp);
-
- g_free (sexp);
-}
-
-#if 0
-/* Sets the query string to the appropriate match for categories */
-static void
-notify_category_is (CalSearchBar *cal_search)
-{
- gchar *sexp;
-
- sexp = get_show_option_sexp (cal_search);
-
- if (!sexp)
- notify_sexp_changed (cal_search, "#t"); /* Match all */
- else
- notify_sexp_changed (cal_search, sexp);
-
- if (sexp)
- g_free (sexp);
-}
-#endif
-
-/* Creates a new query from the values in the widgets and notifies upstream */
-static void
-regen_query (CalSearchBar *cal_search)
-{
- gint id;
- gchar *show_option_sexp = NULL;
- gchar *sexp = NULL;
- GString *out = NULL;
- EFilterBar *efb = (EFilterBar *) cal_search;
-
- /* Fetch the data from the ESearchBar's entry widgets */
- id = e_search_bar_get_item_id (E_SEARCH_BAR (cal_search));
-
- cal_search->priv->start = -1;
- cal_search->priv->end = -1;
-
- /* Get the selected view */
- show_option_sexp = get_show_option_sexp (cal_search);
-
- /* Generate the different types of queries */
- switch (id) {
- case SEARCH_ANY_FIELD_CONTAINS:
- notify_e_cal_view_contains (cal_search, "any", show_option_sexp);
- break;
-
- case SEARCH_SUMMARY_CONTAINS:
- notify_e_cal_view_contains (cal_search, "summary", show_option_sexp);
- break;
-
- case SEARCH_DESCRIPTION_CONTAINS:
- notify_e_cal_view_contains (cal_search, "description", show_option_sexp);
- break;
-
- case SEARCH_COMMENT_CONTAINS:
- notify_e_cal_view_contains (cal_search, "comment", show_option_sexp);
- break;
-
- case SEARCH_LOCATION_CONTAINS:
- notify_e_cal_view_contains (cal_search, "location", show_option_sexp);
- break;
- case SEARCH_ATTENDEE_CONTAINS:
- notify_e_cal_view_contains (cal_search, "attendee", show_option_sexp);
- break;
- case E_FILTERBAR_ADVANCED_ID:
- out = g_string_new ("");
- filter_rule_build_code (efb->current_query, out);
-
- if (show_option_sexp && *show_option_sexp)
- sexp = g_strconcat ("(and ", out->str, show_option_sexp, ")", NULL);
-
- notify_sexp_changed (cal_search, sexp ? sexp : out->str);
-
- g_string_free (out, TRUE);
- g_free(sexp);
- break;
-
- default:
- g_return_if_reached ();
- }
-
- g_free (show_option_sexp);
-}
-
-#if 0
-static void
-regen_view_query (CalSearchBar *cal_search)
-{
- const gchar *category;
- notify_category_is (cal_search);
-
- category = cal_search_bar_get_category (cal_search);
- g_signal_emit (GTK_OBJECT (cal_search), cal_search_bar_signals[CATEGORY_CHANGED], 0, category);
-}
-#endif
-
-/* search_activated handler for the calendar search bar */
-static void
-cal_search_bar_search_activated (ESearchBar *search)
-{
- CalSearchBar *cal_search;
-
- cal_search = CAL_SEARCH_BAR (search);
- regen_query (cal_search);
-}
-
-static GtkWidget *
-generate_viewoption_menu (CALSearchBarItem *subitems)
-{
- GtkWidget *menu, *menu_item;
- gint i = 0;
-
- menu = gtk_menu_new ();
-
- for (i = 0; subitems[i].search.id != -1; ++i) {
- if (subitems[i].search.text) {
- gchar *str = NULL;
- str = e_str_without_underscores (subitems[i].search.text);
- menu_item = gtk_image_menu_item_new_with_label (str);
- if (subitems[i].image) {
- GtkWidget *image;
-
- image = gtk_image_new_from_file (
- subitems[i].image);
- gtk_image_menu_item_set_image (
- GTK_IMAGE_MENU_ITEM (menu_item),
- image);
- }
- g_free (str);
- } else {
- menu_item = gtk_menu_item_new ();
- gtk_widget_set_sensitive (menu_item, FALSE);
- }
-
- g_object_set_data (G_OBJECT (menu_item), "EsbItemId",
- GINT_TO_POINTER (subitems[i].search.id));
-
- gtk_widget_show (menu_item);
- gtk_menu_shell_append(GTK_MENU_SHELL(menu), menu_item);
- }
-
- return menu;
-}
-
-static void
-setup_category_options (CalSearchBar *cal_search, CALSearchBarItem *subitems, gint index, gint offset)
-{
- CalSearchBarPrivate *priv;
- gint i;
-
- priv = cal_search->priv;
-
- if (priv->categories->len > 0) {
- subitems[index].search.text = NULL; /* separator */
- subitems[index].search.id = 0;
- subitems[index].image = NULL;
-
- for (i = 0; i < priv->categories->len; i++) {
- const gchar *category;
-
- category = priv->categories->pdata[i] ? priv->categories->pdata [i] : "";
-
- /* The search.text field should not be free'd */
- subitems[i + offset].search.text = (gchar *) category;
- subitems[i + offset].search.id = i + offset;
- subitems[i + offset].image = e_categories_get_icon_file_for (category);
- }
- index = i + offset;
- }
-
- subitems[index].search.id = -1; /* terminator */
- subitems[index].search.text = NULL;
- subitems[index].image = NULL;
-}
-
-/* Creates the suboptions menu for the ESearchBar with the list of categories */
-static void
-make_suboptions (CalSearchBar *cal_search)
-{
- CalSearchBarPrivate *priv;
- CALSearchBarItem *subitems = NULL;
- GtkWidget *menu;
-
- priv = cal_search->priv;
-
- g_return_if_fail (priv->categories != NULL);
-
- /* Categories plus "all", "unmatched", separator, terminator */
-
- /* All, unmatched, separator */
-
- if (priv->view_flag == CAL_SEARCH_TASKS_DEFAULT) {
- subitems = g_new (CALSearchBarItem, priv->categories->len + CATEGORIES_TASKS_OFFSET + 1);
-
- subitems[0].search.text = _("Any Category");
- subitems[0].search.id = CATEGORIES_ALL;
- subitems[0].image = NULL;
-
- subitems[1].search.text = _("Unmatched");
- subitems[1].search.id = CATEGORIES_UNMATCHED;
- subitems[1].image = NULL;
-
- subitems[2].search.text = NULL;
- subitems[2].search.id = 0;
- subitems[2].image = NULL;
-
- subitems[3].search.text = _("Next 7 Days' Tasks");
- subitems[3].search.id = N_DAY_TASK;
- subitems[3].image = NULL;
-
- subitems[4].search.text = _("Active Tasks");
- subitems[4].search.id = ACTIVE_TASK;
- subitems[4].image = NULL;
-
- subitems[5].search.text = _("Overdue Tasks");
- subitems[5].search.id = OVERDUE_TASK;
- subitems[5].image = NULL;
-
- subitems[6].search.text = _("Completed Tasks");
- subitems[6].search.id = COMPLETED_TASK;
- subitems[6].image = NULL;
-
- subitems[7].search.text = _("Tasks with Attachments");
- subitems[7].search.id = TASK_WITH_ATTACHMENT;
- subitems[7].image = NULL;
-
- /* All the other items */
- setup_category_options (cal_search, subitems, 8, CATEGORIES_TASKS_OFFSET);
-
- menu = generate_viewoption_menu (subitems);
- e_search_bar_set_viewoption_menu ((ESearchBar *)cal_search, menu);
-
- } else if (priv->view_flag == CAL_SEARCH_MEMOS_DEFAULT) {
- subitems = g_new (CALSearchBarItem, priv->categories->len + CATEGORIES_MEMOS_OFFSET + 1);
-
- /* All, unmatched, separator */
-
- subitems[0].search.text = _("Any Category");
- subitems[0].search.id = CATEGORIES_ALL;
- subitems[0].image = NULL;
-
- subitems[1].search.text = _("Unmatched");
- subitems[1].search.id = CATEGORIES_UNMATCHED;
- subitems[1].image = NULL;
-
- /* All the other items */
- setup_category_options (cal_search, subitems, 2, CATEGORIES_MEMOS_OFFSET);
-
- menu = generate_viewoption_menu (subitems);
- e_search_bar_set_viewoption_menu ((ESearchBar *)cal_search, menu);
-
- } else if (priv->view_flag == CAL_SEARCH_CALENDAR_DEFAULT) {
- subitems = g_new (CALSearchBarItem, priv->categories->len + CATEGORIES_CALENDAR_OFFSET + 1);
-
- /* All, unmatched, separator */
-
- subitems[0].search.text = _("Any Category");
- subitems[0].search.id = CATEGORIES_ALL;
- subitems[0].image = NULL;
-
- subitems[1].search.text = _("Unmatched");
- subitems[1].search.id = CATEGORIES_UNMATCHED;
- subitems[1].image = NULL;
-
- subitems[2].search.text = NULL;
- subitems[2].search.id = 0;
- subitems[2].image = NULL;
-
- subitems[3].search.text = _("Active Appointments");
- subitems[3].search.id = ACTIVE_APPONTMENT;
- subitems[3].image = NULL;
-
- subitems[4].search.text = _("Next 7 Days' Appointments");
- subitems[4].search.id = N_DAY_APPOINTMENT;
- subitems[4].image = NULL;
-
- /* All the other items */
- setup_category_options (cal_search, subitems, 5, CATEGORIES_CALENDAR_OFFSET);
-
- menu = generate_viewoption_menu (subitems);
- e_search_bar_set_viewoption_menu ((ESearchBar *)cal_search, menu);
- }
-
- if (subitems != NULL)
- g_free (subitems);
-}
-
-static void
-search_menu_activated (ESearchBar *esb, gint id)
-{
- if (id == E_FILTERBAR_ADVANCED_ID)
- e_search_bar_set_item_id (esb, id);
-}
-
-/**
- * cal_search_bar_construct:
- * @cal_search: A calendar search bar.
- * @flags: bitfield of items to appear in the search menu
- *
- * Constructs a calendar search bar by binding its menu and option items.
- *
- * Return value: The same value as @cal_search.
- **/
-CalSearchBar *
-cal_search_bar_construct (CalSearchBar *cal_search, guint32 flags)
-{
- ESearchBarItem *items;
- guint32 bit = 0x1;
- gint i, j;
- gchar *xmlfile = NULL;
- gchar *userfile = NULL;
- FilterPart *part;
- RuleContext *search_context;
- FilterRule *search_rule;
- const gchar *base_dir;
-
- g_return_val_if_fail (IS_CAL_SEARCH_BAR (cal_search), NULL);
-
- items = g_alloca ((G_N_ELEMENTS (search_option_items) + 1) * sizeof (ESearchBarItem));
- for (i = 0, j = 0; i < G_N_ELEMENTS (search_option_items); i++, bit <<= 1) {
- if ((flags & bit) != 0) {
- items[j].text = search_option_items[i].text;
- items[j].id = search_option_items[i].id;
- items[j].type = search_option_items[i].type;
- j++;
- }
- }
-
- items[j].text = NULL;
- items[j].id = -1;
- search_context = rule_context_new ();
- cal_search->priv->view_flag = flags;
-
- rule_context_add_part_set (search_context, "partset", filter_part_get_type (),
- rule_context_add_part, rule_context_next_part);
- rule_context_add_rule_set (search_context, "ruleset", filter_rule_get_type (),
- rule_context_add_rule, rule_context_next_rule);
-
- if (flags == CAL_SEARCH_MEMOS_DEFAULT) {
- base_dir = memos_component_peek_base_directory (memos_component_peek ());
- xmlfile = g_build_filename (SEARCH_RULE_DIR, "memotypes.xml", NULL);
- } else if (flags == CAL_SEARCH_TASKS_DEFAULT) {
- base_dir = tasks_component_peek_base_directory (tasks_component_peek ());
- xmlfile = g_build_filename (SEARCH_RULE_DIR, "tasktypes.xml", NULL);
- } else {
- base_dir = calendar_component_peek_base_directory (calendar_component_peek ());
- xmlfile = g_build_filename (SEARCH_RULE_DIR, "caltypes.xml", NULL);
- }
-
- userfile = g_build_filename (base_dir, "searches.xml", NULL);
-
- g_object_set_data_full (G_OBJECT (search_context), "user", userfile, g_free);
- g_object_set_data_full (G_OBJECT (search_context), "system", xmlfile, g_free);
-
- rule_context_load (search_context, xmlfile, userfile);
- search_rule = filter_rule_new ();
- part = rule_context_next_part (search_context, NULL);
-
- if (part == NULL)
- g_warning ("Could not load calendar search; no parts.");
- else
- filter_rule_add_part (search_rule, filter_part_clone (part));
-
- e_filter_bar_new_construct (search_context, xmlfile, userfile, NULL, cal_search,
- (EFilterBar*) cal_search );
- e_search_bar_set_menu ((ESearchBar *) cal_search, calendar_search_items);
-
- g_signal_connect ((ESearchBar *) cal_search, "menu_activated", G_CALLBACK (search_menu_activated), cal_search);
-
- make_suboptions (cal_search);
-
- cal_search->priv->search_rule = search_rule;
- cal_search->priv->search_context = search_context;
-
- g_free (xmlfile);
- g_free (userfile);
-
- return cal_search;
-}
-
-/**
- * cal_search_bar_new:
- * flags: bitfield of items to appear in the search menu
- *
- * creates a new calendar search bar.
- *
- * return value: a newly-created calendar search bar. you should connect to the
- * "sexp_changed" signal to monitor changes in the generated sexps.
- **/
-GtkWidget *
-cal_search_bar_new (guint32 flags)
-{
- CalSearchBar *cal_search;
-
- cal_search = g_object_new (TYPE_CAL_SEARCH_BAR, NULL);
- return GTK_WIDGET (cal_search_bar_construct (cal_search, flags));
-}
-
-/* Used from qsort() */
-static gint
-compare_categories_cb (gconstpointer a, gconstpointer b)
-{
- const gchar **ca, **cb;
-
- ca = (const gchar **) a;
- cb = (const gchar **) b;
-
- /* FIXME: should use some utf8 strcoll() thingy */
- return strcmp (*ca, *cb);
-}
-
-/* Creates a sorted array of categories based on the original one; copies the
- * string values.
- */
-static GPtrArray *
-sort_categories (GPtrArray *categories)
-{
- GPtrArray *c;
- gint i;
-
- c = g_ptr_array_new ();
- g_ptr_array_set_size (c, categories->len);
-
- for (i = 0; i < categories->len; i++)
- c->pdata[i] = g_strdup (categories->pdata[i]);
-
- qsort (c->pdata, c->len, sizeof (gpointer), compare_categories_cb);
-
- return c;
-}
-
-/**
- * cal_search_bar_set_categories:
- * @cal_search: A calendar search bar.
- * @categories: Array of pointers to strings for the category names.
- *
- * Sets the list of categories that are to be shown in the drop-down list
- * of a calendar search bar. The search bar will automatically add an item
- * for "unfiled" components, that is, those that have no categories assigned
- * to them.
- **/
-void
-cal_search_bar_set_categories (CalSearchBar *cal_search, GPtrArray *categories)
-{
- CalSearchBarPrivate *priv;
-
- g_return_if_fail (IS_CAL_SEARCH_BAR (cal_search));
- g_return_if_fail (categories != NULL);
-
- priv = cal_search->priv;
-
- g_return_if_fail (priv->categories != NULL);
- free_categories (priv->categories);
-
- priv->categories = sort_categories (categories);
- make_suboptions (cal_search);
-}
-
-/**
- * cal_search_bar_get_category:
- * @cal_search: A calendar search bar.
- *
- * Queries the currently selected category name in a calendar search bar.
- * If "All" or "Unfiled" are selected, this function will return NULL.
- *
- * Return value: Name of the selected category, or NULL if there is no
- * selected category.
- **/
-const gchar *
-cal_search_bar_get_category (CalSearchBar *cal_search)
-{
- const gchar *category;
-
- category = get_current_category (cal_search);
-
- return category;
-}
-
-void
-cal_search_bar_get_time_range (CalSearchBar *cal_search, time_t *start, time_t *end)
-{
- CalSearchBarPrivate *priv;
-
- g_return_if_fail (IS_CAL_SEARCH_BAR (cal_search));
-
- priv = cal_search->priv;
-
- *start = priv->start;
- *end = priv->end;
-}
-
diff --git a/calendar/gui/cal-search-bar.h b/calendar/gui/cal-search-bar.h
deleted file mode 100644
index 3c7304f136..0000000000
--- a/calendar/gui/cal-search-bar.h
+++ /dev/null
@@ -1,91 +0,0 @@
-/*
- *
- * Evolution calendar - Search bar widget for calendar views
- *
- * This program is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 2 of the License, or (at your option) version 3.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with the program; if not, see <http://www.gnu.org/licenses/>
- *
- *
- * Authors:
- * Federico Mena-Quintero <federico@ximian.com>
- *
- * Copyright (C) 1999-2008 Novell, Inc. (www.novell.com)
- *
- */
-
-#ifndef CAL_SEARCH_BAR_H
-#define CAL_SEARCH_BAR_H
-
-#include "misc/e-search-bar.h"
-#include "misc/e-filter-bar.h"
-
-G_BEGIN_DECLS
-
-
-
-#define TYPE_CAL_SEARCH_BAR (cal_search_bar_get_type ())
-#define CAL_SEARCH_BAR(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), TYPE_CAL_SEARCH_BAR, CalSearchBar))
-#define CAL_SEARCH_BAR_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), TYPE_CAL_SEARCH_BAR, \
- CalSearchBarClass))
-#define IS_CAL_SEARCH_BAR(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), TYPE_CAL_SEARCH_BAR))
-#define IS_CAL_SEARCH_BAR_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), TYPE_CAL_SEARCH_BAR))
-
-typedef struct CalSearchBarPrivate CalSearchBarPrivate;
-
-enum {
- CAL_SEARCH_SUMMARY_CONTAINS = (1 << 0),
- CAL_SEARCH_DESCRIPTION_CONTAINS = (1 << 1),
- CAL_SEARCH_CATEGORY_IS = (1 << 2),
- CAL_SEARCH_COMMENT_CONTAINS = (1 << 3),
- CAL_SEARCH_LOCATION_CONTAINS = (1 << 4),
- CAL_SEARCH_ANY_FIELD_CONTAINS = (1 << 5)
-};
-
-#define CAL_SEARCH_ALL (0xff)
-#define CAL_SEARCH_CALENDAR_DEFAULT (0x33)
-#define CAL_SEARCH_TASKS_DEFAULT (0xE3)
-#define CAL_SEARCH_MEMOS_DEFAULT (0x23)
-
-typedef struct {
- EFilterBar search_bar;
-
- /* Private data */
- CalSearchBarPrivate *priv;
-} CalSearchBar;
-
-typedef struct {
- EFilterBarClass parent_class;
-
- /* Notification signals */
-
- void (* sexp_changed) (CalSearchBar *cal_search, const gchar *sexp);
- void (* category_changed) (CalSearchBar *cal_search, const gchar *category);
-} CalSearchBarClass;
-
-GType cal_search_bar_get_type (void);
-
-CalSearchBar *cal_search_bar_construct (CalSearchBar *cal_search, guint32 flags);
-
-GtkWidget *cal_search_bar_new (guint32 flags);
-
-void cal_search_bar_set_categories (CalSearchBar *cal_search, GPtrArray *categories);
-
-const gchar *cal_search_bar_get_category (CalSearchBar *cal_search);
-
-void cal_search_bar_get_time_range (CalSearchBar *cal_search, time_t *start, time_t *end);
-
-
-
-G_END_DECLS
-
-#endif
diff --git a/calendar/gui/calendar-commands.c b/calendar/gui/calendar-commands.c
index 7edf38df65..e849bf2e0b 100644
--- a/calendar/gui/calendar-commands.c
+++ b/calendar/gui/calendar-commands.c
@@ -66,52 +66,6 @@ typedef struct {
guint taskpad_focused : 1;
} FocusData;
-static void
-file_open_event_cb (BonoboUIComponent *uic, gpointer data, const gchar *path)
-{
- GnomeCalendar *gcal;
-
- gcal = GNOME_CALENDAR (data);
-
- e_calendar_view_open_event (E_CALENDAR_VIEW (gnome_calendar_get_current_view_widget (gcal)));
-}
-
-/* Prints the calendar at its current view and time range */
-void
-calendar_command_print (GnomeCalendar *gcal, GtkPrintOperationAction action)
-{
- if (gnome_calendar_get_view (gcal) == GNOME_CAL_LIST_VIEW) {
- ECalListView *list_view;
- ETable *table;
-
- list_view = E_CAL_LIST_VIEW (gnome_calendar_get_current_view_widget (gcal));
- table = e_table_scrolled_get_table (list_view->table_scrolled);
- print_table (table, _("Print"), _("Calendar"), action);
- } else {
- time_t start;
-
- gnome_calendar_get_current_time_range (gcal, &start, NULL);
- print_calendar (gcal, action, start);
- }
-}
-
-/* File/Print callback */
-static void
-file_print_cb (BonoboUIComponent *uic, gpointer data, const gchar *path)
-{
- GnomeCalendar *gcal = GNOME_CALENDAR (data);
-
- calendar_command_print (gcal, GTK_PRINT_OPERATION_ACTION_PRINT_DIALOG);
-}
-
-static void
-file_print_preview_cb (BonoboUIComponent *uic, gpointer data, const gchar *path)
-{
- GnomeCalendar *gcal = GNOME_CALENDAR (data);
-
- calendar_command_print (gcal, GTK_PRINT_OPERATION_ACTION_PREVIEW);
-}
-
/* Sets a clock cursor for the specified calendar window */
static void
set_clock_cursor (GnomeCalendar *gcal)
@@ -133,58 +87,6 @@ set_normal_cursor (GnomeCalendar *gcal)
}
static void
-previous_clicked (BonoboUIComponent *uic, gpointer data, const gchar *path)
-{
- GnomeCalendar *gcal;
-
- gcal = GNOME_CALENDAR (data);
-
- set_clock_cursor (gcal);
- gnome_calendar_previous (gcal);
- set_normal_cursor (gcal);
-}
-
-static void
-next_clicked (BonoboUIComponent *uic, gpointer data, const gchar *path)
-{
- GnomeCalendar *gcal;
-
- gcal = GNOME_CALENDAR (data);
-
- set_clock_cursor (gcal);
- gnome_calendar_next (gcal);
- set_normal_cursor (gcal);
-}
-
-void
-calendar_goto_today (GnomeCalendar *gcal)
-{
- set_clock_cursor (gcal);
- gnome_calendar_goto_today (gcal);
- set_normal_cursor (gcal);
-}
-
-static void
-today_clicked (BonoboUIComponent *uic, gpointer data, const gchar *path)
-{
- GnomeCalendar *gcal;
-
- gcal = GNOME_CALENDAR (data);
-
- calendar_goto_today (gcal);
-}
-
-static void
-goto_clicked (BonoboUIComponent *uic, gpointer data, const gchar *path)
-{
- GnomeCalendar *gcal;
-
- gcal = GNOME_CALENDAR (data);
-
- goto_dialog (gcal);
-}
-
-static void
show_day_view_clicked (BonoboUIComponent *uic, gpointer data, const gchar *path)
{
GnomeCalendar *gcal;
@@ -235,65 +137,6 @@ show_list_view_clicked (BonoboUIComponent *uic, gpointer data, const gchar *path
}
static void
-cut_cmd (BonoboUIComponent *uic, gpointer data, const gchar *path)
-{
- GnomeCalendar *gcal;
-
- gcal = GNOME_CALENDAR (data);
- set_clock_cursor (gcal);
- gnome_calendar_cut_clipboard (gcal);
- set_normal_cursor (gcal);
-}
-
-static void
-copy_cmd (BonoboUIComponent *uic, gpointer data, const gchar *path)
-{
- GnomeCalendar *gcal;
-
- gcal = GNOME_CALENDAR (data);
-
- set_clock_cursor (gcal);
- gnome_calendar_copy_clipboard (gcal);
- set_normal_cursor (gcal);
-}
-
-static void
-paste_cmd (BonoboUIComponent *uic, gpointer data, const gchar *path)
-{
- GnomeCalendar *gcal;
-
- gcal = GNOME_CALENDAR (data);
-
- set_clock_cursor (gcal);
- gnome_calendar_paste_clipboard (gcal);
- set_normal_cursor (gcal);
-}
-
-static void
-delete_cmd (BonoboUIComponent *uic, gpointer data, const gchar *path)
-{
- GnomeCalendar *gcal;
-
- gcal = GNOME_CALENDAR (data);
-
- set_clock_cursor (gcal);
- gnome_calendar_delete_selection (gcal);
- set_normal_cursor (gcal);
-}
-
-static void
-delete_occurrence_cmd (BonoboUIComponent *uic, gpointer data, const gchar *path)
-{
- GnomeCalendar *gcal;
-
- gcal = GNOME_CALENDAR (data);
-
- set_clock_cursor (gcal);
- gnome_calendar_delete_selected_occurrence (gcal);
- set_normal_cursor (gcal);
-}
-
-static void
purge_cmd (BonoboUIComponent *uic, gpointer data, const gchar *path)
{
GnomeCalendar *gcal;
@@ -365,69 +208,6 @@ sensitize_items(BonoboUIComponent *uic, struct _sensitize_item *items, guint32 m
}
}
-static struct _sensitize_item calendar_sensitize_table[] = {
- { "EventOpen", E_CAL_MENU_SELECT_ONE },
- { "Cut", E_CAL_MENU_SELECT_EDITABLE },
- { "Copy", E_CAL_MENU_SELECT_ANY },
- { "Paste", E_CAL_MENU_SELECT_EDITABLE },
- { "Delete", E_CAL_MENU_SELECT_EDITABLE|E_CAL_MENU_SELECT_NONRECURRING },
- { "DeleteOccurrence", E_CAL_MENU_SELECT_EDITABLE|E_CAL_MENU_SELECT_RECURRING },
- { "DeleteAllOccurrences", E_CAL_MENU_SELECT_EDITABLE|E_CAL_MENU_SELECT_RECURRING },
- { NULL }
-};
-
-/* Sensitizes the UI Component menu/toolbar calendar commands based on the
- * number of selected events. (This will always be 0 or 1 currently.) If enable
- * is FALSE, all will be disabled. Otherwise, the currently-selected number of
- * events will be used.
- */
-void
-calendar_control_sensitize_calendar_commands (BonoboControl *control, GnomeCalendar *gcal, gboolean enable)
-{
- BonoboUIComponent *uic;
- GtkWidget *view;
- ECalMenu *menu;
- ECalModel *model;
- GPtrArray *events;
- GList *selected, *l;
- ECalMenuTargetSelect *t;
-
- uic = bonobo_control_get_ui_component (control);
- g_return_if_fail (uic != NULL);
-
- if (bonobo_ui_component_get_container (uic) == CORBA_OBJECT_NIL)
- return;
-
- view = gnome_calendar_get_current_view_widget (gcal);
-
- menu = gnome_calendar_get_calendar_menu (gcal);
- model = e_calendar_view_get_model((ECalendarView *)view);
- events = g_ptr_array_new();
- selected = e_calendar_view_get_selected_events((ECalendarView *)view);
- for (l=selected;l;l=g_list_next(l)) {
- ECalendarViewEvent *event = l->data;
- if (event && event->comp_data)
- g_ptr_array_add (events, e_cal_model_copy_component_data(event->comp_data));
- }
- g_list_free(selected);
-
- t = e_cal_menu_target_new_select(menu, model, events);
- if (!enable)
- t->target.mask = ~0;
-
- sensitize_items(uic, calendar_sensitize_table, t->target.mask);
-#if 0
- /* retrieve read-onlyness of the default client */
- e_cal = e_cal_model_get_default_client (gnome_calendar_get_calendar_model (gcal));
- if (e_cal)
- e_cal_is_read_only (e_cal, &default_read_only, NULL);
- else
- default_read_only = TRUE;
-#endif
-
- e_menu_update_target((EMenu *)menu, (EMenuTarget *)t);
-}
-
static struct _sensitize_item taskpad_sensitize_table[] = {
{ "Cut", E_CAL_MENU_SELECT_EDITABLE },
{ "Copy", E_CAL_MENU_SELECT_ANY },
@@ -555,21 +335,6 @@ help_debug (BonoboUIComponent *uid, gpointer data, const gchar *path)
}
static BonoboUIVerb verbs [] = {
- BONOBO_UI_VERB ("EventOpen", file_open_event_cb),
- BONOBO_UI_VERB ("CalendarPrint", file_print_cb),
- BONOBO_UI_VERB ("CalendarPrintPreview", file_print_preview_cb),
-
- BONOBO_UI_VERB ("Cut", cut_cmd),
- BONOBO_UI_VERB ("Copy", copy_cmd),
- BONOBO_UI_VERB ("Paste", paste_cmd),
- BONOBO_UI_VERB ("Delete", delete_cmd),
- BONOBO_UI_VERB ("DeleteOccurrence", delete_occurrence_cmd),
- BONOBO_UI_VERB ("DeleteAllOccurrences", delete_cmd),
-
- BONOBO_UI_VERB ("CalendarPrev", previous_clicked),
- BONOBO_UI_VERB ("CalendarToday", today_clicked),
- BONOBO_UI_VERB ("CalendarNext", next_clicked),
- BONOBO_UI_VERB ("CalendarGoto", goto_clicked),
BONOBO_UI_VERB ("ShowDayView", show_day_view_clicked),
BONOBO_UI_VERB ("ShowWorkWeekView", show_work_week_view_clicked),
@@ -582,35 +347,6 @@ static BonoboUIVerb verbs [] = {
BONOBO_UI_VERB_END
};
-static EPixmap pixmaps [] = {
- E_PIXMAP ("/commands/CalendarPrev", "go-previous", GTK_ICON_SIZE_MENU),
- E_PIXMAP ("/commands/CalendarPrint", "document-print", GTK_ICON_SIZE_MENU),
- E_PIXMAP ("/commands/DeleteAllOccurrences", "edit-delete", GTK_ICON_SIZE_MENU),
- E_PIXMAP ("/commands/DeleteOccurrence", "edit-delete", GTK_ICON_SIZE_MENU),
- E_PIXMAP ("/commands/CalendarGoto", "go-jump", GTK_ICON_SIZE_MENU),
- E_PIXMAP ("/commands/CalendarNext", "go-next", GTK_ICON_SIZE_MENU),
- E_PIXMAP ("/commands/CalendarPrintPreview", "document-print-preview", GTK_ICON_SIZE_MENU),
- E_PIXMAP ("/commands/Copy", "edit-copy", GTK_ICON_SIZE_MENU),
- E_PIXMAP ("/commands/Cut", "edit-cut", GTK_ICON_SIZE_MENU),
- E_PIXMAP ("/commands/Delete", "edit-delete", GTK_ICON_SIZE_MENU),
- E_PIXMAP ("/commands/Paste", "edit-paste", GTK_ICON_SIZE_MENU),
- E_PIXMAP ("/commands/CalendarToday", "go-today", GTK_ICON_SIZE_MENU),
-
- E_PIXMAP ("/Toolbar/Print", "document-print", GTK_ICON_SIZE_LARGE_TOOLBAR),
- E_PIXMAP ("/Toolbar/Delete", "edit-delete", GTK_ICON_SIZE_LARGE_TOOLBAR),
- E_PIXMAP ("/Toolbar/Prev", "go-previous", GTK_ICON_SIZE_LARGE_TOOLBAR),
- E_PIXMAP ("/Toolbar/Next", "go-next", GTK_ICON_SIZE_LARGE_TOOLBAR),
- E_PIXMAP ("/Toolbar/Goto", "go-jump", GTK_ICON_SIZE_LARGE_TOOLBAR),
- E_PIXMAP ("/Toolbar/DayView", "view-calendar-day", GTK_ICON_SIZE_LARGE_TOOLBAR),
- E_PIXMAP ("/Toolbar/WorkWeekView", "view-calendar-workweek", GTK_ICON_SIZE_LARGE_TOOLBAR),
- E_PIXMAP ("/Toolbar/WeekView", "view-calendar-week", GTK_ICON_SIZE_LARGE_TOOLBAR),
- E_PIXMAP ("/Toolbar/MonthView", "view-calendar-month", GTK_ICON_SIZE_LARGE_TOOLBAR),
- E_PIXMAP ("/Toolbar/ListView", "view-calendar-list", GTK_ICON_SIZE_LARGE_TOOLBAR),
- E_PIXMAP ("/Toolbar/Today", "go-today", GTK_ICON_SIZE_LARGE_TOOLBAR),
-
- E_PIXMAP_END
-};
-
void
calendar_control_activate (BonoboControl *control,
GnomeCalendar *gcal)
@@ -642,8 +378,6 @@ calendar_control_activate (BonoboControl *control,
NULL);
g_free (xmlfile);
- e_pixmaps_update (uic, pixmaps);
-
gnome_calendar_setup_view_menus (gcal, uic);
g_signal_connect (gcal, "calendar_focus_change",
diff --git a/calendar/gui/calendar-component.c b/calendar/gui/calendar-component.c
index 625321a934..02bf9a0072 100644
--- a/calendar/gui/calendar-component.c
+++ b/calendar/gui/calendar-component.c
@@ -65,26 +65,9 @@
#define CREATE_MEETING_ID "meeting"
#define CREATE_ALLDAY_EVENT_ID "allday-event"
#define CREATE_CALENDAR_ID "calendar"
-#define WEB_BASE_URI "webcal://"
-#define CONTACTS_BASE_URI "contacts://"
-#define WEATHER_BASE_URI "weather://"
-#define PERSONAL_RELATIVE_URI "system"
#define CALENDAR_ERROR_LEVEL_KEY "/apps/evolution/calendar/display/error_level"
#define CALENDAR_ERROR_TIME_OUT_KEY "/apps/evolution/calendar/display/error_timeout"
-enum DndTargetType {
- DND_TARGET_TYPE_CALENDAR_LIST
-};
-#define CALENDAR_TYPE "text/calendar"
-#define XCALENDAR_TYPE "text/x-calendar"
-static GtkTargetEntry drag_types[] = {
- { (gchar *) CALENDAR_TYPE, 0, DND_TARGET_TYPE_CALENDAR_LIST },
- { (gchar *) XCALENDAR_TYPE, 0, DND_TARGET_TYPE_CALENDAR_LIST }
-};
-static gint num_drag_types = sizeof(drag_types) / sizeof(drag_types[0]);
-#define CALENDAR_COMPONENT_DEFAULT(cc) if (cc == NULL) cc = calendar_component_peek()
-#define PARENT_TYPE bonobo_object_get_type ()
-
static BonoboObjectClass *parent_class = NULL;
typedef struct
@@ -99,27 +82,17 @@ typedef struct
GnomeCalendar *calendar;
- EInfoLabel *info_label;
GtkWidget *source_selector;
BonoboControl *view_control;
- BonoboControl *sidebar_control;
- BonoboControl *statusbar_control;
GList *notifications;
- EUserCreatableItemsHandler *creatable_items_handler;
-
- EActivityHandler *activity_handler;
-
gfloat vpane_pos;
} CalendarComponentView;
struct _CalendarComponentPrivate {
- gchar *base_directory;
- gchar *config_directory;
- GConfClient *gconf_client;
gint gconf_notify_id;
ESourceList *source_list;
@@ -136,9 +109,6 @@ struct _CalendarComponentPrivate {
GList *notifications;
};
-/* FIXME This should be gnome cal likely */
-extern ECompEditorRegistry *comp_editor_registry;
-
static void
calcomp_vpane_realized (GtkWidget *vpane, CalendarComponentView *view)
{
@@ -156,157 +126,6 @@ calcomp_vpane_resized (GtkWidget *vpane, GdkEventButton *e, CalendarComponentVie
return FALSE;
}
-static void
-ensure_sources (CalendarComponent *component)
-{
- ESourceList *source_list;
- ESourceGroup *on_this_computer;
- ESourceGroup *contacts;
- ESource *personal_source;
- ESource *birthdays_source;
- gchar *base_uri, *base_uri_proto, base_uri_proto_seventh;
- const gchar *base_dir;
- gchar *create_source;
-
- personal_source = NULL;
- birthdays_source = NULL;
-
- if (!e_cal_get_sources (&source_list, E_CAL_SOURCE_TYPE_EVENT, NULL)) {
- g_warning ("Could not get calendar source list from GConf!");
- return;
- }
-
- base_dir = calendar_component_peek_base_directory (component);
- base_uri = g_build_filename (base_dir, "local", NULL);
-
- base_uri_proto = g_filename_to_uri (base_uri, NULL, NULL);
- if (strlen (base_uri_proto) > 7) {
- /* compare only file:// part. If user home dir name changes we do not want to create
- one more group */
- base_uri_proto_seventh = base_uri_proto[7];
- base_uri_proto[7] = 0;
- } else {
- base_uri_proto_seventh = -1;
- }
-
- on_this_computer = e_source_list_ensure_group (source_list, _("On This Computer"), base_uri_proto, TRUE);
- contacts = e_source_list_ensure_group (source_list, _("Contacts"), CONTACTS_BASE_URI, TRUE);
- e_source_list_ensure_group (source_list, _("On The Web"), WEB_BASE_URI, FALSE);
- e_source_list_ensure_group (source_list, _("Weather"), WEATHER_BASE_URI, FALSE);
-
- if (base_uri_proto_seventh != -1) {
- base_uri_proto[7] = base_uri_proto_seventh;
- }
-
- if (on_this_computer) {
- /* make sure "Personal" shows up as a source under
- this group */
- GSList *sources = e_source_group_peek_sources (on_this_computer);
- GSList *s;
- for (s = sources; s; s = s->next) {
- ESource *source = E_SOURCE (s->data);
- const gchar *relative_uri;
-
- relative_uri = e_source_peek_relative_uri (source);
- if (relative_uri == NULL)
- continue;
- if (!strcmp (PERSONAL_RELATIVE_URI, relative_uri)) {
- personal_source = source;
- break;
- }
- }
- /* Make sure we have the correct base uri. This can change when user's
- homedir name changes */
- if (strcmp (base_uri_proto, e_source_group_peek_base_uri (on_this_computer))) {
- e_source_group_set_base_uri (on_this_computer, base_uri_proto);
-
- /* *sigh* . We shouldn't need this sync call here as set_base_uri
- call results in synching to gconf, but that happens in idle loop
- and too late to prevent user seeing "Can not Open ... because of invalid uri" error.*/
- e_source_list_sync (source_list,NULL);
- }
- }
-
- if (personal_source) {
- /* ensure the source name is in current locale, not read from configuration */
- e_source_set_name (personal_source, _("Personal"));
- } else {
- gchar *primary_calendar = calendar_config_get_primary_calendar();
- GSList *calendars_selected;
-
- /* Create the default Person addressbook */
- personal_source = e_source_new (_("Personal"), PERSONAL_RELATIVE_URI);
- e_source_group_add_source (on_this_computer, personal_source, -1);
- g_object_unref (personal_source);
-
- calendars_selected = calendar_config_get_calendars_selected ();
- if (!primary_calendar && !calendars_selected) {
- GSList selected;
-
- calendar_config_set_primary_calendar (e_source_peek_uid (personal_source));
-
- selected.data = (gpointer)e_source_peek_uid (personal_source);
- selected.next = NULL;
- calendar_config_set_calendars_selected (&selected);
- }
-
- if (calendars_selected) {
- g_slist_foreach (calendars_selected, (GFunc) g_free, NULL);
- g_slist_free (calendars_selected);
- }
-
- g_free (primary_calendar);
- e_source_set_color_spec (personal_source, "#BECEDD");
- }
-
- if (contacts) {
- GSList *sources = e_source_group_peek_sources (contacts);
- if (sources) {
- birthdays_source = E_SOURCE (sources->data); /* There is only one source under Contacts Group*/
-
- if (sources->next) {
- /* Ensure we have only one contacts source - we was able to create more than one before */
- GSList *l = NULL, *p;
-
- for (p = sources->next; p; p = p->next)
- l = g_slist_prepend (l, p->data);
-
- for (p = l; p; p = p->next)
- e_source_group_remove_source (contacts, p->data);
-
- g_slist_free (l);
- }
- }
- }
-
- create_source = e_source_group_get_property (contacts, "create_source");
- if (!create_source)
- e_source_group_set_property (contacts, "create_source", "no");
- g_free (create_source);
-
- if (birthdays_source) {
- /* ensure the source name is in current locale, not read from configuration */
- e_source_set_name (birthdays_source, _("Birthdays & Anniversaries"));
- } else {
- birthdays_source = e_source_new (_("Birthdays & Anniversaries"), "/");
- e_source_group_add_source (contacts, birthdays_source, -1);
- g_object_unref (birthdays_source);
- }
-
- if (!e_source_get_property (birthdays_source, "delete"))
- e_source_set_property(birthdays_source, "delete", "no");
-
- if (e_source_peek_color_spec (birthdays_source) == NULL)
- e_source_set_color_spec (birthdays_source, "#DDBECE");
-
- component->priv->source_list = source_list;
-
- g_object_unref (on_this_computer);
- g_object_unref (contacts);
- g_free (base_uri_proto);
- g_free (base_uri);
-}
-
/* Utility functions. */
static gboolean
@@ -340,88 +159,6 @@ is_in_uids (GSList *uids, ESource *source)
}
static void
-update_uris_for_selection (CalendarComponentView *component_view)
-{
- GSList *selection, *l, *uids_selected = NULL;
-
- selection = e_source_selector_get_selection (E_SOURCE_SELECTOR (component_view->source_selector));
-
- for (l = component_view->source_selection; l; l = l->next) {
- ESource *old_selected_source = l->data;
-
- if (!is_in_selection (selection, old_selected_source))
- gnome_calendar_remove_source (component_view->calendar, E_CAL_SOURCE_TYPE_EVENT, old_selected_source);
- }
-
- for (l = selection; l; l = l->next) {
- ESource *selected_source = l->data;
-
- if (gnome_calendar_add_source (component_view->calendar, E_CAL_SOURCE_TYPE_EVENT, selected_source))
- uids_selected = g_slist_append (uids_selected, (gchar *) e_source_peek_uid (selected_source));
- }
-
- e_source_selector_free_selection (component_view->source_selection);
- component_view->source_selection = selection;
-
- /* Save the selection for next time we start up */
- calendar_config_set_calendars_selected (uids_selected);
- g_slist_free (uids_selected);
-}
-
-static void
-update_uri_for_primary_selection (CalendarComponentView *component_view)
-{
- ESource *source;
-
- source = e_source_selector_peek_primary_selection (E_SOURCE_SELECTOR (component_view->source_selector));
- if (!source)
- return;
-
- /* Set the default */
- gnome_calendar_set_default_source (component_view->calendar, E_CAL_SOURCE_TYPE_EVENT, source);
-
- /* Make sure we are embedded first */
- calendar_control_sensitize_calendar_commands (component_view->view_control, component_view->calendar, TRUE);
-
- /* Save the selection for next time we start up */
- calendar_config_set_primary_calendar (e_source_peek_uid (source));
-}
-
-static void
-update_selection (CalendarComponentView *component_view)
-{
- GSList *selection, *uids_selected, *l;
-
- /* Get the selection in gconf */
- uids_selected = calendar_config_get_calendars_selected ();
-
- /* Remove any that aren't there any more */
- selection = e_source_selector_get_selection (E_SOURCE_SELECTOR (component_view->source_selector));
-
- for (l = selection; l; l = l->next) {
- ESource *source = l->data;
-
- if (!is_in_uids (uids_selected, source))
- e_source_selector_unselect_source (E_SOURCE_SELECTOR (component_view->source_selector), source);
- }
-
- e_source_selector_free_selection (selection);
-
- /* Make sure the whole selection is there */
- for (l = uids_selected; l; l = l->next) {
- gchar *uid = l->data;
- ESource *source;
-
- source = e_source_list_peek_source_by_uid (component_view->source_list, uid);
- if (source)
- e_source_selector_select_source (E_SOURCE_SELECTOR (component_view->source_selector), source);
-
- g_free (uid);
- }
- g_slist_free (uids_selected);
-}
-
-static void
update_task_memo_selection (CalendarComponentView *component_view, ECalSourceType type)
{
GSList *uids_selected, *l, *source_selection;
@@ -471,28 +208,6 @@ update_task_memo_selection (CalendarComponentView *component_view, ECalSourceTyp
}
static void
-update_primary_selection (CalendarComponentView *component_view)
-{
- ESource *source = NULL;
- gchar *uid;
-
- uid = calendar_config_get_primary_calendar ();
- if (uid) {
- source = e_source_list_peek_source_by_uid (component_view->source_list, uid);
- g_free (uid);
- }
-
- if (source) {
- e_source_selector_set_primary_selection (E_SOURCE_SELECTOR (component_view->source_selector), source);
- } else {
- /* Try to create a default if there isn't one */
- source = e_source_list_peek_source_any (component_view->source_list);
- if (source)
- e_source_selector_set_primary_selection (E_SOURCE_SELECTOR (component_view->source_selector), source);
- }
-}
-
-static void
update_primary_task_memo_selection (CalendarComponentView *component_view, ECalSourceType type)
{
ESource *source = NULL;
@@ -517,314 +232,6 @@ update_primary_task_memo_selection (CalendarComponentView *component_view, ECalS
gnome_calendar_set_default_source (component_view->calendar, type, source);
}
-/* Callbacks. */
-static void
-copy_calendar_cb (EPopup *ep, EPopupItem *pitem, gpointer data)
-{
- CalendarComponentView *component_view = data;
- ESource *selected_source;
-
- selected_source = e_source_selector_peek_primary_selection (E_SOURCE_SELECTOR (component_view->source_selector));
- if (!selected_source)
- return;
-
- copy_source_dialog (GTK_WINDOW (gtk_widget_get_toplevel (ep->target->widget)), selected_source, E_CAL_SOURCE_TYPE_EVENT);
-}
-
-static void
-delete_calendar_cb (EPopup *ep, EPopupItem *pitem, gpointer data)
-{
- CalendarComponentView *component_view = data;
- ESource *selected_source;
- ECal *cal;
- gchar *uri;
-
- selected_source = e_source_selector_peek_primary_selection (E_SOURCE_SELECTOR (component_view->source_selector));
- if (!selected_source)
- return;
-
- if (e_error_run((GtkWindow *)gtk_widget_get_toplevel(ep->target->widget),
- "calendar:prompt-delete-calendar", e_source_peek_name(selected_source), NULL) != GTK_RESPONSE_YES)
- return;
-
- /* first, ask the backend to remove the calendar */
- uri = e_source_get_uri (selected_source);
- cal = e_cal_model_get_client_for_uri (gnome_calendar_get_calendar_model (component_view->calendar), uri);
- if (!cal)
- cal = e_cal_new_from_uri (uri, E_CAL_SOURCE_TYPE_EVENT);
- g_free (uri);
- if (cal) {
- if (e_cal_remove (cal, NULL)) {
- if (e_source_selector_source_is_selected (E_SOURCE_SELECTOR (component_view->source_selector),
- selected_source)) {
- gnome_calendar_remove_source (component_view->calendar, E_CAL_SOURCE_TYPE_EVENT, selected_source);
- e_source_selector_unselect_source (E_SOURCE_SELECTOR (component_view->source_selector),
- selected_source);
- }
-
- e_source_group_remove_source (e_source_peek_group (selected_source), selected_source);
- e_source_list_sync (component_view->source_list, NULL);
- }
- }
-}
-
-static void
-new_calendar_cb (EPopup *ep, EPopupItem *pitem, gpointer data)
-{
- calendar_setup_edit_calendar (GTK_WINDOW (gtk_widget_get_toplevel(ep->target->widget)), NULL, pitem->user_data);
-}
-
-static void
-rename_calendar_cb (EPopup *ep, EPopupItem *pitem, gpointer data)
-{
- CalendarComponentView *component_view = data;
- ESourceSelector *selector;
-
- selector = E_SOURCE_SELECTOR (component_view->source_selector);
- e_source_selector_edit_primary_selection (selector);
-}
-
-static void
-edit_calendar_cb (EPopup *ep, EPopupItem *pitem, gpointer data)
-{
- CalendarComponentView *component_view = data;
- ESource *selected_source;
-
- selected_source = e_source_selector_peek_primary_selection (E_SOURCE_SELECTOR (component_view->source_selector));
- if (!selected_source)
- return;
-
- calendar_setup_edit_calendar (GTK_WINDOW (gtk_widget_get_toplevel(ep->target->widget)), selected_source, NULL);
-}
-
-static void
-set_offline_availability (EPopup *ep, EPopupItem *pitem, gpointer data, const gchar *value)
-{
- CalendarComponentView *component_view = data;
- ESource *selected_source;
-
- selected_source = e_source_selector_peek_primary_selection (E_SOURCE_SELECTOR (component_view->source_selector));
- if (!selected_source)
- return;
-
- e_source_set_property (selected_source, "offline_sync", value);
-}
-
-static void
-mark_no_offline_cb (EPopup *ep, EPopupItem *pitem, gpointer data)
-{
- set_offline_availability (ep, pitem, data, "0");
-}
-
-static void
-mark_offline_cb (EPopup *ep, EPopupItem *pitem, gpointer data)
-{
- set_offline_availability (ep, pitem, data, "1");
-}
-
-static EPopupItem ecc_source_popups[] = {
- { E_POPUP_ITEM, (gchar *) "10.new", (gchar *) N_("_New Calendar"), new_calendar_cb, NULL, (gchar *) "x-office-calendar", 0, 0 },
- { E_POPUP_ITEM, (gchar *) "15.copy", (gchar *) N_("_Copy..."), copy_calendar_cb, NULL, (gchar *) "edit-copy", 0, E_CAL_POPUP_SOURCE_PRIMARY },
- { E_POPUP_ITEM, (gchar *) "18.rename", (gchar *) N_("_Rename..."), rename_calendar_cb, NULL, NULL, 0, E_CAL_POPUP_SOURCE_PRIMARY },
-
- { E_POPUP_BAR, (gchar *) "20.bar" },
- { E_POPUP_ITEM, (gchar *) "20.delete", (gchar *) N_("_Delete"), delete_calendar_cb, NULL, (gchar *) "edit-delete", 0,E_CAL_POPUP_SOURCE_USER|E_CAL_POPUP_SOURCE_PRIMARY|E_CAL_POPUP_SOURCE_DELETE },
- { E_POPUP_ITEM, (gchar *) "30.mark_calendar_offline", (gchar *) N_("_Make available for offline use"), mark_offline_cb, NULL, (gchar *) "stock_disconnect", E_CAL_POPUP_SOURCE_OFFLINE, E_CAL_POPUP_SOURCE_USER|E_CAL_POPUP_SOURCE_PRIMARY|E_CAL_POPUP_SOURCE_OFFLINE },
- { E_POPUP_ITEM, (gchar *) "40.mark_calendar_no_offline", (gchar *) N_("_Do not make available for offline use"), mark_no_offline_cb, NULL, (gchar *) "stock_connect", E_CAL_POPUP_SOURCE_NO_OFFLINE, E_CAL_POPUP_SOURCE_USER|E_CAL_POPUP_SOURCE_PRIMARY|E_CAL_POPUP_SOURCE_NO_OFFLINE },
-
- { E_POPUP_BAR, (gchar *) "99.bar" },
- { E_POPUP_ITEM, (gchar *) "99.properties", (gchar *) N_("_Properties"), edit_calendar_cb, NULL, (gchar *) "document-properties", 0, E_CAL_POPUP_SOURCE_PRIMARY },
-};
-
-static void
-ecc_source_popup_free(EPopup *ep, GSList *list, gpointer data)
-{
- g_slist_free(list);
-}
-
-static gboolean
-popup_event_cb(ESourceSelector *selector, ESource *insource, GdkEventButton *event, CalendarComponentView *component_view)
-{
- ECalPopup *ep;
- ECalPopupTargetSource *t;
- GSList *menus = NULL;
- gint i;
- GtkMenu *menu;
-
- /** @HookPoint-ECalPopup: Calendar Source Selector Context Menu
- * @Id: org.gnome.evolution.calendar.source.popup
- * @Class: org.gnome.evolution.calendar.popup:1.0
- * @Target: ECalPopupTargetSource
- *
- * The context menu on the source selector in the calendar window.
- */
- ep = e_cal_popup_new("org.gnome.evolution.calendar.source.popup");
- t = e_cal_popup_target_new_source(ep, selector);
- t->target.widget = (GtkWidget *)component_view->calendar;
-
- for (i=0;i<sizeof(ecc_source_popups)/sizeof(ecc_source_popups[0]);i++)
- menus = g_slist_prepend(menus, &ecc_source_popups[i]);
-
- e_popup_add_items((EPopup *)ep, menus, NULL, ecc_source_popup_free, component_view);
-
- menu = e_popup_create_menu_once((EPopup *)ep, (EPopupTarget *)t, 0);
- gtk_menu_popup(menu, NULL, NULL, NULL, NULL, event?event->button:0, event?event->time:gtk_get_current_event_time());
-
- return TRUE;
-}
-
-static void
-source_selection_changed_cb (ESourceSelector *selector, CalendarComponentView *component_view)
-{
- update_uris_for_selection (component_view);
-}
-
-static void
-primary_source_selection_changed_cb (ESourceSelector *selector, CalendarComponentView *component_view)
-{
- update_uri_for_primary_selection (component_view);
-}
-
-static void
-source_changed_cb (ESource *source, GnomeCalendar *calendar)
-{
- if (calendar) {
- GtkWidget *widget = gnome_calendar_get_current_view_widget (calendar);
-
- if (widget)
- gtk_widget_queue_draw (widget);
- }
-}
-
-static void
-source_added_cb (GnomeCalendar *calendar, ECalSourceType source_type, ESource *source, CalendarComponentView *component_view)
-{
- switch (source_type) {
- case E_CAL_SOURCE_TYPE_EVENT:
- e_source_selector_select_source (E_SOURCE_SELECTOR (component_view->source_selector), source);
- g_signal_connect (source, "changed", G_CALLBACK (source_changed_cb), calendar);
- break;
- default:
- break;
- }
-}
-
-static void
-source_removed_cb (GnomeCalendar *calendar, ECalSourceType source_type, ESource *source, CalendarComponentView *component_view)
-{
- switch (source_type) {
- case E_CAL_SOURCE_TYPE_EVENT:
- g_signal_handlers_disconnect_by_func (source, G_CALLBACK (source_changed_cb), calendar);
- e_source_selector_unselect_source (E_SOURCE_SELECTOR (component_view->source_selector), source);
- break;
- default:
- break;
- }
-}
-
-static void
-set_info (CalendarComponentView *component_view)
-{
- icaltimezone *zone;
- struct icaltimetype start_tt, end_tt;
- time_t start_time, end_time;
- struct tm start_tm, end_tm;
- gchar buffer[512], end_buffer[256];
- GnomeCalendarViewType view;
-
- gnome_calendar_get_visible_time_range (component_view->calendar, &start_time, &end_time);
- zone = gnome_calendar_get_timezone (component_view->calendar);
-
- start_tt = icaltime_from_timet_with_zone (start_time, FALSE, zone);
- start_tm.tm_year = start_tt.year - 1900;
- start_tm.tm_mon = start_tt.month - 1;
- start_tm.tm_mday = start_tt.day;
- start_tm.tm_hour = start_tt.hour;
- start_tm.tm_min = start_tt.minute;
- start_tm.tm_sec = start_tt.second;
- start_tm.tm_isdst = -1;
- start_tm.tm_wday = time_day_of_week (start_tt.day, start_tt.month - 1,
- start_tt.year);
-
- /* Take one off end_time so we don't get an extra day. */
- end_tt = icaltime_from_timet_with_zone (end_time - 1, FALSE, zone);
- end_tm.tm_year = end_tt.year - 1900;
- end_tm.tm_mon = end_tt.month - 1;
- end_tm.tm_mday = end_tt.day;
- end_tm.tm_hour = end_tt.hour;
- end_tm.tm_min = end_tt.minute;
- end_tm.tm_sec = end_tt.second;
- end_tm.tm_isdst = -1;
- end_tm.tm_wday = time_day_of_week (end_tt.day, end_tt.month - 1,
- end_tt.year);
-
- view = gnome_calendar_get_view (component_view->calendar);
-
- switch (view) {
- case GNOME_CAL_DAY_VIEW:
- case GNOME_CAL_WORK_WEEK_VIEW:
- case GNOME_CAL_WEEK_VIEW:
- if (start_tm.tm_year == end_tm.tm_year
- && start_tm.tm_mon == end_tm.tm_mon
- && start_tm.tm_mday == end_tm.tm_mday) {
- e_utf8_strftime (buffer, sizeof (buffer),
- _("%A %d %b %Y"), &start_tm);
- } else if (start_tm.tm_year == end_tm.tm_year) {
- e_utf8_strftime (buffer, sizeof (buffer),
- _("%a %d %b"), &start_tm);
- e_utf8_strftime (end_buffer, sizeof (end_buffer),
- _("%a %d %b %Y"), &end_tm);
- strcat (buffer, " - ");
- strcat (buffer, end_buffer);
- } else {
- e_utf8_strftime (buffer, sizeof (buffer),
- _("%a %d %b %Y"), &start_tm);
- e_utf8_strftime (end_buffer, sizeof (end_buffer),
- _("%a %d %b %Y"), &end_tm);
- strcat (buffer, " - ");
- strcat (buffer, end_buffer);
- }
- break;
- case GNOME_CAL_MONTH_VIEW:
- case GNOME_CAL_LIST_VIEW:
- if (start_tm.tm_year == end_tm.tm_year) {
- if (start_tm.tm_mon == end_tm.tm_mon) {
- e_utf8_strftime (buffer, sizeof (buffer),
- "%d", &start_tm);
- e_utf8_strftime (end_buffer, sizeof (end_buffer),
- _("%d %b %Y"), &end_tm);
- strcat (buffer, " - ");
- strcat (buffer, end_buffer);
- } else {
- e_utf8_strftime (buffer, sizeof (buffer),
- _("%d %b"), &start_tm);
- e_utf8_strftime (end_buffer, sizeof (end_buffer),
- _("%d %b %Y"), &end_tm);
- strcat (buffer, " - ");
- strcat (buffer, end_buffer);
- }
- } else {
- e_utf8_strftime (buffer, sizeof (buffer),
- _("%d %b %Y"), &start_tm);
- e_utf8_strftime (end_buffer, sizeof (end_buffer),
- _("%d %b %Y"), &end_tm);
- strcat (buffer, " - ");
- strcat (buffer, end_buffer);
- }
- break;
- default:
- g_return_if_reached ();
- }
-
- e_info_label_set_info (component_view->info_label, _("Calendars"), buffer);
-}
-
-static void
-calendar_dates_changed_cb (GnomeCalendar *calendar, CalendarComponentView *component_view)
-{
- set_info (component_view);
-}
-
static void
config_primary_selection_changed_cb (GConfClient *client, guint id, GConfEntry *entry, gpointer data)
{
@@ -945,84 +352,6 @@ impl_handleURI (PortableServer_Servant servant, const gchar *uri, CORBA_Environm
}
static void
-impl_upgradeFromVersion (PortableServer_Servant servant,
- CORBA_short major,
- CORBA_short minor,
- CORBA_short revision,
- CORBA_Environment *ev)
-{
- GError *err = NULL;
- CalendarComponent *calendar_component = CALENDAR_COMPONENT (bonobo_object_from_servant (servant));
-
- if (!migrate_calendars (calendar_component, major, minor, revision, &err)) {
- GNOME_Evolution_Component_UpgradeFailed *failedex;
-
- failedex = GNOME_Evolution_Component_UpgradeFailed__alloc();
- failedex->what = CORBA_string_dup(_("Failed upgrading calendars."));
- failedex->why = CORBA_string_dup(err->message);
- CORBA_exception_set(ev, CORBA_USER_EXCEPTION, ex_GNOME_Evolution_Component_UpgradeFailed, failedex);
- }
-
- if (err)
- g_error_free(err);
-}
-
-static gboolean
-selector_tree_data_dropped (ESourceSelector *selector,
- GtkSelectionData *data,
- ESource *destination,
- GdkDragAction action,
- guint info,
- CalendarComponent *component)
-{
- gboolean success = FALSE;
- ECal *client;
-
- client = auth_new_cal_from_source (destination, E_CAL_SOURCE_TYPE_EVENT);
-
- if (!client || !e_cal_open (client, TRUE, NULL)) {
- if (client)
- g_object_unref (client);
-
- return FALSE;
- }
-
- if (data->data) {
- icalcomponent *icalcomp = NULL;
- gchar *comp_str; /* do not free this! */
-
- /* data->data is "source_uid\ncomponent_string" */
- comp_str = strchr ((gchar *)data->data, '\n');
- if (comp_str) {
- comp_str [0] = 0;
- comp_str++;
-
- icalcomp = icalparser_parse_string (comp_str);
-
- if (icalcomp) {
- success = cal_comp_process_source_list_drop (client, icalcomp, action, (gchar *)data->data, component->priv->source_list);
- icalcomponent_free (icalcomp);
- }
- }
- }
-
- return success;
-}
-
-static void
-control_activate_cb (BonoboControl *control, gboolean activate, gpointer data)
-{
- CalendarComponentView *component_view = data;
-
- if (activate) {
- BonoboUIComponent *uic;
- uic = bonobo_control_get_ui_component (component_view->view_control);
-
- e_user_creatable_items_handler_activate (component_view->creatable_items_handler, uic);
- }
-}
-
-static void
config_create_ecal_changed_cb (GConfClient *client, guint id, GConfEntry *entry, gpointer data)
{
CalendarComponent *calendar_component = data;
@@ -1120,79 +449,13 @@ setup_create_ecal (CalendarComponent *calendar_component, CalendarComponentView
return priv->create_ecal;
}
-static gboolean
-create_new_event (CalendarComponent *calendar_component, CalendarComponentView *component_view, gboolean is_allday, gboolean is_meeting)
-{
- ECal *ecal;
- ECalendarView *view;
-
- ecal = setup_create_ecal (calendar_component, component_view);
- if (!ecal)
- return FALSE;
-
- if (component_view && (view = E_CALENDAR_VIEW (gnome_calendar_get_current_view_widget (component_view->calendar)))) {
- e_calendar_view_new_appointment_full (view, is_allday, is_meeting, TRUE);
- } else {
- ECalComponent *comp;
- CompEditor *editor;
- CompEditorFlags flags;
-
- flags = COMP_EDITOR_USER_ORG | COMP_EDITOR_NEW_ITEM;
- if (is_meeting)
- flags |= COMP_EDITOR_MEETING;
- comp = cal_comp_event_new_with_current_time (ecal, is_allday);
- editor = event_editor_new (ecal, flags);
- e_cal_component_commit_sequence (comp);
-
- comp_editor_edit_comp (editor, comp);
- if (is_meeting)
- event_editor_show_meeting (EVENT_EDITOR (editor));
- gtk_window_present (GTK_WINDOW (editor));
-
- e_comp_editor_registry_add (comp_editor_registry, editor, TRUE);
- }
-
- return TRUE;
-}
-
-static void
-create_local_item_cb (EUserCreatableItemsHandler *handler, const gchar *item_type_name, gpointer data)
-{
- CalendarComponent *calendar_component = data;
- CalendarComponentPrivate *priv;
- CalendarComponentView *component_view = NULL;
- GList *l;
-
- priv = calendar_component->priv;
-
- for (l = priv->views; l; l = l->next) {
- component_view = l->data;
-
- if (component_view->creatable_items_handler == handler)
- break;
-
- component_view = NULL;
- }
-
- if (strcmp (item_type_name, CREATE_EVENT_ID) == 0)
- create_new_event (calendar_component, component_view, FALSE, FALSE);
- else if (strcmp (item_type_name, CREATE_ALLDAY_EVENT_ID) == 0)
- create_new_event (calendar_component, component_view, TRUE, FALSE);
- else if (strcmp (item_type_name, CREATE_MEETING_ID) == 0)
- create_new_event (calendar_component, component_view, FALSE, TRUE);
- else if (strcmp (item_type_name, CREATE_CALENDAR_ID) == 0)
- calendar_setup_new_calendar (GTK_WINDOW (gtk_widget_get_toplevel (GTK_WIDGET (component_view->calendar))));
-}
-
static CalendarComponentView *
create_component_view (CalendarComponent *calendar_component)
{
CalendarComponentPrivate *priv;
CalendarComponentView *component_view;
- GtkWidget *selector_scrolled_window, *vbox, *vpane;
- GtkWidget *statusbar_widget;
+ GtkWidget **vpane;
guint not;
- AtkObject *a11y;
priv = calendar_component->priv;
@@ -1209,14 +472,8 @@ create_component_view (CalendarComponent *calendar_component)
component_view->source_list = g_object_ref (priv->source_list);
component_view->task_source_list = g_object_ref (priv->task_source_list);
component_view->memo_source_list = g_object_ref (priv->memo_source_list);
- component_view->vpane_pos = calendar_config_get_tag_vpane_pos ();
-
/* Create sidebar selector */
component_view->source_selector = e_source_selector_new (calendar_component->priv->source_list);
- e_source_selector_set_select_new ((ESourceSelector *)component_view->source_selector, TRUE);
- a11y = gtk_widget_get_accessible (GTK_WIDGET (component_view->source_selector));
- atk_object_set_name (a11y, _("Calendar Source Selector"));
-
g_signal_connect (
component_view->source_selector, "data-dropped",
G_CALLBACK (selector_tree_data_dropped), calendar_component);
@@ -1286,18 +543,11 @@ create_component_view (CalendarComponent *calendar_component)
g_signal_connect (component_view->source_selector, "popup_event",
G_CALLBACK (popup_event_cb), component_view);
+>>>>>>> 23df769955ea54f756a579c19964df87ae6fd5c8:calendar/gui/calendar-component.c
/* Set up the "new" item handler */
- component_view->creatable_items_handler = e_user_creatable_items_handler_new ("calendar", create_local_item_cb, calendar_component);
g_signal_connect (component_view->view_control, "activate", G_CALLBACK (control_activate_cb), component_view);
- /* We use this to update the component information */
- set_info (component_view);
- g_signal_connect (component_view->calendar, "dates_shown_changed",
- G_CALLBACK (calendar_dates_changed_cb), component_view);
-
/* Load the selection from the last run */
- update_selection (component_view);
- update_primary_selection (component_view);
update_task_memo_selection (component_view, E_CAL_SOURCE_TYPE_TODO);
update_primary_task_memo_selection (component_view, E_CAL_SOURCE_TYPE_TODO);
update_task_memo_selection (component_view, E_CAL_SOURCE_TYPE_JOURNAL);
@@ -1345,12 +595,6 @@ destroy_component_view (CalendarComponentView *component_view)
calendar_config_remove_notification (GPOINTER_TO_UINT (l->data));
g_list_free (component_view->notifications);
- if (component_view->creatable_items_handler)
- g_object_unref (component_view->creatable_items_handler);
-
- if (component_view->activity_handler)
- g_object_unref (component_view->activity_handler);
-
if (component_view->task_source_selection) {
g_slist_foreach (component_view->task_source_selection, (GFunc) g_free, NULL);
g_slist_free (component_view->task_source_selection);
@@ -1385,109 +629,6 @@ view_destroyed_cb (gpointer data, GObject *where_the_object_was)
}
}
-static GNOME_Evolution_ComponentView
-impl_createView (PortableServer_Servant servant,
- GNOME_Evolution_ShellView parent,
- CORBA_boolean select_item,
- CORBA_Environment *ev)
-{
- CalendarComponent *calendar_component = CALENDAR_COMPONENT (bonobo_object_from_servant (servant));
- CalendarComponentPrivate *priv;
- CalendarComponentView *component_view;
- EComponentView *ecv;
-
- priv = calendar_component->priv;
-
- /* Create the calendar component view */
- component_view = create_component_view (calendar_component);
- if (!component_view) {
- /* FIXME Should we describe the problem in a control? */
- bonobo_exception_set (ev, ex_GNOME_Evolution_Component_Failed);
-
- return CORBA_OBJECT_NIL;
- }
-
- g_object_weak_ref (G_OBJECT (component_view->view_control), view_destroyed_cb, calendar_component);
- priv->views = g_list_append (priv->views, component_view);
-
- /* TODO: Make CalendarComponentView just subclass EComponentView */
- ecv = e_component_view_new_controls (parent, "calendar", component_view->sidebar_control,
- component_view->view_control, component_view->statusbar_control);
-
- return BONOBO_OBJREF(ecv);
-}
-
-static GNOME_Evolution_CreatableItemTypeList *
-impl__get_userCreatableItems (PortableServer_Servant servant,
- CORBA_Environment *ev)
-{
- GNOME_Evolution_CreatableItemTypeList *list = GNOME_Evolution_CreatableItemTypeList__alloc ();
-
- list->_length = 4;
- list->_maximum = list->_length;
- list->_buffer = GNOME_Evolution_CreatableItemTypeList_allocbuf (list->_length);
-
- CORBA_sequence_set_release (list, FALSE);
-
- list->_buffer[0].id = (gchar *) CREATE_EVENT_ID;
- list->_buffer[0].description = (gchar *) _("New appointment");
- list->_buffer[0].menuDescription = (gchar *) C_("New", "_Appointment");
- list->_buffer[0].tooltip = (gchar *) _("Create a new appointment");
- list->_buffer[0].menuShortcut = 'a';
- list->_buffer[0].iconName = (gchar *) "appointment-new";
- list->_buffer[0].type = GNOME_Evolution_CREATABLE_OBJECT;
-
- list->_buffer[1].id = (gchar *) CREATE_MEETING_ID;
- list->_buffer[1].description = (gchar *) _("New meeting");
- list->_buffer[1].menuDescription = (gchar *) C_("New", "M_eeting");
- list->_buffer[1].tooltip = (gchar *) _("Create a new meeting request");
- list->_buffer[1].menuShortcut = 'e';
- list->_buffer[1].iconName = (gchar *) "stock_new-meeting";
- list->_buffer[1].type = GNOME_Evolution_CREATABLE_OBJECT;
-
- list->_buffer[2].id = (gchar *) CREATE_ALLDAY_EVENT_ID;
- list->_buffer[2].description = (gchar *) _("New all day appointment");
- list->_buffer[2].menuDescription = (gchar *) C_("New", "All Day A_ppointment");
- list->_buffer[2].tooltip = (gchar *) _("Create a new all-day appointment");
- list->_buffer[2].menuShortcut = '\0';
- list->_buffer[2].iconName = (gchar *) "stock_new-24h-appointment";
- list->_buffer[2].type = GNOME_Evolution_CREATABLE_OBJECT;
-
- list->_buffer[3].id = (gchar *) CREATE_CALENDAR_ID;
- list->_buffer[3].description = (gchar *) _("New calendar");
- list->_buffer[3].menuDescription = (gchar *) C_("New", "Cale_ndar");
- list->_buffer[3].tooltip = (gchar *) _("Create a new calendar");
- list->_buffer[3].menuShortcut = '\0';
- list->_buffer[3].iconName = (gchar *) "x-office-calendar";
- list->_buffer[3].type = GNOME_Evolution_CREATABLE_FOLDER;
-
- return list;
-}
-
-static void
-impl_requestCreateItem (PortableServer_Servant servant,
- const CORBA_char *item_type_name,
- CORBA_Environment *ev)
-{
- CalendarComponent *calendar_component = CALENDAR_COMPONENT (bonobo_object_from_servant (servant));
- gboolean result = FALSE;
-
- if (strcmp (item_type_name, CREATE_EVENT_ID) == 0)
- result = create_new_event (calendar_component, NULL, FALSE, FALSE);
- else if (strcmp (item_type_name, CREATE_ALLDAY_EVENT_ID) == 0)
- result = create_new_event (calendar_component, NULL, TRUE, FALSE);
- else if (strcmp (item_type_name, CREATE_MEETING_ID) == 0)
- result = create_new_event (calendar_component, NULL, FALSE, TRUE);
- else if (strcmp (item_type_name, CREATE_CALENDAR_ID) == 0)
- /* FIXME Should we use the last opened window? */
- calendar_setup_new_calendar (NULL);
- else
- bonobo_exception_set (ev, ex_GNOME_Evolution_Component_UnknownType);
-
- if (!result)
- bonobo_exception_set (ev, ex_GNOME_Evolution_Component_Failed);
-}
-
/* GObject methods. */
static void
@@ -1502,9 +643,9 @@ impl_dispose (GObject *object)
priv->source_list = NULL;
}
- if (priv->gconf_client != NULL) {
- g_object_unref (priv->gconf_client);
- priv->gconf_client = NULL;
+ if (priv->activity_handler != NULL) {
+ g_object_unref (priv->activity_handler);
+ priv->activity_handler = NULL;
}
if (priv->activity_handler != NULL) {
@@ -1534,27 +675,6 @@ impl_dispose (GObject *object)
}
static void
-impl_finalize (GObject *object)
-{
- CalendarComponentPrivate *priv = CALENDAR_COMPONENT (object)->priv;
- GList *l;
-
- for (l = priv->views; l; l = l->next) {
- CalendarComponentView *component_view = l->data;
-
- destroy_component_view (component_view);
- }
- g_list_free (priv->views);
-
- g_free (priv->base_directory);
- g_free (priv->config_directory);
- g_object_unref (priv->logger);
- g_free (priv);
-
- (* G_OBJECT_CLASS (parent_class)->finalize) (object);
-}
-
-static void
calendar_component_class_init (CalendarComponentClass *class)
{
POA_GNOME_Evolution_Component__epv *epv = &class->epv;
@@ -1565,17 +685,9 @@ calendar_component_class_init (CalendarComponentClass *class)
parent_class = g_type_class_peek_parent (class);
- epv->upgradeFromVersion = impl_upgradeFromVersion;
- epv->createView = impl_createView;
- epv->_get_userCreatableItems = impl__get_userCreatableItems;
- epv->requestCreateItem = impl_requestCreateItem;
epv->handleURI = impl_handleURI;
object_class->dispose = impl_dispose;
- object_class->finalize = impl_finalize;
-
- /* Register attachment handler types. */
- e_attachment_handler_calendar_get_type ();
}
static void
@@ -1584,15 +696,6 @@ calendar_component_init (CalendarComponent *component)
CalendarComponentPrivate *priv;
guint not;
- priv = g_new0 (CalendarComponentPrivate, 1);
-
- priv->base_directory = g_build_filename (e_get_user_data_dir (), "calendar", NULL);
- priv->config_directory = g_build_filename (priv->base_directory, "config", NULL);
-
- /* EPFIXME: Should use a custom one instead? Also we should add
- * calendar_component_peek_gconf_client(). */
- priv->gconf_client = gconf_client_get_default ();
-
not = calendar_config_add_notification_primary_calendar (config_primary_selection_changed_cb,
component);
priv->notifications = g_list_prepend (priv->notifications, GUINT_TO_POINTER (not));
@@ -1603,67 +706,7 @@ calendar_component_init (CalendarComponent *component)
e_activity_handler_set_error_flush_time (priv->activity_handler,eni_config_get_error_timeout (CALENDAR_ERROR_TIME_OUT_KEY)*1000);
component->priv = priv;
- ensure_sources (component);
e_cal_get_sources (&priv->task_source_list, E_CAL_SOURCE_TYPE_TODO, NULL);
e_cal_get_sources (&priv->memo_source_list, E_CAL_SOURCE_TYPE_JOURNAL, NULL);
}
-
-/* Public API. */
-
-CalendarComponent *
-calendar_component_peek (void)
-{
- static CalendarComponent *component = NULL;
-
- if (component == NULL) {
- component = g_object_new (calendar_component_get_type (), NULL);
-
- if (g_mkdir_with_parents (calendar_component_peek_config_directory (component), 0777) != 0) {
- g_warning (G_STRLOC ": Cannot create directory %s: %s",
- calendar_component_peek_config_directory (component),
- g_strerror (errno));
- g_object_unref (component);
- component = NULL;
- }
- }
-
- return component;
-}
-
-const gchar *
-calendar_component_peek_base_directory (CalendarComponent *component)
-{
- return component->priv->base_directory;
-}
-
-const gchar *
-calendar_component_peek_config_directory (CalendarComponent *component)
-{
- return component->priv->config_directory;
-}
-
-ESourceList *
-calendar_component_peek_source_list (CalendarComponent *component)
-{
- return component->priv->source_list;
-}
-
-EActivityHandler *
-calendar_component_peek_activity_handler (CalendarComponent *component)
-{
- CALENDAR_COMPONENT_DEFAULT(component);
-
- return component->priv->activity_handler;
-}
-
-void
-calendar_component_show_logger (gpointer top)
-{
- CalendarComponent *cc = calendar_component_peek ();
- ELogger *logger = cc->priv->logger;
-
- eni_show_logger(logger, top, CALENDAR_ERROR_TIME_OUT_KEY, CALENDAR_ERROR_LEVEL_KEY);
-}
-
-BONOBO_TYPE_FUNC_FULL (CalendarComponent, GNOME_Evolution_Component, PARENT_TYPE, calendar_component)
diff --git a/calendar/gui/calendar-component.h b/calendar/gui/calendar-component.h
index 480b0c4c93..fbdd8efd23 100644
--- a/calendar/gui/calendar-component.h
+++ b/calendar/gui/calendar-component.h
@@ -52,12 +52,4 @@ struct _CalendarComponentClass {
GType calendar_component_get_type (void);
-CalendarComponent *calendar_component_peek (void);
-
-const gchar *calendar_component_peek_base_directory (CalendarComponent *component);
-const gchar *calendar_component_peek_config_directory (CalendarComponent *component);
-ESourceList *calendar_component_peek_source_list (CalendarComponent *component);
-EActivityHandler *calendar_component_peek_activity_handler (CalendarComponent *component);
-void calendar_component_show_logger (gpointer);
-
#endif /* _CALENDAR_COMPONENT_H_ */
diff --git a/calendar/gui/calendar-config-keys.h b/calendar/gui/calendar-config-keys.h
index 9b2bd1c644..b12b3b2b92 100644
--- a/calendar/gui/calendar-config-keys.h
+++ b/calendar/gui/calendar-config-keys.h
@@ -28,18 +28,10 @@ G_BEGIN_DECLS
#define CALENDAR_CONFIG_PREFIX "/apps/evolution/calendar"
/* Display settings */
-#define CALENDAR_CONFIG_USE_SYSTEM_TIMEZONE CALENDAR_CONFIG_PREFIX "/display/use_system_timezone"
#define CALENDAR_CONFIG_TIMEZONE CALENDAR_CONFIG_PREFIX "/display/timezone"
#define CALENDAR_CONFIG_SELECTED_CALENDARS CALENDAR_CONFIG_PREFIX "/display/selected_calendars"
-#define CALENDAR_CONFIG_PRIMARY_CALENDAR CALENDAR_CONFIG_PREFIX "/display/primary_calendar"
#define CALENDAR_CONFIG_24HOUR CALENDAR_CONFIG_PREFIX "/display/use_24hour_format"
#define CALENDAR_CONFIG_SHOW_ATTENDEE CALENDAR_CONFIG_PREFIX "/display/show_attendee"
-#define CALENDAR_CONFIG_SHOW_ROLE CALENDAR_CONFIG_PREFIX "/display/show_role"
-#define CALENDAR_CONFIG_SHOW_STATUS CALENDAR_CONFIG_PREFIX "/display/show_status"
-#define CALENDAR_CONFIG_SHOW_TYPE CALENDAR_CONFIG_PREFIX "/display/show_type"
-#define CALENDAR_CONFIG_SHOW_RSVP CALENDAR_CONFIG_PREFIX "/display/show_rsvp"
-#define CALENDAR_CONFIG_SHOW_TIMEZONE CALENDAR_CONFIG_PREFIX "/display/show_timezone"
-#define CALENDAR_CONFIG_SHOW_CATEGORIES CALENDAR_CONFIG_PREFIX "/display/show_categories"
#define CALENDAR_CONFIG_WEEK_START CALENDAR_CONFIG_PREFIX "/display/week_start_day"
#define CALENDAR_CONFIG_DAY_START_HOUR CALENDAR_CONFIG_PREFIX "/display/day_start_hour"
#define CALENDAR_CONFIG_DAY_START_MINUTE CALENDAR_CONFIG_PREFIX "/display/day_start_minute"
diff --git a/calendar/gui/calendar-config.c b/calendar/gui/calendar-config.c
index f1730d5bc7..a57b0c2411 100644
--- a/calendar/gui/calendar-config.c
+++ b/calendar/gui/calendar-config.c
@@ -29,12 +29,13 @@
#include <config.h>
#endif
-#include <string.h>
#include <time.h>
-#include <libedataserver/e-data-server-util.h>
+#include <string.h>
#include <e-util/e-util.h>
-#include <widgets/e-timezone-dialog/e-timezone-dialog.h>
#include <libecal/e-cal-time-util.h>
+#include <libedataserver/e-data-server-util.h>
+#include <widgets/e-timezone-dialog/e-timezone-dialog.h>
+#include <shell/e-shell.h>
#include "calendar-config-keys.h"
#include "calendar-config.h"
@@ -150,72 +151,23 @@ calendar_config_add_notification_calendars_selected (GConfClientNotifyFunc func,
return id;
}
-/* The primary calendar */
-gchar *
-calendar_config_get_primary_calendar (void)
-{
- calendar_config_init ();
-
- return gconf_client_get_string (config, CALENDAR_CONFIG_PRIMARY_CALENDAR, NULL);
-}
-
-void
-calendar_config_set_primary_calendar (const gchar *primary_uid)
-{
- calendar_config_init ();
-
- gconf_client_set_string (config, CALENDAR_CONFIG_PRIMARY_CALENDAR, primary_uid, NULL);
-}
-
-guint
-calendar_config_add_notification_primary_calendar (GConfClientNotifyFunc func, gpointer data)
-{
- guint id;
-
- calendar_config_init ();
-
- id = gconf_client_notify_add (config, CALENDAR_CONFIG_PRIMARY_CALENDAR, func, data, NULL, NULL);
-
- return id;
-}
-
-gboolean
-calendar_config_get_use_system_timezone (void)
-{
- calendar_config_init ();
-
- return gconf_client_get_bool (config, CALENDAR_CONFIG_USE_SYSTEM_TIMEZONE, NULL);
-}
-
-void
-calendar_config_set_use_system_timezone (gboolean use)
-{
- calendar_config_init ();
-
- if (calendar_config_get_use_system_timezone () != use) {
- gconf_client_set_bool (config, CALENDAR_CONFIG_USE_SYSTEM_TIMEZONE, use, NULL);
- gconf_client_notify (config, CALENDAR_CONFIG_TIMEZONE);
-
- /* FIXME: notify CALENDAR_CONFIG_TIMEZONE change on system timezone change
- itself too, when using system timezone. How to receive such change? */
- }
-}
-
-guint
-calendar_config_add_notification_use_system_timezone (GConfClientNotifyFunc func, gpointer data)
-{
- calendar_config_init ();
-
- return gconf_client_notify_add (config, CALENDAR_CONFIG_USE_SYSTEM_TIMEZONE, func, data, NULL, NULL);
-}
-
/* The current timezone, e.g. "Europe/London". It may be NULL, in which case
you should assume UTC (though Evolution will show the timezone-setting
dialog the next time a calendar or task folder is selected). */
gchar *
calendar_config_get_timezone (void)
{
- if (calendar_config_get_use_system_timezone ())
+ EShell *shell;
+ EShellSettings *shell_settings;
+ gboolean use_system_timezone;
+
+ shell = e_shell_get_default ();
+ shell_settings = e_shell_get_shell_settings (shell);
+
+ use_system_timezone = e_shell_settings_get_boolean (
+ shell_settings, "cal-use-system-timezone");
+
+ if (use_system_timezone)
return e_cal_util_get_system_timezone_location ();
return calendar_config_get_timezone_stored ();
@@ -307,106 +259,6 @@ calendar_config_add_notification_24_hour_format (GConfClientNotifyFunc func, gpo
return id;
}
-/* Show RSVP*/
-gboolean
-calendar_config_get_show_rsvp (void)
-{
- calendar_config_init ();
-
- return gconf_client_get_bool (config, CALENDAR_CONFIG_SHOW_RSVP, NULL);
-}
-
-void
-calendar_config_set_show_rsvp (gboolean state)
-{
- calendar_config_init ();
-
- gconf_client_set_bool (config, CALENDAR_CONFIG_SHOW_RSVP, state, NULL);
-}
-
-/* Show Role*/
-gboolean
-calendar_config_get_show_role (void)
-{
- calendar_config_init ();
-
- return gconf_client_get_bool (config, CALENDAR_CONFIG_SHOW_ROLE, NULL);
-}
-
-void
-calendar_config_set_show_role (gboolean state)
-{
- calendar_config_init ();
-
- gconf_client_set_bool (config, CALENDAR_CONFIG_SHOW_ROLE, state, NULL);
-}
-
-/* Show Type*/
-gboolean
-calendar_config_get_show_type (void)
-{
- calendar_config_init ();
-
- return gconf_client_get_bool (config, CALENDAR_CONFIG_SHOW_TYPE, NULL);
-}
-
-void
-calendar_config_set_show_type (gboolean state)
-{
- calendar_config_init ();
-
- gconf_client_set_bool (config, CALENDAR_CONFIG_SHOW_TYPE, state, NULL);
-}
-
-/* Show status */
-gboolean
-calendar_config_get_show_status (void)
-{
- calendar_config_init ();
-
- return gconf_client_get_bool (config, CALENDAR_CONFIG_SHOW_STATUS, NULL);
-}
-
-void
-calendar_config_set_show_status (gboolean state)
-{
- calendar_config_init ();
-
- gconf_client_set_bool (config, CALENDAR_CONFIG_SHOW_STATUS, state, NULL);
-}
-
-/* Show timezone */
-gboolean
-calendar_config_get_show_timezone (void)
-{
- calendar_config_init ();
-
- return gconf_client_get_bool (config, CALENDAR_CONFIG_SHOW_TIMEZONE, NULL);
-}
-
-void
-calendar_config_set_show_timezone (gboolean status)
-{
- calendar_config_init ();
-
- gconf_client_set_bool (config, CALENDAR_CONFIG_SHOW_TIMEZONE, status, NULL);
-}
-
-gboolean
-calendar_config_get_show_categories (void)
-{
- calendar_config_init ();
-
- return gconf_client_get_bool (config, CALENDAR_CONFIG_SHOW_CATEGORIES, NULL);
-}
-void
-calendar_config_set_show_categories (gboolean status)
-{
- calendar_config_init ();
-
- gconf_client_set_bool (config, CALENDAR_CONFIG_SHOW_CATEGORIES, status, NULL);
-}
-
/* The start day of the week (0 = Sun to 6 = Mon). */
gint
calendar_config_get_week_start_day (void)
@@ -713,22 +565,6 @@ calendar_config_set_hpane_pos (gint hpane_pos)
gconf_client_set_int (config, CALENDAR_CONFIG_HPANE_POS, hpane_pos, NULL);
}
-gint
-calendar_config_get_vpane_pos (void)
-{
- calendar_config_init ();
-
- return gconf_client_get_int (config, CALENDAR_CONFIG_VPANE_POS, NULL);
-}
-
-void
-calendar_config_set_vpane_pos (gint vpane_pos)
-{
- calendar_config_init ();
-
- gconf_client_set_int (config, CALENDAR_CONFIG_VPANE_POS, vpane_pos, NULL);
-}
-
gboolean
calendar_config_get_preview_state (void)
{
@@ -773,22 +609,6 @@ calendar_config_set_month_hpane_pos (gint hpane_pos)
gconf_client_set_int (config, CALENDAR_CONFIG_MONTH_HPANE_POS, hpane_pos, NULL);
}
-gint
-calendar_config_get_month_vpane_pos (void)
-{
- calendar_config_init ();
-
- return gconf_client_get_int (config, CALENDAR_CONFIG_MONTH_VPANE_POS, NULL);
-}
-
-void
-calendar_config_set_month_vpane_pos (gint vpane_pos)
-{
- calendar_config_init ();
-
- gconf_client_set_int (config, CALENDAR_CONFIG_MONTH_VPANE_POS, vpane_pos, NULL);
-}
-
gfloat
calendar_config_get_tag_vpane_pos (void)
{
diff --git a/calendar/gui/calendar-config.h b/calendar/gui/calendar-config.h
index a009ed73d7..241ed8fe4c 100644
--- a/calendar/gui/calendar-config.h
+++ b/calendar/gui/calendar-config.h
@@ -66,16 +66,6 @@ GSList *calendar_config_get_calendars_selected (void);
void calendar_config_set_calendars_selected (GSList *selected);
guint calendar_config_add_notification_calendars_selected (GConfClientNotifyFunc func, gpointer data);
-/* The primary calendar */
-gchar *calendar_config_get_primary_calendar (void);
-void calendar_config_set_primary_calendar (const gchar *primary_uid);
-guint calendar_config_add_notification_primary_calendar (GConfClientNotifyFunc func, gpointer data);
-
-/* Use system timezone; if TRUE, then influences also the current timezone functions. */
-gboolean calendar_config_get_use_system_timezone (void);
-void calendar_config_set_use_system_timezone (gboolean use);
-guint calendar_config_add_notification_use_system_timezone (GConfClientNotifyFunc func, gpointer data);
-
/* The current timezone, e.g. "Europe/London". */
gchar * calendar_config_get_timezone (void);
gchar * calendar_config_get_timezone_stored (void);
@@ -115,24 +105,6 @@ gboolean calendar_config_get_24_hour_format (void);
void calendar_config_set_24_hour_format (gboolean use_24_hour);
guint calendar_config_add_notification_24_hour_format (GConfClientNotifyFunc func, gpointer data);
-gboolean calendar_config_get_show_status (void);
-void calendar_config_set_show_status (gboolean status);
-
-gboolean calendar_config_get_show_type (void);
-void calendar_config_set_show_type (gboolean status);
-
-gboolean calendar_config_get_show_rsvp (void);
-void calendar_config_set_show_rsvp (gboolean status);
-
-gboolean calendar_config_get_show_timezone (void);
-void calendar_config_set_show_timezone (gboolean status);
-
-gboolean calendar_config_get_show_categories (void);
-void calendar_config_set_show_categories (gboolean status);
-
-gboolean calendar_config_get_show_role (void);
-void calendar_config_set_show_role (gboolean state);
-
/* The time divisions in the Day/Work-Week view in minutes (5/10/15/30/60). */
gint calendar_config_get_time_divisions (void);
void calendar_config_set_time_divisions (gint divisions);
@@ -166,9 +138,6 @@ guint calendar_config_add_notification_dview_show_week_no (GConfClientNotifyFunc
gint calendar_config_get_hpane_pos (void);
void calendar_config_set_hpane_pos (gint hpane_pos);
-gint calendar_config_get_vpane_pos (void);
-void calendar_config_set_vpane_pos (gint vpane_pos);
-
gboolean calendar_config_get_preview_state (void);
void calendar_config_set_preview_state (gboolean state);
guint calendar_config_add_notification_preview_state (GConfClientNotifyFunc func, gpointer data);
diff --git a/calendar/gui/calendar-view-factory.c b/calendar/gui/calendar-view-factory.c
index 95497b1782..34e8344a88 100644
--- a/calendar/gui/calendar-view-factory.c
+++ b/calendar/gui/calendar-view-factory.c
@@ -181,7 +181,7 @@ calendar_view_factory_new_view (GalViewFactory *factory, const gchar *name)
*
* Return value: The same value as @cal_view_factory.
**/
-CalendarViewFactory *
+GalViewFactory *
calendar_view_factory_construct (CalendarViewFactory *cal_view_factory,
GnomeCalendarViewType view_type)
{
@@ -194,7 +194,7 @@ calendar_view_factory_construct (CalendarViewFactory *cal_view_factory,
priv->view_type = view_type;
- return cal_view_factory;
+ return GAL_VIEW_FACTORY (cal_view_factory);
}
/**
@@ -205,7 +205,7 @@ calendar_view_factory_construct (CalendarViewFactory *cal_view_factory,
*
* Return value: A newly-created calendar view factory.
**/
-CalendarViewFactory *
+GalViewFactory *
calendar_view_factory_new (GnomeCalendarViewType view_type)
{
CalendarViewFactory *cal_view_factory;
diff --git a/calendar/gui/calendar-view-factory.h b/calendar/gui/calendar-view-factory.h
index 0f182a11e1..c0b90f2bd9 100644
--- a/calendar/gui/calendar-view-factory.h
+++ b/calendar/gui/calendar-view-factory.h
@@ -57,10 +57,10 @@ typedef struct {
GType calendar_view_factory_get_type (void);
-CalendarViewFactory *calendar_view_factory_construct (CalendarViewFactory *cal_view_factory,
+GalViewFactory *calendar_view_factory_construct (CalendarViewFactory *cal_view_factory,
GnomeCalendarViewType view_type);
-CalendarViewFactory *calendar_view_factory_new (GnomeCalendarViewType view_type);
+GalViewFactory *calendar_view_factory_new (GnomeCalendarViewType view_type);
diff --git a/calendar/gui/comp-editor-factory.c b/calendar/gui/comp-editor-factory.c
deleted file mode 100644
index ee80a00ae5..0000000000
--- a/calendar/gui/comp-editor-factory.c
+++ /dev/null
@@ -1,642 +0,0 @@
-/*
- * Evolution calendar - Component editor factory object
- *
- * This program is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 2 of the License, or (at your option) version 3.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with the program; if not, see <http://www.gnu.org/licenses/>
- *
- *
- * Authors:
- * Federico Mena-Quintero <federico@ximian.com>
- *
- * Copyright (C) 1999-2008 Novell, Inc. (www.novell.com)
- *
- */
-
-#ifdef HAVE_CONFIG_H
-#include <config.h>
-#endif
-
-#include <gtk/gtk.h>
-#include <glib/gi18n.h>
-#include <bonobo/bonobo-exception.h>
-#include <evolution-calendar.h>
-#include <libedataserver/e-url.h>
-#include <libecal/e-cal.h>
-#include "calendar-config.h"
-#include "e-comp-editor-registry.h"
-#include "comp-editor-factory.h"
-#include "comp-util.h"
-#include "common/authentication.h"
-#include "dialogs/event-editor.h"
-#include "dialogs/task-editor.h"
-
-extern ECompEditorRegistry *comp_editor_registry;
-
-
-
-/* A pending request */
-
-typedef enum {
- REQUEST_EXISTING,
- REQUEST_NEW
-} RequestType;
-
-typedef struct {
- RequestType type;
-
- union {
- struct {
- gchar *uid;
- } existing;
-
- struct {
- GNOME_Evolution_Calendar_CompEditorFactory_CompEditorMode type;
- } new;
- } u;
-} Request;
-
-/* A client we have open */
-typedef struct {
- /* Our parent CompEditorFactory */
- CompEditorFactory *factory;
-
- /* Uri of the calendar, used as key in the clients hash table */
- gchar *uri;
-
- /* Client of the calendar */
- ECal *client;
-
- /* Count editors using this client */
- gint editor_count;
-
- /* Pending requests; they are pending if the client is still being opened */
- GSList *pending;
-
- /* Whether this is open or still waiting */
- guint open : 1;
-} OpenClient;
-
-/* Private part of the CompEditorFactory structure */
-struct CompEditorFactoryPrivate {
- /* Hash table of URI->OpenClient */
- GHashTable *uri_client_hash;
-};
-
-
-
-static void comp_editor_factory_class_init (CompEditorFactoryClass *class);
-static void comp_editor_factory_init (CompEditorFactory *factory);
-static void comp_editor_factory_finalize (GObject *object);
-
-static void impl_editExisting (PortableServer_Servant servant,
- const CORBA_char *str_uri,
- const CORBA_char *uid,
- const GNOME_Evolution_Calendar_CompEditorFactory_CompEditorMode corba_type,
- CORBA_Environment *ev);
-static void impl_editNew (PortableServer_Servant servant,
- const CORBA_char *str_uri,
- const GNOME_Evolution_Calendar_CalObjType type,
- CORBA_Environment *ev);
-
-static BonoboObjectClass *parent_class = NULL;
-
-
-
-BONOBO_TYPE_FUNC_FULL (CompEditorFactory,
- GNOME_Evolution_Calendar_CompEditorFactory,
- BONOBO_OBJECT_TYPE,
- comp_editor_factory)
-
-/* Class initialization function for the component editor factory */
-static void
-comp_editor_factory_class_init (CompEditorFactoryClass *class)
-{
- GObjectClass *object_class;
-
- object_class = (GObjectClass *) class;
-
- parent_class = g_type_class_peek_parent (class);
-
- class->epv.editExisting = impl_editExisting;
- class->epv.editNew = impl_editNew;
-
- object_class->finalize = comp_editor_factory_finalize;
-}
-
-/* Frees a Request structure */
-static void
-free_request (Request *r)
-{
- if (r->type == REQUEST_EXISTING)
- g_free (r->u.existing.uid);
-
- g_free (r);
-}
-
-/* Frees an OpenClient structure */
-static void
-free_client (OpenClient *oc)
-{
- GSList *l;
-
- g_free (oc->uri);
- oc->uri = NULL;
-
- g_object_unref (oc->client);
- oc->client = NULL;
-
- for (l = oc->pending; l; l = l->next) {
- Request *r;
-
- r = l->data;
- free_request (r);
- }
- g_slist_free (oc->pending);
- oc->pending = NULL;
-
- g_free (oc);
-}
-
-/* Object initialization function for the component editor factory */
-static void
-comp_editor_factory_init (CompEditorFactory *factory)
-{
- CompEditorFactoryPrivate *priv;
-
- priv = g_new (CompEditorFactoryPrivate, 1);
- factory->priv = priv;
-
- priv->uri_client_hash = g_hash_table_new_full (
- g_str_hash, g_str_equal,
- (GDestroyNotify) NULL,
- (GDestroyNotify) free_client);
-}
-
-/* Destroy handler for the component editor factory */
-static void
-comp_editor_factory_finalize (GObject *object)
-{
- CompEditorFactory *factory;
- CompEditorFactoryPrivate *priv;
-
- g_return_if_fail (object != NULL);
- g_return_if_fail (IS_COMP_EDITOR_FACTORY (object));
-
- factory = COMP_EDITOR_FACTORY (object);
- priv = factory->priv;
-
- g_hash_table_destroy (priv->uri_client_hash);
- priv->uri_client_hash = NULL;
-
- g_free (priv);
- factory->priv = NULL;
-
- if (G_OBJECT_CLASS (parent_class)->finalize)
- (* G_OBJECT_CLASS (parent_class)->finalize) (object);
-}
-
-
-
-/* Callback used when a component editor gets destroyed */
-static void
-editor_destroy_cb (GtkObject *object, gpointer data)
-{
- OpenClient *oc;
- CompEditorFactory *factory;
- CompEditorFactoryPrivate *priv;
-
- oc = data;
- factory = oc->factory;
- priv = factory->priv;
-
- oc->editor_count--;
-
- /* See if we need to free the client */
- g_return_if_fail (oc->pending == NULL);
-
- if (oc->editor_count != 0)
- return;
-
- g_hash_table_remove (priv->uri_client_hash, oc->uri);
-}
-
-/* Starts editing an existing component on a client that is already open */
-static void
-edit_existing (OpenClient *oc, const gchar *uid)
-{
- ECalComponent *comp;
- icalcomponent *icalcomp;
- CompEditor *editor;
- ECalComponentVType vtype;
- CompEditorFlags flags = { 0, };
-
- g_return_if_fail (oc->open);
-
- /* Get the object */
- if (!e_cal_get_object (oc->client, uid, NULL, &icalcomp, NULL)) {
- /* FIXME Better error handling */
- g_warning (G_STRLOC ": Syntax error while getting component `%s'", uid);
-
- return;
- }
-
- comp = e_cal_component_new ();
- if (!e_cal_component_set_icalcomponent (comp, icalcomp)) {
- g_object_unref (comp);
- icalcomponent_free (icalcomp);
- return;
- }
-
- /* Create the appropriate type of editor */
-
- vtype = e_cal_component_get_vtype (comp);
- if (itip_organizer_is_user (comp, oc->client))
- flags |= COMP_EDITOR_USER_ORG;
-
- switch (vtype) {
- case E_CAL_COMPONENT_EVENT:
- if (e_cal_component_has_attendees (comp))
- flags |= COMP_EDITOR_MEETING;
-
- editor = event_editor_new (oc->client, flags);
- break;
-
- case E_CAL_COMPONENT_TODO:
- editor = COMP_EDITOR (task_editor_new (oc->client, flags));
- break;
-
- default:
- g_message ("edit_exiting(): Unsupported object type %d", (gint) vtype);
- g_object_unref (comp);
- return;
- }
-
- /* Set the object on the editor */
- comp_editor_edit_comp (editor, comp);
- gtk_window_present (GTK_WINDOW (editor));
- g_object_unref (comp);
-
- oc->editor_count++;
- g_signal_connect (editor, "destroy", G_CALLBACK (editor_destroy_cb), oc);
-
- e_comp_editor_registry_add (comp_editor_registry, editor, TRUE);
-}
-
-static ECalComponent *
-get_default_task (ECal *client)
-{
- ECalComponent *comp;
-
- comp = cal_comp_task_new_with_defaults (client);
-
- return comp;
-}
-
-/* Edits a new object in the context of a client */
-static void
-edit_new (OpenClient *oc, const GNOME_Evolution_Calendar_CompEditorFactory_CompEditorMode type)
-{
- ECalComponent *comp;
- CompEditor *editor;
-
- switch (type) {
- case GNOME_Evolution_Calendar_CompEditorFactory_EDITOR_MODE_EVENT:
- editor = event_editor_new (oc->client, FALSE);
- comp = cal_comp_event_new_with_current_time (oc->client, FALSE);
- break;
- case GNOME_Evolution_Calendar_CompEditorFactory_EDITOR_MODE_MEETING:
- editor = event_editor_new (oc->client, TRUE);
- comp = cal_comp_event_new_with_current_time (oc->client, FALSE);
- break;
- case GNOME_Evolution_Calendar_CompEditorFactory_EDITOR_MODE_ALLDAY_EVENT:
- editor = event_editor_new (oc->client, FALSE);
- comp = cal_comp_event_new_with_current_time (oc->client, TRUE);
- break;
- case GNOME_Evolution_Calendar_CompEditorFactory_EDITOR_MODE_TODO:
- editor = COMP_EDITOR (task_editor_new (oc->client, FALSE));
- comp = get_default_task (oc->client);
- break;
- default:
- g_return_if_reached ();
- return;
- }
-
- comp_editor_edit_comp (editor, comp);
- if (type == GNOME_Evolution_Calendar_CompEditorFactory_EDITOR_MODE_MEETING)
- event_editor_show_meeting (EVENT_EDITOR (editor));
- gtk_window_present (GTK_WINDOW (editor));
-
- oc->editor_count++;
- g_signal_connect (editor, "destroy", G_CALLBACK (editor_destroy_cb), oc);
-
- e_comp_editor_registry_add (comp_editor_registry, editor, TRUE);
-}
-
-/* Resolves all the pending requests for a client */
-static void
-resolve_pending_requests (OpenClient *oc)
-{
- GSList *l;
- icaltimezone *zone;
-
- if (!oc->pending)
- return;
-
- /* Set the default timezone in the backend. */
- zone = calendar_config_get_icaltimezone ();
-
- /* FIXME Error handling? */
- e_cal_set_default_timezone (oc->client, zone, NULL);
-
- for (l = oc->pending; l; l = l->next) {
- Request *request;
-
- request = l->data;
-
- switch (request->type) {
- case REQUEST_EXISTING:
- edit_existing (oc, request->u.existing.uid);
- break;
-
- case REQUEST_NEW:
- edit_new (oc, request->u.new.type);
- break;
- }
-
- free_request (request);
- }
-
- g_slist_free (oc->pending);
- oc->pending = NULL;
-}
-
-/* Callback used when a client is finished opening. We resolve all the pending
- * requests.
- */
-static void
-cal_opened_cb (ECal *client, ECalendarStatus status, gpointer data)
-{
- OpenClient *oc;
- CompEditorFactory *factory;
- CompEditorFactoryPrivate *priv;
- GtkWidget *dialog = NULL;
-
- oc = data;
- factory = oc->factory;
- priv = factory->priv;
-
- switch (status) {
- case E_CALENDAR_STATUS_OK:
- oc->open = TRUE;
- resolve_pending_requests (oc);
- return;
-
- case E_CALENDAR_STATUS_OTHER_ERROR:
- case E_CALENDAR_STATUS_NO_SUCH_CALENDAR:
- dialog = gtk_message_dialog_new (NULL, GTK_DIALOG_MODAL,
- GTK_MESSAGE_ERROR, GTK_BUTTONS_CLOSE,
- "%s", _("Error while opening the calendar"));
- break;
-
- case E_CALENDAR_STATUS_PROTOCOL_NOT_SUPPORTED:
- dialog = gtk_message_dialog_new (NULL, GTK_DIALOG_MODAL,
- GTK_MESSAGE_ERROR, GTK_BUTTONS_CLOSE,
- "%s", _("Method not supported when opening the calendar"));
- break;
-
- case E_CALENDAR_STATUS_PERMISSION_DENIED :
- dialog = gtk_message_dialog_new (NULL, GTK_DIALOG_MODAL,
- GTK_MESSAGE_ERROR, GTK_BUTTONS_CLOSE,
- "%s", _("Permission denied to open the calendar"));
- break;
-
- case E_CALENDAR_STATUS_AUTHENTICATION_REQUIRED:
- dialog = gtk_message_dialog_new (NULL, GTK_DIALOG_MODAL,
- GTK_MESSAGE_ERROR, GTK_BUTTONS_CLOSE,
- "%s", _("Authentication Required"));
- break;
-
- case E_CALENDAR_STATUS_AUTHENTICATION_FAILED :
- dialog = gtk_message_dialog_new (NULL, GTK_DIALOG_MODAL,
- GTK_MESSAGE_ERROR, GTK_BUTTONS_CLOSE,
- "%s", _("Authentication Failed"));
- break;
-
- default:
- dialog = gtk_message_dialog_new (NULL, GTK_DIALOG_MODAL,
- GTK_MESSAGE_ERROR, GTK_BUTTONS_CLOSE,
- "%s", _("Unknown error"));
- return;
- }
-
- gtk_dialog_run (GTK_DIALOG (dialog));
- gtk_widget_destroy (dialog);
-
- g_hash_table_remove (priv->uri_client_hash, oc->uri);
-}
-
-/* Creates a new OpenClient structure and queues the component editing/creation
- * process until the client is open. Returns NULL if it could not issue the
- * open request.
- */
-static OpenClient *
-open_client (CompEditorFactory *factory, ECalSourceType source_type, const gchar *uristr)
-{
- CompEditorFactoryPrivate *priv;
- ECal *client;
- OpenClient *oc;
- GError *error = NULL;
-
- priv = factory->priv;
-
- client = auth_new_cal_from_uri (uristr, source_type);
- if (!client)
- return NULL;
-
- oc = g_new (OpenClient, 1);
- oc->factory = factory;
-
- oc->uri = g_strdup (uristr);
-
- oc->client = client;
- oc->editor_count = 0;
- oc->pending = NULL;
- oc->open = FALSE;
-
- g_signal_connect (oc->client, "cal_opened", G_CALLBACK (cal_opened_cb), oc);
-
- g_hash_table_insert (priv->uri_client_hash, oc->uri, oc);
-
- if (!e_cal_open (oc->client, FALSE, &error)) {
- g_warning (G_STRLOC ": %s", error->message);
- g_free (oc->uri);
- g_object_unref (oc->client);
- g_free (oc);
- g_error_free (error);
-
- return NULL;
- }
-
- return oc;
-}
-
-/* Looks up an open client or queues it for being opened. Returns the client or
- * NULL on failure; in the latter case it sets the ev exception.
- */
-static OpenClient *
-lookup_open_client (CompEditorFactory *factory, ECalSourceType source_type, const gchar *str_uri, CORBA_Environment *ev)
-{
- CompEditorFactoryPrivate *priv;
- OpenClient *oc;
- EUri *uri;
-
- priv = factory->priv;
-
- /* Look up the client */
-
- uri = e_uri_new (str_uri);
- if (!uri) {
- bonobo_exception_set (ev, ex_GNOME_Evolution_Calendar_CompEditorFactory_InvalidURI);
- return NULL;
- }
- e_uri_free (uri);
-
- oc = g_hash_table_lookup (priv->uri_client_hash, str_uri);
- if (!oc) {
- oc = open_client (factory, source_type, str_uri);
- if (!oc) {
- bonobo_exception_set (ev, ex_GNOME_Evolution_Calendar_CompEditorFactory_BackendContactError);
- return NULL;
- }
- }
-
- return oc;
-}
-
-/* Queues a request for editing an existing object */
-static void
-queue_edit_existing (OpenClient *oc, const gchar *uid)
-{
- Request *request;
-
- g_return_if_fail (!oc->open);
-
- request = g_new (Request, 1);
- request->type = REQUEST_EXISTING;
- request->u.existing.uid = g_strdup (uid);
-
- oc->pending = g_slist_append (oc->pending, request);
-}
-
-/* ::editExisting() method implementation */
-static void
-impl_editExisting (PortableServer_Servant servant,
- const CORBA_char *str_uri,
- const CORBA_char *uid,
- const GNOME_Evolution_Calendar_CompEditorFactory_CompEditorMode corba_type,
- CORBA_Environment *ev)
-{
- CompEditorFactory *factory;
- OpenClient *oc;
- CompEditor *editor;
- ECalSourceType source_type;
-
- factory = COMP_EDITOR_FACTORY (bonobo_object_from_servant (servant));
-
- switch (corba_type) {
- case GNOME_Evolution_Calendar_CompEditorFactory_EDITOR_MODE_TODO:
- source_type = E_CAL_SOURCE_TYPE_TODO;
- break;
- default:
- source_type = E_CAL_SOURCE_TYPE_EVENT;
- }
-
- oc = lookup_open_client (factory, source_type, str_uri, ev);
- if (!oc)
- return;
-
- if (!oc->open) {
- queue_edit_existing (oc, uid);
- return;
- }
-
- /* Look up the component */
- editor = e_comp_editor_registry_find (comp_editor_registry, uid);
- if (editor == NULL) {
- edit_existing (oc, uid);
- } else {
- gtk_window_present (GTK_WINDOW (editor));
- }
-}
-
-/* Queues a request for creating a new object */
-static void
-queue_edit_new (OpenClient *oc, const GNOME_Evolution_Calendar_CompEditorFactory_CompEditorMode type)
-{
- Request *request;
-
- g_return_if_fail (!oc->open);
-
- request = g_new (Request, 1);
- request->type = REQUEST_NEW;
- request->u.new.type = type;
-
- oc->pending = g_slist_append (oc->pending, request);
-}
-
-/* ::editNew() method implementation */
-static void
-impl_editNew (PortableServer_Servant servant,
- const CORBA_char *str_uri,
- const GNOME_Evolution_Calendar_CompEditorFactory_CompEditorMode corba_type,
- CORBA_Environment *ev)
-{
- CompEditorFactory *factory;
- OpenClient *oc;
- ECalSourceType source_type;
-
- factory = COMP_EDITOR_FACTORY (bonobo_object_from_servant (servant));
-
- switch (corba_type) {
- case GNOME_Evolution_Calendar_CompEditorFactory_EDITOR_MODE_TODO:
- source_type = E_CAL_SOURCE_TYPE_TODO;
- break;
- default:
- source_type = E_CAL_SOURCE_TYPE_EVENT;
- }
-
- oc = lookup_open_client (factory, source_type, str_uri, ev);
- if (!oc)
- return;
-
- if (!oc->open)
- queue_edit_new (oc, corba_type);
- else
- edit_new (oc, corba_type);
-}
-
-
-
-/**
- * comp_editor_factory_new:
- *
- * Creates a new calendar component editor factory.
- *
- * Return value: A newly-created component editor factory.
- **/
-CompEditorFactory *
-comp_editor_factory_new (void)
-{
- return g_object_new (TYPE_COMP_EDITOR_FACTORY, NULL);
-}
-
diff --git a/calendar/gui/comp-editor-factory.h b/calendar/gui/comp-editor-factory.h
deleted file mode 100644
index 3e79992d67..0000000000
--- a/calendar/gui/comp-editor-factory.h
+++ /dev/null
@@ -1,62 +0,0 @@
-/*
- * Evolution calendar - Component editor factory object
- *
- * This program is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 2 of the License, or (at your option) version 3.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with the program; if not, see <http://www.gnu.org/licenses/>
- *
- *
- * Authors:
- * Federico Mena-Quintero <federico@ximian.com>
- *
- * Copyright (C) 1999-2008 Novell, Inc. (www.novell.com)
- *
- */
-
-#ifndef COMP_EDITOR_FACTORY_H
-#define COMP_EDITOR_FACTORY_H
-
-#include <bonobo/bonobo-object.h>
-#include "evolution-calendar.h"
-
-
-
-#define TYPE_COMP_EDITOR_FACTORY (comp_editor_factory_get_type ())
-#define COMP_EDITOR_FACTORY(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), TYPE_COMP_EDITOR_FACTORY, \
- CompEditorFactory))
-#define COMP_EDITOR_FACTORY_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), \
- TYPE_COMP_EDITOR_FACTORY, CompEditorFactoryClass))
-#define IS_COMP_EDITOR_FACTORY(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), TYPE_COMP_EDITOR_FACTORY))
-#define IS_COMP_EDITOR_FACTORY_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), TYPE_COMP_EDITOR_FACTORY))
-
-typedef struct CompEditorFactoryPrivate CompEditorFactoryPrivate;
-
-typedef struct {
- BonoboObject object;
-
- /* Private data */
- CompEditorFactoryPrivate *priv;
-} CompEditorFactory;
-
-typedef struct {
- BonoboObjectClass parent_class;
-
- POA_GNOME_Evolution_Calendar_CompEditorFactory__epv epv;
-} CompEditorFactoryClass;
-
-GType comp_editor_factory_get_type (void);
-
-CompEditorFactory *comp_editor_factory_new (void);
-
-
-
-#endif
diff --git a/calendar/gui/control-factory.c b/calendar/gui/control-factory.c
deleted file mode 100644
index 3e7b7499cc..0000000000
--- a/calendar/gui/control-factory.c
+++ /dev/null
@@ -1,79 +0,0 @@
-/*
- * This program is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 2 of the License, or (at your option) version 3.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with the program; if not, see <http://www.gnu.org/licenses/>
- *
- *
- * Authors:
- * Ettore Perazzoli <ettore@ximian.com>
- *
- * Copyright (C) 1999-2008 Novell, Inc. (www.novell.com)
- *
- */
-
-#include <config.h>
-#include <string.h>
-#include <gtk/gtk.h>
-#include <glade/glade.h>
-#include <bonobo/bonobo-control.h>
-#include <bonobo/bonobo-generic-factory.h>
-#include <bonobo/bonobo-persist-file.h>
-#include <bonobo/bonobo-context.h>
-#include <glade/glade.h>
-
-#include <libecal/e-cal-time-util.h>
-#include <gui/gnome-cal.h>
-#include <gui/calendar-commands.h>
-#include <gui/calendar-config.h>
-
-#include "control-factory.h"
-
-/* Are these supposed to be global or static? */
-CORBA_Environment ev;
-CORBA_ORB orb;
-
-static void
-control_activate_cb (BonoboControl *control, gboolean activate, gpointer data)
-{
- GnomeCalendar *gcal;
-
- gcal = GNOME_CALENDAR (data);
-
- if (activate)
- calendar_control_activate (control, gcal);
- else
- calendar_control_deactivate (control, gcal);
-}
-
-BonoboControl *
-control_factory_new_control (void)
-{
- BonoboControl *control;
- GnomeCalendar *gcal;
-
- gcal = GNOME_CALENDAR (gnome_calendar_new ());
- if (!gcal)
- return NULL;
-
- gtk_widget_show (GTK_WIDGET (gcal));
-
- control = bonobo_control_new (GTK_WIDGET (gcal));
- if (!control) {
- g_message ("control_factory_fn(): could not create the control!");
- return NULL;
- }
- g_object_set_data (G_OBJECT (gcal), "control", control);
-
- g_signal_connect (control, "activate", G_CALLBACK (control_activate_cb), gcal);
-
- return control;
-}
diff --git a/calendar/gui/dialogs/cal-prefs-dialog.c b/calendar/gui/dialogs/cal-prefs-dialog.c
index 2c19acaadd..09f6d104b6 100644
--- a/calendar/gui/dialogs/cal-prefs-dialog.c
+++ b/calendar/gui/dialogs/cal-prefs-dialog.c
@@ -31,6 +31,7 @@
#include "../calendar-config.h"
#include "cal-prefs-dialog.h"
#include <widgets/misc/e-dateedit.h>
+#include <e-util/e-binding.h>
#include <e-util/e-dialog-widgets.h>
#include <e-util/e-util-private.h>
#include <glib/gi18n.h>
@@ -496,7 +497,9 @@ template_url_changed (GtkEntry *entry, CalendarPrefsDialog *prefs)
}
static void
-update_system_tz_widgets (CalendarPrefsDialog *prefs)
+update_system_tz_widgets (EShellSettings *shell_settings,
+ GParamSpec *pspec,
+ CalendarPrefsDialog *prefs)
{
icaltimezone *zone;
@@ -508,15 +511,6 @@ update_system_tz_widgets (CalendarPrefsDialog *prefs)
} else {
gtk_label_set_text (GTK_LABEL (prefs->system_tz_label), "(UTC)");
}
-
- gtk_widget_set_sensitive (prefs->timezone, !gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (prefs->use_system_tz_check)));
-}
-
-static void
-use_system_tz_changed (GtkWidget *check, CalendarPrefsDialog *prefs)
-{
- calendar_config_set_use_system_timezone (gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (check)));
- update_system_tz_widgets (prefs);
}
static void
@@ -527,7 +521,6 @@ setup_changes (CalendarPrefsDialog *prefs)
for (i = 0; i < 7; i ++)
g_signal_connect (G_OBJECT (prefs->working_days[i]), "toggled", G_CALLBACK (working_days_changed), prefs);
- g_signal_connect (G_OBJECT (prefs->use_system_tz_check), "toggled", G_CALLBACK (use_system_tz_changed), prefs);
g_signal_connect (G_OBJECT (prefs->timezone), "changed", G_CALLBACK (timezone_changed), prefs);
g_signal_connect (G_OBJECT (prefs->day_second_zone), "clicked", G_CALLBACK (day_second_zone_clicked), prefs);
@@ -667,11 +660,6 @@ show_config (CalendarPrefsDialog *prefs)
CalUnits units;
gint interval;
- /* Use system timezone */
- gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (prefs->use_system_tz_check), calendar_config_get_use_system_timezone ());
- gtk_widget_set_sensitive (prefs->system_tz_label, FALSE);
- update_system_tz_widgets (prefs);
-
/* Timezone. */
location = calendar_config_get_timezone_stored ();
zone = icaltimezone_get_builtin_timezone (location);
@@ -681,6 +669,9 @@ show_config (CalendarPrefsDialog *prefs)
/* Day's second zone */
update_day_second_zone_caption (prefs);
+ /* Day's second zone */
+ update_day_second_zone_caption (prefs);
+
/* Working Days. */
working_days = calendar_config_get_working_days ();
mask = 1 << 0;
@@ -773,13 +764,16 @@ eccp_free (EConfig *ec, GSList *items, gpointer data)
}
static void
-calendar_prefs_dialog_construct (CalendarPrefsDialog *prefs)
+calendar_prefs_dialog_construct (CalendarPrefsDialog *prefs,
+ EShell *shell)
{
GladeXML *gui;
ECalConfig *ec;
ECalConfigTargetPrefs *target;
+ EShellSettings *shell_settings;
gint i;
GtkWidget *toplevel;
+ GtkWidget *widget;
GSList *l;
const gchar *working_day_names[] = {
"sun_button",
@@ -792,6 +786,8 @@ calendar_prefs_dialog_construct (CalendarPrefsDialog *prefs)
};
gchar *gladefile;
+ shell_settings = e_shell_get_shell_settings (shell);
+
gladefile = g_build_filename (EVOLUTION_GLADEDIR,
"cal-prefs-dialog.glade",
NULL);
@@ -815,8 +811,20 @@ calendar_prefs_dialog_construct (CalendarPrefsDialog *prefs)
l = g_slist_prepend (l, &eccp_items[i]);
e_config_add_items ((EConfig *) ec, l, NULL, NULL, eccp_free, prefs);
+ widget = glade_xml_get_widget (gui, "use-system-tz-check");
+ e_mutual_binding_new (
+ G_OBJECT (shell_settings), "cal-use-system-timezone",
+ G_OBJECT (widget), "active");
+ g_signal_connect (
+ G_OBJECT (shell_settings), "notify::cal-use-system-timezone",
+ G_CALLBACK (update_system_tz_widgets), prefs);
+
+ widget = glade_xml_get_widget (gui, "timezone");
+ e_mutual_binding_new_with_negation (
+ G_OBJECT (shell_settings), "cal-use-system-timezone",
+ G_OBJECT (widget), "sensitive");
+
/* General tab */
- prefs->use_system_tz_check = glade_xml_get_widget (gui, "use-system-tz-check");
prefs->system_tz_label = glade_xml_get_widget (gui, "system-tz-label");
prefs->timezone = glade_xml_get_widget (gui, "timezone");
prefs->day_second_zone = glade_xml_get_widget (gui, "day_second_zone");
@@ -887,14 +895,18 @@ calendar_prefs_dialog_get_type (void)
}
GtkWidget *
-calendar_prefs_dialog_new (void)
+calendar_prefs_dialog_new (EShell *shell)
{
CalendarPrefsDialog *dialog;
- dialog = (CalendarPrefsDialog *) g_object_new (calendar_prefs_dialog_get_type (), NULL);
- calendar_prefs_dialog_construct (dialog);
+ g_return_val_if_fail (E_IS_SHELL (shell), NULL);
+
+ dialog = g_object_new (CALENDAR_TYPE_PREFS_DIALOG, NULL);
+
+ /* FIXME Kill this function. */
+ calendar_prefs_dialog_construct (dialog, shell);
- return (GtkWidget *) dialog;
+ return GTK_WIDGET (dialog);
}
/* called by libglade to create our custom EDateEdit widgets. */
diff --git a/calendar/gui/dialogs/cal-prefs-dialog.h b/calendar/gui/dialogs/cal-prefs-dialog.h
index 611d4aabcc..0889a395bf 100644
--- a/calendar/gui/dialogs/cal-prefs-dialog.h
+++ b/calendar/gui/dialogs/cal-prefs-dialog.h
@@ -21,14 +21,33 @@
*
*/
-#ifndef _CAL_PREFS_DIALOG_H_
-#define _CAL_PREFS_DIALOG_H_
+#ifndef CAL_PREFS_DIALOG_H
+#define CAL_PREFS_DIALOG_H
#include <gtk/gtk.h>
#include <glade/glade.h>
#include <gconf/gconf-client.h>
#include <libedataserverui/e-source-selector.h>
-#include "evolution-config-control.h"
+#include <shell/e-shell.h>
+
+/* Standard GObject macros */
+#define CALENDAR_TYPE_PREFS_DIALOG \
+ (calendar_prefs_dialog_get_type ())
+#define CALENDAR_PREFS_DIALOG(obj) \
+ (G_TYPE_CHECK_INSTANCE_CAST \
+ ((obj), CALENDAR_TYPE_PREFS_DIALOG, CalendarPrefsDialog))
+#define CALENDAR_PREFS_DIALOG_CLASS(cls) \
+ (G_TYPE_CHECK_CLASS_CAST \
+ ((cls), CALENDAR_TYPE_PREFS_DIALOG, CalendarPrefsDialogClass))
+#define CALENDAR_IS_PREFS_DIALOG(obj) \
+ (G_TYPE_CHECK_INSTANCE_TYPE \
+ ((obj), CALENDAR_TYPE_PREFS_DIALOG))
+#define CALENDAR_IS_PREFS_DIALOG_CLASS(cls) \
+ (G_TYPE_CHECK_CLASS_TYPE \
+ ((cls), CALENDAR_TYPE_PREFS_DIALOG))
+#define CALENDAR_PREFS_DIALOG_GET_CLASS(obj) \
+ (G_TYPE_INSTANCE_GET_CLASS \
+ ((obj), CALENDAR_TYPE_PREFS_DIALOG, CalendarPrefsDialogClass))
G_BEGIN_DECLS
@@ -43,7 +62,6 @@ struct _CalendarPrefsDialog {
GConfClient *gconf;
/* General tab */
- GtkWidget *use_system_tz_check;
GtkWidget *system_tz_label;
GtkWidget *timezone;
GtkWidget *day_second_zone;
@@ -96,9 +114,9 @@ struct _CalendarPrefsDialogClass {
GtkVBoxClass parent;
};
-GType calendar_prefs_dialog_get_type (void);
-GtkWidget *calendar_prefs_dialog_new (void);
+GType calendar_prefs_dialog_get_type (void);
+GtkWidget * calendar_prefs_dialog_new (EShell *shell);
G_END_DECLS
-#endif /* _CAL_PREFS_DIALOG_H_ */
+#endif /* CAL_PREFS_DIALOG_H */
diff --git a/calendar/gui/dialogs/comp-editor.c b/calendar/gui/dialogs/comp-editor.c
index 28d33d60b0..7aa242f18e 100644
--- a/calendar/gui/dialogs/comp-editor.c
+++ b/calendar/gui/dialogs/comp-editor.c
@@ -39,7 +39,7 @@
#include <e-util/e-dialog-utils.h>
#include <e-util/e-util-private.h>
#include <e-util/gconf-bridge.h>
-#include <evolution-shell-component-utils.h>
+#include <shell/e-shell.h>
#include <camel/camel-url.h>
#include <camel/camel-exception.h>
@@ -76,6 +76,9 @@
/* Private part of the CompEditor structure */
struct _CompEditorPrivate {
+
+ gpointer shell; /* weak pointer */
+
/* Client to use */
ECal *client;
@@ -125,6 +128,7 @@ enum {
PROP_CHANGED,
PROP_CLIENT,
PROP_FLAGS,
+ PROP_SHELL,
PROP_SUMMARY
};
@@ -133,7 +137,10 @@ static const gchar *ui =
" <menubar action='main-menu'>"
" <menu action='file-menu'>"
" <menuitem action='save'/>"
+" <separator/>"
+" <menuitem action='print-preview'/>"
" <menuitem action='print'/>"
+" <separator/>"
" <menuitem action='close'/>"
" </menu>"
" <menu action='edit-menu'>"
@@ -170,8 +177,8 @@ static void close_dialog (CompEditor *editor);
static void page_dates_changed_cb (CompEditor *editor, CompEditorPageDates *dates, CompEditorPage *page);
-static void obj_modified_cb (ECal *client, GList *objs, gpointer data);
-static void obj_removed_cb (ECal *client, GList *uids, gpointer data);
+static void obj_modified_cb (ECal *client, GList *objs, CompEditor *editor);
+static void obj_removed_cb (ECal *client, GList *uids, CompEditor *editor);
G_DEFINE_TYPE (CompEditor, comp_editor, GTK_TYPE_WINDOW)
@@ -180,7 +187,15 @@ enum {
LAST_SIGNAL
};
-static guint comp_editor_signals[LAST_SIGNAL] = { 0 };
+static guint signals[LAST_SIGNAL];
+static GList *active_editors;
+
+static void
+comp_editor_weak_notify_cb (gpointer unused,
+ GObject *where_the_object_was)
+{
+ active_editors = g_list_remove (active_editors, where_the_object_was);
+}
static void
attachment_store_changed_cb (CompEditor *editor)
@@ -706,17 +721,22 @@ action_print_cb (GtkAction *action,
CompEditor *editor)
{
CompEditorPrivate *priv = editor->priv;
+ GtkPrintOperationAction print_action;
ECalComponent *comp;
GList *l;
- icalcomponent *icalcomp = e_cal_component_get_icalcomponent (priv->comp);
+ icalcomponent *component;
+ icalcomponent *clone;
comp = e_cal_component_new ();
- e_cal_component_set_icalcomponent (comp, icalcomponent_new_clone (icalcomp));
+ component = e_cal_component_get_icalcomponent (priv->comp);
+ clone = icalcomponent_new_clone (component);
+ e_cal_component_set_icalcomponent (comp, clone);
for (l = priv->pages; l != NULL; l = l->next)
comp_editor_page_fill_component (l->data, comp);
- print_comp (comp, priv->client, GTK_PRINT_OPERATION_ACTION_PRINT_DIALOG);
+ print_action = GTK_PRINT_OPERATION_ACTION_PRINT_DIALOG;
+ print_comp (comp, priv->client, print_action);
g_object_unref (comp);
}
@@ -726,15 +746,22 @@ action_print_preview_cb (GtkAction *action,
CompEditor *editor)
{
CompEditorPrivate *priv = editor->priv;
+ GtkPrintOperationAction print_action;
ECalComponent *comp;
GList *l;
- icalcomponent *icalcomp = e_cal_component_get_icalcomponent (priv->comp);
+ icalcomponent *component;
+ icalcomponent *clone;
comp = e_cal_component_new ();
- e_cal_component_set_icalcomponent (comp, icalcomponent_new_clone (icalcomp));
+ component = e_cal_component_get_icalcomponent (priv->comp);
+ clone = icalcomponent_new_clone (component);
+ e_cal_component_set_icalcomponent (comp, clone);
+
for (l = priv->pages; l != NULL; l = l->next)
comp_editor_page_fill_component (l->data, comp);
- print_comp (comp, priv->client, TRUE);
+
+ print_action = GTK_PRINT_OPERATION_ACTION_PREVIEW;
+ print_comp (comp, priv->client, print_action);
g_object_unref (comp);
}
@@ -802,12 +829,10 @@ action_save_cb (GtkAction *action,
if (e_cal_component_has_recurrences (priv->comp)) {
if (!recur_component_dialog (priv->client, priv->comp, &priv->mod, GTK_WINDOW (editor), delegated))
return;
-
} else if (e_cal_component_is_instance (priv->comp))
priv->mod = CALOBJ_MOD_THIS;
comp = comp_editor_get_current_comp (editor, &correct);
-
e_cal_component_get_summary (comp, &text);
g_object_unref (comp);
@@ -1189,6 +1214,17 @@ comp_editor_setup_recent_menu (CompEditor *editor)
}
static void
+comp_editor_set_shell (CompEditor *editor,
+ EShell *shell)
+{
+ g_return_if_fail (editor->priv->shell == NULL);
+
+ editor->priv->shell = shell;
+
+ g_object_add_weak_pointer (G_OBJECT (shell), &editor->priv->shell);
+}
+
+static void
comp_editor_set_property (GObject *object,
guint property_id,
const GValue *value,
@@ -1213,6 +1249,12 @@ comp_editor_set_property (GObject *object,
g_value_get_int (value));
return;
+ case PROP_SHELL:
+ comp_editor_set_shell (
+ COMP_EDITOR (object),
+ g_value_get_object (value));
+ return;
+
case PROP_SUMMARY:
comp_editor_set_summary (
COMP_EDITOR (object),
@@ -1248,6 +1290,12 @@ comp_editor_get_property (GObject *object,
COMP_EDITOR (object)));
return;
+ case PROP_SHELL:
+ g_value_set_object (
+ value, comp_editor_get_shell (
+ COMP_EDITOR (object)));
+ return;
+
case PROP_SUMMARY:
g_value_set_string (
value, comp_editor_get_summary (
@@ -1265,6 +1313,12 @@ comp_editor_dispose (GObject *object)
priv = COMP_EDITOR_GET_PRIVATE (object);
+ if (priv->shell != NULL) {
+ g_object_remove_weak_pointer (
+ G_OBJECT (priv->shell), &priv->shell);
+ priv->shell = NULL;
+ }
+
if (priv->client) {
g_object_unref (priv->client);
priv->client = NULL;
@@ -1323,42 +1377,39 @@ static void
comp_editor_map (GtkWidget *widget)
{
CompEditor *editor = COMP_EDITOR (widget);
- GConfBridge *bridge = gconf_bridge_get ();
+ GConfBridge *bridge;
GtkAction *action;
+ const gchar *key;
+
+ bridge = gconf_bridge_get ();
/* Give subclasses a chance to construct their pages before
* we fiddle with their widgets. That's why we don't do this
* until after object construction. */
+ key = "/apps/evolution/calendar/display/show_categories";
action = comp_editor_get_action (editor, "view-categories");
- gconf_bridge_bind_property (
- bridge, CALENDAR_CONFIG_SHOW_CATEGORIES,
- G_OBJECT (action), "active");
+ gconf_bridge_bind_property (bridge, key, G_OBJECT (action), "active");
+ key = "/apps/evolution/calendar/display/show_role";
action = comp_editor_get_action (editor, "view-role");
- gconf_bridge_bind_property (
- bridge, CALENDAR_CONFIG_SHOW_ROLE,
- G_OBJECT (action), "active");
+ gconf_bridge_bind_property (bridge, key, G_OBJECT (action), "active");
+ key = "/apps/evolution/calendar/display/show_rsvp";
action = comp_editor_get_action (editor, "view-rsvp");
- gconf_bridge_bind_property (
- bridge, CALENDAR_CONFIG_SHOW_RSVP,
- G_OBJECT (action), "active");
+ gconf_bridge_bind_property (bridge, key, G_OBJECT (action), "active");
+ key = "/apps/evolution/calendar/display/show_status";
action = comp_editor_get_action (editor, "view-status");
- gconf_bridge_bind_property (
- bridge, CALENDAR_CONFIG_SHOW_STATUS,
- G_OBJECT (action), "active");
+ gconf_bridge_bind_property (bridge, key, G_OBJECT (action), "active");
+ key = "/apps/evolution/calendar/display/show_timezone";
action = comp_editor_get_action (editor, "view-time-zone");
- gconf_bridge_bind_property (
- bridge, CALENDAR_CONFIG_SHOW_TIMEZONE,
- G_OBJECT (action), "active");
+ gconf_bridge_bind_property (bridge, key, G_OBJECT (action), "active");
+ key = "/apps/evolution/calendar/display/show_type";
action = comp_editor_get_action (editor, "view-type");
- gconf_bridge_bind_property (
- bridge, CALENDAR_CONFIG_SHOW_TYPE,
- G_OBJECT (action), "active");
+ gconf_bridge_bind_property (bridge, key, G_OBJECT (action), "active");
/* Chain up to parent's map() method. */
GTK_WIDGET_CLASS (comp_editor_parent_class)->map (widget);
@@ -1505,6 +1556,17 @@ comp_editor_class_init (CompEditorClass *class)
g_object_class_install_property (
object_class,
+ PROP_SHELL,
+ g_param_spec_object (
+ "shell",
+ NULL,
+ NULL,
+ E_TYPE_SHELL,
+ G_PARAM_READWRITE |
+ G_PARAM_CONSTRUCT_ONLY));
+
+ g_object_class_install_property (
+ object_class,
PROP_SUMMARY,
g_param_spec_string (
"summary",
@@ -1513,7 +1575,7 @@ comp_editor_class_init (CompEditorClass *class)
NULL,
G_PARAM_READWRITE));
- comp_editor_signals[OBJECT_CREATED] =
+ signals[OBJECT_CREATED] =
g_signal_new ("object_created",
G_TYPE_FROM_CLASS (class),
G_SIGNAL_RUN_LAST,
@@ -1536,11 +1598,18 @@ comp_editor_init (CompEditor *editor)
GtkAction *action;
GtkWidget *container;
GtkWidget *widget;
+ EShell *shell;
gint n_targets;
GError *error = NULL;
editor->priv = priv = COMP_EDITOR_GET_PRIVATE (editor);
+ g_object_weak_ref (
+ G_OBJECT (editor), (GWeakNotify)
+ comp_editor_weak_notify_cb, NULL);
+
+ active_editors = g_list_prepend (active_editors, editor);
+
priv->pages = NULL;
priv->changed = FALSE;
priv->needs_send = FALSE;
@@ -1674,6 +1743,10 @@ comp_editor_init (CompEditor *editor)
g_signal_connect_swapped (
store, "row-inserted",
G_CALLBACK (attachment_store_changed_cb), editor);
+
+ /* FIXME Shell should be passed in. */
+ shell = e_shell_get_default ();
+ e_shell_watch_window (shell, GTK_WINDOW (editor));
}
static gboolean
@@ -1755,7 +1828,18 @@ close_dialog (CompEditor *editor)
gtk_widget_destroy (GTK_WIDGET (editor));
}
-
+gint
+comp_editor_compare (CompEditor *editor_a,
+ CompEditor *editor_b)
+{
+ const gchar *uid_a = NULL;
+ const gchar *uid_b = NULL;
+
+ e_cal_component_get_uid (editor_a->priv->comp, &uid_a);
+ e_cal_component_get_uid (editor_b->priv->comp, &uid_b);
+
+ return g_strcmp0 (uid_a, uid_b);
+}
void
comp_editor_set_existing_org (CompEditor *editor, gboolean existing_org)
@@ -1841,6 +1925,14 @@ comp_editor_get_classification (CompEditor *editor)
return gtk_radio_action_get_current_value (GTK_RADIO_ACTION (action));
}
+EShell *
+comp_editor_get_shell (CompEditor *editor)
+{
+ g_return_val_if_fail (IS_COMP_EDITOR (editor), NULL);
+
+ return editor->priv->shell;
+}
+
void
comp_editor_set_summary (CompEditor *editor,
const gchar *summary)
@@ -1950,7 +2042,7 @@ comp_editor_set_flags (CompEditor *editor,
CompEditorFlags
comp_editor_get_flags (CompEditor *editor)
{
- g_return_val_if_fail (IS_COMP_EDITOR (editor), FALSE);
+ g_return_val_if_fail (IS_COMP_EDITOR (editor), 0);
return editor->priv->flags;
}
@@ -2008,6 +2100,20 @@ comp_editor_get_managed_widget (CompEditor *editor,
return widget;
}
+CompEditor *
+comp_editor_find_instance (const gchar *uid)
+{
+ GList *link;
+
+ g_return_val_if_fail (uid != NULL, NULL);
+
+ link = g_list_find_custom (
+ active_editors, uid,
+ (GCompareFunc) comp_editor_compare);
+
+ return (link != NULL) ? link->data : NULL;
+}
+
/**
* comp_editor_set_needs_send:
* @editor: A component editor
@@ -2331,8 +2437,14 @@ fill_widgets (CompEditor *editor)
EAttachmentStore *store;
EAttachmentView *view;
CompEditorPrivate *priv;
- GList *l;
GtkAction *action;
+ GList *iter;
+
+ view = E_ATTACHMENT_VIEW (editor->priv->attachment_view);
+ store = e_attachment_view_get_store (view);
+
+ view = E_ATTACHMENT_VIEW (editor->priv->attachment_view);
+ store = e_attachment_view_get_store (view);
view = E_ATTACHMENT_VIEW (editor->priv->attachment_view);
store = e_attachment_view_get_store (view);
@@ -2355,12 +2467,14 @@ fill_widgets (CompEditor *editor)
}
action = comp_editor_get_action (editor, "classify-public");
- g_signal_handlers_block_by_func (action, G_CALLBACK (action_classification_cb), editor);
+ g_signal_handlers_block_by_func (
+ action, G_CALLBACK (action_classification_cb), editor);
- for (l = priv->pages; l != NULL; l = l->next)
- comp_editor_page_fill_widgets (l->data, priv->comp);
+ for (iter = priv->pages; iter != NULL; iter = iter->next)
+ comp_editor_page_fill_widgets (iter->data, priv->comp);
- g_signal_handlers_unblock_by_func (action, G_CALLBACK (action_classification_cb), editor);
+ g_signal_handlers_unblock_by_func (
+ action, G_CALLBACK (action_classification_cb), editor);
}
static void
@@ -2763,9 +2877,10 @@ page_dates_changed_cb (CompEditor *editor,
}
static void
-obj_modified_cb (ECal *client, GList *objects, gpointer data)
+obj_modified_cb (ECal *client,
+ GList *objects,
+ CompEditor *editor)
{
- CompEditor *editor = COMP_EDITOR (data);
CompEditorPrivate *priv;
ECalComponent *comp = NULL;
@@ -2798,12 +2913,11 @@ obj_modified_cb (ECal *client, GList *objects, gpointer data)
}
static void
-obj_removed_cb (ECal *client, GList *uids, gpointer data)
+obj_removed_cb (ECal *client,
+ GList *uids,
+ CompEditor *editor)
{
- CompEditor *editor = COMP_EDITOR (data);
- CompEditorPrivate *priv;
-
- priv = editor->priv;
+ CompEditorPrivate *priv = editor->priv;
if (changed_component_dialog ((GtkWindow *) editor, priv->comp, TRUE, priv->changed))
close_dialog (editor);
diff --git a/calendar/gui/dialogs/comp-editor.h b/calendar/gui/dialogs/comp-editor.h
index 2106970386..6753635b1a 100644
--- a/calendar/gui/dialogs/comp-editor.h
+++ b/calendar/gui/dialogs/comp-editor.h
@@ -29,6 +29,7 @@
#include <libecal/e-cal.h>
#include "../itip-utils.h"
#include "comp-editor-page.h"
+#include <shell/e-shell.h>
/* Standard GObject macros */
#define TYPE_COMP_EDITOR \
@@ -87,6 +88,8 @@ typedef enum {
} CompEditorFlags;
GType comp_editor_get_type (void);
+gint comp_editor_compare (CompEditor *editor_a,
+ CompEditor *editor_b);
void comp_editor_set_changed (CompEditor *editor,
gboolean changed);
gboolean comp_editor_get_changed (CompEditor *editor);
@@ -106,6 +109,7 @@ void comp_editor_set_classification (CompEditor *editor,
ECalComponentClassification classification);
ECalComponentClassification
comp_editor_get_classification (CompEditor *editor);
+EShell * comp_editor_get_shell (CompEditor *editor);
void comp_editor_set_summary (CompEditor *editor,
const gchar *summary);
const gchar * comp_editor_get_summary (CompEditor *editor);
@@ -149,6 +153,7 @@ GtkActionGroup *
const gchar *group_name);
GtkWidget * comp_editor_get_managed_widget (CompEditor *editor,
const gchar *widget_path);
+CompEditor * comp_editor_find_instance (const gchar *uid);
G_END_DECLS
diff --git a/calendar/gui/dialogs/event-editor.c b/calendar/gui/dialogs/event-editor.c
index 4643f8f697..e7d602c335 100644
--- a/calendar/gui/dialogs/event-editor.c
+++ b/calendar/gui/dialogs/event-editor.c
@@ -36,7 +36,6 @@
#include <misc/e-dateedit.h>
#include <e-util/e-plugin-ui.h>
#include <e-util/e-util-private.h>
-#include <evolution-shell-component-utils.h>
#include "event-page.h"
#include "recurrence-page.h"
@@ -466,6 +465,7 @@ event_editor_init (EventEditor *ee)
GtkUIManager *ui_manager;
GtkActionGroup *action_group;
GtkAction *action;
+ const gchar *id;
GError *error = NULL;
ee->priv = EVENT_EDITOR_GET_PRIVATE (ee);
@@ -488,7 +488,10 @@ event_editor_init (EventEditor *ee)
ui_manager = comp_editor_get_ui_manager (editor);
gtk_ui_manager_add_ui_from_string (ui_manager, ui, -1, &error);
- e_plugin_ui_register_manager ("event-editor", ui_manager, ee);
+
+ id = "org.gnome.evolution.event-editor";
+ e_plugin_ui_register_manager (ui_manager, id, ee);
+ e_plugin_ui_enable_manager (ui_manager, id);
if (error != NULL) {
g_critical ("%s: %s", G_STRFUNC, error->message);
@@ -662,13 +665,16 @@ event_editor_send_comp (CompEditor *editor, ECalComponentItipMethod method, gboo
* editor could not be created.
**/
CompEditor *
-event_editor_new (ECal *client, CompEditorFlags flags)
+event_editor_new (ECal *client,
+ EShell *shell,
+ CompEditorFlags flags)
{
g_return_val_if_fail (E_IS_CAL (client), NULL);
+ g_return_val_if_fail (E_IS_SHELL (shell), NULL);
return g_object_new (
TYPE_EVENT_EDITOR,
- "flags", flags, "client", client, NULL);
+ "client", client, "flags", flags, "shell", shell, NULL);
}
void
diff --git a/calendar/gui/dialogs/event-editor.h b/calendar/gui/dialogs/event-editor.h
index 03afd6448a..abb8f0e659 100644
--- a/calendar/gui/dialogs/event-editor.h
+++ b/calendar/gui/dialogs/event-editor.h
@@ -66,6 +66,7 @@ struct _EventEditorClass {
GType event_editor_get_type (void);
CompEditor * event_editor_new (ECal *client,
+ EShell *shell,
CompEditorFlags flags);
void event_editor_show_meeting (EventEditor *ee);
diff --git a/calendar/gui/dialogs/event-page.c b/calendar/gui/dialogs/event-page.c
index 7e95d72ce1..ed31badd11 100644
--- a/calendar/gui/dialogs/event-page.c
+++ b/calendar/gui/dialogs/event-page.c
@@ -381,9 +381,11 @@ update_time (EventPage *epage, ECalComponentDateTime *start_date, ECalComponentD
EventPagePrivate *priv = epage->priv;
CompEditor *editor;
ECal *client;
+ GtkAction *action;
struct icaltimetype *start_tt, *end_tt, implied_tt;
icaltimezone *start_zone = NULL, *def_zone = NULL;
gboolean all_day_event, homezone=TRUE;
+ gboolean show_timezone;
editor = comp_editor_page_get_editor (COMP_EDITOR_PAGE (epage));
client = comp_editor_get_client (editor);
@@ -455,7 +457,9 @@ update_time (EventPage *epage, ECalComponentDateTime *start_date, ECalComponentD
if (!def_zone || !start_zone || strcmp (icaltimezone_get_tzid(def_zone), icaltimezone_get_tzid (start_zone)))
homezone = FALSE;
- event_page_set_show_timezone (epage, (calendar_config_get_show_timezone()|| !homezone) & !all_day_event);
+ action = comp_editor_get_action (editor, "view-time-zone");
+ show_timezone = gtk_toggle_action_get_active (GTK_TOGGLE_ACTION (action));
+ event_page_set_show_timezone (epage, (show_timezone || !homezone) & !all_day_event);
/*unblock the endtimezone widget*/
g_signal_handlers_unblock_matched (priv->end_timezone, G_SIGNAL_MATCH_DATA, 0, 0, NULL, NULL, epage);
@@ -1813,15 +1817,10 @@ remove_clicked_cb (GtkButton *btn, EventPage *epage)
}
static void
-invite_cb (GtkWidget *widget, gpointer data)
+invite_cb (GtkWidget *widget,
+ EventPage *page)
{
- EventPage *page;
- EventPagePrivate *priv;
-
- page = EVENT_PAGE (data);
- priv = page->priv;
-
- e_meeting_list_view_invite_others_dialog (priv->list_view);
+ e_meeting_list_view_invite_others_dialog (page->priv->list_view);
}
static void
@@ -2010,6 +2009,7 @@ event_page_set_all_day_event (EventPage *epage, gboolean all_day)
CompEditor *editor;
GtkAction *action;
gboolean date_set;
+ gboolean active;
editor = comp_editor_page_get_editor (COMP_EDITOR_PAGE (epage));
@@ -2088,7 +2088,10 @@ event_page_set_all_day_event (EventPage *epage, gboolean all_day)
TRUE);
}
- event_page_set_show_timezone (epage, calendar_config_get_show_timezone() & !all_day);
+ action = comp_editor_get_action (editor, "view-time-zone");
+ active = gtk_toggle_action_get_active (GTK_TOGGLE_ACTION (action));
+ event_page_set_show_timezone (epage, active & !all_day);
+
g_signal_handlers_block_matched (priv->start_time, G_SIGNAL_MATCH_DATA, 0, 0, NULL, NULL, epage);
g_signal_handlers_block_matched (priv->end_time, G_SIGNAL_MATCH_DATA, 0, 0, NULL, NULL, epage);
@@ -2170,10 +2173,12 @@ event_page_set_info_string (EventPage *epage, const gchar *icon, const gchar *ms
static gboolean
get_widgets (EventPage *epage)
{
+ CompEditor *editor;
CompEditorPage *page = COMP_EDITOR_PAGE (epage);
GtkEntryCompletion *completion;
EventPagePrivate *priv;
GSList *accel_groups;
+ GtkAction *action;
GtkWidget *toplevel;
GtkWidget *sw;
@@ -2181,6 +2186,8 @@ get_widgets (EventPage *epage)
#define GW(name) glade_xml_get_widget (priv->xml, name)
+ editor = comp_editor_page_get_editor (page);
+
priv->main = GW ("event-page");
if (!priv->main)
return FALSE;
@@ -2202,7 +2209,8 @@ get_widgets (EventPage *epage)
gtk_widget_show (priv->status_icons);
- if (!calendar_config_get_show_timezone()) {
+ action = comp_editor_get_action (editor, "view-time-zone");
+ if (!gtk_toggle_action_get_active (GTK_TOGGLE_ACTION (action))) {
gtk_widget_hide (priv->timezone_label);
gtk_widget_hide (priv->start_timezone);
} else {
@@ -2475,14 +2483,10 @@ times_updated (EventPage *epage, gboolean adjust_end_time)
* start date < end date and we set the "all day event" button as appropriate.
*/
static void
-start_date_changed_cb (GtkWidget *dedit, gpointer data)
+start_date_changed_cb (GtkWidget *dedit,
+ EventPage *epage)
{
- EventPage *epage;
-
- epage = EVENT_PAGE (data);
-
hour_minute_changed (epage);
-
times_updated (epage, TRUE);
}
@@ -2490,12 +2494,9 @@ start_date_changed_cb (GtkWidget *dedit, gpointer data)
* start date < end date and we set the "all day event" button as appropriate.
*/
static void
-end_date_changed_cb (GtkWidget *dedit, gpointer data)
+end_date_changed_cb (GtkWidget *dedit,
+ EventPage *epage)
{
- EventPage *epage;
-
- epage = EVENT_PAGE (data);
-
times_updated (epage, FALSE);
}
@@ -2504,15 +2505,12 @@ end_date_changed_cb (GtkWidget *dedit, gpointer data)
* labels on the other notebook pages.
*/
static void
-start_timezone_changed_cb (GtkWidget *widget, gpointer data)
+start_timezone_changed_cb (GtkWidget *widget,
+ EventPage *epage)
{
- EventPage *epage;
- EventPagePrivate *priv;
+ EventPagePrivate *priv = epage->priv;
icaltimezone *zone;
- epage = EVENT_PAGE (data);
- priv = epage->priv;
-
if (priv->sync_timezones) {
zone = e_timezone_entry_get_timezone (E_TIMEZONE_ENTRY (priv->start_timezone));
comp_editor_page_set_updating (COMP_EDITOR_PAGE (epage), TRUE);
@@ -2529,17 +2527,13 @@ start_timezone_changed_cb (GtkWidget *widget, gpointer data)
* category list dialog.
*/
static void
-categories_clicked_cb (GtkWidget *button, gpointer data)
+categories_clicked_cb (GtkWidget *button,
+ EventPage *epage)
{
- EventPage *epage;
- EventPagePrivate *priv;
- GtkWidget *entry;
+ GtkEntry *entry;
- epage = EVENT_PAGE (data);
- priv = epage->priv;
-
- entry = priv->categories;
- e_categories_config_open_dialog_for_entry (GTK_ENTRY (entry));
+ entry = GTK_ENTRY (epage->priv->categories);
+ e_categories_config_open_dialog_for_entry (entry);
}
void
@@ -2658,13 +2652,10 @@ set_subscriber_info_string (EventPage *epage, const gchar *backend_address)
}
static void
-alarm_changed_cb (GtkWidget *widget, gpointer data)
+alarm_changed_cb (GtkWidget *widget,
+ EventPage *epage)
{
- EventPage *epage;
- EventPagePrivate *priv;
-
- epage = EVENT_PAGE (data);
- priv = epage->priv;
+ EventPagePrivate *priv = epage->priv;
if (e_dialog_combo_box_get (priv->alarm_time_combo, priv->alarm_map) != ALARM_NONE) {
ECalComponentAlarm *ca;
@@ -2806,7 +2797,9 @@ init_widgets (EventPage *epage)
GtkTextBuffer *text_buffer;
icaltimezone *zone;
gchar *combo_label = NULL;
+ GtkAction *action;
GtkTreeSelection *selection;
+ gboolean active;
ECal *client;
editor = comp_editor_page_get_editor (COMP_EDITOR_PAGE (epage));
@@ -2862,11 +2855,28 @@ init_widgets (EventPage *epage)
g_signal_connect((priv->start_timezone), "changed",
G_CALLBACK (start_timezone_changed_cb), epage);
- e_meeting_list_view_column_set_visible (priv->list_view, E_MEETING_STORE_ATTENDEE_COL, TRUE);
- e_meeting_list_view_column_set_visible (priv->list_view, E_MEETING_STORE_ROLE_COL, calendar_config_get_show_role ());
- e_meeting_list_view_column_set_visible (priv->list_view, E_MEETING_STORE_RSVP_COL, calendar_config_get_show_rsvp ());
- e_meeting_list_view_column_set_visible (priv->list_view, E_MEETING_STORE_STATUS_COL, calendar_config_get_show_status ());
- e_meeting_list_view_column_set_visible (priv->list_view, E_MEETING_STORE_TYPE_COL, calendar_config_get_show_type ());
+ e_meeting_list_view_column_set_visible (
+ priv->list_view, E_MEETING_STORE_ATTENDEE_COL, TRUE);
+
+ action = comp_editor_get_action (editor, "view-role");
+ active = gtk_toggle_action_get_active (GTK_TOGGLE_ACTION (action));
+ e_meeting_list_view_column_set_visible (
+ priv->list_view, E_MEETING_STORE_ROLE_COL, active);
+
+ action = comp_editor_get_action (editor, "view-rsvp");
+ active = gtk_toggle_action_get_active (GTK_TOGGLE_ACTION (action));
+ e_meeting_list_view_column_set_visible (
+ priv->list_view, E_MEETING_STORE_RSVP_COL, active);
+
+ action = comp_editor_get_action (editor, "view-status");
+ active = gtk_toggle_action_get_active (GTK_TOGGLE_ACTION (action));
+ e_meeting_list_view_column_set_visible (
+ priv->list_view, E_MEETING_STORE_STATUS_COL, active);
+
+ action = comp_editor_get_action (editor, "view-type");
+ active = gtk_toggle_action_get_active (GTK_TOGGLE_ACTION (action));
+ e_meeting_list_view_column_set_visible (
+ priv->list_view, E_MEETING_STORE_TYPE_COL, active);
selection = gtk_tree_view_get_selection (GTK_TREE_VIEW (priv->list_view));
gtk_tree_selection_set_mode (selection, GTK_SELECTION_MULTIPLE);
@@ -2902,7 +2912,8 @@ init_widgets (EventPage *epage)
gtk_widget_show (GTK_WIDGET (priv->list_view));
/* categories */
- if (!calendar_config_get_show_categories()) {
+ action = comp_editor_get_action (editor, "view-categories");
+ if (!gtk_toggle_action_get_active (GTK_TOGGLE_ACTION (action))) {
gtk_widget_hide (priv->categories_btn);
gtk_widget_hide (priv->categories);
} else {
@@ -2996,7 +3007,9 @@ init_widgets (EventPage *epage)
e_timezone_entry_set_default_timezone (E_TIMEZONE_ENTRY (priv->start_timezone), zone);
e_timezone_entry_set_default_timezone (E_TIMEZONE_ENTRY (priv->end_timezone), zone);
- event_page_set_show_timezone (epage, calendar_config_get_show_timezone());
+ action = comp_editor_get_action (editor, "view-time-zone");
+ active = gtk_toggle_action_get_active (GTK_TOGGLE_ACTION (action));
+ event_page_set_show_timezone (epage, active);
return TRUE;
}
diff --git a/calendar/gui/dialogs/memo-editor.c b/calendar/gui/dialogs/memo-editor.c
index cf3781a3c2..bda54e55eb 100644
--- a/calendar/gui/dialogs/memo-editor.c
+++ b/calendar/gui/dialogs/memo-editor.c
@@ -34,7 +34,6 @@
#include <e-util/e-plugin-ui.h>
#include <e-util/e-util-private.h>
-#include <evolution-shell-component-utils.h>
#include "memo-page.h"
#include "cancel-comp.h"
@@ -135,6 +134,7 @@ memo_editor_init (MemoEditor *me)
{
CompEditor *editor = COMP_EDITOR (me);
GtkUIManager *ui_manager;
+ const gchar *id;
GError *error = NULL;
me->priv = MEMO_EDITOR_GET_PRIVATE (me);
@@ -142,7 +142,10 @@ memo_editor_init (MemoEditor *me)
ui_manager = comp_editor_get_ui_manager (editor);
gtk_ui_manager_add_ui_from_string (ui_manager, ui, -1, &error);
- e_plugin_ui_register_manager ("memo-editor", ui_manager, me);
+
+ id = "org.gnome.evolution.memo-editor";
+ e_plugin_ui_register_manager (ui_manager, id, me);
+ e_plugin_ui_enable_manager (ui_manager, id);
if (error != NULL) {
g_critical ("%s: %s", G_STRFUNC, error->message);
@@ -160,11 +163,14 @@ memo_editor_init (MemoEditor *me)
* editor could not be created.
**/
CompEditor *
-memo_editor_new (ECal *client, CompEditorFlags flags)
+memo_editor_new (ECal *client,
+ EShell *shell,
+ CompEditorFlags flags)
{
g_return_val_if_fail (E_IS_CAL (client), NULL);
+ g_return_val_if_fail (E_IS_SHELL (shell), NULL);
return g_object_new (
TYPE_MEMO_EDITOR,
- "flags", flags, "client", client, NULL);
+ "client", client, "flags", flags, "shell", shell, NULL);
}
diff --git a/calendar/gui/dialogs/memo-editor.h b/calendar/gui/dialogs/memo-editor.h
index 2e431b507f..cd4bc194ac 100644
--- a/calendar/gui/dialogs/memo-editor.h
+++ b/calendar/gui/dialogs/memo-editor.h
@@ -68,6 +68,7 @@ struct _MemoEditorClass {
GType memo_editor_get_type (void);
CompEditor * memo_editor_new (ECal *client,
+ EShell *shell,
CompEditorFlags flags);
G_END_DECLS
diff --git a/calendar/gui/dialogs/memo-page.c b/calendar/gui/dialogs/memo-page.c
index c82bed2efc..1edee08466 100644
--- a/calendar/gui/dialogs/memo-page.c
+++ b/calendar/gui/dialogs/memo-page.c
@@ -928,9 +928,14 @@ to_button_clicked_cb (GtkButton *button,
static gboolean
init_widgets (MemoPage *mpage)
{
+ CompEditor *editor;
MemoPagePrivate *priv = mpage->priv;
GtkTextBuffer *buffer;
GtkTextView *view;
+ GtkAction *action;
+ gboolean active;
+
+ editor = comp_editor_page_get_editor (COMP_EDITOR_PAGE (mpage));
/* Generic informative messages */
gtk_widget_hide (priv->info_hbox);
@@ -995,8 +1000,9 @@ init_widgets (MemoPage *mpage)
G_CALLBACK (comp_editor_page_changed), mpage);
}
- memo_page_set_show_categories (
- mpage, calendar_config_get_show_categories());
+ action = comp_editor_get_action (editor, "view-categories");
+ active = gtk_toggle_action_get_active (GTK_TOGGLE_ACTION (action));
+ memo_page_set_show_categories (mpage, active);
return TRUE;
}
diff --git a/calendar/gui/dialogs/memo-page.glade b/calendar/gui/dialogs/memo-page.glade
index b1ff10f3f4..8728c9366e 100644
--- a/calendar/gui/dialogs/memo-page.glade
+++ b/calendar/gui/dialogs/memo-page.glade
@@ -159,6 +159,7 @@
<widget class="GtkLabel" id="label18">
<property name="visible">True</property>
<property name="label" translatable="yes">_Description:</property>
+ <property name="mnemonic_widget">memo_content</property>
<property name="use_underline">True</property>
<property name="use_markup">False</property>
<property name="justify">GTK_JUSTIFY_CENTER</property>
diff --git a/calendar/gui/dialogs/task-details-page.c b/calendar/gui/dialogs/task-details-page.c
index 8c63c4dd02..e6104ee2d0 100644
--- a/calendar/gui/dialogs/task-details-page.c
+++ b/calendar/gui/dialogs/task-details-page.c
@@ -515,16 +515,15 @@ complete_date_changed (TaskDetailsPage *tdpage, time_t ctime, gboolean complete)
}
static void
-date_changed_cb (EDateEdit *dedit, gpointer data)
+date_changed_cb (EDateEdit *dedit,
+ TaskDetailsPage *tdpage)
{
- TaskDetailsPage *tdpage;
- TaskDetailsPagePrivate *priv;
+ TaskDetailsPagePrivate *priv = tdpage->priv;
CompEditorPageDates dates = {NULL, NULL, NULL, NULL};
struct icaltimetype completed_tt = icaltime_null_time ();
icalproperty_status status;
gboolean date_set;
- tdpage = TASK_DETAILS_PAGE (data);
priv = tdpage->priv;
if (comp_editor_page_get_updating (COMP_EDITOR_PAGE (tdpage)))
diff --git a/calendar/gui/dialogs/task-details-page.glade b/calendar/gui/dialogs/task-details-page.glade
index 44fc3b2fbb..aac90876ed 100644
--- a/calendar/gui/dialogs/task-details-page.glade
+++ b/calendar/gui/dialogs/task-details-page.glade
@@ -4,7 +4,7 @@
<glade-interface>
<widget class="GtkWindow" id="task-details-toplevel">
- <property name="title">window1</property>
+ <property name="title" translatable="no">window1</property>
<property name="type">GTK_WINDOW_TOPLEVEL</property>
<property name="window_position">GTK_WIN_POS_NONE</property>
<property name="modal">False</property>
@@ -15,8 +15,6 @@
<property name="skip_pager_hint">False</property>
<property name="type_hint">GDK_WINDOW_TYPE_HINT_NORMAL</property>
<property name="gravity">GDK_GRAVITY_NORTH_WEST</property>
- <property name="focus_on_map">True</property>
- <property name="urgency_hint">False</property>
<child>
<widget class="GtkVBox" id="task-details-page">
@@ -38,10 +36,6 @@
<property name="yalign">0.5</property>
<property name="xpad">0</property>
<property name="ypad">0</property>
- <property name="ellipsize">PANGO_ELLIPSIZE_NONE</property>
- <property name="width_chars">-1</property>
- <property name="single_line_mode">False</property>
- <property name="angle">0</property>
</widget>
<packing>
<property name="padding">0</property>
@@ -69,10 +63,6 @@
<property name="yalign">0.5</property>
<property name="xpad">12</property>
<property name="ypad">0</property>
- <property name="ellipsize">PANGO_ELLIPSIZE_NONE</property>
- <property name="width_chars">-1</property>
- <property name="single_line_mode">False</property>
- <property name="angle">0</property>
</widget>
<packing>
<property name="padding">0</property>
@@ -103,10 +93,7 @@
<property name="yalign">0.5</property>
<property name="xpad">0</property>
<property name="ypad">0</property>
- <property name="ellipsize">PANGO_ELLIPSIZE_NONE</property>
- <property name="width_chars">-1</property>
- <property name="single_line_mode">False</property>
- <property name="angle">0</property>
+ <property name="mnemonic_widget">status</property>
</widget>
<packing>
<property name="left_attach">0</property>
@@ -132,10 +119,6 @@
<property name="xpad">0</property>
<property name="ypad">0</property>
<property name="mnemonic_widget">percent-complete</property>
- <property name="ellipsize">PANGO_ELLIPSIZE_NONE</property>
- <property name="width_chars">-1</property>
- <property name="single_line_mode">False</property>
- <property name="angle">0</property>
</widget>
<packing>
<property name="left_attach">0</property>
@@ -160,10 +143,7 @@
<property name="yalign">0.5</property>
<property name="xpad">0</property>
<property name="ypad">0</property>
- <property name="ellipsize">PANGO_ELLIPSIZE_NONE</property>
- <property name="width_chars">-1</property>
- <property name="single_line_mode">False</property>
- <property name="angle">0</property>
+ <property name="mnemonic_widget">priority</property>
</widget>
<packing>
<property name="left_attach">0</property>
@@ -188,10 +168,6 @@
<property name="yalign">0.5</property>
<property name="xpad">0</property>
<property name="ypad">0</property>
- <property name="ellipsize">PANGO_ELLIPSIZE_NONE</property>
- <property name="width_chars">-1</property>
- <property name="single_line_mode">False</property>
- <property name="angle">0</property>
</widget>
<packing>
<property name="left_attach">0</property>
@@ -204,85 +180,153 @@
</child>
<child>
- <widget class="GtkSpinButton" id="percent-complete">
+ <widget class="GtkOptionMenu" id="priority">
<property name="visible">True</property>
<property name="can_focus">True</property>
- <property name="climb_rate">1</property>
- <property name="digits">0</property>
- <property name="numeric">True</property>
- <property name="update_policy">GTK_UPDATE_ALWAYS</property>
- <property name="snap_to_ticks">False</property>
- <property name="wrap">False</property>
- <property name="adjustment">0 0 100 1 10 0</property>
+ <property name="history">0</property>
+
+ <child internal-child="menu">
+ <widget class="GtkMenu" id="convertwidget7">
+ <property name="visible">True</property>
+
+ <child>
+ <widget class="GtkMenuItem" id="convertwidget8">
+ <property name="visible">True</property>
+ <property name="label" translatable="yes">High</property>
+ <property name="use_underline">True</property>
+ </widget>
+ </child>
+
+ <child>
+ <widget class="GtkMenuItem" id="convertwidget9">
+ <property name="visible">True</property>
+ <property name="label" translatable="yes">Normal</property>
+ <property name="use_underline">True</property>
+ </widget>
+ </child>
+
+ <child>
+ <widget class="GtkMenuItem" id="convertwidget10">
+ <property name="visible">True</property>
+ <property name="label" translatable="yes">Low</property>
+ <property name="use_underline">True</property>
+ </widget>
+ </child>
+
+ <child>
+ <widget class="GtkMenuItem" id="convertwidget11">
+ <property name="visible">True</property>
+ <property name="label" translatable="yes">Undefined</property>
+ <property name="use_underline">True</property>
+ </widget>
+ </child>
+ </widget>
+ </child>
</widget>
<packing>
<property name="left_attach">1</property>
<property name="right_attach">2</property>
- <property name="top_attach">1</property>
- <property name="bottom_attach">2</property>
+ <property name="top_attach">2</property>
+ <property name="bottom_attach">3</property>
<property name="x_options">fill</property>
<property name="y_options"></property>
</packing>
</child>
<child>
- <widget class="Custom" id="completed-date">
+ <widget class="GtkOptionMenu" id="status">
<property name="visible">True</property>
- <property name="creation_function">task_details_page_create_date_edit</property>
- <property name="int1">0</property>
- <property name="int2">0</property>
- <property name="last_modification_time">Fri, 01 Jun 2001 18:58:51 GMT</property>
- <accessibility>
- <atkrelation target="date_completed_label" type="labelled-by"/>
- </accessibility>
+ <property name="can_focus">True</property>
+ <property name="history">0</property>
+
+ <child internal-child="menu">
+ <widget class="GtkMenu" id="convertwidget1">
+ <property name="visible">True</property>
+
+ <child>
+ <widget class="GtkMenuItem" id="convertwidget2">
+ <property name="visible">True</property>
+ <property name="label" translatable="yes">Not Started</property>
+ <property name="use_underline">True</property>
+ </widget>
+ </child>
+
+ <child>
+ <widget class="GtkMenuItem" id="convertwidget3">
+ <property name="visible">True</property>
+ <property name="label" translatable="yes">In Progress</property>
+ <property name="use_underline">True</property>
+ </widget>
+ </child>
+
+ <child>
+ <widget class="GtkMenuItem" id="convertwidget5">
+ <property name="visible">True</property>
+ <property name="label" translatable="yes">Completed</property>
+ <property name="use_underline">True</property>
+ </widget>
+ </child>
+
+ <child>
+ <widget class="GtkMenuItem" id="convertwidget6">
+ <property name="visible">True</property>
+ <property name="label" translatable="yes">Canceled</property>
+ <property name="use_underline">True</property>
+ </widget>
+ </child>
+ </widget>
+ </child>
</widget>
<packing>
<property name="left_attach">1</property>
<property name="right_attach">2</property>
- <property name="top_attach">3</property>
- <property name="bottom_attach">4</property>
+ <property name="top_attach">0</property>
+ <property name="bottom_attach">1</property>
<property name="x_options">fill</property>
<property name="y_options"></property>
</packing>
</child>
<child>
- <widget class="GtkComboBox" id="priority-combobox">
+ <widget class="GtkSpinButton" id="percent-complete">
<property name="visible">True</property>
- <property name="items" translatable="yes">High
-Normal
-Low
-Undefined</property>
- <property name="add_tearoffs">False</property>
- <property name="focus_on_click">True</property>
+ <property name="can_focus">True</property>
+ <property name="climb_rate">1</property>
+ <property name="digits">0</property>
+ <property name="numeric">True</property>
+ <property name="update_policy">GTK_UPDATE_ALWAYS</property>
+ <property name="snap_to_ticks">False</property>
+ <property name="wrap">False</property>
+ <property name="adjustment">0 0 100 1 10 0</property>
</widget>
<packing>
<property name="left_attach">1</property>
<property name="right_attach">2</property>
- <property name="top_attach">2</property>
- <property name="bottom_attach">3</property>
+ <property name="top_attach">1</property>
+ <property name="bottom_attach">2</property>
<property name="x_options">fill</property>
- <property name="y_options">fill</property>
+ <property name="y_options"></property>
</packing>
</child>
<child>
- <widget class="GtkComboBox" id="status-combobox">
+ <widget class="Custom" id="completed-date">
<property name="visible">True</property>
- <property name="items" translatable="yes">Not Started
-In Progress
-Completed
-Canceled</property>
- <property name="add_tearoffs">False</property>
- <property name="focus_on_click">True</property>
+ <property name="creation_function">task_details_page_create_date_edit</property>
+ <property name="int1">0</property>
+ <property name="int2">0</property>
+ <property name="last_modification_time">Fri, 01 Jun 2001 18:58:51 GMT</property>
+ <accessibility>
+ <atkrelation target="date_completed_label" type="labelled-by"/>
+ </accessibility>
</widget>
<packing>
<property name="left_attach">1</property>
<property name="right_attach">2</property>
- <property name="top_attach">0</property>
- <property name="bottom_attach">1</property>
+ <property name="top_attach">3</property>
+ <property name="bottom_attach">4</property>
<property name="x_options">fill</property>
- <property name="y_options">fill</property>
+ <property name="y_options"></property>
</packing>
</child>
</widget>
@@ -313,10 +357,6 @@ Canceled</property>
<property name="yalign">0.5</property>
<property name="xpad">0</property>
<property name="ypad">0</property>
- <property name="ellipsize">PANGO_ELLIPSIZE_NONE</property>
- <property name="width_chars">-1</property>
- <property name="single_line_mode">False</property>
- <property name="angle">0</property>
</widget>
<packing>
<property name="padding">0</property>
@@ -344,10 +384,6 @@ Canceled</property>
<property name="yalign">0.5</property>
<property name="xpad">12</property>
<property name="ypad">0</property>
- <property name="ellipsize">PANGO_ELLIPSIZE_NONE</property>
- <property name="width_chars">-1</property>
- <property name="single_line_mode">False</property>
- <property name="angle">0</property>
</widget>
<packing>
<property name="padding">0</property>
@@ -379,10 +415,6 @@ Canceled</property>
<property name="yalign">0.5</property>
<property name="xpad">0</property>
<property name="ypad">0</property>
- <property name="ellipsize">PANGO_ELLIPSIZE_NONE</property>
- <property name="width_chars">-1</property>
- <property name="single_line_mode">False</property>
- <property name="angle">0</property>
</widget>
<packing>
<property name="left_attach">0</property>
diff --git a/calendar/gui/dialogs/task-editor.c b/calendar/gui/dialogs/task-editor.c
index 1e3afc95eb..2829def666 100644
--- a/calendar/gui/dialogs/task-editor.c
+++ b/calendar/gui/dialogs/task-editor.c
@@ -35,7 +35,6 @@
#include <e-util/e-plugin-ui.h>
#include <e-util/e-util-private.h>
-#include <evolution-shell-component-utils.h>
#include "task-page.h"
#include "task-details-page.h"
@@ -304,6 +303,7 @@ task_editor_init (TaskEditor *te)
CompEditor *editor = COMP_EDITOR (te);
GtkUIManager *ui_manager;
GtkActionGroup *action_group;
+ const gchar *id;
GError *error = NULL;
te->priv = TASK_EDITOR_GET_PRIVATE (te);
@@ -346,7 +346,10 @@ task_editor_init (TaskEditor *te)
ui_manager = comp_editor_get_ui_manager (editor);
gtk_ui_manager_add_ui_from_string (ui_manager, ui, -1, &error);
- e_plugin_ui_register_manager ("task-editor", ui_manager, te);
+
+ id = "org.gnome.evolution.task-editor";
+ e_plugin_ui_register_manager (ui_manager, id, te);
+ e_plugin_ui_enable_manager (ui_manager, id);
if (error != NULL) {
g_critical ("%s: %s", G_STRFUNC, error->message);
@@ -488,13 +491,16 @@ task_editor_send_comp (CompEditor *editor, ECalComponentItipMethod method, gbool
* editor could not be created.
**/
CompEditor *
-task_editor_new (ECal *client, CompEditorFlags flags)
+task_editor_new (ECal *client,
+ EShell *shell,
+ CompEditorFlags flags)
{
g_return_val_if_fail (E_IS_CAL (client), NULL);
+ g_return_val_if_fail (E_IS_SHELL (shell), NULL);
return g_object_new (
TYPE_TASK_EDITOR,
- "flags", flags, "client", client, NULL);
+ "client", client, "flags", flags, "shell", shell, NULL);
}
void
diff --git a/calendar/gui/dialogs/task-editor.h b/calendar/gui/dialogs/task-editor.h
index 57ab33b54f..f026acae0c 100644
--- a/calendar/gui/dialogs/task-editor.h
+++ b/calendar/gui/dialogs/task-editor.h
@@ -66,6 +66,7 @@ struct _TaskEditorClass {
GType task_editor_get_type (void);
CompEditor * task_editor_new (ECal *client,
+ EShell *shell,
CompEditorFlags flags);
void task_editor_show_assignment (TaskEditor *te);
diff --git a/calendar/gui/dialogs/task-page.c b/calendar/gui/dialogs/task-page.c
index f1b13df8f6..8a273c2944 100644
--- a/calendar/gui/dialogs/task-page.c
+++ b/calendar/gui/dialogs/task-page.c
@@ -451,12 +451,14 @@ task_page_fill_widgets (CompEditorPage *page, ECalComponent *comp)
ECalComponentClassification cl;
CompEditor *editor;
CompEditorFlags flags;
+ GtkAction *action;
ECal *client;
GSList *l;
icalcomponent *icalcomp;
const gchar *categories, *uid;
icaltimezone *zone, *default_zone;
gchar *backend_addr = NULL;
+ gboolean active;
tpage = TASK_PAGE (page);
priv = tpage->priv;
@@ -538,7 +540,10 @@ task_page_fill_widgets (CompEditorPage *page, ECalComponent *comp)
e_timezone_entry_set_timezone (E_TIMEZONE_ENTRY (priv->timezone),
zone ? zone : default_zone);
- task_page_set_show_timezone (tpage, calendar_config_get_show_timezone());
+
+ action = comp_editor_get_action (editor, "view-time-zone");
+ active = gtk_toggle_action_get_active (GTK_TOGGLE_ACTION (action));
+ task_page_set_show_timezone (tpage, active);
if (!(flags & COMP_EDITOR_NEW_ITEM) && !zone) {
GtkAction *action;
@@ -1123,15 +1128,10 @@ remove_clicked_cb (GtkButton *btn, TaskPage *page)
}
static void
-invite_cb (GtkWidget *widget, gpointer data)
+invite_cb (GtkWidget *widget,
+ TaskPage *page)
{
- TaskPage *page;
- TaskPagePrivate *priv;
-
- page = TASK_PAGE (data);
- priv = page->priv;
-
- e_meeting_list_view_invite_others_dialog (priv->list_view);
+ e_meeting_list_view_invite_others_dialog (page->priv->list_view);
}
static void
@@ -1491,17 +1491,16 @@ summary_changed_cb (GtkEditable *editable,
* other pages in the task editor, so they can update any labels.
*/
static void
-date_changed_cb (EDateEdit *dedit, gpointer data)
+date_changed_cb (EDateEdit *dedit,
+ TaskPage *tpage)
{
- TaskPage *tpage;
- TaskPagePrivate *priv;
+ TaskPagePrivate *priv = tpage->priv;
CompEditorPageDates dates;
gboolean date_set, time_set;
ECalComponentDateTime start_dt, due_dt;
struct icaltimetype start_tt = icaltime_null_time();
struct icaltimetype due_tt = icaltime_null_time();
- tpage = TASK_PAGE (data);
priv = tpage->priv;
if (comp_editor_page_get_updating (COMP_EDITOR_PAGE (tpage)))
@@ -1560,33 +1559,24 @@ date_changed_cb (EDateEdit *dedit, gpointer data)
}
static void
-timezone_changed_cb (EDateEdit *dedit, gpointer data)
+timezone_changed_cb (EDateEdit *dedit,
+ TaskPage *tpage)
{
- TaskPage *tpage;
- TaskPagePrivate *priv;
-
- tpage = TASK_PAGE (data);
- priv = tpage->priv;
-
- date_changed_cb ((EDateEdit *) priv->start_date, tpage);
- date_changed_cb ((EDateEdit *) priv->due_date, tpage);
+ date_changed_cb ((EDateEdit *) tpage->priv->start_date, tpage);
+ date_changed_cb ((EDateEdit *) tpage->priv->due_date, tpage);
}
/* Callback used when the categories button is clicked; we must bring up the
* category list dialog.
*/
static void
-categories_clicked_cb (GtkWidget *button, gpointer data)
+categories_clicked_cb (GtkWidget *button,
+ TaskPage *tpage)
{
- TaskPage *tpage;
- TaskPagePrivate *priv;
- GtkWidget *entry;
+ GtkEntry *entry;
- tpage = TASK_PAGE (data);
- priv = tpage->priv;
-
- entry = priv->categories;
- e_categories_config_open_dialog_for_entry (GTK_ENTRY (entry));
+ entry = GTK_ENTRY (tpage->priv->categories);
+ e_categories_config_open_dialog_for_entry (entry);
}
static gboolean
@@ -1840,12 +1830,17 @@ task_page_sendoptions_clicked_cb (TaskPage *tpage)
static gboolean
init_widgets (TaskPage *tpage)
{
+ CompEditor *editor;
TaskPagePrivate *priv;
+ GtkAction *action;
GtkTextBuffer *text_buffer;
icaltimezone *zone;
+ gboolean active;
priv = tpage->priv;
+ editor = comp_editor_page_get_editor (COMP_EDITOR_PAGE (tpage));
+
/* Make sure the EDateEdit widgets use our timezones to get the
current time. */
e_date_edit_set_get_time_callback (E_DATE_EDIT (priv->start_date),
@@ -1941,15 +1936,36 @@ init_widgets (TaskPage *tpage)
zone = calendar_config_get_icaltimezone ();
e_timezone_entry_set_default_timezone (E_TIMEZONE_ENTRY (priv->timezone), zone);
- task_page_set_show_timezone (tpage, calendar_config_get_show_timezone());
+ action = comp_editor_get_action (editor, "view-time-zone");
+ active = gtk_toggle_action_get_active (GTK_TOGGLE_ACTION (action));
+ task_page_set_show_timezone (tpage, active);
+
+ e_meeting_list_view_column_set_visible (
+ priv->list_view, E_MEETING_STORE_ATTENDEE_COL, TRUE);
+
+ action = comp_editor_get_action (editor, "view-role");
+ active = gtk_toggle_action_get_active (GTK_TOGGLE_ACTION (action));
+ e_meeting_list_view_column_set_visible (
+ priv->list_view, E_MEETING_STORE_ROLE_COL, active);
+
+ action = comp_editor_get_action (editor, "view-rsvp");
+ active = gtk_toggle_action_get_active (GTK_TOGGLE_ACTION (action));
+ e_meeting_list_view_column_set_visible (
+ priv->list_view, E_MEETING_STORE_RSVP_COL, active);
+
+ action = comp_editor_get_action (editor, "view-status");
+ active = gtk_toggle_action_get_active (GTK_TOGGLE_ACTION (action));
+ e_meeting_list_view_column_set_visible (
+ priv->list_view, E_MEETING_STORE_STATUS_COL, active);
- e_meeting_list_view_column_set_visible (priv->list_view, E_MEETING_STORE_ATTENDEE_COL, TRUE);
- e_meeting_list_view_column_set_visible (priv->list_view, E_MEETING_STORE_ROLE_COL, calendar_config_get_show_role ());
- e_meeting_list_view_column_set_visible (priv->list_view, E_MEETING_STORE_RSVP_COL, calendar_config_get_show_rsvp ());
- e_meeting_list_view_column_set_visible (priv->list_view, E_MEETING_STORE_STATUS_COL, calendar_config_get_show_status ());
- e_meeting_list_view_column_set_visible (priv->list_view, E_MEETING_STORE_TYPE_COL, calendar_config_get_show_type ());
+ action = comp_editor_get_action (editor, "view-type");
+ active = gtk_toggle_action_get_active (GTK_TOGGLE_ACTION (action));
+ e_meeting_list_view_column_set_visible (
+ priv->list_view, E_MEETING_STORE_TYPE_COL, active);
- task_page_set_show_categories (tpage, calendar_config_get_show_categories());
+ action = comp_editor_get_action (editor, "view-categories");
+ active = gtk_toggle_action_get_active (GTK_TOGGLE_ACTION (action));
+ task_page_set_show_categories (tpage, active);
return TRUE;
}
diff --git a/calendar/gui/e-cal-component-memo-preview.c b/calendar/gui/e-cal-component-memo-preview.c
deleted file mode 100644
index f3969157a9..0000000000
--- a/calendar/gui/e-cal-component-memo-preview.c
+++ /dev/null
@@ -1,365 +0,0 @@
-/*
- * This program is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 2 of the License, or (at your option) version 3.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with the program; if not, see <http://www.gnu.org/licenses/>
- *
- *
- * Authors:
- * Federico Mena Quintero <federico@ximian.com>
- * Damon Chaplin <damon@ximian.com>
- * Rodrigo Moya <rodrigo@ximian.com>
- * Nathan Owens <pianocomp81@yahoo.com>
- *
- * Copyright (C) 1999-2008 Novell, Inc. (www.novell.com)
- *
- */
-
-#ifdef HAVE_CONFIG_H
-#include <config.h>
-#endif
-
-#include <string.h>
-#include <gtk/gtk.h>
-#include <glib/gi18n.h>
-#include <libecal/e-cal-time-util.h>
-#include <libedataserver/e-categories.h>
-#include <gtkhtml/gtkhtml.h>
-#include <gtkhtml/gtkhtml-stream.h>
-#include <libedataserver/e-time-utils.h>
-#include <e-util/e-util.h>
-#include <e-util/e-categories-config.h>
-#include "calendar-config.h"
-#include "e-cal-component-memo-preview.h"
-#include "e-cal-component-preview.h"
-#include <camel/camel-mime-filter-tohtml.h>
-
-struct _ECalComponentMemoPreviewPrivate {
- GtkWidget *html;
-
- icaltimezone *zone;
-};
-
-G_DEFINE_TYPE (ECalComponentMemoPreview, e_cal_component_memo_preview, GTK_TYPE_TABLE)
-
-static void
-on_link_clicked (GtkHTML *html, const gchar *url, gpointer data)
-{
- /* FIXME Pass a parent window. */
- e_show_uri (NULL, url);
-}
-
-static void
-on_url_cb (GtkHTML *html, const gchar *url, gpointer data)
-{
-#if 0
- gchar *msg;
- ECalComponentMemoPreview *preview = data;
-
- if (url && *url) {
- msg = g_strdup_printf (_("Click to open %s"), url);
- e_calendar_table_set_status_message (e_tasks_get_calendar_table (tasks), msg);
- g_free (msg);
- } else
- e_calendar_table_set_status_message (e_tasks_get_calendar_table (tasks), NULL);
-#endif
-}
-
-/* Converts a time_t to a string, relative to the specified timezone */
-static gchar *
-timet_to_str_with_zone (ECalComponentDateTime *dt, ECal *ecal, icaltimezone *default_zone)
-{
- struct icaltimetype itt;
- icaltimezone *zone;
- struct tm tm;
- gchar buf[256];
-
- if (dt->tzid) {
- /* If we can't find the zone, we'll guess its "local" */
- if (!e_cal_get_timezone (ecal, dt->tzid, &zone, NULL))
- zone = NULL;
- } else if (dt->value->is_utc) {
- zone = icaltimezone_get_utc_timezone ();
- } else {
- zone = NULL;
- }
-
- itt = *dt->value;
- if (zone)
- icaltimezone_convert_time (&itt, zone, default_zone);
- tm = icaltimetype_to_tm (&itt);
-
- e_time_format_date_and_time (&tm, calendar_config_get_24_hour_format (),
- FALSE, FALSE, buf, sizeof (buf));
-
- return g_locale_to_utf8 (buf, -1, NULL, NULL, NULL);
-}
-
-static void
-write_html (GtkHTMLStream *stream, ECal *ecal, ECalComponent *comp, icaltimezone *default_zone)
-{
- ECalComponentText text;
- ECalComponentDateTime dt;
- gchar *str;
- GSList *l;
- gboolean one_added = FALSE;
-
- g_return_if_fail (E_IS_CAL_COMPONENT (comp));
-
- /* write document header */
- e_cal_component_get_summary (comp, &text);
-
- if (text.value)
- gtk_html_stream_printf (stream,
- "<HTML><BODY><H1>%s</H1>",
- text.value);
- else
- gtk_html_stream_printf (stream,
- "<HTML><BODY><H1><I>%s</I></H1>",
- _("Untitled"));
-
- /* write icons for the categories */
- e_cal_component_get_categories_list (comp, &l);
- if (l) {
- GSList *node;
- GString *string = g_string_new (NULL);
-
- gtk_html_stream_printf(stream, "<H3>%s: ", _("Categories"));
-
- for (node = l; node != NULL; node = node->next) {
- const gchar *icon_file;
-
- icon_file = e_categories_get_icon_file_for ((const gchar *) node->data);
- if (icon_file && g_file_test(icon_file, G_FILE_TEST_EXISTS)) {
- gchar *icon_file_uri = g_filename_to_uri (icon_file, NULL, NULL);
- gtk_html_stream_printf (stream, "<IMG ALT=\"%s\" SRC=\"%s\">",
- (const gchar *) node->data, icon_file_uri);
- g_free (icon_file_uri);
- one_added = TRUE;
- }
- else{
- if (one_added == FALSE) {
- g_string_append_printf (string, "%s", (const gchar *) node->data);
- one_added = TRUE;
- }
- else{
- g_string_append_printf (string, ", %s", (const gchar *) node->data);
- }
- }
- }
-
- if (string->len > 0)
- gtk_html_stream_printf(stream, "%s", string->str);
-
- g_string_free (string, TRUE);
-
- gtk_html_stream_printf(stream, "</H3>");
-
- e_cal_component_free_categories_list (l);
- }
-
- /* Start table */
- gtk_html_stream_printf (stream, "<TABLE BORDER=\"0\" WIDTH=\"80%%\">"
- "<TR><TD VALIGN=\"TOP\" ALIGN=\"RIGHT\" WIDTH=\"15%%\"></TD></TR>");
-
- /* write start date */
- e_cal_component_get_dtstart (comp, &dt);
- if (dt.value != NULL) {
- str = timet_to_str_with_zone (&dt, ecal, default_zone);
- gtk_html_stream_printf (stream, "<TR><TD VALIGN=\"TOP\" ALIGN=\"RIGHT\"><B>%s</B></TD><TD>%s</TD></TR>",
- _("Start Date:"), str);
-
- g_free (str);
- }
- e_cal_component_free_datetime (&dt);
-
- /* write description and URL */
- gtk_html_stream_printf (stream, "<TR><TD COLSPAN=\"2\"><HR></TD></TR>");
-
- e_cal_component_get_description_list (comp, &l);
- if (l) {
- GSList *node;
-
- gtk_html_stream_printf (stream, "<TR><TD VALIGN=\"TOP\" ALIGN=\"RIGHT\"><B>%s</B></TD>", _("Description:"));
-
- gtk_html_stream_printf (stream, "<TD><TT>");
-
- for (node = l; node != NULL; node = node->next) {
- gchar *html;
-
- text = * (ECalComponentText *) node->data;
- html = camel_text_to_html (text.value ? text.value : "", CAMEL_MIME_FILTER_TOHTML_CONVERT_NL | CAMEL_MIME_FILTER_TOHTML_CONVERT_SPACES | CAMEL_MIME_FILTER_TOHTML_CONVERT_URLS | CAMEL_MIME_FILTER_TOHTML_CONVERT_ADDRESSES, 0);
-
- if (html)
- gtk_html_stream_printf (stream, "%s", html);
-
- g_free (html);
- }
-
- gtk_html_stream_printf (stream, "</TT></TD></TR>");
-
- e_cal_component_free_text_list (l);
- }
-
- /* URL */
- e_cal_component_get_url (comp, (const gchar **) &str);
- if (str) {
- gtk_html_stream_printf (stream, "<TR><TD VALIGN=\"TOP\" ALIGN=\"RIGHT\"><B>%s</B></TD>", _("Web Page:"));
- gtk_html_stream_printf (stream, "<TD><A HREF=\"%s\">%s</A></TD></TR>", str, str);
- }
-
- gtk_html_stream_printf (stream, "</TABLE>");
-
- /* close document */
- gtk_html_stream_printf (stream, "</BODY></HTML>");
-}
-
-static void
-e_cal_component_memo_preview_init (ECalComponentMemoPreview *preview)
-{
- ECalComponentMemoPreviewPrivate *priv;
- GtkWidget *scroll;
-
- priv = g_new0 (ECalComponentMemoPreviewPrivate, 1);
- preview->priv = priv;
-
- priv->html = gtk_html_new ();
- gtk_html_set_default_content_type (GTK_HTML (priv->html), "charset=utf-8");
- gtk_html_load_empty (GTK_HTML (priv->html));
-
- g_signal_connect (G_OBJECT (priv->html), "url_requested",
- G_CALLBACK (e_cal_comp_preview_url_requested_cb), NULL);
- g_signal_connect (G_OBJECT (priv->html), "link_clicked",
- G_CALLBACK (on_link_clicked), preview);
- g_signal_connect (G_OBJECT (priv->html), "on_url",
- G_CALLBACK (on_url_cb), preview);
-
- scroll = gtk_scrolled_window_new (NULL, NULL);
- gtk_scrolled_window_set_policy (GTK_SCROLLED_WINDOW (scroll),
- GTK_POLICY_AUTOMATIC,
- GTK_POLICY_AUTOMATIC);
- gtk_scrolled_window_set_shadow_type (GTK_SCROLLED_WINDOW (scroll), GTK_SHADOW_IN);
-
- gtk_container_add (GTK_CONTAINER (scroll), priv->html);
- gtk_container_add (GTK_CONTAINER (preview), scroll);
- gtk_widget_show_all (scroll);
-
- priv->zone = icaltimezone_get_utc_timezone ();
-}
-
-static void
-e_cal_component_memo_preview_destroy (GtkObject *object)
-{
- ECalComponentMemoPreview *preview;
- ECalComponentMemoPreviewPrivate *priv;
-
- g_return_if_fail (object != NULL);
- g_return_if_fail (E_IS_CAL_COMPONENT_MEMO_PREVIEW (object));
-
- preview = E_CAL_COMPONENT_MEMO_PREVIEW (object);
- priv = preview->priv;
-
- if (priv) {
-
- g_free (priv);
- preview->priv = NULL;
- }
-
- if (GTK_OBJECT_CLASS (e_cal_component_memo_preview_parent_class)->destroy)
- (* GTK_OBJECT_CLASS (e_cal_component_memo_preview_parent_class)->destroy) (object);
-}
-
-static void
-e_cal_component_memo_preview_class_init (ECalComponentMemoPreviewClass *klass)
-{
- GtkObjectClass *object_class;
-
- object_class = (GtkObjectClass *) klass;
-
- object_class->destroy = e_cal_component_memo_preview_destroy;
-}
-
-GtkWidget *
-e_cal_component_memo_preview_new (void)
-{
- ECalComponentMemoPreview *preview;
-
- preview = g_object_new (e_cal_component_memo_preview_get_type (), NULL);
-
- return GTK_WIDGET (preview);
-}
-
-icaltimezone *
-e_cal_component_memo_preview_get_default_timezone (ECalComponentMemoPreview *preview)
-{
- ECalComponentMemoPreviewPrivate *priv;
-
- g_return_val_if_fail (preview != NULL, NULL);
- g_return_val_if_fail (E_IS_CAL_COMPONENT_MEMO_PREVIEW (preview), NULL);
-
- priv = preview->priv;
-
- return priv->zone;
-}
-
-void
-e_cal_component_memo_preview_set_default_timezone (ECalComponentMemoPreview *preview, icaltimezone *zone)
-{
- ECalComponentMemoPreviewPrivate *priv;
-
- g_return_if_fail (preview != NULL);
- g_return_if_fail (E_IS_CAL_COMPONENT_MEMO_PREVIEW (preview));
- g_return_if_fail (zone != NULL);
-
- priv = preview->priv;
-
- priv->zone = zone;
-}
-
-void
-e_cal_component_memo_preview_display (ECalComponentMemoPreview *preview, ECal *ecal, ECalComponent *comp)
-{
- ECalComponentMemoPreviewPrivate *priv;
- GtkHTMLStream *stream;
-
- g_return_if_fail (preview != NULL);
- g_return_if_fail (E_IS_CAL_COMPONENT_MEMO_PREVIEW (preview));
- g_return_if_fail (comp != NULL);
- g_return_if_fail (E_IS_CAL_COMPONENT (comp));
-
- priv = preview->priv;
-
- stream = gtk_html_begin (GTK_HTML (priv->html));
- write_html (stream, ecal, comp, priv->zone);
- gtk_html_stream_close (stream, GTK_HTML_STREAM_OK);
-}
-
-void
-e_cal_component_memo_preview_clear (ECalComponentMemoPreview *preview)
-{
- ECalComponentMemoPreviewPrivate *priv;
-
- g_return_if_fail (preview != NULL);
- g_return_if_fail (E_IS_CAL_COMPONENT_MEMO_PREVIEW (preview));
-
- priv = preview->priv;
-
- gtk_html_load_empty (GTK_HTML (priv->html));
-}
-
-GtkWidget *
-e_cal_component_memo_preview_get_html (ECalComponentMemoPreview *preview)
-{
- g_return_val_if_fail (preview != NULL, NULL);
- g_return_val_if_fail (E_IS_CAL_COMPONENT_MEMO_PREVIEW (preview), NULL);
-
- return preview->priv->html;
-}
diff --git a/calendar/gui/e-cal-component-memo-preview.h b/calendar/gui/e-cal-component-memo-preview.h
deleted file mode 100644
index 0f8c21c565..0000000000
--- a/calendar/gui/e-cal-component-memo-preview.h
+++ /dev/null
@@ -1,66 +0,0 @@
-/*
- * This program is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 2 of the License, or (at your option) version 3.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with the program; if not, see <http://www.gnu.org/licenses/>
- *
- *
- * Authors:
- * Federico Mena Quintero <federico@ximian.com>
- * Damon Chaplin <damon@ximian.com>
- * Nathan Owens <pianocomp81@yahoo.com>
- *
- * Copyright (C) 1999-2008 Novell, Inc. (www.novell.com)
- *
- */
-
-#ifndef _E_CAL_COMPONENT_MEMO_PREVIEW_H_
-#define _E_CAL_COMPONENT_MEMO_PREVIEW_H_
-
-#include <gtk/gtk.h>
-#include <libecal/e-cal.h>
-
-#define E_TYPE_CAL_COMPONENT_MEMO_PREVIEW (e_cal_component_memo_preview_get_type ())
-#define E_CAL_COMPONENT_MEMO_PREVIEW(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), E_TYPE_CAL_COMPONENT_MEMO_PREVIEW, ECalComponentMemoPreview))
-#define E_CAL_COMPONENT_MEMO_PREVIEW_CLASS(klass) (G_TYPE_CHECK_INSTANCE_CAST_CLASS ((klass), E_TYPE_CAL_COMPONENT_MEMO_PREVIEW, \
- ECalComponentMemoPreviewClass))
-#define E_IS_CAL_COMPONENT_MEMO_PREVIEW(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), E_TYPE_CAL_COMPONENT_MEMO_PREVIEW))
-#define E_IS_CAL_COMPONENT_MEMO_PREVIEW_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), E_TYPE_CAL_COMPONENT_MEMO_PREVIEW))
-
-typedef struct _ECalComponentMemoPreview ECalComponentMemoPreview;
-typedef struct _ECalComponentMemoPreviewClass ECalComponentMemoPreviewClass;
-typedef struct _ECalComponentMemoPreviewPrivate ECalComponentMemoPreviewPrivate;
-
-struct _ECalComponentMemoPreview {
- GtkTable table;
-
- /* Private data */
- ECalComponentMemoPreviewPrivate *priv;
-};
-
-struct _ECalComponentMemoPreviewClass {
- GtkTableClass parent_class;
-
- /* Notification signals */
- void (* selection_changed) (ECalComponentMemoPreview *preview, gint n_selected);
-};
-
-GType e_cal_component_memo_preview_get_type (void);
-GtkWidget *e_cal_component_memo_preview_new (void);
-
-icaltimezone *e_cal_component_memo_preview_get_default_timezone (ECalComponentMemoPreview *preview);
-void e_cal_component_memo_preview_set_default_timezone (ECalComponentMemoPreview *preview, icaltimezone *zone);
-
-void e_cal_component_memo_preview_display (ECalComponentMemoPreview *preview, ECal *ecal, ECalComponent *comp);
-void e_cal_component_memo_preview_clear (ECalComponentMemoPreview *preview);
-GtkWidget *e_cal_component_memo_preview_get_html (ECalComponentMemoPreview *preview);
-
-#endif /* _E_CAL_COMPONENT_MEMO_PREVIEW_H_ */
diff --git a/calendar/gui/e-cal-component-preview.c b/calendar/gui/e-cal-component-preview.c
index 8a33d48c0b..de6f6fcd3d 100644
--- a/calendar/gui/e-cal-component-preview.c
+++ b/calendar/gui/e-cal-component-preview.c
@@ -22,42 +22,41 @@
*
*/
-#ifdef HAVE_CONFIG_H
-#include <config.h>
-#endif
+#include "e-cal-component-preview.h"
#include <string.h>
-#include <gio/gio.h>
#include <gtk/gtk.h>
#include <glib/gi18n.h>
-#include <libedataserver/e-categories.h>
#include <libecal/e-cal-time-util.h>
-#include <gtkhtml/gtkhtml.h>
+#include <libedataserver/e-categories.h>
#include <gtkhtml/gtkhtml-stream.h>
#include <libedataserver/e-time-utils.h>
#include <e-util/e-util.h>
#include <e-util/e-categories-config.h>
#include "calendar-config.h"
-#include "e-cal-component-preview.h"
#include <camel/camel-mime-filter-tohtml.h>
-struct _ECalComponentPreviewPrivate {
- GtkWidget *html;
+#define E_CAL_COMPONENT_PREVIEW_GET_PRIVATE(obj) \
+ (G_TYPE_INSTANCE_GET_PRIVATE \
+ ((obj), E_TYPE_CAL_COMPONENT_PREVIEW, ECalComponentPreviewPrivate))
+struct _ECalComponentPreviewPrivate {
icaltimezone *zone;
};
-G_DEFINE_TYPE (ECalComponentPreview, e_cal_component_preview, GTK_TYPE_TABLE)
+static gpointer parent_class;
static void
-on_link_clicked (GtkHTML *html, const gchar *url, gpointer data)
+cal_component_preview_link_clicked (GtkHTML *html,
+ const gchar *uri)
{
/* FIXME Pass a parent window. */
- e_show_uri (NULL, url);
+ e_show_uri (NULL, uri);
}
static void
-on_url_cb (GtkHTML *html, const gchar *url, gpointer data)
+cal_component_preview_on_url (GtkHTML *html,
+ const gchar *url)
{
#if 0
gchar *msg;
@@ -72,51 +71,11 @@ on_url_cb (GtkHTML *html, const gchar *url, gpointer data)
#endif
}
-/* Callback used when the user selects a URL in the HTML widget */
-void
-e_cal_comp_preview_url_requested_cb (GtkHTML *html, const gchar *url, GtkHTMLStream *html_stream, gpointer data)
-{
- gint len = strlen ("file:///");
-
- if (!strncmp ("file:///", url, len)) {
- GFile *file;
- const gchar *path = url + len - 1;
-
- g_return_if_fail (html_stream != NULL);
- g_return_if_fail (path != NULL);
-
- file = g_file_new_for_path (path);
- if (file) {
- gchar buffer[4096];
- GInputStream *stream;
-
- /* ignore errors here */
- stream = G_INPUT_STREAM (g_file_read (file, NULL, NULL));
-
- if (stream) {
- gssize bread;
-
- do {
- /* ignore errors here as well */
- bread = g_input_stream_read (stream, buffer, sizeof (buffer), NULL, NULL);
- if (bread > 0)
- gtk_html_stream_write (html_stream, buffer, bread);
- } while (bread > 0);
-
- g_input_stream_close (stream, NULL, NULL);
- g_object_unref (stream);
-
- gtk_html_stream_close (html_stream, GTK_HTML_STREAM_OK);
- }
-
- g_object_unref (file);
- }
- }
-}
-
/* Converts a time_t to a string, relative to the specified timezone */
static gchar *
-timet_to_str_with_zone (ECalComponentDateTime *dt, ECal *ecal, icaltimezone *default_zone)
+timet_to_str_with_zone (ECalComponentDateTime *dt,
+ ECal *ecal,
+ icaltimezone *default_zone)
{
struct icaltimetype itt;
icaltimezone *zone;
@@ -145,12 +104,18 @@ timet_to_str_with_zone (ECalComponentDateTime *dt, ECal *ecal, icaltimezone *def
}
static void
-write_html (GtkHTMLStream *stream, ECal *ecal, ECalComponent *comp, icaltimezone *default_zone)
+cal_component_preview_write_html (GtkHTMLStream *stream,
+ ECal *ecal,
+ ECalComponent *comp,
+ icaltimezone *default_zone)
{
ECalComponentText text;
ECalComponentDateTime dt;
gchar *str;
- GSList *l;
+ GString *string;
+ GSList *list, *iter;
+ icalcomponent *icalcomp;
+ icalproperty *icalprop;
icalproperty_status status;
const gchar *location;
gint *priority_value;
@@ -170,26 +135,33 @@ write_html (GtkHTMLStream *stream, ECal *ecal, ECalComponent *comp, icaltimezone
_("Untitled"));
/* write icons for the categories */
- e_cal_component_get_categories_list (comp, &l);
- if (l) {
- GSList *node;
-
- for (node = l; node != NULL; node = node->next) {
- const gchar *icon_file;
-
- icon_file = e_categories_get_icon_file_for ((const gchar *) node->data);
- if (icon_file) {
- gchar *icon_file_uri = g_filename_to_uri (icon_file, NULL, NULL);
- gtk_html_stream_printf (stream, "<IMG ALT=\"%s\" SRC=\"%s\">",
- (const gchar *) node->data, icon_file_uri);
- g_free (icon_file_uri);
- }
+ string = g_string_new (NULL);
+ e_cal_component_get_categories_list (comp, &list);
+ if (list != NULL)
+ gtk_html_stream_printf (stream, "<H3>%s ", _("Categories:"));
+ for (iter = list; iter != NULL; iter = iter->next) {
+ const gchar *category = iter->data;
+ const gchar *icon_file;
+
+ icon_file = e_categories_get_icon_file_for (category);
+ if (icon_file && g_file_test (icon_file, G_FILE_TEST_EXISTS)) {
+ gchar *uri;
+
+ uri = g_filename_to_uri (icon_file, NULL, NULL);
+ gtk_html_stream_printf (
+ stream, "<IMG ALT=\"%s\" SRC=\"%s\">",
+ category, uri);
+ g_free (uri);
+ } else {
+ if (iter != list)
+ g_string_append_len (string, ", ", 2);
+ g_string_append (string, category);
}
-
- e_cal_component_free_categories_list (l);
-
- gtk_html_stream_printf (stream, "<BR><BR><BR>");
}
+ if (string->len > 0)
+ gtk_html_stream_printf (stream, "%s</H3>", string->str);
+ e_cal_component_free_categories_list (list);
+ g_string_free (string, TRUE);
/* Start table */
gtk_html_stream_printf (stream, "<TABLE BORDER=\"0\" WIDTH=\"80%%\">"
@@ -235,26 +207,31 @@ write_html (GtkHTMLStream *stream, ECal *ecal, ECalComponent *comp, icaltimezone
e_cal_component_free_datetime (&dt);
/* write status */
- gtk_html_stream_printf (stream, "<TR><TD VALIGN=\"TOP\" ALIGN=\"RIGHT\"><B>%s</B></TD>", _("Status:"));
- e_cal_component_get_status (comp, &status);
- switch (status) {
- case ICAL_STATUS_INPROCESS :
- str = g_strdup (_("In Progress"));
- break;
- case ICAL_STATUS_COMPLETED :
- str = g_strdup (_("Completed"));
- break;
- case ICAL_STATUS_CANCELLED :
- str = g_strdup (_("Canceled"));
- break;
- case ICAL_STATUS_NONE :
- default :
- str = g_strdup (_("Not Started"));
- break;
- }
+ icalcomp = e_cal_component_get_icalcomponent (comp);
+ icalprop = icalcomponent_get_first_property (
+ icalcomp, ICAL_STATUS_PROPERTY);
+ if (icalprop != NULL) {
+ gtk_html_stream_printf (stream, "<TR><TD VALIGN=\"TOP\" ALIGN=\"RIGHT\"><B>%s</B></TD>", _("Status:"));
+ e_cal_component_get_status (comp, &status);
+ switch (status) {
+ case ICAL_STATUS_INPROCESS :
+ str = g_strdup (_("In Progress"));
+ break;
+ case ICAL_STATUS_COMPLETED :
+ str = g_strdup (_("Completed"));
+ break;
+ case ICAL_STATUS_CANCELLED :
+ str = g_strdup (_("Canceled"));
+ break;
+ case ICAL_STATUS_NONE :
+ default :
+ str = g_strdup (_("Not Started"));
+ break;
+ }
- gtk_html_stream_printf (stream, "<TD>%s</TD></TR>", str);
- g_free (str);
+ gtk_html_stream_printf (stream, "<TD>%s</TD></TR>", str);
+ g_free (str);
+ }
/* write priority */
e_cal_component_get_priority (comp, &priority_value);
@@ -278,15 +255,15 @@ write_html (GtkHTMLStream *stream, ECal *ecal, ECalComponent *comp, icaltimezone
/* write description and URL */
gtk_html_stream_printf (stream, "<TR><TD COLSPAN=\"2\"><HR></TD></TR>");
- e_cal_component_get_description_list (comp, &l);
- if (l) {
+ e_cal_component_get_description_list (comp, &list);
+ if (list) {
GSList *node;
gtk_html_stream_printf (stream, "<TR><TD VALIGN=\"TOP\" ALIGN=\"RIGHT\"><B>%s</B></TD>", _("Description:"));
gtk_html_stream_printf (stream, "<TD><TT>");
- for (node = l; node != NULL; node = node->next) {
+ for (node = list; node != NULL; node = node->next) {
gchar *html;
text = * (ECalComponentText *) node->data;
@@ -300,7 +277,7 @@ write_html (GtkHTMLStream *stream, ECal *ecal, ECalComponent *comp, icaltimezone
gtk_html_stream_printf (stream, "</TT></TD></TR>");
- e_cal_component_free_text_list (l);
+ e_cal_component_free_text_list (list);
}
/* URL */
@@ -317,143 +294,119 @@ write_html (GtkHTMLStream *stream, ECal *ecal, ECalComponent *comp, icaltimezone
}
static void
-e_cal_component_preview_init (ECalComponentPreview *preview)
+cal_component_preview_finalize (GObject *object)
{
ECalComponentPreviewPrivate *priv;
- GtkWidget *scroll;
- priv = g_new0 (ECalComponentPreviewPrivate, 1);
- preview->priv = priv;
+ priv = E_CAL_COMPONENT_PREVIEW_GET_PRIVATE (object);
+
+ /* XXX Nothing to do? */
- priv->html = gtk_html_new ();
- gtk_html_set_default_content_type (GTK_HTML (priv->html), "charset=utf-8");
- gtk_html_load_empty (GTK_HTML (priv->html));
+ /* Chain up to parent's finalize() method. */
+ G_OBJECT_CLASS (parent_class)->finalize (object);
+}
- g_signal_connect (G_OBJECT (priv->html), "url_requested",
- G_CALLBACK (e_cal_comp_preview_url_requested_cb), NULL);
- g_signal_connect (G_OBJECT (priv->html), "link_clicked",
- G_CALLBACK (on_link_clicked), preview);
- g_signal_connect (G_OBJECT (priv->html), "on_url",
- G_CALLBACK (on_url_cb), preview);
+static void
+cal_component_preview_class_init (ECalComponentPreviewClass *class)
+{
+ GObjectClass *object_class;
+ GtkHTMLClass *gtkhtml_class;
- scroll = gtk_scrolled_window_new (NULL, NULL);
- gtk_scrolled_window_set_policy (GTK_SCROLLED_WINDOW (scroll),
- GTK_POLICY_AUTOMATIC,
- GTK_POLICY_AUTOMATIC);
- gtk_scrolled_window_set_shadow_type (GTK_SCROLLED_WINDOW (scroll), GTK_SHADOW_IN);
+ parent_class = g_type_class_peek_parent (class);
+ g_type_class_add_private (class, sizeof (ECalComponentPreviewPrivate));
- gtk_container_add (GTK_CONTAINER (scroll), priv->html);
- gtk_container_add (GTK_CONTAINER (preview), scroll);
- gtk_widget_show_all (scroll);
+ object_class = G_OBJECT_CLASS (class);
+ object_class->finalize = cal_component_preview_finalize;
- priv->zone = icaltimezone_get_utc_timezone ();
+ gtkhtml_class = GTK_HTML_CLASS (class);
+ gtkhtml_class->link_clicked = cal_component_preview_link_clicked;
+ gtkhtml_class->on_url = cal_component_preview_on_url;
}
static void
-e_cal_component_preview_destroy (GtkObject *object)
+cal_component_preview_init (ECalComponentPreview *preview)
{
- ECalComponentPreview *preview;
- ECalComponentPreviewPrivate *priv;
-
- g_return_if_fail (object != NULL);
- g_return_if_fail (E_IS_CAL_COMPONENT_PREVIEW (object));
-
- preview = E_CAL_COMPONENT_PREVIEW (object);
- priv = preview->priv;
+ GtkHTML *html;
- if (priv) {
+ preview->priv = E_CAL_COMPONENT_PREVIEW_GET_PRIVATE (preview);
- g_free (priv);
- preview->priv = NULL;
- }
+ html = GTK_HTML (preview);
+ gtk_html_set_default_content_type (html, "charset=utf-8");
+ gtk_html_load_empty (html);
- if (GTK_OBJECT_CLASS (e_cal_component_preview_parent_class)->destroy)
- (* GTK_OBJECT_CLASS (e_cal_component_preview_parent_class)->destroy) (object);
+ preview->priv->zone = icaltimezone_get_utc_timezone ();
}
-static void
-e_cal_component_preview_class_init (ECalComponentPreviewClass *klass)
+GType
+e_cal_component_preview_get_type (void)
{
- GtkObjectClass *object_class;
-
- object_class = (GtkObjectClass *) klass;
+ static GType type = 0;
+
+ if (G_UNLIKELY (type == 0)) {
+ static const GTypeInfo type_info = {
+ sizeof (ECalComponentPreviewClass),
+ (GBaseInitFunc) NULL,
+ (GBaseFinalizeFunc) NULL,
+ (GClassInitFunc) cal_component_preview_class_init,
+ (GClassFinalizeFunc) NULL,
+ NULL, /* class_data */
+ sizeof (ECalComponentPreview),
+ 0, /* n_preallocs */
+ (GInstanceInitFunc) cal_component_preview_init,
+ NULL /* value_table */
+ };
+
+ type = g_type_register_static (
+ GTK_TYPE_HTML, "ECalComponentPreview", &type_info, 0);
+ }
- object_class->destroy = e_cal_component_preview_destroy;
+ return type;
}
GtkWidget *
e_cal_component_preview_new (void)
{
- ECalComponentPreview *preview;
-
- preview = g_object_new (e_cal_component_preview_get_type (), NULL);
-
- return GTK_WIDGET (preview);
+ return g_object_new (E_TYPE_CAL_COMPONENT_PREVIEW, NULL);
}
icaltimezone *
e_cal_component_preview_get_default_timezone (ECalComponentPreview *preview)
{
- ECalComponentPreviewPrivate *priv;
-
- g_return_val_if_fail (preview != NULL, NULL);
g_return_val_if_fail (E_IS_CAL_COMPONENT_PREVIEW (preview), NULL);
- priv = preview->priv;
-
- return priv->zone;
+ return preview->priv->zone;
}
void
-e_cal_component_preview_set_default_timezone (ECalComponentPreview *preview, icaltimezone *zone)
+e_cal_component_preview_set_default_timezone (ECalComponentPreview *preview,
+ icaltimezone *zone)
{
- ECalComponentPreviewPrivate *priv;
-
- g_return_if_fail (preview != NULL);
g_return_if_fail (E_IS_CAL_COMPONENT_PREVIEW (preview));
g_return_if_fail (zone != NULL);
- priv = preview->priv;
-
- priv->zone = zone;
+ preview->priv->zone = zone;
}
void
-e_cal_component_preview_display (ECalComponentPreview *preview, ECal *ecal, ECalComponent *comp)
+e_cal_component_preview_display (ECalComponentPreview *preview,
+ ECal *ecal,
+ ECalComponent *comp)
{
- ECalComponentPreviewPrivate *priv;
GtkHTMLStream *stream;
- g_return_if_fail (preview != NULL);
g_return_if_fail (E_IS_CAL_COMPONENT_PREVIEW (preview));
- g_return_if_fail (comp != NULL);
g_return_if_fail (E_IS_CAL_COMPONENT (comp));
- priv = preview->priv;
-
- stream = gtk_html_begin (GTK_HTML (priv->html));
- write_html (stream, ecal, comp, priv->zone);
+ stream = gtk_html_begin (GTK_HTML (preview));
+ cal_component_preview_write_html (
+ stream, ecal, comp, preview->priv->zone);
gtk_html_stream_close (stream, GTK_HTML_STREAM_OK);
}
void
e_cal_component_preview_clear (ECalComponentPreview *preview)
{
- ECalComponentPreviewPrivate *priv;
-
- g_return_if_fail (preview != NULL);
g_return_if_fail (E_IS_CAL_COMPONENT_PREVIEW (preview));
- priv = preview->priv;
-
- gtk_html_load_empty (GTK_HTML (priv->html));
-}
-
-GtkWidget *
-e_cal_component_preview_get_html (ECalComponentPreview *preview)
-{
- g_return_val_if_fail (preview != NULL, NULL);
- g_return_val_if_fail (E_IS_CAL_COMPONENT_PREVIEW (preview), NULL);
-
- return preview->priv->html;
+ gtk_html_load_empty (GTK_HTML (preview));
}
diff --git a/calendar/gui/e-cal-component-preview.h b/calendar/gui/e-cal-component-preview.h
index f1d26a79f7..8b2b0acd18 100644
--- a/calendar/gui/e-cal-component-preview.h
+++ b/calendar/gui/e-cal-component-preview.h
@@ -1,5 +1,4 @@
/*
- *
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
@@ -22,51 +21,62 @@
*
*/
-#ifndef _E_CAL_COMPONENT_PREVIEW_H_
-#define _E_CAL_COMPONENT_PREVIEW_H_
+#ifndef E_CAL_COMPONENT_PREVIEW_H
+#define E_CAL_COMPONENT_PREVIEW_H
#include <gtk/gtk.h>
#include <libecal/e-cal.h>
#include <gtkhtml/gtkhtml.h>
-#include <gtkhtml/gtkhtml-stream.h>
-#define E_TYPE_CAL_COMPONENT_PREVIEW (e_cal_component_preview_get_type ())
-#define E_CAL_COMPONENT_PREVIEW(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), E_TYPE_CAL_COMPONENT_PREVIEW, ECalComponentPreview))
-#define E_CAL_COMPONENT_PREVIEW_CLASS(klass) (G_TYPE_CHECK_INSTANCE_CAST_CLASS ((klass), E_TYPE_CAL_COMPONENT_PREVIEW, \
- ECalComponentPreviewClass))
-#define E_IS_CAL_COMPONENT_PREVIEW(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), E_TYPE_CAL_COMPONENT_PREVIEW))
-#define E_IS_CAL_COMPONENT_PREVIEW_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), E_TYPE_CAL_COMPONENT_PREVIEW))
+/* Standard GObject macros */
+#define E_TYPE_CAL_COMPONENT_PREVIEW \
+ (e_cal_component_preview_get_type ())
+#define E_CAL_COMPONENT_PREVIEW(obj) \
+ (G_TYPE_CHECK_INSTANCE_CAST \
+ ((obj), E_TYPE_CAL_COMPONENT_PREVIEW, ECalComponentPreview))
+#define E_CAL_COMPONENT_PREVIEW_CLASS(cls) \
+ (G_TYPE_CHECK_INSTANCE_CAST_CLASS \
+ ((cls), E_TYPE_CAL_COMPONENT_PREVIEW, ECalComponentPreviewClass))
+#define E_IS_CAL_COMPONENT_PREVIEW(obj) \
+ (G_TYPE_CHECK_INSTANCE_TYPE \
+ ((obj), E_TYPE_CAL_COMPONENT_PREVIEW))
+#define E_IS_CAL_COMPONENT_PREVIEW_CLASS(cls) \
+ (G_TYPE_CHECK_CLASS_TYPE \
+ ((cls), E_TYPE_CAL_COMPONENT_PREVIEW))
+#define E_CAL_COMPONENT_PREVIEW_GET_CLASS(obj) \
+ (G_TYPE_INSTANCE_GET_CLASS \
+ ((obj), E_TYPE_CAL_COMPONENT_PREVIEW, ECalComponentPreviewClass))
+
+G_BEGIN_DECLS
typedef struct _ECalComponentPreview ECalComponentPreview;
typedef struct _ECalComponentPreviewClass ECalComponentPreviewClass;
typedef struct _ECalComponentPreviewPrivate ECalComponentPreviewPrivate;
struct _ECalComponentPreview {
- GtkTable table;
-
- /* Private data */
+ GtkHTML parent;
ECalComponentPreviewPrivate *priv;
};
struct _ECalComponentPreviewClass {
- GtkTableClass parent_class;
+ GtkHTMLClass parent_class;
/* Notification signals */
void (* selection_changed) (ECalComponentPreview *preview, gint n_selected);
};
-GType e_cal_component_preview_get_type (void);
-GtkWidget *e_cal_component_preview_new (void);
-
-icaltimezone *e_cal_component_preview_get_default_timezone (ECalComponentPreview *preview);
-void e_cal_component_preview_set_default_timezone (ECalComponentPreview *preview, icaltimezone *zone);
-
-void e_cal_component_preview_display (ECalComponentPreview *preview, ECal *ecal, ECalComponent *comp);
-void e_cal_component_preview_clear (ECalComponentPreview *preview);
-
-/* Callback used when GtkHTML widget requests URL */
-void e_cal_comp_preview_url_requested_cb (GtkHTML *html, const gchar *url, GtkHTMLStream *html_stream, gpointer data);
+GType e_cal_component_preview_get_type(void);
+GtkWidget * e_cal_component_preview_new (void);
+icaltimezone * e_cal_component_preview_get_default_timezone
+ (ECalComponentPreview *preview);
+void e_cal_component_preview_set_default_timezone
+ (ECalComponentPreview *preview,
+ icaltimezone *zone);
+void e_cal_component_preview_display (ECalComponentPreview *preview,
+ ECal *ecal,
+ ECalComponent *comp);
+void e_cal_component_preview_clear (ECalComponentPreview *preview);
-GtkWidget *e_cal_component_preview_get_html (ECalComponentPreview *preview);
+G_END_DECLS
-#endif /* _E_CAL_COMPONENT_PREVIEW_H_ */
+#endif /* E_CAL_COMPONENT_PREVIEW_H */
diff --git a/calendar/gui/e-cal-event.c b/calendar/gui/e-cal-event.c
index 86bd20e4e7..eb37ae190f 100644
--- a/calendar/gui/e-cal-event.c
+++ b/calendar/gui/e-cal-event.c
@@ -43,10 +43,12 @@ static void
ece_target_free (EEvent *ev, EEventTarget *t)
{
switch (t->type) {
- case E_CAL_EVENT_TARGET_COMPONENT: {
- ECalEventTargetComponent *s = (ECalEventTargetComponent *) t;
- if (s->component)
- g_object_unref (s->component);
+ case E_CAL_EVENT_TARGET_MODULE: {
+ ECalEventTargetModule *s = (ECalEventTargetModule *) t;
+ if (s->shell_backend)
+ g_object_unref (s->shell_backend);
+ if (s->source_list)
+ g_object_unref (s->source_list);
break; }
}
@@ -92,12 +94,13 @@ e_cal_event_peek (void)
return e_cal_event;
}
-ECalEventTargetComponent *
-e_cal_event_target_new_component (ECalEvent *ece, struct _CalendarComponent *component, guint32 flags)
+ECalEventTargetModule *
+e_cal_event_target_new_module (ECalEvent *ece, EShellBackend *shell_backend, ESourceList *source_list, guint32 flags)
{
- ECalEventTargetComponent *t = e_event_target_new (&ece->event, E_CAL_EVENT_TARGET_COMPONENT, sizeof (*t));
+ ECalEventTargetModule *t = e_event_target_new (&ece->event, E_CAL_EVENT_TARGET_MODULE, sizeof (*t));
- t->component = g_object_ref (component);
+ t->shell_backend = g_object_ref (shell_backend);
+ t->source_list = g_object_ref (source_list);
t->target.mask = ~flags;
return t;
@@ -107,13 +110,13 @@ e_cal_event_target_new_component (ECalEvent *ece, struct _CalendarComponent *com
static gpointer eceh_parent_class;
-static const EEventHookTargetMask eceh_component_masks[] = {
- { "migration", E_CAL_EVENT_COMPONENT_MIGRATION },
+static const EEventHookTargetMask eceh_module_masks[] = {
+ { "migration", E_CAL_EVENT_MODULE_MIGRATION },
{ NULL },
};
static const EEventHookTargetMap eceh_targets[] = {
- { "component", E_CAL_EVENT_TARGET_COMPONENT, eceh_component_masks },
+ { "module", E_CAL_EVENT_TARGET_MODULE, eceh_module_masks },
{ NULL },
};
diff --git a/calendar/gui/e-cal-event.h b/calendar/gui/e-cal-event.h
index 8fb28dfd17..e9f5987673 100644
--- a/calendar/gui/e-cal-event.h
+++ b/calendar/gui/e-cal-event.h
@@ -25,8 +25,10 @@
#define __E_CAL_EVENT_H__
#include <glib-object.h>
+#include <libedataserver/e-source-list.h>
#include "e-util/e-event.h"
+#include "shell/e-shell-backend.h"
G_BEGIN_DECLS
@@ -34,20 +36,20 @@ typedef struct _ECalEvent ECalEvent;
typedef struct _ECalEventClass ECalEventClass;
enum _e_cal_event_target_t {
- E_CAL_EVENT_TARGET_COMPONENT
+ E_CAL_EVENT_TARGET_MODULE,
};
-/* Flags that describe TARGET_COMPONENT */
+/* Flags that describe TARGET_MODULE */
enum {
- E_CAL_EVENT_COMPONENT_MIGRATION = 1 << 0
+ E_CAL_EVENT_MODULE_MIGRATION = 1 << 0,
};
-typedef struct _ECalEventTargetComponent ECalEventTargetComponent;
+typedef struct _ECalEventTargetModule ECalEventTargetModule;
-struct _ECalEventTargetComponent {
+struct _ECalEventTargetModule {
EEventTarget target;
-
- struct _CalendarComponent *component;
+ EShellBackend *shell_backend;
+ ESourceList *source_list;
};
struct _ECalEvent {
@@ -62,7 +64,7 @@ struct _ECalEventClass {
GType e_cal_event_get_type (void);
ECalEvent* e_cal_event_peek (void);
-ECalEventTargetComponent* e_cal_event_target_new_component (ECalEvent *ece, struct _CalendarComponent *component, guint32 flags);
+ECalEventTargetModule* e_cal_event_target_new_module (ECalEvent *ece, EShellBackend *shell_backend, ESourceList *source_list, guint32 flags);
/* ********************************************************************** */
diff --git a/calendar/gui/e-cal-list-view.c b/calendar/gui/e-cal-list-view.c
index 0081dc1340..65a8ec5f9d 100644
--- a/calendar/gui/e-cal-list-view.c
+++ b/calendar/gui/e-cal-list-view.c
@@ -25,7 +25,7 @@
#endif
#include "e-cal-list-view.h"
-#include "ea-calendar.h"
+/*#include "a11y/ea-calendar.h"*/ /* KILL-BONOBO */
#include <math.h>
#include <time.h>
@@ -41,7 +41,7 @@
#include <table/e-cell-text.h>
#include <table/e-cell-combo.h>
#include <misc/e-popup-menu.h>
-#include <misc/e-cell-date-edit.h>
+#include <table/e-cell-date-edit.h>
#include <e-util/e-categories-config.h>
#include <e-util/e-dialog-utils.h>
#include <e-util/e-util-private.h>
@@ -56,7 +56,6 @@
#include "dialogs/recur-comp.h"
#include "comp-util.h"
#include "itip-utils.h"
-#include "calendar-commands.h"
#include "calendar-config.h"
#include "goto.h"
#include "misc.h"
@@ -358,10 +357,12 @@ e_cal_list_view_destroy (GtkObject *object)
static void
e_cal_list_view_show_popup_menu (ECalListView *cal_list_view, gint row, GdkEvent *gdk_event)
{
+#if 0 /* KILL-BONOBO */
GtkMenu *menu;
menu = e_calendar_view_create_popup_menu (E_CALENDAR_VIEW (cal_list_view));
gtk_menu_popup(menu, NULL, NULL, NULL, NULL, gdk_event?gdk_event->button.button:0, gdk_event?gdk_event->button.time:gtk_get_current_event_time());
+#endif
}
static gboolean
diff --git a/calendar/gui/e-cal-model-memos.c b/calendar/gui/e-cal-model-memos.c
index dc21b9bdda..38e55ef71a 100644
--- a/calendar/gui/e-cal-model-memos.c
+++ b/calendar/gui/e-cal-model-memos.c
@@ -260,7 +260,7 @@ ecmm_fill_component_from_model (ECalModel *model, ECalModelComponent *comp_data,
/**
* e_cal_model_memos_new
*/
-ECalModelMemos *
+ECalModel *
e_cal_model_memos_new (void)
{
return g_object_new (E_TYPE_CAL_MODEL_MEMOS, NULL);
diff --git a/calendar/gui/e-cal-model-memos.h b/calendar/gui/e-cal-model-memos.h
index 34b8e5a14d..f7a5d17091 100644
--- a/calendar/gui/e-cal-model-memos.h
+++ b/calendar/gui/e-cal-model-memos.h
@@ -55,8 +55,8 @@ typedef struct {
ECalModelClass parent_class;
} ECalModelMemosClass;
-GType e_cal_model_memos_get_type (void);
-ECalModelMemos *e_cal_model_memos_new (void);
+GType e_cal_model_memos_get_type (void);
+ECalModel * e_cal_model_memos_new (void);
G_END_DECLS
diff --git a/calendar/gui/e-cal-model-tasks.c b/calendar/gui/e-cal-model-tasks.c
index d951d13878..6d841c495e 100644
--- a/calendar/gui/e-cal-model-tasks.c
+++ b/calendar/gui/e-cal-model-tasks.c
@@ -1106,7 +1106,7 @@ ecmt_fill_component_from_model (ECalModel *model, ECalModelComponent *comp_data,
/**
* e_cal_model_tasks_new
*/
-ECalModelTasks *
+ECalModel *
e_cal_model_tasks_new (void)
{
return g_object_new (E_TYPE_CAL_MODEL_TASKS, NULL);
diff --git a/calendar/gui/e-cal-model-tasks.h b/calendar/gui/e-cal-model-tasks.h
index 0900d1e155..88b0d071e2 100644
--- a/calendar/gui/e-cal-model-tasks.h
+++ b/calendar/gui/e-cal-model-tasks.h
@@ -64,7 +64,7 @@ typedef struct {
} ECalModelTasksClass;
GType e_cal_model_tasks_get_type (void);
-ECalModelTasks *e_cal_model_tasks_new (void);
+ECalModel * e_cal_model_tasks_new (void);
void e_cal_model_tasks_mark_comp_complete (ECalModelTasks *model, ECalModelComponent *comp_data);
void e_cal_model_tasks_mark_comp_incomplete (ECalModelTasks *model, ECalModelComponent *comp_data);
diff --git a/calendar/gui/e-cal-model.c b/calendar/gui/e-cal-model.c
index bd1913edab..0ddcc20d07 100644
--- a/calendar/gui/e-cal-model.c
+++ b/calendar/gui/e-cal-model.c
@@ -35,8 +35,8 @@
#include "e-cal-model.h"
#include "itip-utils.h"
#include "misc.h"
-#include "e-util/e-util.h"
#include "calendar-config.h"
+#include "e-util/e-util.h"
typedef struct {
ECal *client;
diff --git a/calendar/gui/e-calendar-selector.c b/calendar/gui/e-calendar-selector.c
new file mode 100644
index 0000000000..54858e56f9
--- /dev/null
+++ b/calendar/gui/e-calendar-selector.c
@@ -0,0 +1,226 @@
+/* -*- Mode: C; indent-tabs-mode: t; c-basic-offset: 8; tab-width: 8 -*- */
+/* e-calendar-selector.c
+ *
+ * Copyright (C) 1999-2008 Novell, Inc. (www.novell.com)
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of version 2 of the GNU General Public
+ * License as published by the Free Software Foundation.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public
+ * License along with this program; if not, write to the
+ * Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
+ * Boston, MA 02110-1301, USA.
+ */
+
+#include "e-calendar-selector.h"
+
+#include <libecal/e-cal.h>
+#include "common/authentication.h"
+
+#define E_CALENDAR_SELECTOR_GET_PRIVATE(obj) \
+ (G_TYPE_INSTANCE_GET_PRIVATE \
+ ((obj), E_TYPE_CALENDAR_SELECTOR, ECalendarSelectorPrivate))
+
+struct _ECalendarSelectorPrivate {
+ gint dummy_value;
+};
+
+enum {
+ DND_TARGET_TYPE_CALENDAR_LIST
+};
+
+static GtkTargetEntry drag_types[] = {
+ { "text/calendar", 0, DND_TARGET_TYPE_CALENDAR_LIST },
+ { "text/x-calendar", 0, DND_TARGET_TYPE_CALENDAR_LIST }
+};
+
+static gpointer parent_class;
+
+static gboolean
+calendar_selector_update_single_object (ECal *client,
+ icalcomponent *icalcomp)
+{
+ gchar *uid;
+ icalcomponent *tmp_icalcomp;
+
+ uid = (gchar *) icalcomponent_get_uid (icalcomp);
+
+ if (e_cal_get_object (client, uid, NULL, &tmp_icalcomp, NULL))
+ return e_cal_modify_object (
+ client, icalcomp, CALOBJ_MOD_ALL, NULL);
+
+ return e_cal_create_object (client, icalcomp, &uid, NULL);
+}
+
+static gboolean
+calendar_selector_update_objects (ECal *client,
+ icalcomponent *icalcomp)
+{
+ icalcomponent *subcomp;
+ icalcomponent_kind kind;
+
+ kind = icalcomponent_isa (icalcomp);
+ if (kind == ICAL_VTODO_COMPONENT || kind == ICAL_VEVENT_COMPONENT)
+ return calendar_selector_update_single_object (
+ client, icalcomp);
+ else if (kind != ICAL_VCALENDAR_COMPONENT)
+ return FALSE;
+
+ subcomp = icalcomponent_get_first_component (
+ icalcomp, ICAL_ANY_COMPONENT);
+ while (subcomp != NULL) {
+ gboolean success;
+
+ kind = icalcomponent_isa (subcomp);
+ if (kind == ICAL_VTIMEZONE_COMPONENT) {
+ icaltimezone *zone;
+
+ zone = icaltimezone_new ();
+ icaltimezone_set_component (zone, subcomp);
+
+ success = e_cal_add_timezone (client, zone, NULL);
+ icaltimezone_free (zone, 1);
+ if (!success)
+ return FALSE;
+ } else if (kind == ICAL_VTODO_COMPONENT ||
+ kind == ICAL_VEVENT_COMPONENT) {
+ success = calendar_selector_update_single_object (
+ client, subcomp);
+ if (!success)
+ return FALSE;
+ }
+
+ subcomp = icalcomponent_get_next_component (
+ icalcomp, ICAL_ANY_COMPONENT);
+ }
+
+ return TRUE;
+}
+
+static gboolean
+calendar_selector_data_dropped (ESourceSelector *selector,
+ GtkSelectionData *selection_data,
+ ESource *destination,
+ GdkDragAction action,
+ guint info)
+{
+ GtkTreeView *tree_view;
+ GtkTreeModel *model;
+ GtkTreePath *path = NULL;
+ ECal *client;
+ icalcomponent *icalcomp;
+ const gchar *string;
+ gboolean remove_from_source;
+ gboolean success = FALSE;
+ gpointer object = NULL;
+
+ tree_view = GTK_TREE_VIEW (selector);
+ model = gtk_tree_view_get_model (tree_view);
+
+ string = (const gchar *) selection_data->data;
+ remove_from_source = (action == GDK_ACTION_MOVE);
+
+ icalcomp = icalparser_parse_string (string);
+
+ if (icalcomp == NULL)
+ goto exit;
+
+ /* FIXME Deal with GDK_ACTION_ASK. */
+ if (action == GDK_ACTION_COPY) {
+ gchar *uid;
+
+ uid = e_cal_component_gen_uid ();
+ icalcomponent_set_uid (icalcomp, uid);
+ }
+
+ client = auth_new_cal_from_source (
+ destination, E_CAL_SOURCE_TYPE_EVENT);
+
+ if (client != NULL) {
+ if (e_cal_open (client, TRUE, NULL)) {
+ success = TRUE;
+ calendar_selector_update_objects (client, icalcomp);
+ }
+
+ g_object_unref (client);
+ }
+
+ icalcomponent_free (icalcomp);
+
+ success = TRUE;
+
+exit:
+ if (path != NULL)
+ gtk_tree_path_free (path);
+
+ if (object != NULL)
+ g_object_unref (object);
+
+ return TRUE;
+}
+
+static void
+calendar_selector_class_init (ECalendarSelectorClass *class)
+{
+ ESourceSelectorClass *source_selector_class;
+
+ parent_class = g_type_class_peek_parent (class);
+ g_type_class_add_private (class, sizeof (ECalendarSelectorPrivate));
+
+ source_selector_class = E_SOURCE_SELECTOR_CLASS (class);
+ source_selector_class->data_dropped = calendar_selector_data_dropped;
+}
+
+static void
+calendar_selector_init (ECalendarSelector *selector)
+{
+ selector->priv = E_CALENDAR_SELECTOR_GET_PRIVATE (selector);
+
+ gtk_drag_dest_set (
+ GTK_WIDGET (selector), GTK_DEST_DEFAULT_ALL,
+ drag_types, G_N_ELEMENTS (drag_types),
+ GDK_ACTION_COPY | GDK_ACTION_MOVE);
+}
+
+GType
+e_calendar_selector_get_type (void)
+{
+ static GType type = 0;
+
+ if (G_UNLIKELY (type == 0)) {
+ const GTypeInfo type_info = {
+ sizeof (ECalendarSelectorClass),
+ (GBaseInitFunc) NULL,
+ (GBaseFinalizeFunc) NULL,
+ (GClassInitFunc) calendar_selector_class_init,
+ (GClassFinalizeFunc) NULL,
+ NULL, /* class_data */
+ sizeof (ECalendarSelector),
+ 0, /* n_preallocs */
+ (GInstanceInitFunc) calendar_selector_init,
+ NULL /* value_table */
+ };
+
+ type = g_type_register_static (
+ E_TYPE_SOURCE_SELECTOR, "ECalendarSelector",
+ &type_info, 0);
+ }
+
+ return type;
+}
+
+GtkWidget *
+e_calendar_selector_new (ESourceList *source_list)
+{
+ g_return_val_if_fail (E_IS_SOURCE_LIST (source_list), NULL);
+
+ return g_object_new (
+ E_TYPE_CALENDAR_SELECTOR,
+ "source-list", source_list, NULL);
+}
diff --git a/calendar/gui/e-calendar-selector.h b/calendar/gui/e-calendar-selector.h
new file mode 100644
index 0000000000..65d9a2fc81
--- /dev/null
+++ b/calendar/gui/e-calendar-selector.h
@@ -0,0 +1,66 @@
+/* -*- Mode: C; indent-tabs-mode: t; c-basic-offset: 8; tab-width: 8 -*- */
+/* e-calendar-selector.h
+ *
+ * Copyright (C) 1999-2008 Novell, Inc. (www.novell.com)
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of version 2 of the GNU General Public
+ * License as published by the Free Software Foundation.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public
+ * License along with this program; if not, write to the
+ * Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
+ * Boston, MA 02110-1301, USA.
+ */
+
+#ifndef E_CALENDAR_SELECTOR_H
+#define E_CALENDAR_SELECTOR_H
+
+#include <libedataserver/e-source-list.h>
+#include <libedataserverui/e-source-selector.h>
+
+/* Standard GObject macros */
+#define E_TYPE_CALENDAR_SELECTOR \
+ (e_calendar_selector_get_type ())
+#define E_CALENDAR_SELECTOR(obj) \
+ (G_TYPE_CHECK_INSTANCE_CAST \
+ ((obj), E_TYPE_CALENDAR_SELECTOR, ECalendarSelector))
+#define E_CALENDAR_SELECTOR_CLASS(cls) \
+ (G_TYPE_CHECK_CLASS_CAST \
+ ((cls), E_TYPE_CALENDAR_SELECTOR, ECalendarSelectorClass))
+#define E_IS_CALENDAR_SELECTOR(obj) \
+ (G_TYPE_CHECK_INSTANCE_TYPE \
+ ((obj), E_TYPE_CALENDAR_SELECTOR))
+#define E_IS_CALENDAR_SELECTOR_CLASS(cls) \
+ (G_TYPE_CHECK_CLASS_TYPE \
+ ((cls), E_TYPE_CALENDAR_SELECTOR))
+#define E_CALENDAR_SELECTOR_GET_CLASS(obj) \
+ (G_TYPE_INSTANCE_GET_CLASS \
+ ((obj), E_TYPE_CALENDAR_SELECTOR, ECalendarSelectorClass))
+
+G_BEGIN_DECLS
+
+typedef struct _ECalendarSelector ECalendarSelector;
+typedef struct _ECalendarSelectorClass ECalendarSelectorClass;
+typedef struct _ECalendarSelectorPrivate ECalendarSelectorPrivate;
+
+struct _ECalendarSelector {
+ ESourceSelector parent;
+ ECalendarSelectorPrivate *priv;
+};
+
+struct _ECalendarSelectorClass {
+ ESourceSelectorClass parent_class;
+};
+
+GType e_calendar_selector_get_type (void);
+GtkWidget * e_calendar_selector_new (ESourceList *source_list);
+
+G_END_DECLS
+
+#endif /* E_CALENDAR_SELECTOR_H */
diff --git a/calendar/gui/e-calendar-table-config.c b/calendar/gui/e-calendar-table-config.c
index fb8d18c189..8b73056f51 100644
--- a/calendar/gui/e-calendar-table-config.c
+++ b/calendar/gui/e-calendar-table-config.c
@@ -24,221 +24,245 @@
#include "e-cell-date-edit-config.h"
#include "e-calendar-table-config.h"
+#define E_CALENDAR_TABLE_CONFIG_GET_PRIVATE(obj) \
+ (G_TYPE_INSTANCE_GET_PRIVATE \
+ ((obj), E_TYPE_CALENDAR_TABLE_CONFIG, ECalendarTableConfigPrivate))
+
struct _ECalendarTableConfigPrivate {
ECalendarTable *table;
-
ECellDateEditConfig *cell_config;
-
GList *notifications;
};
-/* Property IDs */
-enum props {
+enum {
PROP_0,
PROP_TABLE
};
-G_DEFINE_TYPE (ECalendarTableConfig, e_calendar_table_config, G_TYPE_OBJECT)
+static gpointer parent_class;
static void
-e_calendar_table_config_set_property (GObject *object, guint property_id, const GValue *value, GParamSpec *pspec)
+calendar_table_config_set_timezone (ECalendarTable *table)
{
- ECalendarTableConfig *table_config;
-
- table_config = E_CALENDAR_TABLE_CONFIG (object);
+ ECalModel *model;
+ icaltimezone *zone;
- switch (property_id) {
- case PROP_TABLE:
- e_calendar_table_config_set_table (table_config, g_value_get_object (value));
- break;
- default:
- G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
- break;
- }
+ zone = calendar_config_get_icaltimezone ();
+ model = e_calendar_table_get_model (table);
+ if (model != NULL)
+ e_cal_model_set_timezone (model, zone);
}
static void
-e_calendar_table_config_get_property (GObject *object, guint property_id, GValue *value, GParamSpec *pspec)
+calendar_table_config_timezone_changed_cb (GConfClient *client,
+ guint id,
+ GConfEntry *entry,
+ gpointer data)
{
- ECalendarTableConfig *table_config;
-
- table_config = E_CALENDAR_TABLE_CONFIG (object);
+ ECalendarTableConfig *table_config = data;
- switch (property_id) {
- case PROP_TABLE:
- g_value_set_object (value, e_calendar_table_config_get_table (table_config));
- break;
- default:
- G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
- break;
- }
+ calendar_table_config_set_timezone (table_config->priv->table);
}
static void
-e_calendar_table_config_dispose (GObject *object)
+calendar_table_config_set_twentyfour_hour (ECalendarTable *table)
{
- ECalendarTableConfig *table_config = E_CALENDAR_TABLE_CONFIG (object);
+ ECalModel *model;
+ gboolean use_24_hour;
- e_calendar_table_config_set_table (table_config, NULL);
+ use_24_hour = calendar_config_get_24_hour_format ();
- if (G_OBJECT_CLASS (e_calendar_table_config_parent_class)->dispose)
- G_OBJECT_CLASS (e_calendar_table_config_parent_class)->dispose (object);
+ model = e_calendar_table_get_model (table);
+ if (model != NULL)
+ e_cal_model_set_use_24_hour_format (model, use_24_hour);
}
static void
-e_calendar_table_config_finalize (GObject *object)
+calendar_table_config_twentyfour_hour_changed_cb (GConfClient *client,
+ guint id,
+ GConfEntry *entry,
+ gpointer data)
{
- ECalendarTableConfig *table_config = E_CALENDAR_TABLE_CONFIG (object);
- ECalendarTableConfigPrivate *priv;
-
- priv = table_config->priv;
-
- g_free (priv);
+ ECalendarTableConfig *table_config = data;
- if (G_OBJECT_CLASS (e_calendar_table_config_parent_class)->finalize)
- G_OBJECT_CLASS (e_calendar_table_config_parent_class)->finalize (object);
+ calendar_table_config_set_twentyfour_hour (table_config->priv->table);
}
static void
-e_calendar_table_config_class_init (ECalendarTableConfigClass *klass)
+calendar_table_config_set_property (GObject *object,
+ guint property_id,
+ const GValue *value,
+ GParamSpec *pspec)
{
- GObjectClass *gobject_class = G_OBJECT_CLASS (klass);
- GParamSpec *spec;
-
- /* Method override */
- gobject_class->set_property = e_calendar_table_config_set_property;
- gobject_class->get_property = e_calendar_table_config_get_property;
- gobject_class->dispose = e_calendar_table_config_dispose;
- gobject_class->finalize = e_calendar_table_config_finalize;
-
- spec = g_param_spec_object ("table", NULL, NULL, e_calendar_table_get_type (),
- G_PARAM_READABLE | G_PARAM_WRITABLE | G_PARAM_CONSTRUCT);
- g_object_class_install_property (gobject_class, PROP_TABLE, spec);
+ switch (property_id) {
+ case PROP_TABLE:
+ e_calendar_table_config_set_table (
+ E_CALENDAR_TABLE_CONFIG (object),
+ g_value_get_object (value));
+ return;
+ }
+
+ G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
}
static void
-e_calendar_table_config_init (ECalendarTableConfig *table_config)
+calendar_table_config_get_property (GObject *object,
+ guint property_id,
+ GValue *value,
+ GParamSpec *pspec)
{
- table_config->priv = g_new0 (ECalendarTableConfigPrivate, 1);
+ switch (property_id) {
+ case PROP_TABLE:
+ g_value_set_object (
+ value, e_calendar_table_config_get_table (
+ E_CALENDAR_TABLE_CONFIG (object)));
+ return;
+ }
+ G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
}
-ECalendarTableConfig *
-e_calendar_table_config_new (ECalendarTable *table)
+static void
+calendar_table_config_dispose (GObject *object)
{
- ECalendarTableConfig *table_config;
+ ECalendarTableConfig *table_config = E_CALENDAR_TABLE_CONFIG (object);
- table_config = g_object_new (e_calendar_table_config_get_type (), "table", table, NULL);
+ e_calendar_table_config_set_table (table_config, NULL);
- return table_config;
+ /* Chain up to parent's dispose() method. */
+ G_OBJECT_CLASS (parent_class)->dispose (object);
}
-ECalendarTable *
-e_calendar_table_config_get_table (ECalendarTableConfig *table_config)
+static void
+calendar_table_config_class_init (ECalendarTableConfigClass *class)
{
- ECalendarTableConfigPrivate *priv;
-
- g_return_val_if_fail (table_config != NULL, NULL);
- g_return_val_if_fail (E_IS_CALENDAR_TABLE_CONFIG (table_config), NULL);
-
- priv = table_config->priv;
-
- return priv->table;
+ GObjectClass *object_class;
+
+ parent_class = g_type_class_peek_parent (class);
+ g_type_class_add_private (class, sizeof (ECalendarTableConfigPrivate));
+
+ object_class = G_OBJECT_CLASS (class);
+ object_class->set_property = calendar_table_config_set_property;
+ object_class->get_property = calendar_table_config_get_property;
+ object_class->dispose = calendar_table_config_dispose;
+
+ g_object_class_install_property (
+ object_class,
+ PROP_TABLE,
+ g_param_spec_object (
+ "table",
+ NULL,
+ NULL,
+ E_TYPE_CALENDAR_TABLE,
+ G_PARAM_READWRITE |
+ G_PARAM_CONSTRUCT));
}
static void
-set_timezone (ECalendarTable *table)
+calendar_table_config_init (ECalendarTableConfig *table_config)
{
- ECalModel *model;
- icaltimezone *zone;
-
- zone = calendar_config_get_icaltimezone ();
- model = e_calendar_table_get_model (table);
- if (model)
- e_cal_model_set_timezone (model, zone);
+ table_config->priv =
+ E_CALENDAR_TABLE_CONFIG_GET_PRIVATE (table_config);
}
-static void
-timezone_changed_cb (GConfClient *client, guint id, GConfEntry *entry, gpointer data)
+GType
+e_calendar_table_config_get_type (void)
{
- ECalendarTableConfig *table_config = data;
- ECalendarTableConfigPrivate *priv;
-
- priv = table_config->priv;
+ static GType type = 0;
+
+ if (G_UNLIKELY (type == 0)) {
+ static const GTypeInfo type_info = {
+ sizeof (ECalendarTableConfigClass),
+ (GBaseInitFunc) NULL,
+ (GBaseFinalizeFunc) NULL,
+ (GClassInitFunc) calendar_table_config_class_init,
+ (GClassFinalizeFunc) NULL,
+ NULL, /* class_data */
+ sizeof (ECalendarTableConfig),
+ 0, /* n_preallocs */
+ (GInstanceInitFunc) calendar_table_config_init,
+ NULL /* value_table */
+ };
+
+ type = g_type_register_static (
+ G_TYPE_OBJECT, "ECalendarTableConfig", &type_info, 0);
+ }
- set_timezone (priv->table);
+ return type;
}
-static void
-set_twentyfour_hour (ECalendarTable *table)
+ECalendarTableConfig *
+e_calendar_table_config_new (ECalendarTable *table)
{
- ECalModel *model;
- gboolean use_24_hour;
+ g_return_val_if_fail (E_IS_CALENDAR_TABLE (table), NULL);
- use_24_hour = calendar_config_get_24_hour_format ();
-
- model = e_calendar_table_get_model (table);
- if (model)
- e_cal_model_set_use_24_hour_format (model, use_24_hour);
+ return g_object_new (
+ E_TYPE_CALENDAR_TABLE_CONFIG,
+ "table", table, NULL);
}
-static void
-twentyfour_hour_changed_cb (GConfClient *client, guint id, GConfEntry *entry, gpointer data)
+ECalendarTable *
+e_calendar_table_config_get_table (ECalendarTableConfig *table_config)
{
- ECalendarTableConfig *table_config = data;
- ECalendarTableConfigPrivate *priv;
-
- priv = table_config->priv;
+ g_return_val_if_fail (E_IS_CALENDAR_TABLE_CONFIG (table_config), NULL);
- set_twentyfour_hour (priv->table);
+ return table_config->priv->table;
}
void
-e_calendar_table_config_set_table (ECalendarTableConfig *table_config, ECalendarTable *table)
+e_calendar_table_config_set_table (ECalendarTableConfig *table_config,
+ ECalendarTable *table)
{
ECalendarTableConfigPrivate *priv;
- guint not;
- GList *l;
+ guint notification;
+ GList *list, *iter;
- g_return_if_fail (table_config != NULL);
g_return_if_fail (E_IS_CALENDAR_TABLE_CONFIG (table_config));
priv = table_config->priv;
- if (priv->table) {
- g_object_unref (priv->table);
- priv->table = NULL;
+ if (table_config->priv->table) {
+ g_object_unref (table_config->priv->table);
+ table_config->priv->table = NULL;
}
- if (priv->cell_config) {
- g_object_unref (priv->cell_config);
- priv->cell_config = NULL;
+ if (table_config->priv->cell_config) {
+ g_object_unref (table_config->priv->cell_config);
+ table_config->priv->cell_config = NULL;
}
- 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;
+ list = table_config->priv->notifications;
+ for (iter = list; iter != NULL; iter = iter->next) {
+ notification = GPOINTER_TO_UINT (iter->data);
+ calendar_config_remove_notification (notification);
+ }
+ g_list_free (list);
+ table_config->priv->notifications = NULL;
- /* If the new view is NULL, return right now */
- if (!table)
+ if (table == NULL)
return;
- priv->table = g_object_ref (table);
+ table_config->priv->table = g_object_ref (table);
/* Time zone */
- set_timezone (table);
+ calendar_table_config_set_timezone (table);
- not = calendar_config_add_notification_timezone (timezone_changed_cb, table_config);
- priv->notifications = g_list_prepend (priv->notifications, GUINT_TO_POINTER (not));
+ notification = calendar_config_add_notification_timezone (
+ calendar_table_config_timezone_changed_cb, table_config);
+ table_config->priv->notifications = g_list_prepend (
+ table_config->priv->notifications,
+ GUINT_TO_POINTER (notification));
/* 24 Hour format */
- set_twentyfour_hour (table);
+ calendar_table_config_set_twentyfour_hour (table);
- not = calendar_config_add_notification_24_hour_format (twentyfour_hour_changed_cb, table_config);
- priv->notifications = g_list_prepend (priv->notifications, GUINT_TO_POINTER (not));
+ notification = calendar_config_add_notification_24_hour_format (
+ calendar_table_config_twentyfour_hour_changed_cb, table_config);
+ table_config->priv->notifications = g_list_prepend (
+ table_config->priv->notifications,
+ GUINT_TO_POINTER (notification));
/* Date cell */
- priv->cell_config = e_cell_date_edit_config_new (table->dates_cell);
+ table_config->priv->cell_config =
+ e_cell_date_edit_config_new (table->dates_cell);
}
diff --git a/calendar/gui/e-calendar-table-config.h b/calendar/gui/e-calendar-table-config.h
index 93588a6e57..36745064d1 100644
--- a/calendar/gui/e-calendar-table-config.h
+++ b/calendar/gui/e-calendar-table-config.h
@@ -21,24 +21,38 @@
*
*/
-#ifndef _E_CALENDAR_TABLE_CONFIG_H_
-#define _E_CALENDAR_TABLE_CONFIG_H_
+#ifndef E_CALENDAR_TABLE_CONFIG_H
+#define E_CALENDAR_TABLE_CONFIG_H
#include "e-calendar-table.h"
-G_BEGIN_DECLS
+/* Standard GObject macros */
+#define E_TYPE_CALENDAR_TABLE_CONFIG \
+ (e_calendar_table_config_get_type ())
+#define E_CALENDAR_TABLE_CONFIG(obj) \
+ (G_TYPE_CHECK_INSTANCE_CAST \
+ ((obj), E_TYPE_CALENDAR_TABLE_CONFIG, ECalendarTableConfig))
+#define E_CALENDAR_TABLE_CONFIG_CLASS(cls) \
+ (G_TYPE_CHECK_CLASS_CAST \
+ ((cls), E_TYPE_CALENDAR_TABLE_CONFIG, ECalendarTableConfigClass))
+#define E_IS_CALENDAR_TABLE_CONFIG(obj) \
+ (G_TYPE_CHECK_INSTANCE_TYPE \
+ ((obj), E_TYPE_CALENDAR_TABLE_CONFIG))
+#define E_IS_CALENDAR_TABLE_CONFIG_CLASS(cls) \
+ (G_TYPE_CHECK_CLASS_TYPE \
+ ((cls), E_TYPE_CALENDAR_TABLE_CONFIG))
+#define E_CALENDAR_TABLE_CONFIG_GET_CLASS(obj) \
+ (G_TYPE_INSTANCE_GET_CLASS \
+ ((obj), E_TYPE_CALENDAR_TABLE_CONFIG, ECalendarTableConfigClass))
-#define E_CALENDAR_TABLE_CONFIG(obj) G_TYPE_CHECK_INSTANCE_CAST (obj, e_calendar_table_config_get_type (), ECalendarTableConfig)
-#define E_CALENDAR_TABLE_CONFIG_CLASS(klass) G_TYPE_CHECK_CLASS_CAST (klass, e_calendar_table_config_get_type (), ECalendarTableConfigClass)
-#define E_IS_CALENDAR_TABLE_CONFIG(obj) G_TYPE_CHECK_INSTANCE_TYPE (obj, e_calendar_table_config_get_type ())
+G_BEGIN_DECLS
-typedef struct _ECalendarTableConfig ECalendarTableConfig;
-typedef struct _ECalendarTableConfigClass ECalendarTableConfigClass;
+typedef struct _ECalendarTableConfig ECalendarTableConfig;
+typedef struct _ECalendarTableConfigClass ECalendarTableConfigClass;
typedef struct _ECalendarTableConfigPrivate ECalendarTableConfigPrivate;
struct _ECalendarTableConfig {
GObject parent;
-
ECalendarTableConfigPrivate *priv;
};
@@ -46,11 +60,15 @@ struct _ECalendarTableConfigClass {
GObjectClass parent_class;
};
-GType e_calendar_table_config_get_type (void);
-ECalendarTableConfig *e_calendar_table_config_new (ECalendarTable *table);
-ECalendarTable *e_calendar_table_config_get_table (ECalendarTableConfig *view_config);
-void e_calendar_table_config_set_table (ECalendarTableConfig *view_config, ECalendarTable *table);
+GType e_calendar_table_config_get_type(void);
+ECalendarTableConfig *
+ e_calendar_table_config_new (ECalendarTable *table);
+ECalendarTable *e_calendar_table_config_get_table
+ (ECalendarTableConfig *table_config);
+void e_calendar_table_config_set_table
+ (ECalendarTableConfig *table_config,
+ ECalendarTable *table);
G_END_DECLS
-#endif
+#endif /* E_CALENDAR_TABLE_CONFIG_H */
diff --git a/calendar/gui/e-calendar-table.c b/calendar/gui/e-calendar-table.c
index 180680d5a3..3d08d7850f 100644
--- a/calendar/gui/e-calendar-table.c
+++ b/calendar/gui/e-calendar-table.c
@@ -32,7 +32,6 @@
#include <sys/stat.h>
#include <unistd.h>
-#include <glib.h>
#include <glib/gi18n.h>
#include <glib/gstdio.h>
#include <gtk/gtk.h>
@@ -44,12 +43,11 @@
#include <table/e-cell-combo.h>
#include <e-util/e-dialog-utils.h>
#include <e-util/e-util-private.h>
-#include <misc/e-cell-date-edit.h>
-#include <misc/e-cell-percent.h>
+#include <table/e-cell-date-edit.h>
+#include <table/e-cell-percent.h>
#include <libecal/e-cal-time-util.h>
#include <libedataserver/e-time-utils.h>
-#include "calendar-component.h"
#include "calendar-config.h"
#include "dialogs/delete-comp.h"
#include "dialogs/delete-error.h"
@@ -58,65 +56,50 @@
#include "e-calendar-table.h"
#include "e-calendar-view.h"
#include "e-cell-date-edit-text.h"
-#include "e-comp-editor-registry.h"
#include "print.h"
#include <e-util/e-icon-factory.h>
#include "e-cal-popup.h"
-#include "e-tasks.h"
#include "misc.h"
-enum TargetType{
- TARGET_TYPE_VCALENDAR
-};
+#define E_CALENDAR_TABLE_GET_PRIVATE(obj) \
+ (G_TYPE_INSTANCE_GET_PRIVATE \
+ ((obj), E_TYPE_CALENDAR_TABLE, ECalendarTablePrivate))
-static GtkTargetEntry target_types[] = {
- { (gchar *) "text/x-calendar", 0, TARGET_TYPE_VCALENDAR },
- { (gchar *) "text/calendar", 0, TARGET_TYPE_VCALENDAR }
+struct _ECalendarTablePrivate {
+ gpointer shell_view; /* weak pointer */
+ ECalModel *model;
};
-static guint n_target_types = G_N_ELEMENTS (target_types);
+enum {
+ PROP_0,
+ PROP_MODEL,
+ PROP_SHELL_VIEW
+};
-extern ECompEditorRegistry *comp_editor_registry;
-
-static void e_calendar_table_destroy (GtkObject *object);
-
-static void e_calendar_table_on_double_click (ETable *table,
- gint row,
- gint col,
- GdkEvent *event,
- ECalendarTable *cal_table);
-static gint e_calendar_table_show_popup_menu (ETable *table,
- GdkEvent *gdk_event,
- ECalendarTable *cal_table);
-
-static gint e_calendar_table_on_right_click (ETable *table,
- gint row,
- gint col,
- GdkEvent *event,
- ECalendarTable *cal_table);
-static gboolean e_calendar_table_on_popup_menu (GtkWidget *widget,
- gpointer data);
-
-static gint e_calendar_table_on_key_press (ETable *table,
- gint row,
- gint col,
- GdkEventKey *event,
- ECalendarTable *cal_table);
-
-static struct tm e_calendar_table_get_current_time (ECellDateEdit *ecde,
- gpointer data);
-static void mark_as_complete_cb (EPopup *ep, EPopupItem *pitem, gpointer data);
-
-static void hide_completed_rows (ECalModel *model, GList *clients_list, gchar *hide_sexp, GPtrArray *comp_objects);
-static void show_completed_rows (ECalModel *model, GList *clients_list, gchar *show_sexp, GPtrArray *comp_objects);
-
-/* Signal IDs */
enum {
+ OPEN_COMPONENT,
+ POPUP_EVENT,
+ STATUS_MESSAGE,
USER_CREATED,
LAST_SIGNAL
};
-static guint signals[LAST_SIGNAL] = { 0 };
+enum {
+ TARGET_TYPE_VCALENDAR
+};
+
+static GtkTargetEntry target_types[] = {
+ { "text/calendar", 0, TARGET_TYPE_VCALENDAR },
+ { "text/x-calendar", 0, TARGET_TYPE_VCALENDAR }
+};
+
+static guint n_target_types = G_N_ELEMENTS (target_types);
+
+static struct tm e_calendar_table_get_current_time (ECellDateEdit *ecde, gpointer data);
+
+static gpointer parent_class;
+static guint signals[LAST_SIGNAL];
+static GdkAtom clipboard_atom;
/* The icons to represent the task. */
#define E_CALENDAR_MODEL_NUM_ICONS 4
@@ -125,36 +108,45 @@ static const gchar * icon_names[E_CALENDAR_MODEL_NUM_ICONS] = {
};
static GdkPixbuf* icon_pixbufs[E_CALENDAR_MODEL_NUM_ICONS] = { NULL };
-static GdkAtom clipboard_atom = GDK_NONE;
+static void
+calendar_table_emit_open_component (ECalendarTable *cal_table,
+ ECalModelComponent *comp_data)
+{
+ guint signal_id = signals[OPEN_COMPONENT];
-G_DEFINE_TYPE (ECalendarTable, e_calendar_table, GTK_TYPE_TABLE)
+ g_signal_emit (cal_table, signal_id, 0, comp_data);
+}
static void
-e_calendar_table_class_init (ECalendarTableClass *class)
+calendar_table_emit_popup_event (ECalendarTable *cal_table,
+ GdkEvent *event)
{
- GtkObjectClass *object_class;
+ guint signal_id = signals[POPUP_EVENT];
- object_class = (GtkObjectClass *) class;
+ g_signal_emit (cal_table, signal_id, 0, event);
+}
+
+static void
+calendar_table_emit_status_message (ECalendarTable *cal_table,
+ const gchar *message,
+ gdouble percent)
+{
+ guint signal_id = signals[STATUS_MESSAGE];
- /* Method override */
- object_class->destroy = e_calendar_table_destroy;
+ g_signal_emit (cal_table, signal_id, 0, message, percent);
+}
- signals[USER_CREATED] =
- g_signal_new ("user_created",
- G_TYPE_FROM_CLASS (class),
- G_SIGNAL_RUN_LAST,
- G_STRUCT_OFFSET (ECalendarTableClass, user_created),
- NULL, NULL,
- g_cclosure_marshal_VOID__VOID,
- G_TYPE_NONE, 0);
+static void
+calendar_table_emit_user_created (ECalendarTable *cal_table)
+{
+ guint signal_id = signals[USER_CREATED];
- /* clipboard atom */
- if (!clipboard_atom)
- clipboard_atom = gdk_atom_intern ("CLIPBOARD", FALSE);
+ g_signal_emit (cal_table, signal_id, 0);
}
static gint
-date_compare_cb (gconstpointer a, gconstpointer b)
+calendar_table_date_compare_cb (gconstpointer a,
+ gconstpointer b)
{
ECellDateEditValue *dv1 = (ECellDateEditValue *) a;
ECellDateEditValue *dv2 = (ECellDateEditValue *) b;
@@ -182,24 +174,18 @@ date_compare_cb (gconstpointer a, gconstpointer b)
}
static gint
-percent_compare_cb (gconstpointer a, gconstpointer b)
+calendar_table_percent_compare_cb (gconstpointer a,
+ gconstpointer b)
{
gint percent1 = GPOINTER_TO_INT (a);
gint percent2 = GPOINTER_TO_INT (b);
- gint retval;
-
- if (percent1 > percent2)
- retval = 1;
- else if (percent1 < percent2)
- retval = -1;
- else
- retval = 0;
- return retval;
+ return (percent1 < percent2) ? -1 : (percent1 > percent2);
}
static gint
-priority_compare_cb (gconstpointer a, gconstpointer b)
+calendar_table_priority_compare_cb (gconstpointer a,
+ gconstpointer b)
{
gint priority1, priority2;
@@ -213,71 +199,85 @@ priority_compare_cb (gconstpointer a, gconstpointer b)
priority2 = 10;
/* We'll just use the ordering of the priority values. */
- if (priority1 < priority2)
- return -1;
- else if (priority1 > priority2)
- return 1;
- else
- return 0;
+ return (priority1 < priority2) ? -1 : (priority1 > priority2);
}
static gint
-status_from_string (const gchar *str)
-{
- gint status = -2;
-
- if (!str || !str[0])
- status = -1;
- else if (!g_utf8_collate (str, _("Not Started")))
- status = 0;
- else if (!g_utf8_collate (str, _("In Progress")))
- status = 1;
- else if (!g_utf8_collate (str, _("Completed")))
- status = 2;
- else if (!g_utf8_collate (str, _("Canceled")))
- status = 3;
-
- return status;
+calendar_table_status_compare_cb (gconstpointer a,
+ gconstpointer b)
+{
+ const gchar *string_a = a;
+ const gchar *string_b = b;
+ gint status_a = -2;
+ gint status_b = -2;
+
+ if (string_a == NULL || *string_a == '\0')
+ status_a = -1;
+ else if (!g_utf8_collate (string_a, _("Not Started")))
+ status_a = 0;
+ else if (!g_utf8_collate (string_a, _("In Progress")))
+ status_a = 1;
+ else if (!g_utf8_collate (string_a, _("Completed")))
+ status_a = 2;
+ else if (!g_utf8_collate (string_a, _("Canceled")))
+ status_a = 3;
+
+ if (string_b == NULL || *string_b == '\0')
+ status_b = -1;
+ else if (!g_utf8_collate (string_b, _("Not Started")))
+ status_b = 0;
+ else if (!g_utf8_collate (string_b, _("In Progress")))
+ status_b = 1;
+ else if (!g_utf8_collate (string_b, _("Completed")))
+ status_b = 2;
+ else if (!g_utf8_collate (string_b, _("Canceled")))
+ status_b = 3;
+
+ return (status_a < status_b) ? -1 : (status_a > status_b);
}
-static gint
-status_compare_cb (gconstpointer a, gconstpointer b)
+static void
+calendar_table_double_click_cb (ECalendarTable *cal_table,
+ gint row,
+ gint col,
+ GdkEvent *event)
{
- gint sa = status_from_string ((const gchar *)a);
- gint sb = status_from_string ((const gchar *)b);
-
- if (sa < sb)
- return -1;
- else if (sa > sb)
- return 1;
+ ECalModel *model;
+ ECalModelComponent *comp_data;
- return 0;
+ model = e_calendar_table_get_model (cal_table);
+ comp_data = e_cal_model_get_component_at (model, row);
+ calendar_table_emit_open_component (cal_table, comp_data);
}
static void
-row_appended_cb (ECalModel *model, ECalendarTable *cal_table)
+calendar_table_model_cal_view_progress_cb (ECalendarTable *cal_table,
+ const gchar *message,
+ gint progress,
+ ECalSourceType type)
{
- g_signal_emit (cal_table, signals[USER_CREATED], 0);
+ gdouble percent = (gdouble) progress;
+
+ calendar_table_emit_status_message (cal_table, message, percent);
}
static void
-get_time_as_text (struct icaltimetype *tt, icaltimezone *f_zone, icaltimezone *t_zone, gchar *buff, gint buff_len)
+calendar_table_model_cal_view_done_cb (ECalendarTable *cal_table,
+ ECalendarStatus status,
+ ECalSourceType type)
{
- struct tm tmp_tm;
-
- buff [0] = 0;
-
- tmp_tm = icaltimetype_to_tm_with_zone (tt, f_zone, t_zone);
- e_time_format_date_and_time (&tmp_tm,
- calendar_config_get_24_hour_format (),
- FALSE, FALSE,
- buff, buff_len);
+ calendar_table_emit_status_message (cal_table, NULL, -1.0);
}
-gboolean
-ec_query_tooltip (GtkWidget *widget, gint x, gint y, gboolean keyboard_mode, GtkTooltip *tooltip, GtkWidget *etable_wgt, ECalModel *model)
+static gboolean
+calendar_table_query_tooltip_cb (ECalendarTable *cal_table,
+ gint x,
+ gint y,
+ gboolean keyboard_mode,
+ GtkTooltip *tooltip)
{
- ECalModelComponent *comp;
+ ECalModel *model;
+ ECalModelComponent *comp_data;
gint row = -1, col = -1;
GtkWidget *box, *l, *w;
GtkStyle *style = gtk_widget_get_default_style ();
@@ -289,44 +289,44 @@ ec_query_tooltip (GtkWidget *widget, gint x, gint y, gboolean keyboard_mode, Gtk
ECalComponent *new_comp;
ECalComponentOrganizer organizer;
ECalComponentDateTime dtstart, dtdue;
+ icalcomponent *clone;
icaltimezone *zone, *default_zone;
GSList *desc, *p;
gint len;
ETable *etable;
ESelectionModel *esm;
+ struct tm tmp_tm;
if (keyboard_mode)
return FALSE;
- g_return_val_if_fail (widget != NULL, FALSE);
- g_return_val_if_fail (tooltip != NULL, FALSE);
- g_return_val_if_fail (E_IS_TABLE (etable_wgt), FALSE);
- g_return_val_if_fail (E_IS_CAL_MODEL (model), FALSE);
-
- etable = E_TABLE (etable_wgt);
-
+ etable = e_calendar_table_get_table (cal_table);
e_table_get_mouse_over_cell (etable, &row, &col);
if (row == -1 || !etable)
return FALSE;
- /* respect sorting option, the 'e_table_get_mouse_over_cell' returns sorted row, not the model one */
+ /* Respect sorting option; the 'e_table_get_mouse_over_cell'
+ * returns sorted row, not the model one. */
esm = e_table_get_selection_model (etable);
if (esm && esm->sorter && e_sorter_needs_sorting (esm->sorter))
row = e_sorter_sorted_to_model (esm->sorter, row);
- comp = e_cal_model_get_component_at (model, row);
- if (!comp || !comp->icalcomp)
+ model = e_calendar_table_get_model (cal_table);
+ comp_data = e_cal_model_get_component_at (model, row);
+ if (!comp_data || !comp_data->icalcomp)
return FALSE;
new_comp = e_cal_component_new ();
- if (!e_cal_component_set_icalcomponent (new_comp, icalcomponent_new_clone (comp->icalcomp))) {
+ clone = icalcomponent_new_clone (comp_data->icalcomp);
+ if (!e_cal_component_set_icalcomponent (new_comp, clone)) {
g_object_unref (new_comp);
return FALSE;
}
box = gtk_vbox_new (FALSE, 0);
- str = e_calendar_view_get_icalcomponent_summary (comp->client, comp->icalcomp, &free_text);
+ str = e_calendar_view_get_icalcomponent_summary (
+ comp_data->client, comp_data->icalcomp, &free_text);
if (!(str && *str)) {
if (free_text)
g_free ((gchar *)str);
@@ -366,7 +366,7 @@ ec_query_tooltip (GtkWidget *widget, gint x, gint y, gboolean keyboard_mode, Gtk
if (ptr) {
ptr++;
- /* To Translators: It will display "Organiser: NameOfTheUser <email@ofuser.com>" */
+ /* To Translators: It will display "Organizer: NameOfTheUser <email@ofuser.com>" */
tmp = g_strdup_printf (_("Organizer: %s <%s>"), organizer.cn, ptr);
} else {
/* With SunOne accounts, there may be no ':' in organiser.value */
@@ -383,12 +383,13 @@ ec_query_tooltip (GtkWidget *widget, gint x, gint y, gboolean keyboard_mode, Gtk
e_cal_component_get_dtstart (new_comp, &dtstart);
e_cal_component_get_due (new_comp, &dtdue);
- default_zone = e_cal_model_get_timezone (model);
+ default_zone = e_cal_model_get_timezone (model);
if (dtstart.tzid) {
zone = icalcomponent_get_timezone (e_cal_component_get_icalcomponent (new_comp), dtstart.tzid);
if (!zone)
- e_cal_get_timezone (comp->client, dtstart.tzid, &zone, NULL);
+ e_cal_get_timezone (
+ comp_data->client, dtstart.tzid, &zone, NULL);
if (!zone)
zone = default_zone;
} else {
@@ -398,7 +399,13 @@ ec_query_tooltip (GtkWidget *widget, gint x, gint y, gboolean keyboard_mode, Gtk
tmp2 = g_string_new ("");
if (dtstart.value) {
- get_time_as_text (dtstart.value, zone, default_zone, buff, 1000);
+ buff[0] = 0;
+
+ tmp_tm = icaltimetype_to_tm_with_zone (
+ dtstart.value, zone, default_zone);
+ e_time_format_date_and_time (
+ &tmp_tm, calendar_config_get_24_hour_format (),
+ FALSE, FALSE, buff, 1000);
if (buff [0]) {
g_string_append (tmp2, _("Start: "));
@@ -407,7 +414,13 @@ ec_query_tooltip (GtkWidget *widget, gint x, gint y, gboolean keyboard_mode, Gtk
}
if (dtdue.value) {
- get_time_as_text (dtdue.value, zone, default_zone, buff, 1000);
+ buff[0] = 0;
+
+ tmp_tm = icaltimetype_to_tm_with_zone (
+ dtdue.value, zone, default_zone);
+ e_time_format_date_and_time (
+ &tmp_tm, calendar_config_get_24_hour_format (),
+ FALSE, FALSE, buff, 1000);
if (buff [0]) {
if (tmp2->len)
@@ -429,7 +442,8 @@ ec_query_tooltip (GtkWidget *widget, gint x, gint y, gboolean keyboard_mode, Gtk
e_cal_component_free_datetime (&dtstart);
e_cal_component_free_datetime (&dtdue);
- tmp = e_calendar_view_get_attendees_status_info (new_comp, comp->client);
+ tmp = e_calendar_view_get_attendees_status_info (
+ new_comp, comp_data->client);
if (tmp) {
l = gtk_label_new (tmp);
gtk_misc_set_alignment (GTK_MISC (l), 0.0, 0.5);
@@ -474,22 +488,135 @@ ec_query_tooltip (GtkWidget *widget, gint x, gint y, gboolean keyboard_mode, Gtk
}
static gboolean
-query_tooltip_cb (GtkWidget *widget, gint x, gint y, gboolean keyboard_mode, GtkTooltip *tooltip, gpointer user_data)
+calendar_table_popup_menu_cb (ECalendarTable *cal_table)
{
- ECalendarTable *cal_table;
+ calendar_table_emit_popup_event (cal_table, NULL);
+
+ return TRUE;
+}
+
+static gint
+calendar_table_right_click_cb (ECalendarTable *cal_table,
+ gint row,
+ gint col,
+ GdkEvent *event)
+{
+ calendar_table_emit_popup_event (cal_table, event);
+
+ return TRUE;
+}
+
+static void
+calendar_table_set_model (ECalendarTable *cal_table,
+ ECalModel *model)
+{
+ g_return_if_fail (cal_table->priv->model == NULL);
+
+ cal_table->priv->model = g_object_ref (model);
+
+ g_signal_connect_swapped (
+ model, "row_appended",
+ G_CALLBACK (calendar_table_emit_user_created), cal_table);
+
+ g_signal_connect_swapped (
+ model, "cal-view-progress",
+ G_CALLBACK (calendar_table_model_cal_view_progress_cb),
+ cal_table);
+
+ g_signal_connect_swapped (
+ model, "cal-view-done",
+ G_CALLBACK (calendar_table_model_cal_view_done_cb),
+ cal_table);
+}
+
+static void
+calendar_table_set_shell_view (ECalendarTable *cal_table,
+ EShellView *shell_view)
+{
+ g_return_if_fail (cal_table->priv->shell_view == NULL);
+
+ cal_table->priv->shell_view = shell_view;
+
+ g_object_add_weak_pointer (
+ G_OBJECT (shell_view),
+ &cal_table->priv->shell_view);
+}
+
+static void
+calendar_table_set_property (GObject *object,
+ guint property_id,
+ const GValue *value,
+ GParamSpec *pspec)
+{
+ switch (property_id) {
+ case PROP_MODEL:
+ calendar_table_set_model (
+ E_CALENDAR_TABLE (object),
+ g_value_get_object (value));
+ return;
+
+ case PROP_SHELL_VIEW:
+ calendar_table_set_shell_view (
+ E_CALENDAR_TABLE (object),
+ g_value_get_object (value));
+ return;
+ }
+
+ G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
+}
+
+static void
+calendar_table_get_property (GObject *object,
+ guint property_id,
+ GValue *value,
+ GParamSpec *pspec)
+{
+ switch (property_id) {
+ case PROP_MODEL:
+ g_value_set_object (
+ value, e_calendar_table_get_model (
+ E_CALENDAR_TABLE (object)));
+ return;
+
+ case PROP_SHELL_VIEW:
+ g_value_set_object (
+ value, e_calendar_table_get_shell_view (
+ E_CALENDAR_TABLE (object)));
+ return;
+ }
- g_return_val_if_fail (E_IS_CALENDAR_TABLE (user_data), FALSE);
+ G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
+}
+
+static void
+calendar_table_dispose (GObject *object)
+{
+ ECalendarTablePrivate *priv;
- cal_table = E_CALENDAR_TABLE (user_data);
+ priv = E_CALENDAR_TABLE_GET_PRIVATE (object);
- return ec_query_tooltip (widget, x, y, keyboard_mode, tooltip, GTK_WIDGET (e_calendar_table_get_table (cal_table)), cal_table->model);
+ if (priv->shell_view != NULL) {
+ g_object_remove_weak_pointer (
+ G_OBJECT (priv->shell_view), &priv->shell_view);
+ priv->shell_view = NULL;
+ }
+
+ if (priv->model != NULL) {
+ g_object_unref (priv->model);
+ priv->model = NULL;
+ }
+
+ /* Chain up to parent's dispose() method. */
+ G_OBJECT_CLASS (parent_class)->dispose (object);
}
static void
-e_calendar_table_init (ECalendarTable *cal_table)
+calendar_table_constructed (GObject *object)
{
- GtkWidget *table;
- ETable *e_table;
+ ECalendarTable *cal_table;
+ GtkWidget *widget;
+ ECalModel *model;
+ ETable *table;
ECell *cell, *popup_cell;
ETableExtras *extras;
gint i;
@@ -498,22 +625,18 @@ e_calendar_table_init (ECalendarTable *cal_table)
AtkObject *a11y;
gchar *etspecfile;
- /* Create the model */
-
- cal_table->model = (ECalModel *) e_cal_model_tasks_new ();
- g_signal_connect (cal_table->model, "row_appended", G_CALLBACK (row_appended_cb), cal_table);
-
- cal_table->user_created_cal = NULL;
+ cal_table = E_CALENDAR_TABLE (object);
+ model = e_calendar_table_get_model (cal_table);
/* Create the header columns */
- extras = e_table_extras_new();
+ extras = e_table_extras_new ();
/*
* Normal string fields.
*/
cell = e_cell_text_new (NULL, GTK_JUSTIFY_LEFT);
- g_object_set (G_OBJECT (cell),
+ g_object_set (cell,
"strikeout_column", E_CAL_MODEL_TASKS_FIELD_STRIKEOUT,
"bold_column", E_CAL_MODEL_TASKS_FIELD_OVERDUE,
"bg_color_column", E_CAL_MODEL_FIELD_COLOR,
@@ -525,7 +648,7 @@ e_calendar_table_init (ECalendarTable *cal_table)
* Date fields.
*/
cell = e_cell_date_edit_text_new (NULL, GTK_JUSTIFY_LEFT);
- g_object_set (G_OBJECT (cell),
+ g_object_set (cell,
"strikeout_column", E_CAL_MODEL_TASKS_FIELD_STRIKEOUT,
"bold_column", E_CAL_MODEL_TASKS_FIELD_OVERDUE,
"bg_color_column", E_CAL_MODEL_FIELD_COLOR,
@@ -534,12 +657,13 @@ e_calendar_table_init (ECalendarTable *cal_table)
popup_cell = e_cell_date_edit_new ();
e_cell_popup_set_child (E_CELL_POPUP (popup_cell), cell);
g_object_unref (cell);
+
e_table_extras_add_cell (extras, "dateedit", popup_cell);
cal_table->dates_cell = E_CELL_DATE_EDIT (popup_cell);
- e_cell_date_edit_set_get_time_callback (E_CELL_DATE_EDIT (popup_cell),
- e_calendar_table_get_current_time,
- cal_table, NULL);
+ e_cell_date_edit_set_get_time_callback (
+ E_CELL_DATE_EDIT (popup_cell),
+ e_calendar_table_get_current_time, cal_table, NULL);
/*
* Combo fields.
@@ -547,7 +671,7 @@ e_calendar_table_init (ECalendarTable *cal_table)
/* Classification field. */
cell = e_cell_text_new (NULL, GTK_JUSTIFY_LEFT);
- g_object_set (G_OBJECT (cell),
+ g_object_set (cell,
"strikeout_column", E_CAL_MODEL_TASKS_FIELD_STRIKEOUT,
"bold_column", E_CAL_MODEL_TASKS_FIELD_OVERDUE,
"bg_color_column", E_CAL_MODEL_FIELD_COLOR,
@@ -664,13 +788,13 @@ e_calendar_table_init (ECalendarTable *cal_table)
e_table_extras_add_cell (extras, "calstatus", popup_cell);
e_table_extras_add_compare (extras, "date-compare",
- date_compare_cb);
+ calendar_table_date_compare_cb);
e_table_extras_add_compare (extras, "percent-compare",
- percent_compare_cb);
+ calendar_table_percent_compare_cb);
e_table_extras_add_compare (extras, "priority-compare",
- priority_compare_cb);
+ calendar_table_priority_compare_cb);
e_table_extras_add_compare (extras, "status-compare",
- status_compare_cb);
+ calendar_table_status_compare_cb);
/* Create pixmaps */
@@ -689,51 +813,174 @@ e_calendar_table_init (ECalendarTable *cal_table)
/* Create the table */
- etspecfile = g_build_filename (EVOLUTION_ETSPECDIR,
- "e-calendar-table.etspec",
- NULL);
- table = e_table_scrolled_new_from_spec_file (E_TABLE_MODEL (cal_table->model),
- extras,
- etspecfile,
- NULL);
+ etspecfile = g_build_filename (
+ EVOLUTION_ETSPECDIR, "e-calendar-table.etspec", NULL);
+ widget = e_table_scrolled_new_from_spec_file (
+ E_TABLE_MODEL (model), extras, etspecfile, NULL);
+ gtk_table_attach (
+ GTK_TABLE (cal_table), widget, 0, 1, 0, 1,
+ GTK_EXPAND | GTK_FILL, GTK_EXPAND | GTK_FILL, 0, 0);
+ cal_table->etable = widget;
+ gtk_widget_show (widget);
g_free (etspecfile);
- /* FIXME: this causes a message from GLib about 'extras' having only a floating
- reference */
- /* g_object_unref (extras); */
+ table = e_table_scrolled_get_table (E_TABLE_SCROLLED (widget));
+ g_signal_connect_swapped (
+ table, "double-click",
+ G_CALLBACK (calendar_table_double_click_cb), cal_table);
+ g_signal_connect_swapped (
+ table, "query-tooltip",
+ G_CALLBACK (calendar_table_query_tooltip_cb), cal_table);
+ g_signal_connect_swapped (
+ table, "popup-menu",
+ G_CALLBACK (calendar_table_popup_menu_cb), cal_table);
+ g_signal_connect_swapped (
+ table, "right-click",
+ G_CALLBACK (calendar_table_right_click_cb), cal_table);
+ gtk_widget_set_has_tooltip (GTK_WIDGET (table), TRUE);
+
+ a11y = gtk_widget_get_accessible (GTK_WIDGET (table));
+ if (a11y)
+ atk_object_set_name (a11y, _("Tasks"));
+}
- cal_table->etable = table;
- gtk_table_attach (GTK_TABLE (cal_table), table, 0, 1, 0, 1,
- GTK_EXPAND | GTK_FILL, GTK_EXPAND | GTK_FILL, 0, 0);
- gtk_widget_show (table);
+static void
+calendar_table_class_init (ECalendarTableClass *class)
+{
+ GObjectClass *object_class;
+
+ parent_class = g_type_class_peek_parent (class);
+ g_type_class_add_private (class, sizeof (ECalendarTablePrivate));
+
+ object_class = G_OBJECT_CLASS (class);
+ object_class->set_property = calendar_table_set_property;
+ object_class->get_property = calendar_table_get_property;
+ object_class->dispose = calendar_table_dispose;
+ object_class->constructed = calendar_table_constructed;
+
+ g_object_class_install_property (
+ object_class,
+ PROP_MODEL,
+ g_param_spec_object (
+ "model",
+ _("Model"),
+ NULL,
+ E_TYPE_CAL_MODEL,
+ G_PARAM_READWRITE |
+ G_PARAM_CONSTRUCT_ONLY));
+
+ g_object_class_install_property (
+ object_class,
+ PROP_SHELL_VIEW,
+ g_param_spec_object (
+ "shell-view",
+ _("Shell View"),
+ NULL,
+ E_TYPE_SHELL_VIEW,
+ G_PARAM_READWRITE |
+ G_PARAM_CONSTRUCT_ONLY));
+
+ signals[OPEN_COMPONENT] = g_signal_new (
+ "open-component",
+ G_TYPE_FROM_CLASS (class),
+ G_SIGNAL_RUN_LAST | G_SIGNAL_ACTION,
+ G_STRUCT_OFFSET (ECalendarTableClass, open_component),
+ NULL, NULL,
+ g_cclosure_marshal_VOID__OBJECT,
+ G_TYPE_NONE, 1,
+ E_TYPE_CAL_MODEL_COMPONENT);
+
+ signals[POPUP_EVENT] = g_signal_new (
+ "popup-event",
+ G_TYPE_FROM_CLASS (class),
+ G_SIGNAL_RUN_LAST | G_SIGNAL_ACTION,
+ G_STRUCT_OFFSET (ECalendarTableClass, popup_event),
+ NULL, NULL,
+ g_cclosure_marshal_VOID__BOXED,
+ G_TYPE_NONE, 1,
+ GDK_TYPE_EVENT | G_SIGNAL_TYPE_STATIC_SCOPE);
+
+ signals[STATUS_MESSAGE] = g_signal_new (
+ "status-message",
+ G_TYPE_FROM_CLASS (class),
+ G_SIGNAL_RUN_LAST | G_SIGNAL_ACTION,
+ G_STRUCT_OFFSET (ECalendarTableClass, status_message),
+ NULL, NULL,
+ g_cclosure_marshal_VOID__STRING,
+ G_TYPE_NONE, 1,
+ G_TYPE_STRING);
+
+ signals[USER_CREATED] = g_signal_new (
+ "user-created",
+ G_TYPE_FROM_CLASS (class),
+ G_SIGNAL_RUN_LAST | G_SIGNAL_ACTION,
+ G_STRUCT_OFFSET (ECalendarTableClass, user_created),
+ NULL, NULL,
+ g_cclosure_marshal_VOID__VOID,
+ G_TYPE_NONE, 0);
+
+ clipboard_atom = gdk_atom_intern ("CLIPBOARD", FALSE);
+}
- e_table = e_table_scrolled_get_table (E_TABLE_SCROLLED (table));
- g_signal_connect (e_table, "double_click", G_CALLBACK (e_calendar_table_on_double_click), cal_table);
- g_signal_connect (e_table, "right_click", G_CALLBACK (e_calendar_table_on_right_click), cal_table);
- g_signal_connect (e_table, "key_press", G_CALLBACK (e_calendar_table_on_key_press), cal_table);
- g_signal_connect (e_table, "popup_menu", G_CALLBACK (e_calendar_table_on_popup_menu), cal_table);
- g_signal_connect (e_table, "query-tooltip", G_CALLBACK (query_tooltip_cb), cal_table);
- gtk_widget_set_has_tooltip (GTK_WIDGET (e_table), TRUE);
+static void
+calendar_table_init (ECalendarTable *cal_table)
+{
+ cal_table->priv = E_CALENDAR_TABLE_GET_PRIVATE (cal_table);
+}
- a11y = gtk_widget_get_accessible ((GtkWidget *)e_table);
- if (a11y)
- atk_object_set_name (a11y, _("Tasks"));
+GType
+e_calendar_table_get_type (void)
+{
+ static GType type = 0;
+
+ if (G_UNLIKELY (type == 0)) {
+ static const GTypeInfo type_info = {
+ sizeof (ECalendarTableClass),
+ (GBaseInitFunc) NULL,
+ (GBaseFinalizeFunc) NULL,
+ (GClassInitFunc) calendar_table_class_init,
+ (GClassFinalizeFunc) NULL,
+ NULL, /* class_data */
+ sizeof (ECalendarTable),
+ 0, /* n_preallocs */
+ (GInstanceInitFunc) calendar_table_init,
+ NULL /* value_table */
+ };
+
+ type = g_type_register_static (
+ GTK_TYPE_TABLE, "ECalendarTable", &type_info, 0);
+ }
+
+ return type;
}
/**
* e_calendar_table_new:
- * @Returns: a new #ECalendarTable.
+ * @shell_view: an #EShellView
+ * @model: an #ECalModel for the table
+ *
+ * Returns a new #ECalendarTable.
*
- * Creates a new #ECalendarTable.
+ * Returns: a new #ECalendarTable
**/
GtkWidget *
-e_calendar_table_new (void)
+e_calendar_table_new (EShellView *shell_view,
+ ECalModel *model)
{
- GtkWidget *cal_table;
+ g_return_val_if_fail (E_IS_SHELL_VIEW (shell_view), NULL);
+ g_return_val_if_fail (E_IS_CAL_MODEL (model), NULL);
- cal_table = GTK_WIDGET (g_object_new (e_calendar_table_get_type (), NULL));
+ return g_object_new (
+ E_TYPE_CALENDAR_TABLE,
+ "model", model, "shell-view", shell_view, NULL);
+}
+
+EShellView *
+e_calendar_table_get_shell_view (ECalendarTable *cal_table)
+{
+ g_return_val_if_fail (E_IS_CALENDAR_TABLE (cal_table), NULL);
- return cal_table;
+ return cal_table->priv->shell_view;
}
/**
@@ -747,25 +994,9 @@ e_calendar_table_new (void)
ECalModel *
e_calendar_table_get_model (ECalendarTable *cal_table)
{
- g_return_val_if_fail (cal_table != NULL, NULL);
g_return_val_if_fail (E_IS_CALENDAR_TABLE (cal_table), NULL);
- return cal_table->model;
-}
-
-static void
-e_calendar_table_destroy (GtkObject *object)
-{
- ECalendarTable *cal_table;
-
- cal_table = E_CALENDAR_TABLE (object);
-
- if (cal_table->model) {
- g_object_unref (cal_table->model);
- cal_table->model = NULL;
- }
-
- GTK_OBJECT_CLASS (e_calendar_table_parent_class)->destroy (object);
+ return cal_table->priv->model;
}
/**
@@ -780,37 +1011,13 @@ e_calendar_table_destroy (GtkObject *object)
ETable *
e_calendar_table_get_table (ECalendarTable *cal_table)
{
- g_return_val_if_fail (cal_table != NULL, NULL);
- g_return_val_if_fail (E_IS_CALENDAR_TABLE (cal_table), NULL);
-
- return e_table_scrolled_get_table (E_TABLE_SCROLLED (cal_table->etable));
-}
-
-void
-e_calendar_table_open_selected (ECalendarTable *cal_table)
-{
- ECalModelComponent *comp_data;
- icalproperty *prop;
+ ETableScrolled *table_scrolled;
- comp_data = e_calendar_table_get_selected_comp (cal_table);
- prop = icalcomponent_get_first_property (comp_data->icalcomp, ICAL_ATTENDEE_PROPERTY);
- if (comp_data != NULL)
- e_calendar_table_open_task (cal_table, comp_data->client, comp_data->icalcomp, prop ? TRUE : FALSE);
-}
+ g_return_val_if_fail (E_IS_CALENDAR_TABLE (cal_table), NULL);
-/**
- * e_calendar_table_complete_selected:
- * @cal_table: A calendar table
- *
- * Marks the selected items as completed
- **/
-void
-e_calendar_table_complete_selected (ECalendarTable *cal_table)
-{
- g_return_if_fail (cal_table != NULL);
- g_return_if_fail (E_IS_CALENDAR_TABLE (cal_table));
+ table_scrolled = E_TABLE_SCROLLED (cal_table->etable);
- mark_as_complete_cb (NULL, NULL, cal_table);
+ return e_table_scrolled_get_table (table_scrolled);
}
/* Used from e_table_selected_row_foreach(); puts the selected row number in an
@@ -825,16 +1032,19 @@ get_selected_row_cb (gint model_row, gpointer data)
*row = model_row;
}
-/* Returns the component that is selected in the table; only works if there is
+/*
+ * Returns the component that is selected in the table; only works if there is
* one and only one selected row.
*/
-ECalModelComponent *
-e_calendar_table_get_selected_comp (ECalendarTable *cal_table)
+static ECalModelComponent *
+get_selected_comp (ECalendarTable *cal_table)
{
+ ECalModel *model;
ETable *etable;
gint row;
- etable = e_table_scrolled_get_table (E_TABLE_SCROLLED (cal_table->etable));
+ model = e_calendar_table_get_model (cal_table);
+ etable = e_calendar_table_get_table (cal_table);
if (e_table_selected_count (etable) != 1)
return NULL;
@@ -844,7 +1054,7 @@ e_calendar_table_get_selected_comp (ECalendarTable *cal_table)
&row);
g_return_val_if_fail (row != -1, NULL);
- return e_cal_model_get_component_at (cal_table->model, row);
+ return e_cal_model_get_component_at (model, row);
}
struct get_selected_uids_closure {
@@ -856,40 +1066,27 @@ struct get_selected_uids_closure {
static void
add_uid_cb (gint model_row, gpointer data)
{
- struct get_selected_uids_closure *closure;
+ struct get_selected_uids_closure *closure = data;
ECalModelComponent *comp_data;
+ ECalModel *model;
- closure = data;
-
- comp_data = e_cal_model_get_component_at (closure->cal_table->model, model_row);
+ model = e_calendar_table_get_model (closure->cal_table);
+ comp_data = e_cal_model_get_component_at (model, model_row);
closure->objects = g_slist_prepend (closure->objects, comp_data);
}
-static GSList *
-get_selected_objects (ECalendarTable *cal_table)
-{
- struct get_selected_uids_closure closure;
- ETable *etable;
-
- closure.cal_table = cal_table;
- closure.objects = NULL;
-
- etable = e_table_scrolled_get_table (E_TABLE_SCROLLED (cal_table->etable));
- e_table_selected_row_foreach (etable, add_uid_cb, &closure);
-
- return closure.objects;
-}
-
/* Deletes all of the selected components in the table */
static void
delete_selected_components (ECalendarTable *cal_table)
{
GSList *objs, *l;
+ const gchar *status_message;
- objs = get_selected_objects (cal_table);
+ objs = e_calendar_table_get_selected (cal_table);
- e_calendar_table_set_status_message (cal_table, _("Deleting selected objects"), -1);
+ status_message = _("Deleting selected objects");
+ calendar_table_emit_status_message (cal_table, status_message, -1.0);
for (l = objs; l; l = l->next) {
ECalModelComponent *comp_data = (ECalModelComponent *) l->data;
@@ -901,7 +1098,7 @@ delete_selected_components (ECalendarTable *cal_table)
g_clear_error (&error);
}
- e_calendar_table_set_status_message (cal_table, NULL, -1);
+ calendar_table_emit_status_message (cal_table, NULL, -1.0);
g_slist_free (objs);
}
@@ -962,14 +1159,14 @@ e_calendar_table_delete_selected (ECalendarTable *cal_table)
g_return_if_fail (cal_table != NULL);
g_return_if_fail (E_IS_CALENDAR_TABLE (cal_table));
- etable = e_table_scrolled_get_table (E_TABLE_SCROLLED (cal_table->etable));
+ etable = e_calendar_table_get_table (cal_table);
n_selected = e_table_selected_count (etable);
if (n_selected <= 0)
return;
if (n_selected == 1)
- comp_data = e_calendar_table_get_selected_comp (cal_table);
+ comp_data = get_selected_comp (cal_table);
else
comp_data = NULL;
@@ -1033,7 +1230,16 @@ e_calendar_table_delete_selected (ECalendarTable *cal_table)
GSList *
e_calendar_table_get_selected (ECalendarTable *cal_table)
{
- return get_selected_objects(cal_table);
+ struct get_selected_uids_closure closure;
+ ETable *etable;
+
+ closure.cal_table = cal_table;
+ closure.objects = NULL;
+
+ etable = e_calendar_table_get_table (cal_table);
+ e_table_selected_row_foreach (etable, add_uid_cb, &closure);
+
+ return closure.objects;
}
/**
@@ -1077,6 +1283,7 @@ copy_row_cb (gint model_row, gpointer data)
{
ECalendarTable *cal_table;
ECalModelComponent *comp_data;
+ ECalModel *model;
gchar *comp_str;
icalcomponent *child;
@@ -1084,7 +1291,8 @@ copy_row_cb (gint model_row, gpointer data)
g_return_if_fail (cal_table->tmp_vcal != NULL);
- comp_data = e_cal_model_get_component_at (cal_table->model, model_row);
+ model = e_calendar_table_get_model (cal_table);
+ comp_data = e_cal_model_get_component_at (model, model_row);
if (!comp_data)
return;
@@ -1120,14 +1328,13 @@ e_calendar_table_copy_clipboard (ECalendarTable *cal_table)
/* create temporary VCALENDAR object */
cal_table->tmp_vcal = e_cal_util_new_top_level ();
- etable = e_table_scrolled_get_table (E_TABLE_SCROLLED (cal_table->etable));
+ etable = e_calendar_table_get_table (cal_table);
e_table_selected_row_foreach (etable, copy_row_cb, cal_table);
comp_str = icalcomponent_as_ical_string_r (cal_table->tmp_vcal);
clipboard = gtk_widget_get_clipboard (GTK_WIDGET (cal_table), clipboard_atom);
if (!gtk_clipboard_set_with_data(clipboard, target_types, n_target_types,
clipboard_get_calendar_cb,
NULL, comp_str)) {
-
/* no-op */
} else {
gtk_clipboard_set_can_store (clipboard, target_types + 1, n_target_types - 1);
@@ -1145,8 +1352,10 @@ clipboard_get_calendar_data (ECalendarTable *cal_table, const gchar *text)
icalcomponent *icalcomp;
gchar *uid;
ECalComponent *comp;
+ ECalModel *model;
ECal *client;
icalcomponent_kind kind;
+ const gchar *status_message;
g_return_if_fail (E_IS_CALENDAR_TABLE (cal_table));
@@ -1166,9 +1375,11 @@ clipboard_get_calendar_data (ECalendarTable *cal_table, const gchar *text)
return;
}
- client = e_cal_model_get_default_client (cal_table->model);
+ model = e_calendar_table_get_model (cal_table);
+ client = e_cal_model_get_default_client (model);
- e_calendar_table_set_status_message (cal_table, _("Updating objects"), -1);
+ status_message = _("Updating objects");
+ calendar_table_emit_status_message (cal_table, status_message, -1.0);
if (kind == ICAL_VCALENDAR_COMPONENT) {
icalcomponent_kind child_kind;
@@ -1213,7 +1424,7 @@ clipboard_get_calendar_data (ECalendarTable *cal_table, const gchar *text)
g_object_unref (comp);
}
- e_calendar_table_set_status_message (cal_table, NULL, -1);
+ calendar_table_emit_status_message (cal_table, NULL, -1.0);
}
static void
@@ -1222,7 +1433,7 @@ clipboard_paste_received_cb (GtkClipboard *clipboard,
gpointer data)
{
ECalendarTable *cal_table = E_CALENDAR_TABLE (data);
- ETable *e_table = e_table_scrolled_get_table (E_TABLE_SCROLLED (cal_table->etable));
+ ETable *e_table = e_calendar_table_get_table (cal_table);
GnomeCanvas *canvas = e_table->table_canvas;
GnomeCanvasItem *item = GNOME_CANVAS (canvas)->focused_item;
@@ -1257,446 +1468,15 @@ void
e_calendar_table_paste_clipboard (ECalendarTable *cal_table)
{
GtkClipboard *clipboard;
- g_return_if_fail (E_IS_CALENDAR_TABLE (cal_table));
-
- clipboard = gtk_widget_get_clipboard (GTK_WIDGET (cal_table), clipboard_atom);
- g_object_ref (cal_table);
-
- gtk_clipboard_request_contents (clipboard,
- gdk_atom_intern (target_types[0].target, FALSE),
- clipboard_paste_received_cb, cal_table);
-}
-
-/* Opens a task in the task editor */
-void
-e_calendar_table_open_task (ECalendarTable *cal_table, ECal *client, icalcomponent *icalcomp, gboolean assign)
-{
- CompEditor *tedit;
- const gchar *uid;
- guint32 flags = 0;
-
- uid = icalcomponent_get_uid (icalcomp);
-
- tedit = e_comp_editor_registry_find (comp_editor_registry, uid);
- if (tedit == NULL) {
- ECalComponent *comp;
-
- comp = e_cal_component_new ();
- e_cal_component_set_icalcomponent (comp, icalcomponent_new_clone (icalcomp));
-
- if (assign) {
- flags |= COMP_EDITOR_IS_ASSIGNED;
- if (itip_organizer_is_user (comp, client) ||
- !e_cal_component_has_attendees (comp))
- flags |= COMP_EDITOR_USER_ORG;
- }
-
- tedit = task_editor_new (client, flags);
- comp_editor_edit_comp (tedit, comp);
- g_object_unref (comp);
-
- if (flags & COMP_EDITOR_IS_ASSIGNED)
- task_editor_show_assignment (TASK_EDITOR (tedit));
-
- e_comp_editor_registry_add (comp_editor_registry, tedit, FALSE);
- }
- gtk_window_present (GTK_WINDOW (tedit));
-}
-
-/* Opens the task in the specified row */
-static void
-open_task_by_row (ECalendarTable *cal_table, gint row)
-{
- ECalModelComponent *comp_data;
- icalproperty *prop;
-
- comp_data = e_cal_model_get_component_at (cal_table->model, row);
- prop = icalcomponent_get_first_property (comp_data->icalcomp, ICAL_ATTENDEE_PROPERTY);
- e_calendar_table_open_task (cal_table, comp_data->client, comp_data->icalcomp, prop ? TRUE : FALSE);
-}
-
-static void
-e_calendar_table_on_double_click (ETable *table,
- gint row,
- gint col,
- GdkEvent *event,
- ECalendarTable *cal_table)
-{
- open_task_by_row (cal_table, row);
-}
-
-/* popup menu callbacks */
-
-static void
-e_calendar_table_on_open_task (EPopup *ep, EPopupItem *pitem, gpointer data)
-{
- ECalendarTable *cal_table = data;
- ECalModelComponent *comp_data;
- icalproperty *prop;
-
- comp_data = e_calendar_table_get_selected_comp (cal_table);
-
- if (!comp_data)
- return;
-
- prop = icalcomponent_get_first_property (comp_data->icalcomp, ICAL_ATTENDEE_PROPERTY);
- e_calendar_table_open_task (cal_table, comp_data->client, comp_data->icalcomp, prop ? TRUE : FALSE);
-}
-
-static void
-e_calendar_table_on_save_as (EPopup *ep, EPopupItem *pitem, gpointer data)
-{
- ECalendarTable *cal_table = data;
- ECalModelComponent *comp_data;
- gchar *filename;
- gchar *ical_string;
-
- comp_data = e_calendar_table_get_selected_comp (cal_table);
- if (comp_data == NULL)
- return;
-
- filename = e_file_dialog_save (_("Save as..."), NULL);
- if (filename == NULL)
- return;
-
- ical_string = e_cal_get_component_as_string (comp_data->client, comp_data->icalcomp);
- if (ical_string == NULL) {
- g_warning ("Couldn't convert item to a string");
- return;
- }
-
- e_write_file_uri (filename, ical_string);
-
- g_free (ical_string);
-}
-
-static void
-e_calendar_table_on_print_task (EPopup *ep, EPopupItem *pitem, gpointer data)
-{
- ECalendarTable *cal_table = data;
- ECalModelComponent *comp_data;
- ECalComponent *comp;
-
- comp_data = e_calendar_table_get_selected_comp (cal_table);
- if (comp_data == NULL)
- return;
-
- comp = e_cal_component_new ();
- e_cal_component_set_icalcomponent (comp, icalcomponent_new_clone (comp_data->icalcomp));
- print_comp (comp, comp_data->client, GTK_PRINT_OPERATION_ACTION_PRINT_DIALOG);
-
- g_object_unref (comp);
-}
-
-static void
-e_calendar_table_on_cut (EPopup *ep, EPopupItem *pitem, gpointer data)
-{
- ECalendarTable *cal_table = data;
-
- e_calendar_table_cut_clipboard (cal_table);
-}
-
-static void
-e_calendar_table_on_copy (EPopup *ep, EPopupItem *pitem, gpointer data)
-{
- ECalendarTable *cal_table = data;
-
- e_calendar_table_copy_clipboard (cal_table);
-}
-
-static void
-e_calendar_table_on_paste (EPopup *ep, EPopupItem *pitem, gpointer data)
-{
- ECalendarTable *cal_table = data;
-
- e_calendar_table_paste_clipboard (cal_table);
-}
-
-static void
-e_calendar_table_on_assign (EPopup *ep, EPopupItem *pitem, gpointer data)
-{
- ECalendarTable *cal_table = data;
- ECalModelComponent *comp_data;
-
- comp_data = e_calendar_table_get_selected_comp (cal_table);
- if (comp_data)
- e_calendar_table_open_task (cal_table, comp_data->client, comp_data->icalcomp, TRUE);
-}
-
-static void
-e_calendar_table_on_forward (EPopup *ep, EPopupItem *pitem, gpointer data)
-{
- ECalendarTable *cal_table = data;
- ECalModelComponent *comp_data;
-
- comp_data = e_calendar_table_get_selected_comp (cal_table);
- if (comp_data) {
- ECalComponent *comp;
-
- comp = e_cal_component_new ();
- e_cal_component_set_icalcomponent (comp, icalcomponent_new_clone (comp_data->icalcomp));
- itip_send_comp (E_CAL_COMPONENT_METHOD_PUBLISH, comp, comp_data->client, NULL, NULL, NULL, TRUE);
-
- g_object_unref (comp);
- }
-}
-
-struct AffectedComponents {
- ECalendarTable *cal_table;
- GSList *components; /* contains pointers to ECalModelComponent */
-};
-
-/**
- * get_selected_components_cb
- * Helper function to fill list of selected components in ECalendarTable.
- * This function is called from e_table_selected_row_foreach.
- **/
-static void
-get_selected_components_cb (gint model_row, gpointer data)
-{
- struct AffectedComponents *ac = (struct AffectedComponents *) data;
-
- if (!ac || !ac->cal_table)
- return;
-
- ac->components = g_slist_prepend (ac->components, e_cal_model_get_component_at (E_CAL_MODEL (ac->cal_table->model), model_row));
-}
-
-/**
- * do_for_selected_components
- * Calls function func for all selected components in cal_table.
- *
- * @param cal_table Table with selected components of our interest
- * @param func Function to be called on each selected component from cal_table.
- * The first parameter of this function is a pointer to ECalModelComponent and
- * the second parameter of this function is pointer to cal_table
- **/
-static void
-do_for_selected_components (ECalendarTable *cal_table, GFunc func)
-{
- ETable *etable;
- struct AffectedComponents ac;
-
- g_return_if_fail (cal_table != NULL);
-
- ac.cal_table = cal_table;
- ac.components = NULL;
-
- etable = e_table_scrolled_get_table (E_TABLE_SCROLLED (cal_table->etable));
- e_table_selected_row_foreach (etable, get_selected_components_cb, &ac);
-
- g_slist_foreach (ac.components, func, cal_table);
- g_slist_free (ac.components);
-}
-
-/**
- * mark_comp_complete_cb
- * Function used in call to @ref do_for_selected_components to mark each component as complete
- **/
-static void
-mark_comp_complete_cb (gpointer data, gpointer user_data)
-{
- ECalendarTable *cal_table;
- ECalModelComponent *comp_data;
-
- comp_data = (ECalModelComponent *) data;
- cal_table = E_CALENDAR_TABLE (user_data);
-
- e_cal_model_tasks_mark_comp_complete (E_CAL_MODEL_TASKS (cal_table->model), comp_data);
-}
-
-/**
- * mark_comp_incomplete_cb
- * Function used in call to @ref do_for_selected_components to mark each component as incomplete
- **/
-static void
-mark_comp_incomplete_cb (gpointer data, gpointer user_data)
-{
- ECalendarTable *cal_table;
- ECalModelComponent *comp_data;
-
- comp_data = (ECalModelComponent *) data;
- cal_table = E_CALENDAR_TABLE (user_data);
-
- e_cal_model_tasks_mark_comp_incomplete (E_CAL_MODEL_TASKS (cal_table->model), comp_data);
-}
-
-/* Callback used for the "mark tasks as incomplete" menu item */
-static void
-mark_as_incomplete_cb (EPopup *ep, EPopupItem *pitem, gpointer data)
-{
- do_for_selected_components (data, mark_comp_incomplete_cb);
-}
-
-/* Callback used for the "mark tasks as complete" menu item */
-static void
-mark_as_complete_cb (EPopup *ep, EPopupItem *pitem, gpointer data)
-{
- do_for_selected_components (data, mark_comp_complete_cb);
-}
-
-/* Opens the URL of the task */
-static void
-open_url_cb (EPopup *ep, EPopupItem *pitem, gpointer data)
-{
- ECalendarTable *cal_table = data;
- ECalModelComponent *comp_data;
- icalproperty *prop;
-
- comp_data = e_calendar_table_get_selected_comp (cal_table);
- if (!comp_data)
- return;
-
- prop = icalcomponent_get_first_property (comp_data->icalcomp, ICAL_URL_PROPERTY);
- if (!prop)
- return;
-
- /* FIXME Pass a parent window. */
- e_show_uri (NULL, icalproperty_get_url (prop));
-}
-
-/* Opens a new task editor */
-static void
-on_new_task (EPopup *ep, EPopupItem *pitem, gpointer data)
-{
- ECalendarTable *cal_table = data;
- ETasks *tasks = g_object_get_data (G_OBJECT (cal_table), "tasks");
-
- if (!tasks)
- return;
-
- e_tasks_new_task (tasks);
-
-}
-
-/* Callback for the "delete tasks" menu item */
-static void
-delete_cb (EPopup *ep, EPopupItem *pitem, gpointer data)
-{
- ECalendarTable *cal_table = data;
-
- e_calendar_table_delete_selected (cal_table);
-}
-
-static EPopupItem tasks_popup_items [] = {
- { E_POPUP_ITEM, (gchar *) "00.newtask", (gchar *) N_("New _Task"), on_new_task, NULL, (gchar *) "stock_task", 0, 0},
- { E_POPUP_BAR, (gchar *) "01.bar" },
-
- { E_POPUP_ITEM, (gchar *) "03.open", (gchar *) N_("_Open"), e_calendar_table_on_open_task, NULL, (gchar *) GTK_STOCK_OPEN, E_CAL_POPUP_SELECT_ONE },
- { E_POPUP_ITEM, (gchar *) "05.openweb", (gchar *) N_("Open _Web Page"), open_url_cb, NULL, NULL, E_CAL_POPUP_SELECT_ONE, E_CAL_POPUP_SELECT_HASURL },
- { E_POPUP_ITEM, (gchar *) "10.saveas", (gchar *) N_("_Save As..."), e_calendar_table_on_save_as, NULL, (gchar *) GTK_STOCK_SAVE_AS, E_CAL_POPUP_SELECT_ONE },
- { E_POPUP_ITEM, (gchar *) "20.print", (gchar *) N_("P_rint..."), e_calendar_table_on_print_task, NULL, (gchar *) GTK_STOCK_PRINT, E_CAL_POPUP_SELECT_ONE },
-
- { E_POPUP_BAR, (gchar *) "30.bar" },
-
- { E_POPUP_ITEM, (gchar *) "40.cut", (gchar *) N_("C_ut"), e_calendar_table_on_cut, NULL, (gchar *) GTK_STOCK_CUT, 0, E_CAL_POPUP_SELECT_EDITABLE },
- { E_POPUP_ITEM, (gchar *) "50.copy", (gchar *) N_("_Copy"), e_calendar_table_on_copy, NULL, (gchar *) GTK_STOCK_COPY, 0, 0 },
- { E_POPUP_ITEM, (gchar *) "60.paste", (gchar *) N_("_Paste"), e_calendar_table_on_paste, NULL, (gchar *) GTK_STOCK_PASTE, 0, E_CAL_POPUP_SELECT_EDITABLE },
-
- { E_POPUP_BAR, (gchar *) "70.bar" },
-
- { E_POPUP_ITEM, (gchar *) "80.assign", (gchar *) N_("_Assign Task"), e_calendar_table_on_assign, NULL, NULL, E_CAL_POPUP_SELECT_ONE, E_CAL_POPUP_SELECT_EDITABLE|E_CAL_POPUP_SELECT_ASSIGNABLE },
- { E_POPUP_ITEM, (gchar *) "90.forward", (gchar *) N_("_Forward as iCalendar"), e_calendar_table_on_forward, NULL, (gchar *) "mail-forward", E_CAL_POPUP_SELECT_ONE },
- { E_POPUP_ITEM, (gchar *) "a0.markonecomplete", (gchar *) N_("_Mark as Complete"), mark_as_complete_cb, NULL, NULL, E_CAL_POPUP_SELECT_ONE, E_CAL_POPUP_SELECT_EDITABLE | E_CAL_POPUP_SELECT_NOTCOMPLETE},
- { E_POPUP_ITEM, (gchar *) "b0.markmanycomplete", (gchar *) N_("_Mark Selected Tasks as Complete"), mark_as_complete_cb, NULL, NULL, E_CAL_POPUP_SELECT_MANY, E_CAL_POPUP_SELECT_EDITABLE | E_CAL_POPUP_SELECT_NOTCOMPLETE },
- { E_POPUP_ITEM, (gchar *) "c0.markoneincomplete", (gchar *) N_("_Mark as Incomplete"), mark_as_incomplete_cb, NULL, NULL, E_CAL_POPUP_SELECT_ONE, E_CAL_POPUP_SELECT_EDITABLE|E_CAL_POPUP_SELECT_COMPLETE},
- { E_POPUP_ITEM, (gchar *) "d0.markmanyincomplete", (gchar *) N_("_Mark Selected Tasks as Incomplete"), mark_as_incomplete_cb, NULL, NULL, E_CAL_POPUP_SELECT_MANY, E_CAL_POPUP_SELECT_EDITABLE | E_CAL_POPUP_SELECT_COMPLETE },
-
- { E_POPUP_BAR, (gchar *) "e0.bar" },
-
- { E_POPUP_ITEM, (gchar *) "f0.delete", (gchar *) N_("_Delete"), delete_cb, NULL, (gchar *) GTK_STOCK_DELETE, E_CAL_POPUP_SELECT_ONE, E_CAL_POPUP_SELECT_EDITABLE },
- { E_POPUP_ITEM, (gchar *) "g0.deletemany", (gchar *) N_("_Delete Selected Tasks"), delete_cb, NULL, (gchar *) GTK_STOCK_DELETE, E_CAL_POPUP_SELECT_MANY, E_CAL_POPUP_SELECT_EDITABLE },
-};
-
-static void
-ect_popup_free(EPopup *ep, GSList *items, gpointer data)
-{
- g_slist_free(items);
-}
-
-static gint
-e_calendar_table_show_popup_menu (ETable *table,
- GdkEvent *gdk_event,
- ECalendarTable *cal_table)
-{
- GtkMenu *menu;
- GSList *selection, *l, *menus = NULL;
- GPtrArray *events;
- ECalPopup *ep;
- ECalPopupTargetSelect *t;
- gint i;
-
- selection = get_selected_objects (cal_table);
- if (!selection)
- return TRUE;
-
- /** @HookPoint-ECalPopup: Tasks Table Context Menu
- * @Id: org.gnome.evolution.tasks.table.popup
- * @Class: org.gnome.evolution.calendar.popup:1.0
- * @Target: ECalPopupTargetSelect
- *
- * The context menu on the tasks table.
- */
- ep = e_cal_popup_new("org.gnome.evolution.tasks.table.popup");
-
- events = g_ptr_array_new();
- for (l=selection;l;l=g_slist_next(l))
- g_ptr_array_add(events, e_cal_model_copy_component_data((ECalModelComponent *)l->data));
- g_slist_free(selection);
-
- t = e_cal_popup_target_new_select(ep, cal_table->model, events);
- t->target.widget = (GtkWidget *)cal_table;
-
- for (i=0;i<sizeof(tasks_popup_items)/sizeof(tasks_popup_items[0]);i++)
- menus = g_slist_prepend(menus, &tasks_popup_items[i]);
- e_popup_add_items((EPopup *)ep, menus, NULL, ect_popup_free, cal_table);
-
- menu = e_popup_create_menu_once((EPopup *)ep, (EPopupTarget *)t, 0);
-
- gtk_menu_popup(menu, NULL, NULL, NULL, NULL, gdk_event?gdk_event->button.button:0,
- gdk_event?gdk_event->button.time:gtk_get_current_event_time());
-
- return TRUE;
-}
-
-static gint
-e_calendar_table_on_right_click (ETable *table,
- gint row,
- gint col,
- GdkEvent *event,
- ECalendarTable *cal_table)
-{
- return e_calendar_table_show_popup_menu (table, event, cal_table);
-}
+ g_return_if_fail (E_IS_CALENDAR_TABLE (cal_table));
-static gboolean
-e_calendar_table_on_popup_menu (GtkWidget *widget, gpointer data)
-{
- ETable *table = E_TABLE(widget);
- g_return_val_if_fail(table, FALSE);
+ clipboard = gtk_widget_get_clipboard (
+ GTK_WIDGET (cal_table), clipboard_atom);
- return e_calendar_table_show_popup_menu (table, NULL,
- E_CALENDAR_TABLE(data));
-}
-
-static gint
-e_calendar_table_on_key_press (ETable *table,
- gint row,
- gint col,
- GdkEventKey *event,
- ECalendarTable *cal_table)
-{
- if (event->keyval == GDK_Delete) {
- delete_cb (NULL, NULL, cal_table);
- return TRUE;
- } else if ((event->keyval == GDK_o)
- &&(event->state & GDK_CONTROL_MASK)) {
- open_task_by_row (cal_table, row);
- return TRUE;
- }
-
- return FALSE;
+ gtk_clipboard_request_contents (
+ clipboard, gdk_atom_intern (target_types[0].target, FALSE),
+ clipboard_paste_received_cb, g_object_ref (cal_table));
}
static void
@@ -1787,28 +1567,30 @@ show_completed_rows (ECalModel *model, GList *clients_list, gchar *show_sexp, GP
/* Loads the state of the table (headers shown etc.) from the given file. */
void
-e_calendar_table_load_state (ECalendarTable *cal_table,
- gchar *filename)
+e_calendar_table_load_state (ECalendarTable *cal_table,
+ const gchar *filename)
{
- struct stat st;
+ ETable *table;
g_return_if_fail (E_IS_CALENDAR_TABLE (cal_table));
+ g_return_if_fail (filename != NULL);
- if (g_stat (filename, &st) == 0 && st.st_size > 0
- && S_ISREG (st.st_mode)) {
- e_table_load_state (e_table_scrolled_get_table (E_TABLE_SCROLLED (cal_table->etable)), filename);
- }
+ table = e_calendar_table_get_table (cal_table);
+ e_table_load_state (table, filename);
}
/* Saves the state of the table (headers shown etc.) to the given file. */
void
-e_calendar_table_save_state (ECalendarTable *cal_table,
- gchar *filename)
+e_calendar_table_save_state (ECalendarTable *cal_table,
+ const gchar *filename)
{
+ ETable *table;
+
g_return_if_fail (E_IS_CALENDAR_TABLE (cal_table));
+ g_return_if_fail (filename != NULL);
- e_table_save_state (e_table_scrolled_get_table (E_TABLE_SCROLLED (cal_table->etable)),
- filename);
+ table = e_calendar_table_get_table (cal_table);
+ e_table_save_state (table, filename);
}
/* Returns the current time, for the ECellDateEdit items.
@@ -1838,56 +1620,6 @@ e_calendar_table_get_current_time (ECellDateEdit *ecde, gpointer data)
return tmp_tm;
}
-#ifdef TRANSLATORS_ONLY
-
-static gchar *test[] = {
- N_("Click to add a task")
-};
-
-#endif
-
-void
-e_calendar_table_set_activity_handler (ECalendarTable *cal_table, EActivityHandler *activity_handler)
-{
- g_return_if_fail (E_IS_CALENDAR_TABLE (cal_table));
-
- cal_table->activity_handler = activity_handler;
-}
-
-void
-e_calendar_table_set_status_message (ECalendarTable *cal_table, const gchar *message, gint percent)
-{
- g_return_if_fail (E_IS_CALENDAR_TABLE (cal_table));
-
- if (!cal_table->activity_handler)
- return;
-
- if (!message || !*message) {
- if (cal_table->activity_id != 0) {
- e_activity_handler_operation_finished (cal_table->activity_handler, cal_table->activity_id);
- cal_table->activity_id = 0;
- }
- } else if (cal_table->activity_id == 0) {
- gchar *client_id = g_strdup_printf ("%p", (gpointer) cal_table);
-
- cal_table->activity_id = e_activity_handler_operation_started (
- cal_table->activity_handler, client_id, message, TRUE);
-
- g_free (client_id);
- } else {
-
- double progress;
-
- if (percent < 0)
- progress = -1.0;
- else {
- progress = ((double) percent / 100);
- }
-
- e_activity_handler_operation_progressing (cal_table->activity_handler, cal_table->activity_id, message, progress);
- }
-}
-
/**
* e_calendar_table_hide_completed_tasks:
* @table: A calendar table model.
diff --git a/calendar/gui/e-calendar-table.h b/calendar/gui/e-calendar-table.h
index 0abcd4be0e..4645be188b 100644
--- a/calendar/gui/e-calendar-table.h
+++ b/calendar/gui/e-calendar-table.h
@@ -23,31 +23,43 @@
#ifndef _E_CALENDAR_TABLE_H_
#define _E_CALENDAR_TABLE_H_
-#include <gtk/gtk.h>
+#include <shell/e-shell-view.h>
#include <table/e-table-scrolled.h>
-#include <misc/e-cell-date-edit.h>
-#include "e-activity-handler.h"
+#include <table/e-cell-date-edit.h>
#include "e-cal-model.h"
-G_BEGIN_DECLS
-
/*
* ECalendarTable - displays the iCalendar objects in a table (an ETable).
* Used for calendar events and tasks.
*/
-#define E_CALENDAR_TABLE(obj) G_TYPE_CHECK_INSTANCE_CAST (obj, e_calendar_table_get_type (), ECalendarTable)
-#define E_CALENDAR_TABLE_CLASS(klass) G_TYPE_CHECK_CLASS_CAST (klass, e_calendar_table_get_type (), ECalendarTableClass)
-#define E_IS_CALENDAR_TABLE(obj) G_TYPE_CHECK_INSTANCE_TYPE (obj, e_calendar_table_get_type ())
+/* Standard GObject macros */
+#define E_TYPE_CALENDAR_TABLE \
+ (e_calendar_table_get_type ())
+#define E_CALENDAR_TABLE(obj) \
+ (G_TYPE_CHECK_INSTANCE_CAST \
+ ((obj), E_TYPE_CALENDAR_TABLE, ECalendarTable))
+#define E_CALENDAR_TABLE_CLASS(cls) \
+ (G_TYPE_CHECK_CLASS_CAST \
+ ((cls), E_TYPE_CALENDAR_TABLE, ECalendarTableClass))
+#define E_IS_CALENDAR_TABLE(obj) \
+ (G_TYPE_CHECK_INSTANCE_TYPE \
+ ((obj), E_TYPE_CALENDAR_TABLE))
+#define E_IS_CALENDAR_TABLE_CLASS(cls) \
+ (G_TYPE_CHECK_CLASS_TYPE \
+ ((cls), E_TYPE_CALENDAR_TABLE))
+#define E_CALENDAR_TABLE_GET_CLASS(obj) \
+ (G_TYPE_INSTANCE_GET_CLASS \
+ ((obj), E_TYPE_CALENDAR_TABLE, ECalendarTableClass))
-typedef struct _ECalendarTable ECalendarTable;
-typedef struct _ECalendarTableClass ECalendarTableClass;
+G_BEGIN_DECLS
-struct _ECalendarTable {
- GtkTable table;
+typedef struct _ECalendarTable ECalendarTable;
+typedef struct _ECalendarTableClass ECalendarTableClass;
+typedef struct _ECalendarTablePrivate ECalendarTablePrivate;
- /* The model that we use */
- ECalModel *model;
+struct _ECalendarTable {
+ GtkTable parent;
GtkWidget *etable;
@@ -57,60 +69,55 @@ struct _ECalendarTable {
/* Fields used for cut/copy/paste */
icalcomponent *tmp_vcal;
- /* Activity ID for the EActivityHandler (i.e. the status bar). */
- EActivityHandler *activity_handler;
- guint activity_id;
-
- /* We should know which calendar has been used to create object, so store it here
- before emitting "user_created" signal and make it NULL just after the emit. */
- ECal *user_created_cal;
+ ECalendarTablePrivate *priv;
};
struct _ECalendarTableClass {
GtkTableClass parent_class;
- /* Notification signals */
- void (* user_created) (ECalendarTable *cal_table);
+ /* Signals */
+ void (*open_component) (ECalendarTable *cal_table,
+ ECalModelComponent *comp_data);
+ void (*popup_event) (ECalendarTable *cal_table,
+ GdkEvent *event);
+ void (*status_message) (ECalendarTable *cal_table,
+ const gchar *message,
+ gdouble percent);
+ void (*user_created) (ECalendarTable *cal_table);
};
-GType e_calendar_table_get_type (void);
-GtkWidget* e_calendar_table_new (void);
-
-ECalModel *e_calendar_table_get_model (ECalendarTable *cal_table);
-
-ETable *e_calendar_table_get_table (ECalendarTable *cal_table);
-
-void e_calendar_table_open_selected (ECalendarTable *cal_table);
-void e_calendar_table_complete_selected (ECalendarTable *cal_table);
-void e_calendar_table_delete_selected (ECalendarTable *cal_table);
-
-GSList *e_calendar_table_get_selected (ECalendarTable *cal_table);
+GType e_calendar_table_get_type (void);
+GtkWidget * e_calendar_table_new (EShellView *shell_view,
+ ECalModel *model);
+ECalModel * e_calendar_table_get_model (ECalendarTable *cal_table);
+ETable * e_calendar_table_get_table (ECalendarTable *cal_table);
+EShellView * e_calendar_table_get_shell_view (ECalendarTable *cal_table);
+void e_calendar_table_delete_selected(ECalendarTable *cal_table);
+GSList * e_calendar_table_get_selected (ECalendarTable *cal_table);
/* Clipboard related functions */
-void e_calendar_table_cut_clipboard (ECalendarTable *cal_table);
-void e_calendar_table_copy_clipboard (ECalendarTable *cal_table);
-void e_calendar_table_paste_clipboard (ECalendarTable *cal_table);
+void e_calendar_table_cut_clipboard (ECalendarTable *cal_table);
+void e_calendar_table_copy_clipboard (ECalendarTable *cal_table);
+void e_calendar_table_paste_clipboard(ECalendarTable *cal_table);
/* These load and save the state of the table (headers shown etc.) to/from
the given file. */
-void e_calendar_table_load_state (ECalendarTable *cal_table,
- gchar *filename);
-void e_calendar_table_save_state (ECalendarTable *cal_table,
- gchar *filename);
-
-void e_calendar_table_set_activity_handler (ECalendarTable *cal_table,
- EActivityHandler *activity_handler);
-void e_calendar_table_set_status_message (ECalendarTable *cal_table,
- const gchar *message,
- gint percent);
-void e_calendar_table_open_task (ECalendarTable *cal_table,
- ECal *client,
- icalcomponent *icalcomp,
- gboolean assign);
-ECalModelComponent * e_calendar_table_get_selected_comp (ECalendarTable *cal_table);
-void e_calendar_table_hide_completed_tasks (ECalendarTable *table, GList *clients_list, gboolean config_changed);
-
-void e_calendar_table_process_completed_tasks (ECalendarTable *table, GList *clients_list, gboolean config_changed);
+void e_calendar_table_load_state (ECalendarTable *cal_table,
+ const gchar *filename);
+void e_calendar_table_save_state (ECalendarTable *cal_table,
+ const gchar *filename);
+
+ECalModelComponent *
+ e_calendar_table_get_selected_comp
+ (ECalendarTable *cal_table);
+void e_calendar_table_hide_completed_tasks
+ (ECalendarTable *table,
+ GList *clients_list,
+ gboolean config_changed);
+void e_calendar_table_process_completed_tasks
+ (ECalendarTable *table,
+ GList *clients_list,
+ gboolean config_changed);
gboolean ec_query_tooltip (GtkWidget *widget, gint x, gint y, gboolean keyboard_mode, GtkTooltip *tooltip, GtkWidget *etable_wgt, ECalModel *model);
diff --git a/calendar/gui/e-calendar-view.c b/calendar/gui/e-calendar-view.c
index e02838e35d..9897354e5a 100644
--- a/calendar/gui/e-calendar-view.c
+++ b/calendar/gui/e-calendar-view.c
@@ -37,15 +37,13 @@
#include <e-util/e-icon-factory.h>
#include <libecal/e-cal-time-util.h>
#include <libecal/e-cal-component.h>
+#include <shell/e-shell.h>
#include "common/authentication.h"
-#include "calendar-commands.h"
-#include "calendar-component.h"
#include "calendar-config.h"
#include "comp-util.h"
#include "e-cal-model-calendar.h"
#include "e-calendar-view.h"
-#include "e-comp-editor-registry.h"
#include "itip-utils.h"
#include "dialogs/delete-comp.h"
#include "dialogs/delete-error.h"
@@ -56,7 +54,7 @@
#include "dialogs/select-source-dialog.h"
#include "print.h"
#include "goto.h"
-#include "ea-calendar.h"
+/*#include "a11y/ea-calendar.h"*/ /* KILL-BONOBO */
#include "e-cal-popup.h"
#include "misc.h"
@@ -67,10 +65,6 @@ struct _ECalendarViewPrivate {
/* The calendar model we are monitoring */
ECalModel *model;
- /* Current activity (for the EActivityHandler, i.e. the status bar). */
- EActivityHandler *activity_handler;
- guint activity_id;
-
/* The default category */
gchar *default_category;
};
@@ -79,8 +73,6 @@ static void e_calendar_view_get_property (GObject *object, guint property_id, GV
static void e_calendar_view_set_property (GObject *object, guint property_id, const GValue *value, GParamSpec *pspec);
static void e_calendar_view_destroy (GtkObject *object);
-extern ECompEditorRegistry *comp_editor_registry;
-
/* Property IDs */
enum props {
PROP_0,
@@ -100,7 +92,7 @@ enum {
LAST_SIGNAL
};
-static guint e_calendar_view_signals[LAST_SIGNAL] = { 0 };
+static guint signals[LAST_SIGNAL] = { 0 };
G_DEFINE_TYPE (ECalendarView, e_calendar_view, GTK_TYPE_TABLE)
@@ -181,7 +173,7 @@ e_calendar_view_class_init (ECalendarViewClass *klass)
G_PARAM_READABLE | G_PARAM_WRITABLE));
/* Create class' signals */
- e_calendar_view_signals[SELECTION_CHANGED] =
+ signals[SELECTION_CHANGED] =
g_signal_new ("selection_changed",
G_TYPE_FROM_CLASS (klass),
G_SIGNAL_RUN_LAST,
@@ -189,7 +181,7 @@ e_calendar_view_class_init (ECalendarViewClass *klass)
NULL, NULL,
g_cclosure_marshal_VOID__VOID,
G_TYPE_NONE, 0);
- e_calendar_view_signals[SELECTED_TIME_CHANGED] =
+ signals[SELECTED_TIME_CHANGED] =
g_signal_new ("selected_time_changed",
G_TYPE_FROM_CLASS (klass),
G_SIGNAL_RUN_LAST,
@@ -197,7 +189,7 @@ e_calendar_view_class_init (ECalendarViewClass *klass)
NULL, NULL,
g_cclosure_marshal_VOID__VOID,
G_TYPE_NONE, 0);
- e_calendar_view_signals[TIMEZONE_CHANGED] =
+ signals[TIMEZONE_CHANGED] =
g_signal_new ("timezone_changed",
G_TYPE_FROM_CLASS (klass),
G_SIGNAL_RUN_LAST,
@@ -206,7 +198,7 @@ e_calendar_view_class_init (ECalendarViewClass *klass)
e_marshal_VOID__POINTER_POINTER,
G_TYPE_NONE, 2, G_TYPE_POINTER, G_TYPE_POINTER);
- e_calendar_view_signals[EVENT_CHANGED] =
+ signals[EVENT_CHANGED] =
g_signal_new ("event_changed",
G_TYPE_FROM_CLASS (object_class),
G_SIGNAL_RUN_FIRST | G_SIGNAL_ACTION,
@@ -216,7 +208,7 @@ e_calendar_view_class_init (ECalendarViewClass *klass)
G_TYPE_NONE, 1,
G_TYPE_POINTER);
- e_calendar_view_signals[EVENT_ADDED] =
+ signals[EVENT_ADDED] =
g_signal_new ("event_added",
G_TYPE_FROM_CLASS (object_class),
G_SIGNAL_RUN_FIRST | G_SIGNAL_ACTION,
@@ -226,7 +218,7 @@ e_calendar_view_class_init (ECalendarViewClass *klass)
G_TYPE_NONE, 1,
G_TYPE_POINTER);
- e_calendar_view_signals[USER_CREATED] =
+ signals[USER_CREATED] =
g_signal_new ("user_created",
G_TYPE_FROM_CLASS (klass),
G_SIGNAL_RUN_LAST,
@@ -235,7 +227,7 @@ e_calendar_view_class_init (ECalendarViewClass *klass)
g_cclosure_marshal_VOID__VOID,
G_TYPE_NONE, 0);
- e_calendar_view_signals[OPEN_EVENT] =
+ signals[OPEN_EVENT] =
g_signal_new ("open_event",
G_TYPE_FROM_CLASS (klass),
G_SIGNAL_RUN_FIRST | G_SIGNAL_ACTION,
@@ -254,14 +246,17 @@ e_calendar_view_class_init (ECalendarViewClass *klass)
GDK_CONTROL_MASK,
"open_event", 0);
+#if 0 /* KILL-BONOBO */
/* init the accessibility support for e_day_view */
e_cal_view_a11y_init ();
+#endif
}
void
e_calendar_view_add_event (ECalendarView *cal_view, ECal *client, time_t dtstart,
icaltimezone *default_zone, icalcomponent *icalcomp, gboolean in_top_canvas)
{
+#if 0 /* KILL-BONOBO */
ECalComponent *comp;
struct icaltimetype itime, old_dtstart, old_dtend;
time_t tt_start, tt_end, new_dtstart = 0;
@@ -379,6 +374,7 @@ e_calendar_view_add_event (ECalendarView *cal_view, ECal *client, time_t dtstart
}
g_object_unref (comp);
+#endif
}
static void
@@ -474,7 +470,7 @@ e_calendar_view_set_timezone (ECalendarView *cal_view, icaltimezone *zone)
return;
e_cal_model_set_timezone (cal_view->priv->model, zone);
- g_signal_emit (G_OBJECT (cal_view), e_calendar_view_signals[TIMEZONE_CHANGED], 0,
+ g_signal_emit (G_OBJECT (cal_view), signals[TIMEZONE_CHANGED], 0,
old_zone, zone);
}
@@ -535,55 +531,6 @@ e_calendar_view_set_use_24_hour_format (ECalendarView *cal_view, gboolean use_24
e_cal_model_set_use_24_hour_format (cal_view->priv->model, use_24_hour);
}
-void
-e_calendar_view_set_activity_handler (ECalendarView *cal_view, EActivityHandler *activity_handler)
-{
- ECalendarViewPrivate *priv;
-
- g_return_if_fail (E_IS_CALENDAR_VIEW (cal_view));
-
- priv = cal_view->priv;
-
- priv->activity_handler = activity_handler;
-}
-
-void
-e_calendar_view_set_status_message (ECalendarView *cal_view, const gchar *message, gint percent)
-{
- ECalendarViewPrivate *priv;
-
- g_return_if_fail (E_IS_CALENDAR_VIEW (cal_view));
-
- priv = cal_view->priv;
-
- if (!priv->activity_handler)
- return;
-
- if (!message || !*message) {
- if (priv->activity_id != 0) {
- e_activity_handler_operation_finished (priv->activity_handler, priv->activity_id);
- priv->activity_id = 0;
- }
- } else if (priv->activity_id == 0) {
- gchar *client_id = g_strdup_printf ("%p", (gpointer) cal_view);
-
- priv->activity_id = e_activity_handler_operation_started (
- priv->activity_handler, client_id, message, TRUE);
-
- g_free (client_id);
- } else {
- double progress;
-
- if (percent < 0)
- progress = -1.0;
- else {
- progress = ((double) percent / 100);
- }
-
- e_activity_handler_operation_progressing (priv->activity_handler, priv->activity_id, message, progress);
- }
-}
-
GList *
e_calendar_view_get_selected_events (ECalendarView *cal_view)
{
@@ -654,7 +601,9 @@ e_calendar_view_cut_clipboard (ECalendarView *cal_view)
if (!selected)
return;
+#if 0 /* KILL-BONOBO */
e_calendar_view_set_status_message (cal_view, _("Deleting selected objects"), -1);
+#endif
e_calendar_view_copy_clipboard (cal_view);
for (l = selected; l != NULL; l = l->next) {
@@ -699,7 +648,9 @@ e_calendar_view_cut_clipboard (ECalendarView *cal_view)
g_object_unref (comp);
}
+#if 0 /* KILL-BONOBO */
e_calendar_view_set_status_message (cal_view, NULL, -1);
+#endif
g_list_free (selected);
}
@@ -868,7 +819,9 @@ clipboard_get_calendar_data (ECalendarView *cal_view, const gchar *text)
if (kind != ICAL_VCALENDAR_COMPONENT && kind != ICAL_VEVENT_COMPONENT)
return;
+#if 0 /* KILL-BONOBO */
e_calendar_view_set_status_message (cal_view, _("Updating objects"), -1);
+#endif
e_calendar_view_get_selected_time_range (cal_view, &selected_time_start, &selected_time_end);
if ((selected_time_end - selected_time_start) == 60 * 60 * 24)
@@ -916,7 +869,9 @@ clipboard_get_calendar_data (ECalendarView *cal_view, const gchar *text)
e_calendar_view_add_event (cal_view, client, selected_time_start, default_zone, icalcomp, in_top_canvas);
}
+#if 0 /* KILL-BONOBO */
e_calendar_view_set_status_message (cal_view, NULL, -1);
+#endif
}
static void
@@ -1239,53 +1194,15 @@ e_calendar_view_delete_selected_occurrence (ECalendarView *cal_view)
}
static void
-on_new_appointment (EPopup *ep, EPopupItem *pitem, gpointer data)
-{
- ECalendarView *cal_view = data;
-
- e_calendar_view_new_appointment (cal_view);
-}
-
-static void
-on_new_event (EPopup *ep, EPopupItem *pitem, gpointer data)
-{
- ECalendarView *cal_view = data;
-
- e_calendar_view_new_appointment_full (cal_view, TRUE, FALSE, FALSE);
-}
-
-static void
-on_new_meeting (EPopup *ep, EPopupItem *pitem, gpointer data)
-{
- ECalendarView *cal_view = data;
-
- e_calendar_view_new_appointment_full (cal_view, FALSE, TRUE, FALSE);
-}
-
-static void
on_new_task (EPopup *ep, EPopupItem *pitem, gpointer data)
{
+#if 0 /* KILL-BONOBO */
ECalendarView *cal_view = data;
time_t dtstart, dtend;
e_calendar_view_get_selected_time_range (cal_view, &dtstart, &dtend);
gnome_calendar_new_task (cal_view->priv->calendar, &dtstart, &dtend);
-}
-
-static void
-on_goto_date (EPopup *ep, EPopupItem *pitem, gpointer data)
-{
- ECalendarView *cal_view = data;
-
- goto_dialog (cal_view->priv->calendar);
-}
-
-static void
-on_goto_today (EPopup *ep, EPopupItem *pitem, gpointer data)
-{
- ECalendarView *cal_view = data;
-
- calendar_goto_today (cal_view->priv->calendar);
+#endif
}
static void
@@ -1310,9 +1227,11 @@ on_edit_appointment (EPopup *ep, EPopupItem *pitem, gpointer data)
static void
on_print (EPopup *ep, EPopupItem *pitem, gpointer data)
{
+#if 0 /* KILL-BONOBO */
ECalendarView *cal_view = data;
calendar_command_print (cal_view->priv->calendar, GTK_PRINT_OPERATION_ACTION_PRINT_DIALOG);
+#endif
}
static void
@@ -1346,28 +1265,6 @@ on_save_as (EPopup *ep, EPopupItem *pitem, gpointer data)
}
static void
-on_print_event (EPopup *ep, EPopupItem *pitem, gpointer data)
-{
- ECalendarView *cal_view = data;
- GList *selected;
- ECalendarViewEvent *event;
- ECalComponent *comp;
-
- selected = e_calendar_view_get_selected_events (cal_view);
- if (!selected)
- return;
-
- event = (ECalendarViewEvent *) selected->data;
-
- comp = e_cal_component_new ();
- e_cal_component_set_icalcomponent (comp, icalcomponent_new_clone (event->comp_data->icalcomp));
- print_comp (comp, event->comp_data->client, GTK_PRINT_OPERATION_ACTION_PRINT_DIALOG);
-
- g_object_unref (comp);
- g_list_free (selected);
-}
-
-static void
transfer_item_to (ECalendarViewEvent *event, ECal *dest_client, gboolean remove_item)
{
const gchar *uid;
@@ -1471,16 +1368,20 @@ transfer_selected_items (ECalendarView *cal_view, gboolean remove_item)
return;
}
+#if 0 /* KILL-BONOBO */
/* process all selected events */
if (remove_item)
e_calendar_view_set_status_message (cal_view, _("Moving items"), -1);
else
e_calendar_view_set_status_message (cal_view, _("Copying items"), -1);
+#endif
for (l = selected; l != NULL; l = l->next)
transfer_item_to ((ECalendarViewEvent *) l->data, dest_client, remove_item);
+#if 0 /* KILL-BONOBO */
e_calendar_view_set_status_message (cal_view, NULL, -1);
+#endif
/* free memory */
g_object_unref (destination_source);
@@ -1781,9 +1682,6 @@ on_paste (EPopup *ep, EPopupItem *pitem, gpointer data)
}
static EPopupItem ecv_main_items [] = {
- { E_POPUP_ITEM, (gchar *) "00.new", (gchar *) N_("New _Appointment..."), on_new_appointment, NULL, (gchar *) "appointment-new", 0, 0 },
- { E_POPUP_ITEM, (gchar *) "10.newallday", (gchar *) N_("New All Day _Event"), on_new_event, NULL, (gchar *) "stock_new-24h-appointment", 0, 0},
- { E_POPUP_ITEM, (gchar *) "20.meeting", (gchar *) N_("New _Meeting"), on_new_meeting, NULL, (gchar *) "stock_new-meeting", 0, 0},
{ E_POPUP_ITEM, (gchar *) "30.task", (gchar *) N_("New _Task"), on_new_task, NULL, (gchar *) "stock_task", 0, 0},
{ E_POPUP_BAR, (gchar *) "40."},
@@ -1795,15 +1693,11 @@ static EPopupItem ecv_main_items [] = {
{ E_POPUP_BAR, (gchar *) "60." },
/* FIXME: hook in this somehow */
{ E_POPUP_SUBMENU, (gchar *) "60.view", (gchar *) N_("_Current View") },
-
- { E_POPUP_ITEM, (gchar *) "61.today", (gchar *) N_("Select T_oday"), on_goto_today, NULL, (gchar *) "go-today" },
- { E_POPUP_ITEM, (gchar *) "62.todate", (gchar *) N_("_Select Date..."), on_goto_date, NULL, (gchar *) GTK_STOCK_JUMP_TO },
};
static EPopupItem ecv_child_items [] = {
{ E_POPUP_ITEM, (gchar *) "00.open", (gchar *) N_("_Open"), on_edit_appointment, NULL, (gchar *) GTK_STOCK_OPEN, 0, E_CAL_POPUP_SELECT_NOTEDITING },
{ E_POPUP_ITEM, (gchar *) "10.saveas", (gchar *) N_("_Save As..."), on_save_as, NULL, (gchar *) GTK_STOCK_SAVE_AS, 0, E_CAL_POPUP_SELECT_NOTEDITING },
- { E_POPUP_ITEM, (gchar *) "20.print", (gchar *) N_("Pri_nt..."), on_print_event, NULL, (gchar *) GTK_STOCK_PRINT, 0, E_CAL_POPUP_SELECT_NOTEDITING },
{ E_POPUP_BAR, (gchar *) "30." },
@@ -1829,69 +1723,6 @@ static EPopupItem ecv_child_items [] = {
{ E_POPUP_ITEM, (gchar *) "54.delete", (gchar *) N_("Delete _All Occurrences"), on_delete_appointment, NULL, (gchar *) GTK_STOCK_DELETE, E_CAL_POPUP_SELECT_RECURRING, E_CAL_POPUP_SELECT_NOTEDITING | E_CAL_POPUP_SELECT_EDITABLE },
};
-static void
-ecv_popup_free (EPopup *ep, GSList *list, gpointer data)
-{
- g_slist_free(list);
-}
-
-GtkMenu *
-e_calendar_view_create_popup_menu (ECalendarView *cal_view)
-{
- ECalPopup *ep;
- GSList *menus = NULL;
- GList *selected, *l;
- gint i;
- ECalPopupTargetSelect *t;
- ECalModel *model;
- GPtrArray *events;
-
- g_return_val_if_fail (E_IS_CALENDAR_VIEW (cal_view), NULL);
-
- /* We could do this using a factory on the ECalPopup class,
- * that way we would get called implicitly whenever a popup
- * menu was created rather than everyone having to call us.
- * We could also have a different menu id for each view */
-
- /** @HookPoint-ECalPopup: Calendar Main View Context Menu
- * @Id: org.gnome.evolution.calendar.view.popup
- * @Class: org.gnome.evolution.calendar.popup:1.0
- * @Target: ECalPopupTargetSelect
- *
- * The context menu on the main calendar view. This menu
- * applies to all view types.
- */
- ep = e_cal_popup_new("org.gnome.evolution.calendar.view.popup");
-
- model = e_calendar_view_get_model(cal_view);
- events = g_ptr_array_new();
- selected = e_calendar_view_get_selected_events(cal_view);
- for (l=selected;l;l=g_list_next(l)) {
- ECalendarViewEvent *event = l->data;
-
- if (event)
- g_ptr_array_add(events, e_cal_model_copy_component_data(event->comp_data));
- }
- g_list_free(selected);
-
- t = e_cal_popup_target_new_select(ep, model, events);
- t->target.widget = (GtkWidget *)cal_view;
-
- if (t->events->len == 0) {
- for (i=0;i<sizeof(ecv_main_items)/sizeof(ecv_main_items[0]);i++)
- menus = g_slist_prepend(menus, &ecv_main_items[i]);
-
- gnome_calendar_view_popup_factory(cal_view->priv->calendar, (EPopup *)ep, "60.view");
- } else {
- for (i=0;i<sizeof(ecv_child_items)/sizeof(ecv_child_items[0]);i++)
- menus = g_slist_prepend(menus, &ecv_child_items[i]);
- }
-
- e_popup_add_items((EPopup *)ep, menus, NULL, ecv_popup_free, cal_view);
-
- return e_popup_create_menu_once((EPopup *)ep, (EPopupTarget *)t, 0);
-}
-
void
e_calendar_view_open_event (ECalendarView *cal_view)
{
@@ -2090,7 +1921,7 @@ e_calendar_view_new_appointment (ECalendarView *cal_view)
static void
object_created_cb (CompEditor *ce, ECalendarView *cal_view)
{
- gnome_calendar_emit_user_created_signal (cal_view, e_calendar_view_get_calendar (cal_view), comp_editor_get_client (ce));
+ e_calendar_view_emit_user_created (cal_view);
}
CompEditor *
@@ -2099,12 +1930,16 @@ e_calendar_view_open_event_with_flags (ECalendarView *cal_view, ECal *client, ic
CompEditor *ce;
const gchar *uid;
ECalComponent *comp;
+ EShell *shell;
+
+ /* FIXME ECalendarView should own an EShell pointer. */
+ shell = e_shell_get_default ();
uid = icalcomponent_get_uid (icalcomp);
- ce = e_comp_editor_registry_find (comp_editor_registry, uid);
+ ce = comp_editor_find_instance (uid);
if (!ce) {
- ce = event_editor_new (client, flags);
+ ce = event_editor_new (client, shell, flags);
g_signal_connect (ce, "object_created", G_CALLBACK (object_created_cb), cal_view);
@@ -2114,8 +1949,6 @@ e_calendar_view_open_event_with_flags (ECalendarView *cal_view, ECal *client, ic
if (flags & COMP_EDITOR_MEETING)
event_editor_show_meeting (EVENT_EDITOR (ce));
- e_comp_editor_registry_add (comp_editor_registry, ce, FALSE);
-
g_object_unref (comp);
}
@@ -2599,6 +2432,14 @@ e_calendar_view_get_icalcomponent_summary (ECal *ecal, icalcomponent *icalcomp,
}
void
+e_calendar_view_emit_user_created (ECalendarView *cal_view)
+{
+ g_return_if_fail (E_IS_CALENDAR_VIEW (cal_view));
+
+ g_signal_emit (cal_view, signals[USER_CREATED], 0);
+}
+
+void
draw_curved_rectangle (cairo_t *cr, double x0, double y0,
double rect_width, double rect_height,
double radius)
@@ -2651,31 +2492,10 @@ draw_curved_rectangle (cairo_t *cr, double x0, double y0,
static void
error_response(GtkWidget *widget, gint response, gpointer data)
{
- gtk_widget_destroy (widget);
-}
-
-void
-e_calendar_utils_show_error_silent (GtkWidget *widget)
-{
- EActivityHandler *handler = calendar_component_peek_activity_handler (calendar_component_peek ());
-
- if (!g_object_get_data ((GObject *) widget, "response-handled")) {
- g_signal_connect(widget, "response", G_CALLBACK(error_response), NULL);
- }
-
- e_activity_handler_make_error (handler, "calendar", E_LOG_ERROR, widget);
-}
-
-void
-e_calendar_utils_show_info_silent (GtkWidget *widget)
-{
- EActivityHandler *handler = calendar_component_peek_activity_handler (calendar_component_peek ());
-
- if (!g_object_get_data ((GObject *) widget, "response-handled")) {
- g_signal_connect(widget, "response", G_CALLBACK(error_response), NULL);
- }
-
- e_activity_handler_make_error (handler, "calendar", E_LOG_WARNINGS, widget);
+ if (response == GTK_RESPONSE_DELETE_EVENT)
+ gtk_widget_destroy(widget);
+ else if (response == GTK_RESPONSE_OK)
+ gtk_widget_destroy(widget);
}
/* returns either light or dark yellow, based on the base_background,
diff --git a/calendar/gui/e-calendar-view.h b/calendar/gui/e-calendar-view.h
index 4d33fcba07..5f554720f8 100644
--- a/calendar/gui/e-calendar-view.h
+++ b/calendar/gui/e-calendar-view.h
@@ -20,26 +20,35 @@
*
*/
-#ifndef _E_CALENDAR_VIEW_H_
-#define _E_CALENDAR_VIEW_H_
+#ifndef E_CALENDAR_VIEW_H
+#define E_CALENDAR_VIEW_H
-#include <libecal/e-cal.h>
#include <gtk/gtk.h>
+#include <libecal/e-cal.h>
#include "e-cal-model.h"
#include "gnome-cal.h"
-#include "e-activity-handler.h"
#include "dialogs/comp-editor.h"
-G_BEGIN_DECLS
+/* Standard GObject macros */
+#define E_TYPE_CALENDAR_VIEW \
+ (e_calendar_view_get_type ())
+#define E_CALENDAR_VIEW(obj) \
+ (G_TYPE_CHECK_INSTANCE_CAST \
+ ((obj), E_TYPE_CALENDAR_VIEW, ECalendarView))
+#define E_CALENDAR_VIEW_CLASS(cls) \
+ (G_TYPE_CHECK_CLASS_CAST \
+ ((cls), E_TYPE_CALENDAR_VIEW, ECalendarViewClass))
+#define E_IS_CALENDAR_VIEW(obj) \
+ (G_TYPE_CHECK_INSTANCE_TYPE \
+ ((obj), E_TYPE_CALENDAR_VIEW))
+#define E_IS_CALENDAR_VIEW_CLASS(cls) \
+ (G_TYPE_CHECK_CLASS_TYPE \
+ ((cls), E_TYPE_CALENDAR_VIEW))
+#define E_CALENDAR_VIEW_GET_CLASS(obj) \
+ (G_TYPE_INSTANCE_GET_CLASS \
+ ((obj), E_TYPE_CALENDAR_VIEW, ECalendarViewClass))
-/*
- * EView - base widget class for the calendar views.
- */
-
-#define E_TYPE_CALENDAR_VIEW (e_calendar_view_get_type ())
-#define E_CALENDAR_VIEW(obj) G_TYPE_CHECK_INSTANCE_CAST (obj, e_calendar_view_get_type (), ECalendarView)
-#define E_CALENDAR_VIEW_CLASS(klass) G_TYPE_CHECK_CLASS_CAST (klass, e_calendar_view_get_type (), ECalendarViewClass)
-#define E_IS_CALENDAR_VIEW(obj) G_TYPE_CHECK_INSTANCE_TYPE (obj, e_calendar_view_get_type ())
+G_BEGIN_DECLS
typedef enum {
E_CALENDAR_VIEW_POS_OUTSIDE,
@@ -61,13 +70,13 @@ typedef enum {
} ECalViewMoveDirection;
#define E_CALENDAR_VIEW_EVENT_FIELDS \
- GnomeCanvasItem *canvas_item; \
- ECalModelComponent *comp_data; \
- time_t start; \
- time_t end; \
- guint16 start_minute; \
- guint16 end_minute; \
- guint different_timezone : 1; \
+ GnomeCanvasItem *canvas_item; \
+ ECalModelComponent *comp_data; \
+ time_t start; \
+ time_t end; \
+ guint16 start_minute; \
+ guint16 end_minute; \
+ guint different_timezone : 1; \
gboolean is_editable; \
GtkWidget *tooltip; \
gint timeout; \
@@ -78,13 +87,12 @@ typedef struct {
E_CALENDAR_VIEW_EVENT_FIELDS
} ECalendarViewEvent;
-typedef struct _ECalendarView ECalendarView;
-typedef struct _ECalendarViewClass ECalendarViewClass;
+typedef struct _ECalendarView ECalendarView;
+typedef struct _ECalendarViewClass ECalendarViewClass;
typedef struct _ECalendarViewPrivate ECalendarViewPrivate;
struct _ECalendarView {
- GtkTable table;
-
+ GtkTable parent;
gboolean in_focus;
ECalendarViewPrivate *priv;
};
@@ -130,7 +138,6 @@ void e_calendar_view_set_default_category (ECalendarView *cal_view, co
gboolean e_calendar_view_get_use_24_hour_format (ECalendarView *view);
void e_calendar_view_set_use_24_hour_format (ECalendarView *view, gboolean use_24_hour);
-void e_calendar_view_set_activity_handler (ECalendarView *cal_view, EActivityHandler *activity_handler);
void e_calendar_view_set_status_message (ECalendarView *cal_view, const gchar *message, gint percent);
GList *e_calendar_view_get_selected_events (ECalendarView *cal_view);
@@ -181,6 +188,9 @@ void e_calendar_view_move_tip (GtkWidget *widget, gint x, gint y);
const gchar *e_calendar_view_get_icalcomponent_summary (ECal *ecal, icalcomponent *icalcomp, gboolean *free_text);
gchar *e_calendar_view_get_attendees_status_info (ECalComponent *comp, ECal *client);
+void e_calendar_view_emit_user_created
+ (ECalendarView *cal_view);
+
void draw_curved_rectangle (cairo_t *cr,
double x0,
double y0,
@@ -192,4 +202,4 @@ GdkColor get_today_background (GdkColor event_background);
G_END_DECLS
-#endif
+#endif /* E_CALENDAR_VIEW_H */
diff --git a/calendar/gui/e-cell-date-edit-config.h b/calendar/gui/e-cell-date-edit-config.h
index 455cca7287..9917378dd1 100644
--- a/calendar/gui/e-cell-date-edit-config.h
+++ b/calendar/gui/e-cell-date-edit-config.h
@@ -24,7 +24,7 @@
#ifndef _E_CELL_DATE_EDIT_CONFIG_H_
#define _E_CELL_DATE_EDIT_CONFIG_H_
-#include <misc/e-cell-date-edit.h>
+#include <table/e-cell-date-edit.h>
#include "e-cell-date-edit-text.h"
G_BEGIN_DECLS
diff --git a/calendar/gui/e-day-view-main-item.c b/calendar/gui/e-day-view-main-item.c
index 28091409ce..b55dba425c 100644
--- a/calendar/gui/e-day-view-main-item.c
+++ b/calendar/gui/e-day-view-main-item.c
@@ -32,7 +32,7 @@
#include "e-util/e-categories-config.h"
#include "e-day-view-layout.h"
#include "e-day-view-main-item.h"
-#include "ea-calendar.h"
+/*#include "a11y/ea-calendar.h"*/ /* KILL-BONOBO */
#include "e-calendar-view.h"
#include "comp-util.h"
#include <libecal/e-cal-time-util.h>
@@ -111,7 +111,9 @@ e_day_view_main_item_class_init (EDayViewMainItemClass *class)
G_PARAM_WRITABLE));
/* init the accessibility support for e_day_view */
+#if 0 /* KILL-BONOBO */
e_day_view_main_item_a11y_init ();
+#endif
}
static void
diff --git a/calendar/gui/e-day-view.c b/calendar/gui/e-day-view.c
index 614e7b7d87..c3533e629c 100644
--- a/calendar/gui/e-day-view.c
+++ b/calendar/gui/e-day-view.c
@@ -26,7 +26,7 @@
#endif
#include "e-day-view.h"
-#include "ea-calendar.h"
+/*#include "a11y/ea-calendar.h"*/ /* KILL-BONOBO */
#include <math.h>
#include <time.h>
@@ -35,7 +35,7 @@
#include <misc/e-canvas-utils.h>
#include <misc/e-popup-menu.h>
#include <misc/e-gui-utils.h>
-#include <misc/e-unicode.h>
+#include <e-util/e-unicode.h>
#include <libgnomecanvas/gnome-canvas-rect-ellipse.h>
#include <glib/gi18n.h>
#include <e-util/e-categories-config.h>
@@ -51,7 +51,6 @@
#include "print.h"
#include "comp-util.h"
#include "itip-utils.h"
-#include "calendar-commands.h"
#include "calendar-config.h"
#include "goto.h"
#include "e-cal-model-calendar.h"
@@ -464,8 +463,10 @@ e_day_view_class_init (EDayViewClass *class)
view_class->get_visible_time_range = e_day_view_get_visible_time_range;
view_class->paste_text = e_day_view_paste_text;
+#if 0 /* KILL-BONOBO */
/* init the accessibility support for e_day_view */
e_day_view_a11y_init ();
+#endif
}
static void
@@ -3352,9 +3353,11 @@ e_day_view_show_popup_menu (EDayView *day_view,
day_view->popup_event_day = day;
day_view->popup_event_num = event_num;
+#if 0 /* KILL-BONOBO */
popup = e_calendar_view_create_popup_menu (E_CALENDAR_VIEW (day_view));
g_object_weak_ref (G_OBJECT (popup), popup_destroyed_cb, day_view);
gtk_menu_popup (popup, NULL, NULL, NULL, NULL, gdk_event?gdk_event->button.button:0, gdk_event?gdk_event->button.time:gtk_get_current_event_time());
+#endif
}
static gboolean
@@ -5537,6 +5540,7 @@ e_day_view_cursor_key_down (EDayView *day_view, GdkEventKey *event)
static void
e_day_view_cursor_key_left (EDayView *day_view, GdkEventKey *event)
{
+#if 0 /* KILL-BONOBO */
if (day_view->selection_start_day == 0) {
gnome_calendar_previous (e_calendar_view_get_calendar (E_CALENDAR_VIEW (day_view)));
} else {
@@ -5550,11 +5554,13 @@ e_day_view_cursor_key_left (EDayView *day_view, GdkEventKey *event)
gtk_widget_queue_draw (day_view->main_canvas);
}
g_signal_emit_by_name (day_view, "selected_time_changed");
+#endif
}
static void
e_day_view_cursor_key_right (EDayView *day_view, GdkEventKey *event)
{
+#if 0 /* KILL-BONOBO */
if (day_view->selection_end_day == day_view->days_shown - 1) {
gnome_calendar_next (e_calendar_view_get_calendar (E_CALENDAR_VIEW (day_view)));
} else {
@@ -5568,6 +5574,7 @@ e_day_view_cursor_key_right (EDayView *day_view, GdkEventKey *event)
gtk_widget_queue_draw (day_view->main_canvas);
}
g_signal_emit_by_name (day_view, "selected_time_changed");
+#endif
}
/* Scrolls the main canvas up or down. The pages_to_scroll argument
@@ -6298,7 +6305,8 @@ e_day_view_on_editing_stopped (EDayView *day_view,
if (!e_cal_create_object (client, icalcomp, NULL, NULL))
g_message (G_STRLOC ": Could not create the object!");
else
- gnome_calendar_emit_user_created_signal (day_view, e_calendar_view_get_calendar (E_CALENDAR_VIEW (day_view)), client);
+ e_calendar_view_emit_user_created (
+ E_CALENDAR_VIEW (day_view));
/* we remove the object since we either got the update from the server or failed */
e_day_view_remove_event_cb (day_view, day, event_num, NULL);
diff --git a/calendar/gui/e-itip-control.c b/calendar/gui/e-itip-control.c
index e8922abde7..88abd1b007 100644
--- a/calendar/gui/e-itip-control.c
+++ b/calendar/gui/e-itip-control.c
@@ -31,8 +31,6 @@
#include <unistd.h>
#include <glib/gi18n.h>
#include <glib/gstdio.h>
-#include <bonobo/bonobo-object.h>
-#include <bonobo/bonobo-exception.h>
#include <gtkhtml/gtkhtml.h>
#include <gtkhtml/gtkhtml-embedded.h>
#include <gtkhtml/gtkhtml-stream.h>
@@ -52,6 +50,7 @@
#include "itip-utils.h"
#include "e-itip-control.h"
#include "common/authentication.h"
+#include <shell/e-shell.h>
struct _EItipControlPrivate {
GtkWidget *html;
@@ -243,12 +242,18 @@ source_changed_cb (ESourceComboBox *escb, EItipControl *itip)
static void
find_cal_opened_cb (ECal *ecal, ECalendarStatus status, gpointer data)
{
+ EShell *shell;
+ EShellSettings *shell_settings;
EItipControlFindData *fd = data;
EItipControlPrivate *priv;
ESource *source;
ECalSourceType source_type;
icalcomponent *icalcomp;
+ /* FIXME Pass this in. */
+ shell = e_shell_get_default ();
+ shell_settings = e_shell_get_shell_settings (shell);
+
source_type = e_cal_get_source_type (ecal);
source = e_cal_get_source (ecal);
@@ -275,20 +280,24 @@ find_cal_opened_cb (ECal *ecal, ECalendarStatus status, gpointer data)
if (fd->count == 0) {
if (fd->show_selector && !priv->current_ecal && priv->vbox.widget) {
GtkWidget *escb;
+ const gchar *property_name;
gchar *uid;
switch (priv->type) {
case E_CAL_SOURCE_TYPE_EVENT:
- uid = calendar_config_get_primary_calendar ();
+ property_name = "cal-primary-calendar";
break;
case E_CAL_SOURCE_TYPE_TODO:
- uid = calendar_config_get_primary_tasks ();
+ property_name = "cal-primary-tasks";
break;
default:
uid = NULL;
g_return_if_reached ();
}
+ uid = e_shell_settings_get_string (
+ shell_settings, property_name);
+
if (uid) {
source = e_source_list_peek_source_by_uid (priv->source_lists[priv->type], uid);
g_free (uid);
diff --git a/calendar/gui/e-meeting-time-sel.c b/calendar/gui/e-meeting-time-sel.c
index 1f4f953c9c..9ca98268e7 100644
--- a/calendar/gui/e-meeting-time-sel.c
+++ b/calendar/gui/e-meeting-time-sel.c
@@ -35,14 +35,13 @@
#include <glib/gi18n.h>
#include <libgnomecanvas/gnome-canvas-widget.h>
-#include <misc/e-canvas.h>
-#include <misc/e-canvas-utils.h>
+#include "misc/e-canvas.h"
+#include "misc/e-canvas-utils.h"
-#include <misc/e-dateedit.h>
-#include <e-util/e-cursor.h>
-#include <e-util/e-util.h>
+#include "misc/e-dateedit.h"
+#include "e-util/e-cursor.h"
+#include "e-util/e-util.h"
-#include "calendar-component.h"
#include "calendar-config.h"
#include "e-meeting-utils.h"
#include "e-meeting-list-view.h"
diff --git a/calendar/gui/e-memo-list-selector.c b/calendar/gui/e-memo-list-selector.c
new file mode 100644
index 0000000000..e31a9d4b6e
--- /dev/null
+++ b/calendar/gui/e-memo-list-selector.c
@@ -0,0 +1,287 @@
+/* -*- Mode: C; indent-tabs-mode: t; c-basic-offset: 8; tab-width: 8 -*- */
+/* e-memo-list-selector.c
+ *
+ * Copyright (C) 1999-2008 Novell, Inc. (www.novell.com)
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of version 2 of the GNU General Public
+ * License as published by the Free Software Foundation.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public
+ * License along with this program; if not, write to the
+ * Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
+ * Boston, MA 02110-1301, USA.
+ */
+
+#include "e-memo-list-selector.h"
+
+#include <string.h>
+#include <libecal/e-cal.h>
+#include "calendar/common/authentication.h"
+#include "calendar/gui/comp-util.h"
+
+#define E_MEMO_LIST_SELECTOR_GET_PRIVATE(obj) \
+ (G_TYPE_INSTANCE_GET_PRIVATE \
+ ((obj), E_TYPE_MEMO_LIST_SELECTOR, EMemoListSelectorPrivate))
+
+struct _EMemoListSelectorPrivate {
+ gint dummy_value;
+};
+
+enum {
+ DND_TARGET_TYPE_CALENDAR_LIST
+};
+
+static GtkTargetEntry drag_types[] = {
+ { (gchar *) "text/calendar", 0, DND_TARGET_TYPE_CALENDAR_LIST },
+ { (gchar *) "text/x-calendar", 0, DND_TARGET_TYPE_CALENDAR_LIST }
+};
+
+static gpointer parent_class;
+
+static gboolean
+memo_list_selector_update_single_object (ECal *client,
+ icalcomponent *icalcomp)
+{
+ gchar *uid;
+ icalcomponent *tmp_icalcomp;
+
+ uid = (gchar *) icalcomponent_get_uid (icalcomp);
+
+ if (e_cal_get_object (client, uid, NULL, &tmp_icalcomp, NULL))
+ return e_cal_modify_object (
+ client, icalcomp, CALOBJ_MOD_ALL, NULL);
+
+ return e_cal_create_object (client, icalcomp, &uid, NULL);
+}
+
+static gboolean
+memo_list_selector_update_objects (ECal *client,
+ icalcomponent *icalcomp)
+{
+ icalcomponent *subcomp;
+ icalcomponent_kind kind;
+
+ kind = icalcomponent_isa (icalcomp);
+ if (kind == ICAL_VJOURNAL_COMPONENT)
+ return memo_list_selector_update_single_object (
+ client, icalcomp);
+ else if (kind != ICAL_VCALENDAR_COMPONENT)
+ return FALSE;
+
+ subcomp = icalcomponent_get_first_component (
+ icalcomp, ICAL_ANY_COMPONENT);
+ while (subcomp != NULL) {
+ gboolean success;
+
+ kind = icalcomponent_isa (subcomp);
+ if (kind == ICAL_VTIMEZONE_COMPONENT) {
+ icaltimezone *zone;
+
+ zone = icaltimezone_new ();
+ icaltimezone_set_component (zone, subcomp);
+
+ success = e_cal_add_timezone (client, zone, NULL);
+ icaltimezone_free (zone, 1);
+ if (!success)
+ return FALSE;
+ } else if (kind == ICAL_VJOURNAL_COMPONENT) {
+ success = memo_list_selector_update_single_object (
+ client, subcomp);
+ if (!success)
+ return FALSE;
+ }
+
+ subcomp = icalcomponent_get_next_component (
+ icalcomp, ICAL_ANY_COMPONENT);
+ }
+
+ return TRUE;
+}
+
+static gboolean
+memo_list_selector_process_data (ESourceSelector *selector,
+ ECal *client,
+ const gchar *source_uid,
+ icalcomponent *icalcomp,
+ GdkDragAction action)
+{
+ ESourceList *source_list;
+ ESource *source;
+ icalcomponent *tmp_icalcomp = NULL;
+ const gchar *uid;
+ gchar *old_uid = NULL;
+ gboolean success = FALSE;
+ gboolean read_only = TRUE;
+ GError *error = NULL;
+
+ /* FIXME Deal with GDK_ACTION_ASK. */
+ if (action == GDK_ACTION_COPY) {
+ old_uid = g_strdup (icalcomponent_get_uid (icalcomp));
+ uid = e_cal_component_gen_uid ();
+ icalcomponent_set_uid (icalcomp, uid);
+ }
+
+ uid = icalcomponent_get_uid (icalcomp);
+ if (old_uid == NULL)
+ old_uid = g_strdup (uid);
+
+ if (e_cal_get_object (client, uid, NULL, &tmp_icalcomp, &error)) {
+ icalcomponent_free (tmp_icalcomp);
+ success = TRUE;
+ goto exit;
+ }
+
+ if (error != NULL && error->code != E_CALENDAR_STATUS_OBJECT_NOT_FOUND) {
+ g_message (
+ "Failed to search the object in destination "
+ "task list: %s", error->message);
+ g_error_free (error);
+ goto exit;
+ }
+
+ success = memo_list_selector_update_objects (client, icalcomp);
+
+ if (!success || action != GDK_ACTION_MOVE)
+ goto exit;
+
+ source_list = e_source_selector_get_source_list (selector);
+ source = e_source_list_peek_source_by_uid (source_list, source_uid);
+
+ if (!E_IS_SOURCE (source) || e_source_get_readonly (source))
+ goto exit;
+
+ client = auth_new_cal_from_source (source, E_CAL_SOURCE_TYPE_JOURNAL);
+ if (client == NULL) {
+ g_message ("Cannot create source client to remove old memo");
+ goto exit;
+ }
+
+ e_cal_is_read_only (client, &read_only, NULL);
+ if (!read_only && e_cal_open (client, TRUE, NULL))
+ e_cal_remove_object (client, old_uid, NULL);
+ else if (!read_only)
+ g_message ("Cannot open source client to remove old memo");
+
+ g_object_unref (client);
+
+exit:
+ g_free (old_uid);
+
+ return success;
+}
+
+static gboolean
+memo_list_selector_data_dropped (ESourceSelector *selector,
+ GtkSelectionData *selection_data,
+ ESource *destination,
+ GdkDragAction action,
+ guint info)
+{
+ ECal *client;
+ GSList *list, *iter;
+ gboolean success = FALSE;
+
+ client = auth_new_cal_from_source (
+ destination, E_CAL_SOURCE_TYPE_JOURNAL);
+
+ if (client == NULL || !e_cal_open (client, TRUE, NULL))
+ goto exit;
+
+ list = cal_comp_selection_get_string_list (selection_data);
+
+ for (iter = list; iter != NULL; iter = iter->next) {
+ gchar *source_uid = iter->data;
+ icalcomponent *icalcomp;
+ gchar *component_string;
+
+ /* Each string is "source_uid\ncomponent_string". */
+ component_string = strchr (source_uid, '\n');
+ if (component_string == NULL)
+ continue;
+
+ *component_string++ = '\0';
+ icalcomp = icalparser_parse_string (component_string);
+ if (icalcomp == NULL)
+ continue;
+
+ success = memo_list_selector_process_data (
+ selector, client, source_uid, icalcomp, action);
+
+ icalcomponent_free (icalcomp);
+ }
+
+ g_slist_foreach (list, (GFunc) g_free, NULL);
+ g_slist_free (list);
+
+exit:
+ if (client != NULL)
+ g_object_unref (client);
+
+ return success;
+}
+
+static void
+memo_list_selector_class_init (EMemoListSelectorClass *class)
+{
+ ESourceSelectorClass *source_selector_class;
+
+ parent_class = g_type_class_peek_parent (class);
+ g_type_class_add_private (class, sizeof (EMemoListSelectorPrivate));
+
+ source_selector_class = E_SOURCE_SELECTOR_CLASS (class);
+ source_selector_class->data_dropped = memo_list_selector_data_dropped;
+}
+
+static void
+memo_list_selector_init (EMemoListSelector *selector)
+{
+ selector->priv = E_MEMO_LIST_SELECTOR_GET_PRIVATE (selector);
+
+ gtk_drag_dest_set (
+ GTK_WIDGET (selector), GTK_DEST_DEFAULT_ALL,
+ drag_types, G_N_ELEMENTS (drag_types),
+ GDK_ACTION_COPY | GDK_ACTION_MOVE);
+}
+
+GType
+e_memo_list_selector_get_type (void)
+{
+ static GType type = 0;
+
+ if (G_UNLIKELY (type == 0)) {
+ const GTypeInfo type_info = {
+ sizeof (EMemoListSelectorClass),
+ (GBaseInitFunc) NULL,
+ (GBaseFinalizeFunc) NULL,
+ (GClassInitFunc) memo_list_selector_class_init,
+ (GClassFinalizeFunc) NULL,
+ NULL, /* class_data */
+ sizeof (EMemoListSelector),
+ 0, /* n_preallocs */
+ (GInstanceInitFunc) memo_list_selector_init,
+ NULL /* value_table */
+ };
+
+ type = g_type_register_static (
+ E_TYPE_SOURCE_SELECTOR, "EMemoListSelector",
+ &type_info, 0);
+ }
+
+ return type;
+}
+
+GtkWidget *
+e_memo_list_selector_new (ESourceList *source_list)
+{
+ g_return_val_if_fail (E_IS_SOURCE_LIST (source_list), NULL);
+
+ return g_object_new (
+ E_TYPE_MEMO_LIST_SELECTOR,
+ "source-list", source_list, NULL);
+}
diff --git a/calendar/gui/e-memo-list-selector.h b/calendar/gui/e-memo-list-selector.h
new file mode 100644
index 0000000000..c10cff2a2e
--- /dev/null
+++ b/calendar/gui/e-memo-list-selector.h
@@ -0,0 +1,71 @@
+/* -*- Mode: C; indent-tabs-mode: t; c-basic-offset: 8; tab-width: 8 -*- */
+/* e-memo-list-selector.h
+ *
+ * Copyright (C) 1999-2008 Novell, Inc. (www.novell.com)
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of version 2 of the GNU General Public
+ * License as published by the Free Software Foundation.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public
+ * License along with this program; if not, write to the
+ * Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
+ * Boston, MA 02110-1301, USA.
+ */
+
+/* XXX This widget is nearly identical to ETaskListSelector. If
+ * ECalendarSelector ever learns how to move selections from
+ * one source to another, perhaps these ESourceSelector sub-
+ * classes could someday be combined. */
+
+#ifndef E_MEMO_LIST_SELECTOR_H
+#define E_MEMO_LIST_SELECTOR_H
+
+#include <libedataserver/e-source-list.h>
+#include <libedataserverui/e-source-selector.h>
+
+/* Standard GObject macros */
+#define E_TYPE_MEMO_LIST_SELECTOR \
+ (e_memo_list_selector_get_type ())
+#define E_MEMO_LIST_SELECTOR(obj) \
+ (G_TYPE_CHECK_INSTANCE_CAST \
+ ((obj), E_TYPE_MEMO_LIST_SELECTOR, EMemoListSelector))
+#define E_MEMO_LIST_SELECTOR_CLASS(cls) \
+ (G_TYPE_CHECK_CLASS_CAST \
+ ((cls), E_TYPE_MEMO_LIST_SELECTOR, EMemoListSelectorClass))
+#define E_IS_MEMO_LIST_SELECTOR(obj) \
+ (G_TYPE_CHECK_INSTANCE_TYPE \
+ ((obj), E_TYPE_MEMO_LIST_SELECTOR))
+#define E_IS_MEMO_LIST_SELECTOR_CLASS(cls) \
+ (G_TYPE_CHECK_CLASS_TYPE \
+ ((cls), E_TYPE_MEMO_LIST_SELECTOR))
+#define E_MEMO_LIST_SELECTOR_GET_CLASS(obj) \
+ (G_TYPE_INSTANCE_GET_CLASS \
+ ((obj), E_TYPE_MEMO_LIST_SELECTOR, EMemoListSelectorClass))
+
+G_BEGIN_DECLS
+
+typedef struct _EMemoListSelector EMemoListSelector;
+typedef struct _EMemoListSelectorClass EMemoListSelectorClass;
+typedef struct _EMemoListSelectorPrivate EMemoListSelectorPrivate;
+
+struct _EMemoListSelector {
+ ESourceSelector parent;
+ EMemoListSelectorPrivate *priv;
+};
+
+struct _EMemoListSelectorClass {
+ ESourceSelectorClass parent_class;
+};
+
+GType e_memo_list_selector_get_type (void);
+GtkWidget * e_memo_list_selector_new (ESourceList *source_list);
+
+G_END_DECLS
+
+#endif /* E_MEMO_LIST_SELECTOR_H */
diff --git a/calendar/gui/e-memo-table.c b/calendar/gui/e-memo-table.c
index 553f239a12..1cfc2b662b 100644
--- a/calendar/gui/e-memo-table.c
+++ b/calendar/gui/e-memo-table.c
@@ -24,7 +24,7 @@
/*
* EMemoTable - displays the ECalComponent objects in a table (an ETable).
- * Used for memos.
+ * Used for calendar events and tasks.
*/
#ifdef HAVE_CONFIG_H
@@ -35,15 +35,17 @@
#include <unistd.h>
#include <glib/gi18n.h>
#include <glib/gstdio.h>
-#include <gdk/gdkkeysyms.h>
#include <widgets/misc/e-gui-utils.h>
#include <table/e-cell-checkbox.h>
#include <table/e-cell-toggle.h>
#include <table/e-cell-text.h>
#include <table/e-cell-combo.h>
#include <e-util/e-dialog-utils.h>
-#include <widgets/misc/e-cell-date-edit.h>
-#include <widgets/misc/e-cell-percent.h>
+#include <e-util/e-util-private.h>
+#include <table/e-cell-date-edit.h>
+#include <table/e-cell-percent.h>
+#include <libecal/e-cal-time-util.h>
+#include <libedataserver/e-time-utils.h>
#include "calendar-config.h"
#include "dialogs/delete-comp.h"
@@ -51,63 +53,52 @@
#include "dialogs/memo-editor.h"
#include "e-cal-model-memos.h"
#include "e-memo-table.h"
+#include "e-calendar-view.h"
#include "e-cell-date-edit-text.h"
-#include "e-comp-editor-registry.h"
#include "print.h"
#include <e-util/e-icon-factory.h>
-#include <e-util/e-util-private.h>
#include "e-cal-popup.h"
-#include "e-calendar-table.h"
+#include "misc.h"
+
+#define E_MEMO_TABLE_GET_PRIVATE(obj) \
+ (G_TYPE_INSTANCE_GET_PRIVATE \
+ ((obj), E_TYPE_MEMO_TABLE, EMemoTablePrivate))
+
+struct _EMemoTablePrivate {
+ gpointer shell_view; /* weak pointer */
+ ECalModel *model;
+};
+
+enum {
+ PROP_0,
+ PROP_MODEL,
+ PROP_SHELL_VIEW
+};
-enum TargetType{
+enum {
+ OPEN_COMPONENT,
+ POPUP_EVENT,
+ STATUS_MESSAGE,
+ USER_CREATED,
+ LAST_SIGNAL
+};
+
+enum {
TARGET_TYPE_VCALENDAR
};
static GtkTargetEntry target_types[] = {
- { (gchar *) "text/x-calendar", 0, TARGET_TYPE_VCALENDAR },
- { (gchar *) "text/calendar", 0, TARGET_TYPE_VCALENDAR }
+ { (gchar *) "text/calendar", 0, TARGET_TYPE_VCALENDAR },
+ { (gchar *) "text/x-calendar", 0, TARGET_TYPE_VCALENDAR }
};
static guint n_target_types = G_N_ELEMENTS (target_types);
-extern ECompEditorRegistry *comp_editor_registry;
-
-static void e_memo_table_destroy (GtkObject *object);
-
-static void e_memo_table_on_double_click (ETable *table,
- gint row,
- gint col,
- GdkEvent *event,
- EMemoTable *memo_table);
-static gint e_memo_table_show_popup_menu (ETable *table,
- GdkEvent *gdk_event,
- EMemoTable *memo_table);
-
-static gint e_memo_table_on_right_click (ETable *table,
- gint row,
- gint col,
- GdkEvent *event,
- EMemoTable *memo_table);
-static gboolean e_memo_table_on_popup_menu (GtkWidget *widget,
- gpointer data);
-
-static gint e_memo_table_on_key_press (ETable *table,
- gint row,
- gint col,
- GdkEventKey *event,
- EMemoTable *memo_table);
static struct tm e_memo_table_get_current_time (ECellDateEdit *ecde, gpointer data);
-static ECalModelComponent *get_selected_comp (EMemoTable *memo_table);
-static void open_memo (EMemoTable *memo_table, ECalModelComponent *comp_data);
-
-/* Signal IDs */
-enum {
- USER_CREATED,
- LAST_SIGNAL
-};
-
-static guint signals[LAST_SIGNAL] = { 0 };
+static gpointer parent_class;
+static guint signals[LAST_SIGNAL];
+static GdkAtom clipboard_atom;
/* The icons to represent the task. */
#define E_MEMO_MODEL_NUM_ICONS 2
@@ -116,36 +107,45 @@ static const gchar * icon_names[E_MEMO_MODEL_NUM_ICONS] = {
};
static GdkPixbuf* icon_pixbufs[E_MEMO_MODEL_NUM_ICONS] = { NULL };
-static GdkAtom clipboard_atom = GDK_NONE;
+static void
+memo_table_emit_open_component (EMemoTable *memo_table,
+ ECalModelComponent *comp_data)
+{
+ guint signal_id = signals[OPEN_COMPONENT];
-G_DEFINE_TYPE (EMemoTable, e_memo_table, GTK_TYPE_TABLE)
+ g_signal_emit (memo_table, signal_id, 0, comp_data);
+}
static void
-e_memo_table_class_init (EMemoTableClass *klass)
+memo_table_emit_popup_event (EMemoTable *memo_table,
+ GdkEvent *event)
{
- GtkObjectClass *object_class;
+ guint signal_id = signals[POPUP_EVENT];
- object_class = (GtkObjectClass *) klass;
+ g_signal_emit (memo_table, signal_id, 0, event);
+}
- /* Method override */
- object_class->destroy = e_memo_table_destroy;
+static void
+memo_table_emit_status_message (EMemoTable *memo_table,
+ const gchar *message,
+ gdouble percent)
+{
+ guint signal_id = signals[STATUS_MESSAGE];
- signals[USER_CREATED] =
- g_signal_new ("user_created",
- G_TYPE_FROM_CLASS (klass),
- G_SIGNAL_RUN_LAST,
- G_STRUCT_OFFSET (EMemoTableClass, user_created),
- NULL, NULL,
- g_cclosure_marshal_VOID__VOID,
- G_TYPE_NONE, 0);
+ g_signal_emit (memo_table, signal_id, 0, message, percent);
+}
- /* clipboard atom */
- if (!clipboard_atom)
- clipboard_atom = gdk_atom_intern ("CLIPBOARD", FALSE);
+static void
+memo_table_emit_user_created (EMemoTable *memo_table)
+{
+ guint signal_id = signals[USER_CREATED];
+
+ g_signal_emit (memo_table, signal_id, 0);
}
static gint
-date_compare_cb (gconstpointer a, gconstpointer b)
+memo_table_date_compare_cb (gconstpointer a,
+ gconstpointer b)
{
ECellDateEditValue *dv1 = (ECellDateEditValue *) a;
ECellDateEditValue *dv2 = (ECellDateEditValue *) b;
@@ -173,76 +173,414 @@ date_compare_cb (gconstpointer a, gconstpointer b)
}
static void
-row_appended_cb (ECalModel *model, EMemoTable *memo_table)
+memo_table_double_click_cb (EMemoTable *memo_table,
+ gint row,
+ gint col,
+ GdkEvent *event)
+{
+ ECalModel *model;
+ ECalModelComponent *comp_data;
+
+ model = e_memo_table_get_model (memo_table);
+ comp_data = e_cal_model_get_component_at (model, row);
+ memo_table_emit_open_component (memo_table, comp_data);
+}
+
+static void
+memo_table_model_cal_view_progress_cb (EMemoTable *memo_table,
+ const gchar *message,
+ gint progress,
+ ECalSourceType type)
{
- g_signal_emit (memo_table, signals[USER_CREATED], 0);
+ gdouble percent = (gdouble) progress;
+
+ memo_table_emit_status_message (memo_table, message, percent);
+}
+
+static void
+memo_table_model_cal_view_done_cb (EMemoTable *memo_table,
+ ECalendarStatus status,
+ ECalSourceType type)
+{
+ memo_table_emit_status_message (memo_table, NULL, -1.0);
}
static gboolean
-query_tooltip_cb (GtkWidget *widget, gint x, gint y, gboolean keyboard_mode, GtkTooltip *tooltip, gpointer user_data)
+memo_table_query_tooltip_cb (EMemoTable *memo_table,
+ gint x,
+ gint y,
+ gboolean keyboard_mode,
+ GtkTooltip *tooltip)
{
- EMemoTable *memo_table;
+ ECalModel *model;
+ ECalModelComponent *comp_data;
+ gint row = -1, col = -1;
+ GtkWidget *box, *l, *w;
+ GtkStyle *style = gtk_widget_get_default_style ();
+ gchar *tmp;
+ const gchar *str;
+ GString *tmp2;
+ gchar buff[1001];
+ gboolean free_text = FALSE;
+ ECalComponent *new_comp;
+ ECalComponentOrganizer organizer;
+ ECalComponentDateTime dtstart, dtdue;
+ icalcomponent *clone;
+ icaltimezone *zone, *default_zone;
+ GSList *desc, *p;
+ gint len;
+ ETable *etable;
+ ESelectionModel *esm;
+ struct tm tmp_tm;
+
+ if (keyboard_mode)
+ return FALSE;
+
+ etable = e_memo_table_get_table (memo_table);
+ e_table_get_mouse_over_cell (etable, &row, &col);
+ if (row == -1 || !etable)
+ return FALSE;
+
+ /* Respect sorting option; the 'e_table_get_mouse_over_cell'
+ * returns sorted row, not the model one. */
+ esm = e_table_get_selection_model (etable);
+ if (esm && esm->sorter && e_sorter_needs_sorting (esm->sorter))
+ row = e_sorter_sorted_to_model (esm->sorter, row);
+
+ model = e_memo_table_get_model (memo_table);
+ comp_data = e_cal_model_get_component_at (model, row);
+ if (!comp_data || !comp_data->icalcomp)
+ return FALSE;
+
+ new_comp = e_cal_component_new ();
+ clone = icalcomponent_new_clone (comp_data->icalcomp);
+ if (!e_cal_component_set_icalcomponent (new_comp, clone)) {
+ g_object_unref (new_comp);
+ return FALSE;
+ }
+
+ box = gtk_vbox_new (FALSE, 0);
+
+ str = e_calendar_view_get_icalcomponent_summary (
+ comp_data->client, comp_data->icalcomp, &free_text);
+ if (!(str && *str)) {
+ if (free_text)
+ g_free ((gchar *)str);
+ free_text = FALSE;
+ str = _("* No Summary *");
+ }
+
+ l = gtk_label_new (NULL);
+ tmp = g_markup_printf_escaped ("<b>%s</b>", str);
+ gtk_label_set_line_wrap (GTK_LABEL (l), TRUE);
+ gtk_label_set_markup (GTK_LABEL (l), tmp);
+ gtk_misc_set_alignment (GTK_MISC (l), 0.0, 0.5);
+ w = gtk_event_box_new ();
+
+ gtk_widget_modify_bg (w, GTK_STATE_NORMAL, &(style->bg[GTK_STATE_SELECTED]));
+ gtk_widget_modify_fg (l, GTK_STATE_NORMAL, &(style->text[GTK_STATE_SELECTED]));
+ gtk_container_add (GTK_CONTAINER (w), l);
+ gtk_box_pack_start (GTK_BOX (box), w, TRUE, TRUE, 0);
+ g_free (tmp);
+
+ if (free_text)
+ g_free ((gchar *)str);
+ free_text = FALSE;
+
+ w = gtk_event_box_new ();
+ gtk_widget_modify_bg (w, GTK_STATE_NORMAL, &(style->bg[GTK_STATE_NORMAL]));
+
+ l = gtk_vbox_new (FALSE, 0);
+ gtk_container_add (GTK_CONTAINER (w), l);
+ gtk_box_pack_start (GTK_BOX (box), w, FALSE, FALSE, 0);
+ w = l;
+
+ e_cal_component_get_organizer (new_comp, &organizer);
+ if (organizer.cn) {
+ gchar *ptr;
+ ptr = strchr( organizer.value, ':');
+
+ if (ptr) {
+ ptr++;
+ /* To Translators: It will display "Organizer: NameOfTheUser <email@ofuser.com>" */
+ tmp = g_strdup_printf (_("Organizer: %s <%s>"), organizer.cn, ptr);
+ } else {
+ /* With SunOne accounts, there may be no ':' in organiser.value */
+ tmp = g_strdup_printf (_("Organizer: %s"), organizer.cn);
+ }
+
+ l = gtk_label_new (tmp);
+ gtk_label_set_line_wrap (GTK_LABEL (l), FALSE);
+ gtk_misc_set_alignment (GTK_MISC (l), 0.0, 0.5);
+ gtk_box_pack_start (GTK_BOX (w), l, FALSE, FALSE, 0);
+ g_free (tmp);
+ }
+
+ e_cal_component_get_dtstart (new_comp, &dtstart);
+ e_cal_component_get_due (new_comp, &dtdue);
+
+ default_zone = e_cal_model_get_timezone (model);
+
+ if (dtstart.tzid) {
+ zone = icalcomponent_get_timezone (e_cal_component_get_icalcomponent (new_comp), dtstart.tzid);
+ if (!zone)
+ e_cal_get_timezone (
+ comp_data->client, dtstart.tzid, &zone, NULL);
+ if (!zone)
+ zone = default_zone;
+ } else {
+ zone = NULL;
+ }
+
+ tmp2 = g_string_new ("");
+
+ if (dtstart.value) {
+ buff[0] = 0;
+
+ tmp_tm = icaltimetype_to_tm_with_zone (
+ dtstart.value, zone, default_zone);
+ e_time_format_date_and_time (
+ &tmp_tm, calendar_config_get_24_hour_format (),
+ FALSE, FALSE, buff, 1000);
+
+ if (buff [0]) {
+ g_string_append (tmp2, _("Start: "));
+ g_string_append (tmp2, buff);
+ }
+ }
+
+ if (dtdue.value) {
+ buff[0] = 0;
+
+ tmp_tm = icaltimetype_to_tm_with_zone (
+ dtdue.value, zone, default_zone);
+ e_time_format_date_and_time (
+ &tmp_tm, calendar_config_get_24_hour_format (),
+ FALSE, FALSE, buff, 1000);
+
+ if (buff [0]) {
+ if (tmp2->len)
+ g_string_append (tmp2, "; ");
+
+ g_string_append (tmp2, _("Due: "));
+ g_string_append (tmp2, buff);
+ }
+ }
+
+ if (tmp2->len) {
+ l = gtk_label_new (tmp2->str);
+ gtk_misc_set_alignment (GTK_MISC (l), 0.0, 0.5);
+ gtk_box_pack_start (GTK_BOX (w), l, FALSE, FALSE, 0);
+ }
+
+ g_string_free (tmp2, TRUE);
+
+ e_cal_component_free_datetime (&dtstart);
+ e_cal_component_free_datetime (&dtdue);
+
+ tmp2 = g_string_new ("");
+ e_cal_component_get_description_list (new_comp, &desc);
+ for (len = 0, p = desc; p != NULL; p = p->next) {
+ ECalComponentText *text = p->data;
+
+ if (text->value != NULL) {
+ len += strlen (text->value);
+ g_string_append (tmp2, text->value);
+ if (len > 1024) {
+ g_string_set_size (tmp2, 1020);
+ g_string_append (tmp2, "...");
+ break;
+ }
+ }
+ }
+ e_cal_component_free_text_list (desc);
+
+ if (tmp2->len) {
+ l = gtk_label_new (tmp2->str);
+ gtk_misc_set_alignment (GTK_MISC (l), 0.0, 0.5);
+ gtk_box_pack_start (GTK_BOX (box), l, FALSE, FALSE, 0);
+ }
+
+ g_string_free (tmp2, TRUE);
+
+ gtk_widget_show_all (box);
+ gtk_tooltip_set_custom (tooltip, box);
+
+ g_object_unref (new_comp);
+
+ return TRUE;
+}
+
+static gboolean
+memo_table_popup_menu_cb (EMemoTable *memo_table)
+{
+ memo_table_emit_popup_event (memo_table, NULL);
+
+ return TRUE;
+}
+
+static gint
+memo_table_right_click_cb (EMemoTable *memo_table,
+ gint row,
+ gint col,
+ GdkEvent *event)
+{
+ memo_table_emit_popup_event (memo_table, event);
+
+ return TRUE;
+}
+
+static void
+memo_table_set_model (EMemoTable *memo_table,
+ ECalModel *model)
+{
+ g_return_if_fail (memo_table->priv->model == NULL);
+
+ memo_table->priv->model = g_object_ref (model);
+
+ g_signal_connect_swapped (
+ model, "row-appended",
+ G_CALLBACK (memo_table_emit_user_created), memo_table);
+
+ g_signal_connect_swapped (
+ model, "cal-view-progress",
+ G_CALLBACK (memo_table_model_cal_view_progress_cb),
+ memo_table);
+
+ g_signal_connect_swapped (
+ model, "cal-view-done",
+ G_CALLBACK (memo_table_model_cal_view_done_cb),
+ memo_table);
+}
+
+static void
+memo_table_set_shell_view (EMemoTable *memo_table,
+ EShellView *shell_view)
+{
+ g_return_if_fail (memo_table->priv->shell_view == NULL);
+
+ memo_table->priv->shell_view = shell_view;
- g_return_val_if_fail (E_IS_MEMO_TABLE (user_data), FALSE);
+ g_object_add_weak_pointer (
+ G_OBJECT (shell_view),
+ &memo_table->priv->shell_view);
+}
+
+static void
+memo_table_set_property (GObject *object,
+ guint property_id,
+ const GValue *value,
+ GParamSpec *pspec)
+{
+ switch (property_id) {
+ case PROP_MODEL:
+ memo_table_set_model (
+ E_MEMO_TABLE (object),
+ g_value_get_object (value));
+ return;
+
+ case PROP_SHELL_VIEW:
+ memo_table_set_shell_view (
+ E_MEMO_TABLE (object),
+ g_value_get_object (value));
+ return;
+ }
+
+ G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
+}
+
+static void
+memo_table_get_property (GObject *object,
+ guint property_id,
+ GValue *value,
+ GParamSpec *pspec)
+{
+ switch (property_id) {
+ case PROP_MODEL:
+ g_value_set_object (
+ value, e_memo_table_get_model (
+ E_MEMO_TABLE (object)));
+ return;
+
+ case PROP_SHELL_VIEW:
+ g_value_set_object (
+ value, e_memo_table_get_shell_view (
+ E_MEMO_TABLE (object)));
+ return;
+ }
+
+ G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
+}
+
+static void
+memo_table_dispose (GObject *object)
+{
+ EMemoTablePrivate *priv;
- memo_table = E_MEMO_TABLE (user_data);
+ priv = E_MEMO_TABLE_GET_PRIVATE (object);
+
+ if (priv->shell_view != NULL) {
+ g_object_remove_weak_pointer (
+ G_OBJECT (priv->shell_view), &priv->shell_view);
+ priv->shell_view = NULL;
+ }
- return ec_query_tooltip (widget, x, y, keyboard_mode, tooltip, GTK_WIDGET (e_memo_table_get_table (memo_table)), memo_table->model);
+ if (priv->model != NULL) {
+ g_object_unref (priv->model);
+ priv->model = NULL;
+ }
+
+ /* Chain up to parent's dispose() method. */
+ G_OBJECT_CLASS (parent_class)->dispose (object);
}
static void
-e_memo_table_init (EMemoTable *memo_table)
+memo_table_constructed (GObject *object)
{
- GtkWidget *table;
- ETable *e_table;
+ EMemoTable *memo_table;
+ GtkWidget *widget;
+ ECalModel *model;
+ ETable *table;
ECell *cell, *popup_cell;
ETableExtras *extras;
gint i;
AtkObject *a11y;
gchar *etspecfile;
- /* Create the model */
-
- memo_table->model = (ECalModel *) e_cal_model_memos_new ();
- g_signal_connect (memo_table->model, "row_appended", G_CALLBACK (row_appended_cb), memo_table);
-
- memo_table->user_created_cal = NULL;
+ memo_table = E_MEMO_TABLE (object);
+ model = e_memo_table_get_model (memo_table);
/* Create the header columns */
- extras = e_table_extras_new();
+ extras = e_table_extras_new ();
/*
* Normal string fields.
*/
cell = e_cell_text_new (NULL, GTK_JUSTIFY_LEFT);
- g_object_set (G_OBJECT (cell),
- "bg_color_column", E_CAL_MODEL_FIELD_COLOR,
- NULL);
-
+ g_object_set (cell, "bg_color_column", E_CAL_MODEL_FIELD_COLOR, NULL);
e_table_extras_add_cell (extras, "calstring", cell);
/*
* Date fields.
*/
cell = e_cell_date_edit_text_new (NULL, GTK_JUSTIFY_LEFT);
- g_object_set (G_OBJECT (cell),
- "bg_color_column", E_CAL_MODEL_FIELD_COLOR,
- NULL);
+ g_object_set (cell, "bg_color_column", E_CAL_MODEL_FIELD_COLOR, NULL);
popup_cell = e_cell_date_edit_new ();
e_cell_popup_set_child (E_CELL_POPUP (popup_cell), cell);
g_object_unref (cell);
+
e_table_extras_add_cell (extras, "dateedit", popup_cell);
memo_table->dates_cell = E_CELL_DATE_EDIT (popup_cell);
- e_cell_date_edit_set_get_time_callback (E_CELL_DATE_EDIT (popup_cell),
- e_memo_table_get_current_time,
- memo_table, NULL);
+ e_cell_date_edit_set_get_time_callback (
+ E_CELL_DATE_EDIT (popup_cell),
+ e_memo_table_get_current_time, memo_table, NULL);
/* Sorting */
- e_table_extras_add_compare (extras, "date-compare",
- date_compare_cb);
+ e_table_extras_add_compare (
+ extras, "date-compare", memo_table_date_compare_cb);
/* Create pixmaps */
@@ -252,56 +590,179 @@ e_memo_table_init (EMemoTable *memo_table)
}
cell = e_cell_toggle_new (0, E_MEMO_MODEL_NUM_ICONS, icon_pixbufs);
- e_table_extras_add_cell(extras, "icon", cell);
- e_table_extras_add_pixbuf(extras, "icon", icon_pixbufs[0]);
+ e_table_extras_add_cell (extras, "icon", cell);
+ e_table_extras_add_pixbuf (extras, "icon", icon_pixbufs[0]);
/* Create the table */
- etspecfile = g_build_filename (EVOLUTION_ETSPECDIR,
- "e-memo-table.etspec",
- NULL);
- table = e_table_scrolled_new_from_spec_file (E_TABLE_MODEL (memo_table->model),
- extras,
- etspecfile,
- NULL);
+ etspecfile = g_build_filename (
+ EVOLUTION_ETSPECDIR, "e-memo-table.etspec", NULL);
+ widget = e_table_scrolled_new_from_spec_file (
+ E_TABLE_MODEL (model), extras, etspecfile, NULL);
+ gtk_table_attach (
+ GTK_TABLE (memo_table), widget, 0, 1, 0, 1,
+ GTK_EXPAND | GTK_FILL, GTK_EXPAND | GTK_FILL, 0, 0);
+ memo_table->etable = widget;
+ gtk_widget_show (widget);
g_free (etspecfile);
- /* FIXME: this causes a message from GLib about 'extras' having only a floating
- reference */
- /* g_object_unref (extras); */
+ table = e_table_scrolled_get_table (E_TABLE_SCROLLED (widget));
+ g_signal_connect_swapped (
+ table, "double-click",
+ G_CALLBACK (memo_table_double_click_cb), memo_table);
+ g_signal_connect_swapped (
+ table, "query-tooltip",
+ G_CALLBACK (memo_table_query_tooltip_cb), memo_table);
+ g_signal_connect_swapped (
+ table, "popup-menu",
+ G_CALLBACK (memo_table_popup_menu_cb), memo_table);
+ g_signal_connect_swapped (
+ table, "right-click",
+ G_CALLBACK (memo_table_right_click_cb), memo_table);
+ gtk_widget_set_has_tooltip (GTK_WIDGET (table), TRUE);
+
+ a11y = gtk_widget_get_accessible (GTK_WIDGET (table));
+ if (a11y)
+ atk_object_set_name (a11y, _("Memos"));
+}
- memo_table->etable = table;
- gtk_table_attach (GTK_TABLE (memo_table), table, 0, 1, 0, 1,
- GTK_EXPAND | GTK_FILL, GTK_EXPAND | GTK_FILL, 0, 0);
- gtk_widget_show (table);
+static void
+memo_table_class_init (EMemoTableClass *class)
+{
+ GObjectClass *object_class;
+
+ parent_class = g_type_class_peek_parent (class);
+ g_type_class_add_private (class, sizeof (EMemoTablePrivate));
+
+ object_class = G_OBJECT_CLASS (class);
+ object_class->set_property = memo_table_set_property;
+ object_class->get_property = memo_table_get_property;
+ object_class->dispose = memo_table_dispose;
+ object_class->constructed = memo_table_constructed;
+
+ g_object_class_install_property (
+ object_class,
+ PROP_MODEL,
+ g_param_spec_object (
+ "model",
+ _("Model"),
+ NULL,
+ E_TYPE_CAL_MODEL,
+ G_PARAM_READWRITE |
+ G_PARAM_CONSTRUCT_ONLY));
+
+ g_object_class_install_property (
+ object_class,
+ PROP_SHELL_VIEW,
+ g_param_spec_object (
+ "shell-view",
+ _("Shell View"),
+ NULL,
+ E_TYPE_SHELL_VIEW,
+ G_PARAM_READWRITE |
+ G_PARAM_CONSTRUCT_ONLY));
+
+ signals[OPEN_COMPONENT] = g_signal_new (
+ "open-component",
+ G_TYPE_FROM_CLASS (class),
+ G_SIGNAL_RUN_LAST | G_SIGNAL_ACTION,
+ G_STRUCT_OFFSET (EMemoTableClass, open_component),
+ NULL, NULL,
+ g_cclosure_marshal_VOID__OBJECT,
+ G_TYPE_NONE, 1,
+ E_TYPE_CAL_MODEL_COMPONENT);
+
+ signals[POPUP_EVENT] = g_signal_new (
+ "popup-event",
+ G_TYPE_FROM_CLASS (class),
+ G_SIGNAL_RUN_LAST | G_SIGNAL_ACTION,
+ G_STRUCT_OFFSET (EMemoTableClass, popup_event),
+ NULL, NULL,
+ g_cclosure_marshal_VOID__BOXED,
+ G_TYPE_NONE, 1,
+ GDK_TYPE_EVENT | G_SIGNAL_TYPE_STATIC_SCOPE);
+
+ signals[STATUS_MESSAGE] = g_signal_new (
+ "status-message",
+ G_TYPE_FROM_CLASS (class),
+ G_SIGNAL_RUN_LAST | G_SIGNAL_ACTION,
+ G_STRUCT_OFFSET (EMemoTableClass, status_message),
+ NULL, NULL,
+ g_cclosure_marshal_VOID__STRING,
+ G_TYPE_NONE, 1,
+ G_TYPE_STRING);
+
+ signals[USER_CREATED] = g_signal_new (
+ "user-created",
+ G_TYPE_FROM_CLASS (class),
+ G_SIGNAL_RUN_LAST | G_SIGNAL_ACTION,
+ G_STRUCT_OFFSET (EMemoTableClass, user_created),
+ NULL, NULL,
+ g_cclosure_marshal_VOID__VOID,
+ G_TYPE_NONE, 0);
+
+ clipboard_atom = gdk_atom_intern ("CLIPBOARD", FALSE);
+}
+
+static void
+memo_table_init (EMemoTable *memo_table)
+{
+ memo_table->priv = E_MEMO_TABLE_GET_PRIVATE (memo_table);
+}
- e_table = e_table_scrolled_get_table (E_TABLE_SCROLLED (table));
- g_signal_connect (e_table, "double_click", G_CALLBACK (e_memo_table_on_double_click), memo_table);
- g_signal_connect (e_table, "right_click", G_CALLBACK (e_memo_table_on_right_click), memo_table);
- g_signal_connect (e_table, "key_press", G_CALLBACK (e_memo_table_on_key_press), memo_table);
- g_signal_connect (e_table, "popup_menu", G_CALLBACK (e_memo_table_on_popup_menu), memo_table);
- g_signal_connect (e_table, "query-tooltip", G_CALLBACK (query_tooltip_cb), memo_table);
- gtk_widget_set_has_tooltip (GTK_WIDGET (e_table), TRUE);
+GType
+e_memo_table_get_type (void)
+{
+ static GType type = 0;
+
+ if (G_UNLIKELY (type == 0)) {
+ static const GTypeInfo type_info = {
+ sizeof (EMemoTableClass),
+ (GBaseInitFunc) NULL,
+ (GBaseFinalizeFunc) NULL,
+ (GClassInitFunc) memo_table_class_init,
+ (GClassFinalizeFunc) NULL,
+ NULL, /* class_data */
+ sizeof (EMemoTable),
+ 0, /* n_preallocs */
+ (GInstanceInitFunc) memo_table_init,
+ NULL /* value_table */
+ };
+
+ type = g_type_register_static (
+ GTK_TYPE_TABLE, "EMemoTable", &type_info, 0);
+ }
- a11y = gtk_widget_get_accessible (GTK_WIDGET(e_table));
- if (a11y)
- atk_object_set_name (a11y, _("Memos"));
+ return type;
}
/**
* e_memo_table_new:
- * @Returns: a new #EMemoTable.
+ * @shell_view: an #EShellView
+ * @model: an #ECalModel for the table
+ *
+ * Returns a new #EMemoTable.
*
- * Creates a new #EMemoTable.
+ * Returns: a new #EMemoTable
**/
GtkWidget *
-e_memo_table_new (void)
+e_memo_table_new (EShellView *shell_view,
+ ECalModel *model)
{
- GtkWidget *memo_table;
+ g_return_val_if_fail (E_IS_SHELL_VIEW (shell_view), NULL);
+ g_return_val_if_fail (E_IS_CAL_MODEL (model), NULL);
- memo_table = GTK_WIDGET (g_object_new (e_memo_table_get_type (), NULL));
+ return g_object_new (
+ E_TYPE_MEMO_TABLE,
+ "model", model, "shell-view", shell_view, NULL);
+}
- return memo_table;
+EShellView *
+e_memo_table_get_shell_view (EMemoTable *memo_table)
+{
+ g_return_val_if_fail (E_IS_MEMO_TABLE (memo_table), NULL);
+
+ return memo_table->priv->shell_view;
}
/**
@@ -318,22 +779,7 @@ e_memo_table_get_model (EMemoTable *memo_table)
g_return_val_if_fail (memo_table != NULL, NULL);
g_return_val_if_fail (E_IS_MEMO_TABLE (memo_table), NULL);
- return memo_table->model;
-}
-
-static void
-e_memo_table_destroy (GtkObject *object)
-{
- EMemoTable *memo_table;
-
- memo_table = E_MEMO_TABLE (object);
-
- if (memo_table->model) {
- g_object_unref (memo_table->model);
- memo_table->model = NULL;
- }
-
- GTK_OBJECT_CLASS (e_memo_table_parent_class)->destroy (object);
+ return memo_table->priv->model;
}
/**
@@ -348,20 +794,13 @@ e_memo_table_destroy (GtkObject *object)
ETable *
e_memo_table_get_table (EMemoTable *memo_table)
{
- g_return_val_if_fail (memo_table != NULL, NULL);
- g_return_val_if_fail (E_IS_MEMO_TABLE (memo_table), NULL);
+ ETableScrolled *table_scrolled;
- return e_table_scrolled_get_table (E_TABLE_SCROLLED (memo_table->etable));
-}
+ g_return_val_if_fail (E_IS_MEMO_TABLE (memo_table), NULL);
-void
-e_memo_table_open_selected (EMemoTable *memo_table)
-{
- ECalModelComponent *comp_data;
+ table_scrolled = E_TABLE_SCROLLED (memo_table->etable);
- comp_data = get_selected_comp (memo_table);
- if (comp_data != NULL)
- open_memo (memo_table, comp_data);
+ return e_table_scrolled_get_table (table_scrolled);
}
/* Used from e_table_selected_row_foreach(); puts the selected row number in an
@@ -383,10 +822,12 @@ get_selected_row_cb (gint model_row, gpointer data)
static ECalModelComponent *
get_selected_comp (EMemoTable *memo_table)
{
+ ECalModel *model;
ETable *etable;
gint row;
- etable = e_table_scrolled_get_table (E_TABLE_SCROLLED (memo_table->etable));
+ model = e_memo_table_get_model (memo_table);
+ etable = e_memo_table_get_table (memo_table);
if (e_table_selected_count (etable) != 1)
return NULL;
@@ -396,7 +837,7 @@ get_selected_comp (EMemoTable *memo_table)
&row);
g_return_val_if_fail (row != -1, NULL);
- return e_cal_model_get_component_at (memo_table->model, row);
+ return e_cal_model_get_component_at (model, row);
}
struct get_selected_uids_closure {
@@ -410,38 +851,27 @@ add_uid_cb (gint model_row, gpointer data)
{
struct get_selected_uids_closure *closure;
ECalModelComponent *comp_data;
+ ECalModel *model;
closure = data;
- comp_data = e_cal_model_get_component_at (closure->memo_table->model, model_row);
+ model = e_memo_table_get_model (closure->memo_table);
+ comp_data = e_cal_model_get_component_at (model, model_row);
closure->objects = g_slist_prepend (closure->objects, comp_data);
}
-static GSList *
-get_selected_objects (EMemoTable *memo_table)
-{
- struct get_selected_uids_closure closure;
- ETable *etable;
-
- closure.memo_table = memo_table;
- closure.objects = NULL;
-
- etable = e_table_scrolled_get_table (E_TABLE_SCROLLED (memo_table->etable));
- e_table_selected_row_foreach (etable, add_uid_cb, &closure);
-
- return closure.objects;
-}
-
/* Deletes all of the selected components in the table */
static void
delete_selected_components (EMemoTable *memo_table)
{
GSList *objs, *l;
+ const gchar *status_message;
- objs = get_selected_objects (memo_table);
+ objs = e_memo_table_get_selected (memo_table);
- e_memo_table_set_status_message (memo_table, _("Deleting selected objects"));
+ status_message = _("Deleting selected objects");
+ memo_table_emit_status_message (memo_table, status_message, -1.0);
for (l = objs; l; l = l->next) {
ECalModelComponent *comp_data = (ECalModelComponent *) l->data;
@@ -453,27 +883,12 @@ delete_selected_components (EMemoTable *memo_table)
g_clear_error (&error);
}
- e_memo_table_set_status_message (memo_table, NULL);
+ memo_table_emit_status_message (memo_table, NULL, -1.0);
g_slist_free (objs);
}
/**
- * e_memo_table_get_selected:
- * @memo_table:
- *
- * Get the currently selected ECalModelComponent's on the table.
- *
- * Return value: A GSList of the components, which should be
- * g_slist_free'd when finished with.
- **/
-GSList *
-e_memo_table_get_selected (EMemoTable *memo_table)
-{
- return get_selected_objects(memo_table);
-}
-
-/**
* e_memo_table_delete_selected:
* @memo_table: A memo table.
*
@@ -490,7 +905,7 @@ e_memo_table_delete_selected (EMemoTable *memo_table)
g_return_if_fail (memo_table != NULL);
g_return_if_fail (E_IS_MEMO_TABLE (memo_table));
- etable = e_table_scrolled_get_table (E_TABLE_SCROLLED (memo_table->etable));
+ etable = e_memo_table_get_table (memo_table);
n_selected = e_table_selected_count (etable);
if (n_selected <= 0)
@@ -518,6 +933,30 @@ e_memo_table_delete_selected (EMemoTable *memo_table)
}
/**
+ * e_memo_table_get_selected:
+ * @memo_table:
+ *
+ * Get the currently selected ECalModelComponent's on the table.
+ *
+ * Return value: A GSList of the components, which should be
+ * g_slist_free'd when finished with.
+ **/
+GSList *
+e_memo_table_get_selected (EMemoTable *memo_table)
+{
+ struct get_selected_uids_closure closure;
+ ETable *etable;
+
+ closure.memo_table = memo_table;
+ closure.objects = NULL;
+
+ etable = e_memo_table_get_table (memo_table);
+ e_table_selected_row_foreach (etable, add_uid_cb, &closure);
+
+ return closure.objects;
+}
+
+/**
* e_memo_table_cut_clipboard:
* @memo_table: A calendar table.
*
@@ -532,12 +971,33 @@ e_memo_table_cut_clipboard (EMemoTable *memo_table)
delete_selected_components (memo_table);
}
+static void
+clipboard_get_calendar_cb (GtkClipboard *clipboard,
+ GtkSelectionData *selection_data,
+ guint info,
+ gpointer data)
+{
+ gchar *comp_str = (gchar *) data;
+
+ switch (info) {
+ case TARGET_TYPE_VCALENDAR:
+ gtk_selection_data_set (selection_data,
+ gdk_atom_intern (target_types[info].target, FALSE), 8,
+ (const guchar *) comp_str,
+ (gint) strlen (comp_str));
+ break;
+ default:
+ break;
+ }
+}
+
/* callback for e_table_selected_row_foreach */
static void
copy_row_cb (gint model_row, gpointer data)
{
EMemoTable *memo_table;
ECalModelComponent *comp_data;
+ ECalModel *model;
gchar *comp_str;
icalcomponent *child;
@@ -545,7 +1005,8 @@ copy_row_cb (gint model_row, gpointer data)
g_return_if_fail (memo_table->tmp_vcal != NULL);
- comp_data = e_cal_model_get_component_at (memo_table->model, model_row);
+ model = e_memo_table_get_model (memo_table);
+ comp_data = e_cal_model_get_component_at (model, model_row);
if (!comp_data)
return;
@@ -563,26 +1024,6 @@ copy_row_cb (gint model_row, gpointer data)
g_free (comp_str);
}
-static void
-clipboard_get_calendar_cb (GtkClipboard *clipboard,
- GtkSelectionData *selection_data,
- guint info,
- gpointer data)
-{
- gchar *comp_str = (gchar *) data;
-
- switch (info) {
- case TARGET_TYPE_VCALENDAR:
- gtk_selection_data_set (selection_data,
- gdk_atom_intern (target_types[info].target, FALSE), 8,
- (const guchar *) comp_str,
- (gint) strlen (comp_str));
- break;
- default:
- break;
- }
-}
-
/**
* e_memo_table_copy_clipboard:
* @memo_table: A calendar table.
@@ -601,7 +1042,7 @@ e_memo_table_copy_clipboard (EMemoTable *memo_table)
/* create temporary VCALENDAR object */
memo_table->tmp_vcal = e_cal_util_new_top_level ();
- etable = e_table_scrolled_get_table (E_TABLE_SCROLLED (memo_table->etable));
+ etable = e_memo_table_get_table (memo_table);
e_table_selected_row_foreach (etable, copy_row_cb, memo_table);
comp_str = icalcomponent_as_ical_string_r (memo_table->tmp_vcal);
clipboard = gtk_widget_get_clipboard (GTK_WIDGET (memo_table), clipboard_atom);
@@ -626,7 +1067,9 @@ clipboard_get_calendar_data (EMemoTable *memo_table, const gchar *text)
gchar *uid;
ECalComponent *comp;
ECal *client;
+ ECalModel *model;
icalcomponent_kind kind;
+ const gchar *status_message;
g_return_if_fail (E_IS_MEMO_TABLE (memo_table));
@@ -640,13 +1083,17 @@ clipboard_get_calendar_data (EMemoTable *memo_table, const gchar *text)
/* check the type of the component */
kind = icalcomponent_isa (icalcomp);
if (kind != ICAL_VCALENDAR_COMPONENT &&
+ kind != ICAL_VEVENT_COMPONENT &&
+ kind != ICAL_VTODO_COMPONENT &&
kind != ICAL_VJOURNAL_COMPONENT) {
return;
}
- client = e_cal_model_get_default_client (memo_table->model);
+ model = e_memo_table_get_model (memo_table);
+ client = e_cal_model_get_default_client (model);
- e_memo_table_set_status_message (memo_table, _("Updating objects"));
+ status_message = _("Updating objects");
+ memo_table_emit_status_message (memo_table, status_message, -1.0);
if (kind == ICAL_VCALENDAR_COMPONENT) {
icalcomponent_kind child_kind;
@@ -658,7 +1105,9 @@ clipboard_get_calendar_data (EMemoTable *memo_table, const gchar *text)
vcal_comp, ICAL_ANY_COMPONENT);
while (subcomp) {
child_kind = icalcomponent_isa (subcomp);
- if (child_kind == ICAL_VJOURNAL_COMPONENT) {
+ if (child_kind == ICAL_VEVENT_COMPONENT ||
+ child_kind == ICAL_VTODO_COMPONENT ||
+ child_kind == ICAL_VJOURNAL_COMPONENT) {
ECalComponent *tmp_comp;
uid = e_cal_component_gen_uid ();
@@ -689,7 +1138,7 @@ clipboard_get_calendar_data (EMemoTable *memo_table, const gchar *text)
g_object_unref (comp);
}
- e_memo_table_set_status_message (memo_table, NULL);
+ memo_table_emit_status_message (memo_table, NULL, -1.0);
}
static void
@@ -698,7 +1147,7 @@ clipboard_paste_received_cb (GtkClipboard *clipboard,
gpointer data)
{
EMemoTable *memo_table = E_MEMO_TABLE (data);
- ETable *e_table = e_table_scrolled_get_table (E_TABLE_SCROLLED (memo_table->etable));
+ ETable *e_table = e_memo_table_get_table (memo_table);
GnomeCanvas *canvas = e_table->table_canvas;
GnomeCanvasItem *item = GNOME_CANVAS (canvas)->focused_item;
@@ -733,332 +1182,43 @@ void
e_memo_table_paste_clipboard (EMemoTable *memo_table)
{
GtkClipboard *clipboard;
- g_return_if_fail (E_IS_MEMO_TABLE (memo_table));
-
- clipboard = gtk_widget_get_clipboard (GTK_WIDGET (memo_table), clipboard_atom);
- g_object_ref (memo_table);
-
- gtk_clipboard_request_contents (clipboard,
- gdk_atom_intern (target_types[0].target, FALSE),
- clipboard_paste_received_cb, memo_table);
-}
-
-/* Opens a task in the task editor */
-static void
-open_memo (EMemoTable *memo_table, ECalModelComponent *comp_data)
-{
- CompEditor *medit;
- const gchar *uid;
-
- uid = icalcomponent_get_uid (comp_data->icalcomp);
-
- medit = e_comp_editor_registry_find (comp_editor_registry, uid);
- if (medit == NULL) {
- ECalComponent *comp;
- CompEditorFlags flags = 0;
-
- comp = e_cal_component_new ();
- e_cal_component_set_icalcomponent (comp, icalcomponent_new_clone (comp_data->icalcomp));
-
- if (e_cal_component_has_organizer (comp))
- flags |= COMP_EDITOR_IS_SHARED;
- if (itip_organizer_is_user (comp, comp_data->client))
- flags |= COMP_EDITOR_USER_ORG;
-
- medit = memo_editor_new (comp_data->client, flags);
-
- comp_editor_edit_comp (medit, comp);
- g_object_unref (comp);
-
- e_comp_editor_registry_add (comp_editor_registry, medit, FALSE);
- }
-
- gtk_window_present (GTK_WINDOW (medit));
-}
-
-/* Opens the task in the specified row */
-static void
-open_memo_by_row (EMemoTable *memo_table, gint row)
-{
- ECalModelComponent *comp_data;
-
- comp_data = e_cal_model_get_component_at (memo_table->model, row);
- open_memo (memo_table, comp_data);
-}
-
-static void
-e_memo_table_on_double_click (ETable *table,
- gint row,
- gint col,
- GdkEvent *event,
- EMemoTable *memo_table)
-{
- open_memo_by_row (memo_table, row);
-}
-
-static void
-e_memo_table_on_open_memo (EPopup *ep, EPopupItem *pitem, gpointer data)
-{
- EMemoTable *memo_table = E_MEMO_TABLE (data);
- ECalModelComponent *comp_data;
-
- comp_data = get_selected_comp (memo_table);
- if (comp_data)
- open_memo (memo_table, comp_data);
-}
-
-static void
-e_memo_table_on_save_as (EPopup *ep, EPopupItem *pitem, gpointer data)
-{
- EMemoTable *memo_table = E_MEMO_TABLE (data);
- ECalModelComponent *comp_data;
- gchar *filename;
- gchar *ical_string;
-
- comp_data = get_selected_comp (memo_table);
- if (comp_data == NULL)
- return;
-
- filename = e_file_dialog_save (_("Save as..."), NULL);
- if (filename == NULL)
- return;
-
- ical_string = e_cal_get_component_as_string (comp_data->client, comp_data->icalcomp);
- if (ical_string == NULL) {
- g_warning ("Couldn't convert item to a string");
- return;
- }
-
- e_write_file_uri (filename, ical_string);
- g_free (ical_string);
-}
-
-static void
-e_memo_table_on_print_memo (EPopup *ep, EPopupItem *pitem, gpointer data)
-{
- EMemoTable *memo_table = E_MEMO_TABLE (data);
- ECalModelComponent *comp_data;
- ECalComponent *comp;
-
- comp_data = get_selected_comp (memo_table);
- if (comp_data == NULL)
- return;
-
- comp = e_cal_component_new ();
- e_cal_component_set_icalcomponent (comp, icalcomponent_new_clone (comp_data->icalcomp));
- print_comp (comp, comp_data->client, GTK_PRINT_OPERATION_ACTION_PRINT_DIALOG);
-
- g_object_unref (comp);
-}
-
-static void
-e_memo_table_on_cut (EPopup *ep, EPopupItem *pitem, gpointer data)
-{
- EMemoTable *memo_table = E_MEMO_TABLE (data);
-
- e_memo_table_cut_clipboard (memo_table);
-}
-
-static void
-e_memo_table_on_copy (EPopup *ep, EPopupItem *pitem, gpointer data)
-{
- EMemoTable *memo_table = E_MEMO_TABLE (data);
-
- e_memo_table_copy_clipboard (memo_table);
-}
-
-static void
-e_memo_table_on_paste (EPopup *ep, EPopupItem *pitem, gpointer data)
-{
- EMemoTable *memo_table = E_MEMO_TABLE (data);
-
- e_memo_table_paste_clipboard (memo_table);
-}
-
-static void
-e_memo_table_on_forward (EPopup *ep, EPopupItem *pitem, gpointer data)
-{
- EMemoTable *memo_table = E_MEMO_TABLE (data);
- ECalModelComponent *comp_data;
-
- comp_data = get_selected_comp (memo_table);
- if (comp_data) {
- ECalComponent *comp;
-
- comp = e_cal_component_new ();
- e_cal_component_set_icalcomponent (comp, icalcomponent_new_clone (comp_data->icalcomp));
- itip_send_comp (E_CAL_COMPONENT_METHOD_PUBLISH, comp, comp_data->client, NULL, NULL, NULL, TRUE);
-
- g_object_unref (comp);
- }
-}
-
-/* Opens the URL of the memo */
-static void
-open_url_cb (EPopup *ep, EPopupItem *pitem, gpointer data)
-{
- EMemoTable *memo_table = E_MEMO_TABLE (data);
- ECalModelComponent *comp_data;
- icalproperty *prop;
-
- comp_data = get_selected_comp (memo_table);
- if (!comp_data)
- return;
-
- prop = icalcomponent_get_first_property (comp_data->icalcomp, ICAL_URL_PROPERTY);
- if (!prop)
- return;
-
- /* FIXME Pass a parent window. */
- e_show_uri (NULL, icalproperty_get_url (prop));
-}
-
-/* Callback for the "delete tasks" menu item */
-static void
-delete_cb (EPopup *ep, EPopupItem *pitem, gpointer data)
-{
- EMemoTable *memo_table = E_MEMO_TABLE (data);
-
- e_memo_table_delete_selected (memo_table);
-}
-
-static EPopupItem memos_popup_items [] = {
- { E_POPUP_ITEM, (gchar *) "00.open", (gchar *) N_("_Open"), e_memo_table_on_open_memo, NULL, (gchar *) GTK_STOCK_OPEN, E_CAL_POPUP_SELECT_ONE },
- { E_POPUP_ITEM, (gchar *) "05.openweb", (gchar *) N_("Open _Web Page"), open_url_cb, NULL, NULL, E_CAL_POPUP_SELECT_ONE, E_CAL_POPUP_SELECT_HASURL },
- { E_POPUP_ITEM, (gchar *) "10.saveas", (gchar *) N_("_Save As..."), e_memo_table_on_save_as, NULL, (gchar *) GTK_STOCK_SAVE_AS, E_CAL_POPUP_SELECT_ONE },
- { E_POPUP_ITEM, (gchar *) "20.print", (gchar *) N_("P_rint..."), e_memo_table_on_print_memo, NULL, (gchar *) GTK_STOCK_PRINT, E_CAL_POPUP_SELECT_ONE },
-
- { E_POPUP_BAR, (gchar *) "30.bar" },
-
- { E_POPUP_ITEM, (gchar *) "40.cut", (gchar *) N_("C_ut"), e_memo_table_on_cut, NULL, (gchar *) GTK_STOCK_CUT, 0, E_CAL_POPUP_SELECT_EDITABLE },
- { E_POPUP_ITEM, (gchar *) "50.copy", (gchar *) N_("_Copy"), e_memo_table_on_copy, NULL, (gchar *) GTK_STOCK_COPY, 0, 0 },
- { E_POPUP_ITEM, (gchar *) "60.paste", (gchar *) N_("_Paste"), e_memo_table_on_paste, NULL, (gchar *) GTK_STOCK_PASTE, 0, E_CAL_POPUP_SELECT_EDITABLE },
-
- { E_POPUP_BAR, (gchar *) "70.bar" },
-
- { E_POPUP_ITEM, (gchar *) "80.forward", (gchar *) N_("_Forward as iCalendar"), e_memo_table_on_forward, NULL, (gchar *) "mail-forward", E_CAL_POPUP_SELECT_ONE },
-
- { E_POPUP_BAR, (gchar *) "90.bar" },
-
- { E_POPUP_ITEM, (gchar *) "a0.delete", (gchar *) N_("_Delete"), delete_cb, NULL, (gchar *) GTK_STOCK_DELETE, E_CAL_POPUP_SELECT_ONE, E_CAL_POPUP_SELECT_EDITABLE },
- { E_POPUP_ITEM, (gchar *) "b0.deletemany", (gchar *) N_("_Delete Selected Memos"), delete_cb, NULL, (gchar *) GTK_STOCK_DELETE, E_CAL_POPUP_SELECT_MANY, E_CAL_POPUP_SELECT_EDITABLE },
-};
-
-static void
-emt_popup_free(EPopup *ep, GSList *items, gpointer data)
-{
- g_slist_free(items);
-}
-
-static gint
-e_memo_table_show_popup_menu (ETable *table,
- GdkEvent *gdk_event,
- EMemoTable *memo_table)
-{
- GtkMenu *menu;
- GSList *selection, *l, *menus = NULL;
- GPtrArray *events;
- ECalPopup *ep;
- ECalPopupTargetSelect *t;
- gint i;
-
- selection = get_selected_objects (memo_table);
- if (!selection)
- return TRUE;
-
- /** @HookPoint-ECalPopup: Tasks Table Context Menu
- * @Id: org.gnome.evolution.tasks.table.popup
- * @Class: org.gnome.evolution.calendar.popup:1.0
- * @Target: ECalPopupTargetSelect
- *
- * The context menu on the tasks table.
- */
- ep = e_cal_popup_new("org.gnome.evolution.memos.table.popup");
-
- events = g_ptr_array_new();
- for (l=selection;l;l=g_slist_next(l))
- g_ptr_array_add(events, e_cal_model_copy_component_data((ECalModelComponent *)l->data));
- g_slist_free(selection);
-
- t = e_cal_popup_target_new_select(ep, memo_table->model, events);
- t->target.widget = (GtkWidget *)memo_table;
-
- for (i=0;i<sizeof(memos_popup_items)/sizeof(memos_popup_items[0]);i++)
- menus = g_slist_prepend(menus, &memos_popup_items[i]);
- e_popup_add_items((EPopup *)ep, menus, NULL, emt_popup_free, memo_table);
-
- menu = e_popup_create_menu_once((EPopup *)ep, (EPopupTarget *)t, 0);
-
- gtk_menu_popup(menu, NULL, NULL, NULL, NULL, gdk_event?gdk_event->button.button:0,
- gdk_event?gdk_event->button.time:gtk_get_current_event_time());
-
- return TRUE;
-}
-
-static gint
-e_memo_table_on_right_click (ETable *table,
- gint row,
- gint col,
- GdkEvent *event,
- EMemoTable *memo_table)
-{
- return e_memo_table_show_popup_menu (table, event, memo_table);
-}
-
-static gboolean
-e_memo_table_on_popup_menu (GtkWidget *widget, gpointer data)
-{
- ETable *table = E_TABLE(widget);
- g_return_val_if_fail(table, FALSE);
-
- return e_memo_table_show_popup_menu (table, NULL,
- E_MEMO_TABLE(data));
-}
+ g_return_if_fail (E_IS_MEMO_TABLE (memo_table));
-static gint
-e_memo_table_on_key_press (ETable *table,
- gint row,
- gint col,
- GdkEventKey *event,
- EMemoTable *memo_table)
-{
- if (event->keyval == GDK_Delete) {
- delete_cb (NULL, NULL, memo_table);
- return TRUE;
- } else if ((event->keyval == GDK_o)
- &&(event->state & GDK_CONTROL_MASK)) {
- open_memo_by_row (memo_table, row);
- return TRUE;
- }
+ clipboard = gtk_widget_get_clipboard (
+ GTK_WIDGET (memo_table), clipboard_atom);
- return FALSE;
+ gtk_clipboard_request_contents (
+ clipboard, gdk_atom_intern (target_types[0].target, FALSE),
+ clipboard_paste_received_cb, g_object_ref (memo_table));
}
/* Loads the state of the table (headers shown etc.) from the given file. */
void
e_memo_table_load_state (EMemoTable *memo_table,
- gchar *filename)
+ const gchar *filename)
{
- struct stat st;
+ ETable *table;
g_return_if_fail (E_IS_MEMO_TABLE (memo_table));
+ g_return_if_fail (filename != NULL);
- if (g_stat (filename, &st) == 0 && st.st_size > 0
- && S_ISREG (st.st_mode)) {
- e_table_load_state (e_table_scrolled_get_table (E_TABLE_SCROLLED (memo_table->etable)), filename);
- }
+ table = e_memo_table_get_table (memo_table);
+ e_table_load_state (table, filename);
}
/* Saves the state of the table (headers shown etc.) to the given file. */
void
-e_memo_table_save_state (EMemoTable *memo_table,
- gchar *filename)
+e_memo_table_save_state (EMemoTable *memo_table,
+ const gchar *filename)
{
+ ETable *table;
+
g_return_if_fail (E_IS_MEMO_TABLE (memo_table));
+ g_return_if_fail (filename != NULL);
- e_table_save_state (e_table_scrolled_get_table (E_TABLE_SCROLLED (memo_table->etable)),
- filename);
+ table = e_memo_table_get_table (memo_table);
+ e_table_save_state (table, filename);
}
/* Returns the current time, for the ECellDateEdit items.
@@ -1087,44 +1247,3 @@ e_memo_table_get_current_time (ECellDateEdit *ecde, gpointer data)
return tmp_tm;
}
-
-#ifdef TRANSLATORS_ONLY
-
-static gchar *test[] = {
- N_("Click to add a memo")
-};
-
-#endif
-
-void
-e_memo_table_set_activity_handler (EMemoTable *memo_table, EActivityHandler *activity_handler)
-{
- g_return_if_fail (E_IS_MEMO_TABLE (memo_table));
-
- memo_table->activity_handler = activity_handler;
-}
-
-void
-e_memo_table_set_status_message (EMemoTable *memo_table, const gchar *message)
-{
- g_return_if_fail (E_IS_MEMO_TABLE (memo_table));
-
- if (!memo_table->activity_handler)
- return;
-
- if (!message || !*message) {
- if (memo_table->activity_id != 0) {
- e_activity_handler_operation_finished (memo_table->activity_handler, memo_table->activity_id);
- memo_table->activity_id = 0;
- }
- } else if (memo_table->activity_id == 0) {
- gchar *client_id = g_strdup_printf ("%p", (gpointer) memo_table);
-
- memo_table->activity_id = e_activity_handler_operation_started (
- memo_table->activity_handler, client_id, message, TRUE);
-
- g_free (client_id);
- } else {
- e_activity_handler_operation_progressing (memo_table->activity_handler, memo_table->activity_id, message, -1.0);
- }
-}
diff --git a/calendar/gui/e-memo-table.h b/calendar/gui/e-memo-table.h
index 7fbb7d0f3e..f3b02e0c04 100644
--- a/calendar/gui/e-memo-table.h
+++ b/calendar/gui/e-memo-table.h
@@ -25,31 +25,47 @@
#ifndef _E_MEMO_TABLE_H_
#define _E_MEMO_TABLE_H_
-#include <gtk/gtk.h>
+#include <shell/e-shell-view.h>
#include <table/e-table-scrolled.h>
-#include <widgets/misc/e-cell-date-edit.h>
-#include "e-activity-handler.h"
+#include <table/e-cell-date-edit.h>
#include "e-cal-model.h"
-G_BEGIN_DECLS
-
/*
* EMemoTable - displays the iCalendar objects in a table (an ETable).
* Used for memo events and tasks.
+ *
+ * XXX We should look at merging this back into ECalendarTable, or at
+ * least making ECalendarTable subclassable so we don't have so
+ * much duplicate code.
*/
-#define E_MEMO_TABLE(obj) G_TYPE_CHECK_INSTANCE_CAST (obj, e_memo_table_get_type (), EMemoTable)
-#define E_MEMO_TABLE_CLASS(klass) G_TYPE_CHECK_CLASS_CAST (klass, e_memo_table_get_type (), EMemoTableClass)
-#define E_IS_MEMO_TABLE(obj) G_TYPE_CHECK_INSTANCE_TYPE (obj, e_memo_table_get_type ())
+/* Standard GObject macros */
+#define E_TYPE_MEMO_TABLE \
+ (e_memo_table_get_type ())
+#define E_MEMO_TABLE(obj) \
+ (G_TYPE_CHECK_INSTANCE_CAST \
+ ((obj), E_TYPE_MEMO_TABLE, EMemoTable))
+#define E_MEMO_TABLE_CLASS(cls) \
+ (G_TYPE_CHECK_CLASS_CAST \
+ ((cls), E_TYPE_MEMO_TABLE, EMemoTableClass))
+#define E_IS_MEMO_TABLE(obj) \
+ (G_TYPE_CHECK_INSTANCE_TYPE \
+ ((obj), E_TYPE_MEMO_TABLE))
+#define E_IS_MEMO_TABLE_CLASS(cls) \
+ (G_TYPE_CHECK_CLASS_TYPE \
+ ((cls), E_TYPE_MEMO_TABLE))
+#define E_MEMO_TABLE_GET_CLASS(obj) \
+ (G_TYPE_INSTANCE_GET_CLASS \
+ ((obj), E_TYPE_MEMO_TABLE, EMemoTableClass))
-typedef struct _EMemoTable EMemoTable;
-typedef struct _EMemoTableClass EMemoTableClass;
+G_BEGIN_DECLS
-struct _EMemoTable {
- GtkTable table;
+typedef struct _EMemoTable EMemoTable;
+typedef struct _EMemoTableClass EMemoTableClass;
+typedef struct _EMemoTablePrivate EMemoTablePrivate;
- /* The model that we use */
- ECalModel *model;
+struct _EMemoTable {
+ GtkTable parent;
GtkWidget *etable;
@@ -59,50 +75,43 @@ struct _EMemoTable {
/* Fields used for cut/copy/paste */
icalcomponent *tmp_vcal;
- /* Activity ID for the EActivityHandler (i.e. the status bar). */
- EActivityHandler *activity_handler;
- guint activity_id;
-
- /* We should know which calendar has been used to create object, so store it here
- before emitting "user_created" signal and make it NULL just after the emit. */
- ECal *user_created_cal;
+ EMemoTablePrivate *priv;
};
struct _EMemoTableClass {
GtkTableClass parent_class;
- /* Notification signals */
- void (* user_created) (EMemoTable *memo_table);
+ /* Signals */
+ void (*open_component) (EMemoTable *memo_table,
+ ECalModelComponent *comp_data);
+ void (*popup_event) (EMemoTable *memo_table,
+ GdkEvent *event);
+ void (*status_message) (EMemoTable *memo_table,
+ const gchar *message,
+ gdouble percent);
+ void (*user_created) (EMemoTable *memo_table);
};
-GType e_memo_table_get_type (void);
-GtkWidget* e_memo_table_new (void);
-
-ECalModel *e_memo_table_get_model (EMemoTable *memo_table);
-
-ETable *e_memo_table_get_table (EMemoTable *memo_table);
-
-void e_memo_table_open_selected (EMemoTable *memo_table);
-void e_memo_table_delete_selected (EMemoTable *memo_table);
-
-GSList *e_memo_table_get_selected (EMemoTable *memo_table);
+GType e_memo_table_get_type (void);
+GtkWidget * e_memo_table_new (EShellView *shell_view,
+ ECalModel *model);
+ECalModel * e_memo_table_get_model (EMemoTable *memo_table);
+ETable * e_memo_table_get_table (EMemoTable *memo_table);
+EShellView * e_memo_table_get_shell_view (EMemoTable *memo_table);
+void e_memo_table_delete_selected (EMemoTable *memo_table);
+GSList * e_memo_table_get_selected (EMemoTable *memo_table);
/* Clipboard related functions */
-void e_memo_table_cut_clipboard (EMemoTable *memo_table);
-void e_memo_table_copy_clipboard (EMemoTable *memo_table);
-void e_memo_table_paste_clipboard (EMemoTable *memo_table);
+void e_memo_table_cut_clipboard (EMemoTable *memo_table);
+void e_memo_table_copy_clipboard (EMemoTable *memo_table);
+void e_memo_table_paste_clipboard (EMemoTable *memo_table);
/* These load and save the state of the table (headers shown etc.) to/from
the given file. */
-void e_memo_table_load_state (EMemoTable *memo_table,
- gchar *filename);
-void e_memo_table_save_state (EMemoTable *memo_table,
- gchar *filename);
-
-void e_memo_table_set_activity_handler (EMemoTable *memo_table,
- EActivityHandler *activity_handler);
-void e_memo_table_set_status_message (EMemoTable *memo_table,
- const gchar *message);
+void e_memo_table_load_state (EMemoTable *memo_table,
+ const gchar *filename);
+void e_memo_table_save_state (EMemoTable *memo_table,
+ const gchar *filename);
G_END_DECLS
diff --git a/calendar/gui/e-memos.c b/calendar/gui/e-memos.c
index 82f6d91c33..8a10802bff 100644
--- a/calendar/gui/e-memos.c
+++ b/calendar/gui/e-memos.c
@@ -38,7 +38,6 @@
#include "e-util/e-error.h"
#include "e-util/e-categories-config.h"
#include "e-util/e-util-private.h"
-#include "shell/e-user-creatable-items-handler.h"
#include <libecal/e-cal-time-util.h>
#include <libedataserver/e-url.h>
#include <libedataserver/e-categories.h>
@@ -46,11 +45,9 @@
#include "dialogs/delete-error.h"
#include "calendar-config.h"
#include "cal-search-bar.h"
-#include "calendar-component.h"
#include "comp-util.h"
#include "e-memo-table-config.h"
#include "misc.h"
-#include "memos-component.h"
#include "e-cal-component-memo-preview.h"
#include "e-memos.h"
#include "common/authentication.h"
@@ -71,9 +68,6 @@ struct _EMemosPrivate {
/* Calendar search bar for memos */
GtkWidget *search_bar;
- /* Paned widget */
- GtkWidget *paned;
-
/* The preview */
GtkWidget *preview;
@@ -92,7 +86,6 @@ static void e_memos_destroy (GtkObject *object);
static void update_view (EMemos *memos);
static void categories_changed_cb (gpointer object, gpointer user_data);
-static void backend_error_cb (ECal *client, const gchar *message, gpointer data);
/* Signal IDs */
enum {
@@ -102,100 +95,10 @@ enum {
LAST_SIGNAL
};
-enum DndTargetType {
- TARGET_VCALENDAR
-};
-
-static GtkTargetEntry list_drag_types[] = {
- { (gchar *) "text/calendar", 0, TARGET_VCALENDAR },
- { (gchar *) "text/x-calendar", 0, TARGET_VCALENDAR }
-};
-static const gint num_list_drag_types = sizeof (list_drag_types) / sizeof (list_drag_types[0]);
-
static guint e_memos_signals[LAST_SIGNAL] = { 0 };
G_DEFINE_TYPE (EMemos, e_memos, GTK_TYPE_TABLE)
-/* Callback used when the cursor changes in the table */
-static void
-table_cursor_change_cb (ETable *etable, gint row, gpointer data)
-{
- EMemos *memos;
- EMemosPrivate *priv;
- ECalModel *model;
- ECalModelComponent *comp_data;
- ECalComponent *comp;
- const gchar *uid;
-
- gint n_selected;
-
- memos = E_MEMOS (data);
- priv = memos->priv;
-
- n_selected = e_table_selected_count (etable);
-
- /* update the HTML widget */
- if (n_selected != 1) {
- e_cal_component_memo_preview_clear (E_CAL_COMPONENT_MEMO_PREVIEW (priv->preview));
-
- return;
- }
-
- model = e_memo_table_get_model (E_MEMO_TABLE (priv->memos_view));
-
- comp_data = e_cal_model_get_component_at (model, e_table_get_cursor_row (etable));
- comp = e_cal_component_new ();
- e_cal_component_set_icalcomponent (comp, icalcomponent_new_clone (comp_data->icalcomp));
-
- e_cal_component_memo_preview_display (E_CAL_COMPONENT_MEMO_PREVIEW (priv->preview), comp_data->client, comp);
-
- e_cal_component_get_uid (comp, &uid);
- if (priv->current_uid)
- g_free (priv->current_uid);
- priv->current_uid = g_strdup (uid);
-
- g_object_unref (comp);
-}
-
-/* Callback used when the selection changes in the table. */
-static void
-table_selection_change_cb (ETable *etable, gpointer data)
-{
- EMemos *memos;
- gint n_selected;
-
- memos = E_MEMOS (data);
-
- n_selected = e_table_selected_count (etable);
- g_signal_emit (memos, e_memos_signals[SELECTION_CHANGED], 0, n_selected);
-
- if (n_selected != 1)
- e_cal_component_memo_preview_clear (E_CAL_COMPONENT_MEMO_PREVIEW (memos->priv->preview));
-
-}
-
-static void
-user_created_cb (GtkWidget *view, EMemos *memos)
-{
- EMemosPrivate *priv;
- EMemoTable *memo_table;
- ECal *ecal;
-
- priv = memos->priv;
- memo_table = E_MEMO_TABLE (priv->memos_view);
-
- if (memo_table->user_created_cal)
- ecal = memo_table->user_created_cal;
- else {
- ECalModel *model;
-
- model = e_memo_table_get_model (E_MEMO_TABLE (priv->memos_view));
- ecal = e_cal_model_get_default_client (model);
- }
-
- e_memos_add_memo_source (memos, e_cal_get_source (ecal));
-}
-
/* Callback used when the sexp in the search bar changes */
static void
search_bar_sexp_changed_cb (CalSearchBar *cal_search, const gchar *sexp, gpointer data)
@@ -229,14 +132,6 @@ search_bar_category_changed_cb (CalSearchBar *cal_search, const gchar *category,
e_cal_model_set_default_category (model, category);
}
-static gboolean
-vpaned_resized_cb (GtkWidget *widget, GdkEventButton *event, EMemos *memos)
-{
- calendar_config_set_task_vpane_pos (gtk_paned_get_position (GTK_PANED (widget)));
-
- return FALSE;
-}
-
static void
set_timezone (EMemos *memos)
{
@@ -255,10 +150,6 @@ set_timezone (EMemos *memos)
e_cal_set_default_timezone (client, zone, NULL);
}
- if (priv->default_client && e_cal_get_load_state (priv->default_client) == E_CAL_LOAD_LOADED)
- /* FIXME Error checking */
- e_cal_set_default_timezone (priv->default_client, zone, NULL);
-
if (priv->preview)
e_cal_component_memo_preview_set_default_timezone (E_CAL_COMPONENT_MEMO_PREVIEW (priv->preview), zone);
}
@@ -287,33 +178,6 @@ update_view (EMemos *memos)
}
static void
-model_row_changed_cb (ETableModel *etm, gint row, gpointer data)
-{
- EMemos *memos;
- EMemosPrivate *priv;
- ECalModelComponent *comp_data;
-
- memos = E_MEMOS (data);
- priv = memos->priv;
-
- if (priv->current_uid) {
- const gchar *uid;
-
- comp_data = e_cal_model_get_component_at (E_CAL_MODEL (etm), row);
- if (comp_data) {
- uid = icalcomponent_get_uid (comp_data->icalcomp);
- if (!strcmp (uid ? uid : "", priv->current_uid)) {
- ETable *etable;
-
- etable = e_table_scrolled_get_table (
- E_TABLE_SCROLLED (E_MEMO_TABLE (priv->memos_view)->etable));
- table_cursor_change_cb (etable, 0, memos);
- }
- }
- }
-}
-
-static void
setup_config (EMemos *memos)
{
EMemosPrivate *priv;
@@ -328,155 +192,6 @@ setup_config (EMemos *memos)
priv->notifications = g_list_prepend (priv->notifications, GUINT_TO_POINTER (not));
}
-struct AffectedComponents {
- EMemoTable *memo_table;
- GSList *components; /* contains pointers to ECalModelComponent */
-};
-
-/**
- * get_selected_components_cb
- * Helper function to fill list of selected components in EMemoTable.
- * This function is called from e_table_selected_row_foreach.
- **/
-static void
-get_selected_components_cb (gint model_row, gpointer data)
-{
- struct AffectedComponents *ac = (struct AffectedComponents *) data;
-
- if (!ac || !ac->memo_table)
- return;
-
- ac->components = g_slist_prepend (ac->components, e_cal_model_get_component_at (E_CAL_MODEL (e_memo_table_get_model (ac->memo_table)), model_row));
-}
-
-/**
- * do_for_selected_components
- * Calls function func for all selected components in memo_table.
- *
- * @param memo_table Table with selected components of our interest.
- * @param func Function to be called on each selected component from cal_table.
- * The first parameter of this function is a pointer to ECalModelComponent and
- * the second parameter of this function is pointer to cal_table
- * @param user_data User data, will be passed to func.
- **/
-static void
-do_for_selected_components (EMemoTable *memo_table, GFunc func, gpointer user_data)
-{
- ETable *etable;
- struct AffectedComponents ac;
-
- g_return_if_fail (memo_table != NULL);
-
- ac.memo_table = memo_table;
- ac.components = NULL;
-
- etable = e_table_scrolled_get_table (E_TABLE_SCROLLED (memo_table->etable));
- e_table_selected_row_foreach (etable, get_selected_components_cb, &ac);
-
- g_slist_foreach (ac.components, func, user_data);
- g_slist_free (ac.components);
-}
-
-/**
- * obtain_list_of_components
- * As a callback function to convert each ECalModelComponent to string
- * of format "source_uid\ncomponent_str" and add this newly allocated
- * string to the list of components. Strings should be freed with g_free.
- *
- * @param data ECalModelComponent object.
- * @param user_data Pointer to GSList list, where to put new strings.
- **/
-static void
-obtain_list_of_components (gpointer data, gpointer user_data)
-{
- GSList **list;
- ECalModelComponent *comp_data;
-
- list = (GSList **) user_data;
- comp_data = (ECalModelComponent *) data;
-
- if (list && comp_data) {
- gchar *comp_str;
- icalcomponent *vcal;
-
- vcal = e_cal_util_new_top_level ();
- e_cal_util_add_timezones_from_component (vcal, comp_data->icalcomp);
- icalcomponent_add_component (vcal, icalcomponent_new_clone (comp_data->icalcomp));
-
- comp_str = icalcomponent_as_ical_string_r (vcal);
- if (comp_str) {
- ESource *source = e_cal_get_source (comp_data->client);
- const gchar *source_uid = e_source_peek_uid (source);
-
- *list = g_slist_prepend (*list, g_strdup_printf ("%s\n%s", source_uid, comp_str));
-
- /* do not free this pointer, it owns libical */
- /* g_free (comp_str); */
- }
-
- icalcomponent_free (vcal);
- g_free (comp_str);
- }
-}
-
-static void
-table_drag_data_get (ETable *table,
- gint row,
- gint col,
- GdkDragContext *context,
- GtkSelectionData *selection_data,
- guint info,
- guint time,
- EMemos *memos)
-{
- EMemosPrivate *priv;
-
- priv = memos->priv;
-
- if (info == TARGET_VCALENDAR) {
- /* we will pass an icalcalendar component for both types */
- GSList *components = NULL;
-
- do_for_selected_components (E_MEMO_TABLE (priv->memos_view), obtain_list_of_components, &components);
-
- if (components) {
- cal_comp_selection_set_string_list (selection_data, components);
-
- g_slist_foreach (components, (GFunc)g_free, NULL);
- g_slist_free (components);
- }
- }
-}
-
-static void
-table_drag_data_delete (ETable *table,
- gint row,
- gint col,
- GdkDragContext *context,
- EMemos *memos)
-{
- /* Moved components are deleted from source immediately when moved,
- because some of them can be part of destination source, and we
- don't want to delete not-moved tasks. There is no such information
- which event has been moved and which not, so skip this method.
- */
-}
-
-#define E_MEMOS_TABLE_DEFAULT_STATE \
- "<?xml version=\"1.0\"?>" \
- "<ETableState>" \
- "<column source=\"1\"/>" \
- "<column source=\"0\"/>" \
- "<column source=\"2\"/>" \
- "<grouping></grouping>" \
- "</ETableState>"
-
-static void
-pane_realized (GtkWidget *widget, EMemos *memos)
-{
- gtk_paned_set_position ((GtkPaned *)widget, calendar_config_get_task_vpane_pos ());
-}
-
static void
setup_widgets (EMemos *memos)
{
@@ -498,50 +213,12 @@ setup_widgets (EMemos *memos)
GTK_EXPAND | GTK_FILL | GTK_SHRINK, 0, 0, 0);
gtk_widget_show (priv->search_bar);
- /* add the paned widget for the memo list and memo detail areas */
- priv->paned = gtk_vpaned_new ();
- g_signal_connect (priv->paned, "realize", G_CALLBACK (pane_realized), memos);
-
- g_signal_connect (G_OBJECT (priv->paned), "button_release_event",
- G_CALLBACK (vpaned_resized_cb), memos);
- gtk_table_attach (GTK_TABLE (memos), priv->paned, 0, 1, 1, 2,
- GTK_EXPAND | GTK_FILL, GTK_EXPAND | GTK_FILL, 0, 0);
- gtk_widget_show (priv->paned);
-
/* create the memo list */
priv->memos_view = e_memo_table_new ();
priv->memos_view_config = e_memo_table_config_new (E_MEMO_TABLE (priv->memos_view));
- g_signal_connect (priv->memos_view, "user_created", G_CALLBACK (user_created_cb), memos);
-
- etable = e_table_scrolled_get_table (
- E_TABLE_SCROLLED (E_MEMO_TABLE (priv->memos_view)->etable));
- e_table_set_state (etable, E_MEMOS_TABLE_DEFAULT_STATE);
-
- gtk_paned_add1 (GTK_PANED (priv->paned), priv->memos_view);
- gtk_widget_show (priv->memos_view);
-
- e_table_drag_source_set (etable, GDK_BUTTON1_MASK,
- list_drag_types, num_list_drag_types,
- GDK_ACTION_MOVE|GDK_ACTION_COPY|GDK_ACTION_ASK);
-
g_signal_connect (etable, "table_drag_data_get",
G_CALLBACK(table_drag_data_get), memos);
- g_signal_connect (etable, "table_drag_data_delete",
- G_CALLBACK(table_drag_data_delete), memos);
-
- g_signal_connect (etable, "cursor_change", G_CALLBACK (table_cursor_change_cb), memos);
- g_signal_connect (etable, "selection_change", G_CALLBACK (table_selection_change_cb), memos);
-
- /* create the memo detail */
- priv->preview = e_cal_component_memo_preview_new ();
- e_cal_component_memo_preview_set_default_timezone (E_CAL_COMPONENT_MEMO_PREVIEW (priv->preview), calendar_config_get_icaltimezone ());
- gtk_paned_add2 (GTK_PANED (priv->paned), priv->preview);
- gtk_widget_show (priv->preview);
-
- model = e_memo_table_get_model (E_MEMO_TABLE (priv->memos_view));
- g_signal_connect (G_OBJECT (model), "model_row_changed",
- G_CALLBACK (model_row_changed_cb), memos);
}
/* Class initialization function for the gnome calendar */
@@ -634,30 +311,9 @@ e_memos_init (EMemos *memos)
priv->view_menus = NULL;
priv->current_uid = NULL;
priv->sexp = g_strdup ("#t");
- priv->default_client = NULL;
update_view (memos);
}
-GtkWidget *
-e_memos_new (void)
-{
- EMemos *memos;
-
- memos = g_object_new (e_memos_get_type (), NULL);
-
- return GTK_WIDGET (memos);
-}
-
-void
-e_memos_set_ui_component (EMemos *memos,
- BonoboUIComponent *ui_component)
-{
- g_return_if_fail (E_IS_MEMOS (memos));
- g_return_if_fail (ui_component == NULL || BONOBO_IS_UI_COMPONENT (ui_component));
-
- e_search_bar_set_ui_component (E_SEARCH_BAR (memos->priv->search_bar), ui_component);
-}
-
static void
e_memos_destroy (GtkObject *object)
{
@@ -684,10 +340,6 @@ e_memos_destroy (GtkObject *object)
g_hash_table_destroy (priv->clients);
g_list_free (priv->clients_list);
- if (priv->default_client)
- g_object_unref (priv->default_client);
- priv->default_client = NULL;
-
if (priv->current_uid) {
g_free (priv->current_uid);
priv->current_uid = NULL;
@@ -715,323 +367,6 @@ e_memos_destroy (GtkObject *object)
(* GTK_OBJECT_CLASS (e_memos_parent_class)->destroy) (object);
}
-static void
-set_status_message (EMemos *memos, const gchar *message, ...)
-{
- EMemosPrivate *priv;
- va_list args;
- gchar sz[2048], *msg_string = NULL;
-
- if (message) {
- va_start (args, message);
- vsnprintf (sz, sizeof sz, message, args);
- va_end (args);
- msg_string = sz;
- }
-
- priv = memos->priv;
-
- e_memo_table_set_status_message (E_MEMO_TABLE (priv->memos_view), msg_string);
-}
-
-/* Callback from the calendar client when an error occurs in the backend */
-static void
-backend_error_cb (ECal *client, const gchar *message, gpointer data)
-{
- EMemos *memos;
- GtkWidget *dialog;
- gchar *urinopwd;
-
- memos = E_MEMOS (data);
-
- urinopwd = get_uri_without_password (e_cal_get_uri (client));
-
- dialog = gtk_message_dialog_new (
- GTK_WINDOW (gtk_widget_get_toplevel (GTK_WIDGET (memos))),
- GTK_DIALOG_DESTROY_WITH_PARENT,
- GTK_MESSAGE_ERROR,
- GTK_BUTTONS_OK,
- _("Error on %s:\n %s"), urinopwd, message);
- gtk_dialog_run (GTK_DIALOG (dialog));
- gtk_widget_destroy (dialog);
-
- g_free (urinopwd);
-}
-
-/* Callback from the calendar client when the backend dies */
-static void
-backend_died_cb (ECal *client, gpointer data)
-{
- EMemos *memos;
- EMemosPrivate *priv;
- ESource *source;
-
- memos = E_MEMOS (data);
- priv = memos->priv;
-
- source = g_object_ref (e_cal_get_source (client));
-
- priv->clients_list = g_list_remove (priv->clients_list, client);
- g_hash_table_remove (priv->clients, e_source_peek_uid (source));
-
- g_signal_emit (memos, e_memos_signals[SOURCE_REMOVED], 0, source);
-
- e_memo_table_set_status_message (E_MEMO_TABLE (e_memos_get_calendar_table (memos)), NULL);
-
- e_error_run (GTK_WINDOW (gtk_widget_get_toplevel (GTK_WIDGET (memos))),
- "calendar:memos-crashed", NULL);
-
- g_object_unref (source);
-}
-
-/* Callback from the calendar client when the calendar is opened */
-static void
-client_cal_opened_cb (ECal *ecal, ECalendarStatus status, EMemos *memos)
-{
- ECalModel *model;
- ESource *source;
- EMemosPrivate *priv;
-
- priv = memos->priv;
-
- source = e_cal_get_source (ecal);
-
- if (status == E_CALENDAR_STATUS_AUTHENTICATION_FAILED || status == E_CALENDAR_STATUS_AUTHENTICATION_REQUIRED)
- auth_cal_forget_password (ecal);
-
- switch (status) {
- case E_CALENDAR_STATUS_OK :
- g_signal_handlers_disconnect_matched (ecal, G_SIGNAL_MATCH_FUNC, 0, 0, NULL, client_cal_opened_cb, NULL);
-
- set_status_message (memos, _("Loading memos"));
- model = e_memo_table_get_model (E_MEMO_TABLE (priv->memos_view));
- e_cal_model_add_client (model, ecal);
-
- set_timezone (memos);
- set_status_message (memos, NULL);
- break;
- case E_CALENDAR_STATUS_AUTHENTICATION_FAILED:
- /* try to reopen calendar - it'll ask for a password once again */
- e_cal_open_async (ecal, FALSE);
- return;
- case E_CALENDAR_STATUS_BUSY :
- break;
- case E_CALENDAR_STATUS_REPOSITORY_OFFLINE:
- e_error_run (GTK_WINDOW (gtk_widget_get_toplevel (GTK_WIDGET (memos))), "calendar:prompt-no-contents-offline-memos", NULL);
- default :
- /* Make sure the source doesn't disappear on us */
- g_object_ref (source);
-
- priv->clients_list = g_list_remove (priv->clients_list, ecal);
- g_signal_handlers_disconnect_matched (ecal, G_SIGNAL_MATCH_DATA,
- 0, 0, NULL, NULL, memos);
-
- /* Do this last because it unrefs the client */
- g_hash_table_remove (priv->clients, e_source_peek_uid (source));
-
- g_signal_emit (memos, e_memos_signals[SOURCE_REMOVED], 0, source);
-
- set_status_message (memos, NULL);
- g_object_unref (source);
-
- break;
- }
-}
-
-static void
-default_client_cal_opened_cb (ECal *ecal, ECalendarStatus status, EMemos *memos)
-{
- ECalModel *model;
- ESource *source;
- EMemosPrivate *priv;
-
- priv = memos->priv;
-
- source = e_cal_get_source (ecal);
-
- if (status == E_CALENDAR_STATUS_AUTHENTICATION_FAILED || status == E_CALENDAR_STATUS_AUTHENTICATION_REQUIRED)
- auth_cal_forget_password (ecal);
-
- switch (status) {
- case E_CALENDAR_STATUS_OK :
- g_signal_handlers_disconnect_matched (ecal, G_SIGNAL_MATCH_FUNC, 0, 0, NULL, default_client_cal_opened_cb, NULL);
- model = e_memo_table_get_model (E_MEMO_TABLE (priv->memos_view));
-
- set_timezone (memos);
- e_cal_model_set_default_client (model, ecal);
- set_status_message (memos, NULL);
- break;
- case E_CALENDAR_STATUS_AUTHENTICATION_FAILED:
- /* try to reopen calendar - it'll ask for a password once again */
- e_cal_open_async (ecal, FALSE);
- return;
- case E_CALENDAR_STATUS_BUSY:
- break;
- default :
- /* Make sure the source doesn't disappear on us */
- g_object_ref (source);
-
- priv->clients_list = g_list_remove (priv->clients_list, ecal);
- g_signal_handlers_disconnect_matched (ecal, G_SIGNAL_MATCH_DATA,
- 0, 0, NULL, NULL, memos);
-
- /* Do this last because it unrefs the client */
- g_hash_table_remove (priv->clients, e_source_peek_uid (source));
-
- g_signal_emit (memos, e_memos_signals[SOURCE_REMOVED], 0, source);
-
- set_status_message (memos, NULL);
- g_object_unref (priv->default_client);
- priv->default_client = NULL;
- g_object_unref (source);
-
- break;
- }
-}
-
-typedef void (*open_func) (ECal *, ECalendarStatus, EMemos *);
-
-static gboolean
-open_ecal (EMemos *memos, ECal *cal, gboolean only_if_exists, open_func of)
-{
- set_status_message (memos, _("Opening memos at %s"), e_cal_get_uri (cal));
-
- g_signal_connect (G_OBJECT (cal), "cal_opened", G_CALLBACK (of), memos);
- e_cal_open_async (cal, only_if_exists);
-
- return TRUE;
-}
-
-void
-e_memos_open_memo (EMemos *memos)
-{
- EMemoTable *cal_table;
-
- cal_table = e_memos_get_calendar_table (memos);
- e_memo_table_open_selected (cal_table);
-}
-
-void
-e_memos_new_memo (EMemos *memos)
-{
- /* used for click_to_add ?? Can't figure out anything else it's used for */
-}
-
-gboolean
-e_memos_add_memo_source (EMemos *memos, ESource *source)
-{
- EMemosPrivate *priv;
- ECal *client;
- const gchar *uid;
-
- g_return_val_if_fail (memos != NULL, FALSE);
- g_return_val_if_fail (E_IS_MEMOS (memos), FALSE);
- g_return_val_if_fail (E_IS_SOURCE (source), FALSE);
-
- priv = memos->priv;
-
- uid = e_source_peek_uid (source);
- client = g_hash_table_lookup (priv->clients, uid);
- if (client) {
- /* We already have it */
-
- return TRUE;
- } else {
- ESource *default_source;
-
- if (priv->default_client) {
- default_source = e_cal_get_source (priv->default_client);
-
- /* We don't have it but the default client is it */
- if (!strcmp (e_source_peek_uid (default_source), uid))
- client = g_object_ref (priv->default_client);
- }
-
- /* Create a new one */
- if (!client) {
- client = auth_new_cal_from_source (source, E_CAL_SOURCE_TYPE_JOURNAL);
- if (!client)
- return FALSE;
- }
- }
-
- g_signal_connect (G_OBJECT (client), "backend_error", G_CALLBACK (backend_error_cb), memos);
- g_signal_connect (G_OBJECT (client), "backend_died", G_CALLBACK (backend_died_cb), memos);
-
- /* add the client to internal structure */
- g_hash_table_insert (priv->clients, g_strdup (uid) , client);
- priv->clients_list = g_list_prepend (priv->clients_list, client);
-
- g_signal_emit (memos, e_memos_signals[SOURCE_ADDED], 0, source);
-
- open_ecal (memos, client, FALSE, client_cal_opened_cb);
-
- return TRUE;
-}
-
-gboolean
-e_memos_remove_memo_source (EMemos *memos, ESource *source)
-{
- EMemosPrivate *priv;
- ECal *client;
- ECalModel *model;
- const gchar *uid;
-
- g_return_val_if_fail (memos != NULL, FALSE);
- g_return_val_if_fail (E_IS_MEMOS (memos), FALSE);
- g_return_val_if_fail (E_IS_SOURCE (source), FALSE);
-
- priv = memos->priv;
-
- uid = e_source_peek_uid (source);
- client = g_hash_table_lookup (priv->clients, uid);
- if (!client)
- return TRUE;
-
- priv->clients_list = g_list_remove (priv->clients_list, client);
- g_signal_handlers_disconnect_matched (client, G_SIGNAL_MATCH_DATA,
- 0, 0, NULL, NULL, memos);
-
- model = e_memo_table_get_model (E_MEMO_TABLE (priv->memos_view));
- e_cal_model_remove_client (model, client);
-
- g_hash_table_remove (priv->clients, uid);
-
- g_signal_emit (memos, e_memos_signals[SOURCE_REMOVED], 0, source);
-
- return TRUE;
-}
-
-gboolean
-e_memos_set_default_source (EMemos *memos, ESource *source)
-{
- EMemosPrivate *priv;
- ECal *ecal;
-
- g_return_val_if_fail (memos != NULL, FALSE);
- g_return_val_if_fail (E_IS_MEMOS (memos), FALSE);
- g_return_val_if_fail (E_IS_SOURCE (source), FALSE);
-
- priv = memos->priv;
-
- ecal = g_hash_table_lookup (priv->clients, e_source_peek_uid (source));
-
- if (priv->default_client)
- g_object_unref (priv->default_client);
-
- if (ecal) {
- priv->default_client = g_object_ref (ecal);
- } else {
- priv->default_client = auth_new_cal_from_source (source, E_CAL_SOURCE_TYPE_JOURNAL);
- if (!priv->default_client)
- return FALSE;
- }
-
- open_ecal (memos, priv->default_client, FALSE, default_client_cal_opened_cb);
-
- return TRUE;
-}
-
ECal *
e_memos_get_default_client (EMemos *memos)
{
@@ -1044,186 +379,3 @@ e_memos_get_default_client (EMemos *memos)
return e_cal_model_get_default_client (e_memo_table_get_model (E_MEMO_TABLE (priv->memos_view)));
}
-
-/**
- * e_memos_delete_selected:
- * @memos: A memos control widget.
- *
- * Deletes the selected memos in the memo list.
- **/
-void
-e_memos_delete_selected (EMemos *memos)
-{
- EMemosPrivate *priv;
- EMemoTable *cal_table;
-
- g_return_if_fail (memos != NULL);
- g_return_if_fail (E_IS_MEMOS (memos));
-
- priv = memos->priv;
-
- cal_table = E_MEMO_TABLE (priv->memos_view);
- set_status_message (memos, _("Deleting selected objects..."));
- e_memo_table_delete_selected (cal_table);
- set_status_message (memos, NULL);
-
- e_cal_component_memo_preview_clear (E_CAL_COMPONENT_MEMO_PREVIEW (priv->preview));
-}
-
-/* Callback used from the view collection when we need to display a new view */
-static void
-display_view_cb (GalViewInstance *instance, GalView *view, gpointer data)
-{
- EMemos *memos;
-
- memos = E_MEMOS (data);
-
- if (GAL_IS_VIEW_ETABLE (view)) {
- gal_view_etable_attach_table (GAL_VIEW_ETABLE (view), e_table_scrolled_get_table (E_TABLE_SCROLLED (E_MEMO_TABLE (memos->priv->memos_view)->etable)));
- }
-
- gtk_paned_set_position ((GtkPaned *)memos->priv->paned, calendar_config_get_task_vpane_pos ());
-}
-
-/**
- * e_memos_setup_view_menus:
- * @memos: A memos widget.
- * @uic: UI controller to use for the menus.
- *
- * Sets up the #GalView menus for a memos control. This function should be
- * called from the Bonobo control activation callback for this memos control.
- * Also, the menus should be discarded using e_memos_discard_view_menus().
- */
-void
-e_memos_setup_view_menus (EMemos *memos, BonoboUIComponent *uic)
-{
- EMemosPrivate *priv;
- GalViewFactory *factory;
- ETableSpecification *spec;
- gchar *dir0, *dir1, *filename;
- static GalViewCollection *collection = NULL;
-
- g_return_if_fail (memos != NULL);
- g_return_if_fail (E_IS_MEMOS (memos));
- g_return_if_fail (uic != NULL);
- g_return_if_fail (BONOBO_IS_UI_COMPONENT (uic));
-
- priv = memos->priv;
-
- g_return_if_fail (priv->view_instance == NULL);
-
- g_return_if_fail (priv->view_instance == NULL);
- g_return_if_fail (priv->view_menus == NULL);
-
- /* Create the view instance */
-
- if (collection == NULL) {
- collection = gal_view_collection_new ();
-
- gal_view_collection_set_title (collection, _("Memos"));
-
- dir0 = g_build_filename (EVOLUTION_GALVIEWSDIR,
- "memos",
- NULL);
- dir1 = g_build_filename (memos_component_peek_base_directory (memos_component_peek ()),
- "views", NULL);
- gal_view_collection_set_storage_directories (collection,
- dir0,
- dir1);
- g_free (dir1);
- g_free (dir0);
-
- /* Create the views */
-
- spec = e_table_specification_new ();
- filename = g_build_filename (EVOLUTION_ETSPECDIR,
- "e-memo-table.etspec",
- NULL);
- if (!e_table_specification_load_from_file (spec, filename))
- g_error ("Unable to load ETable specification file "
- "for memos");
- g_free (filename);
-
- factory = gal_view_factory_etable_new (spec);
- g_object_unref (spec);
- gal_view_collection_add_factory (collection, factory);
- g_object_unref (factory);
-
- /* Load the collection and create the menus */
-
- gal_view_collection_load (collection);
- }
-
- 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), memos);
- display_view_cb (priv->view_instance, gal_view_instance_get_current_view (priv->view_instance), memos);
-}
-
-/**
- * e_memos_discard_view_menus:
- * @memos: A memos widget.
- *
- * Discards the #GalView menus used by a memos control. This function should be
- * called from the Bonobo control deactivation callback for this memos control.
- * The menus should have been set up with e_memos_setup_view_menus().
- **/
-void
-e_memos_discard_view_menus (EMemos *memos)
-{
- EMemosPrivate *priv;
-
- g_return_if_fail (memos != NULL);
- g_return_if_fail (E_IS_MEMOS (memos));
-
- priv = memos->priv;
-
- g_return_if_fail (priv->view_instance != NULL);
-
- 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;
-}
-
-/**
- * e_memos_get_calendar_table:
- * @memos: A memos widget.
- *
- * Queries the #EMemoTable contained in a memos widget.
- *
- * Return value: The #EMemoTable that the memos widget uses to display its
- * information.
- **/
-EMemoTable *
-e_memos_get_calendar_table (EMemos *memos)
-{
- EMemosPrivate *priv;
-
- g_return_val_if_fail (memos != NULL, NULL);
- g_return_val_if_fail (E_IS_MEMOS (memos), NULL);
-
- priv = memos->priv;
- return E_MEMO_TABLE (priv->memos_view);
-}
-
-/**
- * e_memos_get_preview:
- * @memos: A memos widget.
- *
- * Queries the #ECalComponentMemoPreview contained in a memos widget.
- **/
-GtkWidget *
-e_memos_get_preview (EMemos *memos)
-{
- g_return_val_if_fail (memos != NULL, NULL);
- g_return_val_if_fail (E_IS_MEMOS (memos), NULL);
-
- return memos->priv->preview;
-}
diff --git a/calendar/gui/e-memos.h b/calendar/gui/e-memos.h
index a03541c6d6..4c49f56a79 100644
--- a/calendar/gui/e-memos.h
+++ b/calendar/gui/e-memos.h
@@ -25,7 +25,6 @@
#ifndef _E_MEMOS_H_
#define _E_MEMOS_H_
-#include <bonobo/bonobo-ui-component.h>
#include <gtk/gtk.h>
#include <libedataserver/e-source.h>
#include <libecal/e-cal.h>
@@ -63,9 +62,6 @@ GtkWidget *e_memos_construct (EMemos *memos);
GtkWidget *e_memos_new (void);
-void e_memos_set_ui_component (EMemos *memos,
- BonoboUIComponent *ui_component);
-
gboolean e_memos_add_memo_source (EMemos *memos, ESource *source);
gboolean e_memos_remove_memo_source (EMemos *memos, ESource *source);
gboolean e_memos_set_default_source (EMemos *memos, ESource *source);
diff --git a/calendar/gui/e-month-view.c b/calendar/gui/e-month-view.c
new file mode 100644
index 0000000000..6f00e1d233
--- /dev/null
+++ b/calendar/gui/e-month-view.c
@@ -0,0 +1,211 @@
+/*
+ * e-month-view.c
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2 of the License, or (at your option) version 3.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with the program; if not, see <http://www.gnu.org/licenses/>
+ *
+ *
+ * Copyright (C) 1999-2008 Novell, Inc. (www.novell.com)
+ *
+ */
+
+#include "e-month-view.h"
+
+#define E_MONTH_VIEW_GET_PRIVATE(obj) \
+ (G_TYPE_INSTANCE_GET_PRIVATE \
+ ((obj), E_TYPE_MONTH_VIEW, EMonthViewPrivate))
+
+struct _EMonthViewPrivate {
+ gint placeholder;
+};
+
+static gpointer parent_class;
+
+static void
+month_view_cursor_key_up (EWeekView *week_view)
+{
+ if (week_view->selection_start_day == -1)
+ return;
+
+ if (week_view->selection_start_day < 7) {
+ /* No easy way to calculate new selection_start_day, so
+ * calculate a time_t value and set_selected_time_range. */
+ time_t current;
+
+ if (e_calendar_view_get_selected_time_range (
+ E_CALENDAR_VIEW (week_view), &current, NULL)) {
+
+ current = time_add_week (current, -1);
+ e_week_view_scroll_a_step (
+ week_view, E_CAL_VIEW_MOVE_PAGE_UP);
+ e_week_view_set_selected_time_range_visible (
+ week_view, current, current);
+ }
+ } else {
+ week_view->selection_start_day -= 7;
+ week_view->selection_end_day = week_view->selection_start_day;
+ }
+
+ g_signal_emit_by_name (week_view, "selected-time-changed");
+ gtk_widget_queue_draw (week_view->main_canvas);
+}
+
+static void
+month_view_cursor_key_down (EWeekView *week_view)
+{
+ gint weeks_shown;
+
+ if (week_view->selection_start_day == -1)
+ return;
+
+ weeks_shown = e_week_view_get_weeks_shown (week_view);
+
+ if (week_view->selection_start_day >= (weeks_shown - 1) * 7) {
+ /* No easy way to calculate new selection_start_day, so
+ * calculate a time_t value and set_selected_time_range. */
+ time_t current;
+
+ if (e_calendar_view_get_selected_time_range (
+ E_CALENDAR_VIEW (week_view), &current, NULL)) {
+
+ current = time_add_week (current, -1);
+ e_week_view_scroll_a_step (
+ week_view, E_CAL_VIEW_MOVE_PAGE_DOWN);
+ e_week_view_set_selected_time_range_visible (
+ week_view, current, current);
+ }
+ } else {
+ week_view->selection_start_day += 7;
+ week_view->selection_end_day = week_view->selection_start_day;
+ }
+
+ g_signal_emit_by_name (week_view, "selected-time-changed");
+ gtk_widget_queue_draw (week_view->main_canvas);
+}
+
+static void
+month_view_cursor_key_left (EWeekView *week_view)
+{
+ if (week_view->selection_start_day == -1)
+ return;
+
+ if (week_view->selection_start_day == 0) {
+ /* No easy way to calculate new selection_start_day, so
+ * calculate a time_t value and set_selected_time_range. */
+ time_t current;
+
+ if (e_calendar_view_get_selected_time_range (
+ E_CALENDAR_VIEW (week_view), &current, NULL)) {
+
+ current = time_add_day (current, -1);
+ e_week_view_scroll_a_step (
+ week_view, E_CAL_VIEW_MOVE_PAGE_UP);
+ e_week_view_set_selected_time_range_visible (
+ week_view, current, current);
+ }
+ } else {
+ week_view->selection_start_day--;
+ week_view->selection_end_day = week_view->selection_start_day;
+ }
+
+ g_signal_emit_by_name (week_view, "selected-time-changed");
+ gtk_widget_queue_draw (week_view->main_canvas);
+}
+
+static void
+month_view_cursor_key_right (EWeekView *week_view)
+{
+ gint weeks_shown;
+
+ if (week_view->selection_start_day == -1)
+ return;
+
+ weeks_shown = e_week_view_get_weeks_shown (week_view);
+
+ if (week_view->selection_start_day == weeks_shown * 7 - 1) {
+ /* No easy way to calculate new selection_start_day, so
+ * calculate a time_t value and set_selected_time_range. */
+ time_t current;
+
+ if (e_calendar_view_get_selected_time_range (
+ E_CALENDAR_VIEW (week_view), &current, NULL)) {
+
+ current = time_add_day (current, 1);
+ e_week_view_scroll_a_step (
+ week_view, E_CAL_VIEW_MOVE_PAGE_DOWN);
+ e_week_view_set_selected_time_range_visible (
+ week_view, current, current);
+ }
+ } else {
+ week_view->selection_start_day++;
+ week_view->selection_end_day = week_view->selection_start_day;
+ }
+
+ g_signal_emit_by_name (week_view, "selected-time-changed");
+ gtk_widget_queue_draw (week_view->main_canvas);
+}
+
+static void
+month_view_class_init (EMonthViewClass *class)
+{
+ EWeekViewClass *week_view_class;
+
+ parent_class = g_type_class_peek_parent (class);
+ g_type_class_add_private (class, sizeof (EMonthViewPrivate));
+
+ week_view_class = E_WEEK_VIEW_CLASS (class);
+ week_view_class->cursor_key_up = month_view_cursor_key_up;
+ week_view_class->cursor_key_down = month_view_cursor_key_down;
+ week_view_class->cursor_key_left = month_view_cursor_key_left;
+ week_view_class->cursor_key_right = month_view_cursor_key_right;
+}
+
+static void
+month_view_init (EMonthView *month_view)
+{
+ month_view->priv = E_MONTH_VIEW_GET_PRIVATE (month_view);
+}
+
+GType
+e_month_view_get_type (void)
+{
+ static GType type = 0;
+
+ if (G_UNLIKELY (type == 0)) {
+ const GTypeInfo type_info = {
+ sizeof (EMonthViewClass),
+ (GBaseInitFunc) NULL,
+ (GBaseFinalizeFunc) NULL,
+ (GClassInitFunc) month_view_class_init,
+ (GClassFinalizeFunc) NULL,
+ NULL, /* class_data */
+ sizeof (EMonthView),
+ 0, /* n_preallocs */
+ (GInstanceInitFunc) month_view_init,
+ NULL /* value_table */
+ };
+
+ type = g_type_register_static (
+ E_TYPE_WEEK_VIEW, "EMonthView", &type_info, 0);
+ }
+
+ return type;
+}
+
+GtkWidget *
+e_month_view_new (ECalModel *model)
+{
+ g_return_val_if_fail (E_IS_CAL_MODEL (model), NULL);
+
+ return g_object_new (E_TYPE_MONTH_VIEW, "model", model, NULL);
+}
diff --git a/calendar/gui/e-month-view.h b/calendar/gui/e-month-view.h
new file mode 100644
index 0000000000..c68346b3e2
--- /dev/null
+++ b/calendar/gui/e-month-view.h
@@ -0,0 +1,66 @@
+/*
+ * e-month-view.h
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2 of the License, or (at your option) version 3.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with the program; if not, see <http://www.gnu.org/licenses/>
+ *
+ *
+ * Copyright (C) 1999-2008 Novell, Inc. (www.novell.com)
+ *
+ */
+
+#ifndef E_MONTH_VIEW_H
+#define E_MONTH_VIEW_H
+
+#include "e-week-view.h"
+
+/* Standard GObject macros */
+#define E_TYPE_MONTH_VIEW \
+ (e_month_view_get_type ())
+#define E_MONTH_VIEW(obj) \
+ (G_TYPE_CHECK_INSTANCE_CAST \
+ ((obj), E_TYPE_MONTH_VIEW, EMonthView))
+#define E_MONTH_VIEW_CLASS(cls) \
+ (G_TYPE_CHECK_CLASS_CAST \
+ ((obj), E_TYPE_MONTH_VIEW, EMonthViewClass))
+#define E_IS_MONTH_VIEW(obj) \
+ (G_TYPE_CHECK_INSTANCE_TYPE \
+ ((obj), E_TYPE_MONTH_VIEW))
+#define E_IS_MONTH_VIEW_CLASS(cls) \
+ (G_TYPE_CHECK_CLASS_TYPE \
+ ((cls), E_TYPE_MONTH_VIEW))
+#define E_MONTH_VIEW_GET_CLASS(obj) \
+ (G_TYPE_CHECK_INSTANCE_TYPE \
+ ((obj), E_TYPE_MONTH_VIEW, EMonthViewClass))
+
+G_BEGIN_DECLS
+
+typedef struct _EMonthView EMonthView;
+typedef struct _EMonthViewClass EMonthViewClass;
+typedef struct _EMonthViewPrivate EMonthViewPrivate;
+
+struct _EMonthView {
+ EWeekView parent;
+ EMonthViewPrivate *priv;
+};
+
+struct _EMonthViewClass {
+ EWeekViewClass parent_class;
+};
+
+GType e_month_view_get_type (void);
+GtkWidget * e_month_view_new (ECalModel *model);
+
+G_END_DECLS
+
+#endif /* E_MONTH_VIEW_H */
diff --git a/calendar/gui/e-task-list-selector.c b/calendar/gui/e-task-list-selector.c
new file mode 100644
index 0000000000..fa6bd328d9
--- /dev/null
+++ b/calendar/gui/e-task-list-selector.c
@@ -0,0 +1,288 @@
+/* -*- Mode: C; indent-tabs-mode: t; c-basic-offset: 8; tab-width: 8 -*- */
+/* e-task-list-selector.c
+ *
+ * Copyright (C) 1999-2008 Novell, Inc. (www.novell.com)
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of version 2 of the GNU General Public
+ * License as published by the Free Software Foundation.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public
+ * License along with this program; if not, write to the
+ * Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
+ * Boston, MA 02110-1301, USA.
+ */
+
+#include "e-task-list-selector.h"
+
+#include <string.h>
+#include <libecal/e-cal.h>
+#include "calendar/common/authentication.h"
+#include "calendar/gui/comp-util.h"
+
+#define E_TASK_LIST_SELECTOR_GET_PRIVATE(obj) \
+ (G_TYPE_INSTANCE_GET_PRIVATE \
+ ((obj), E_TYPE_TASK_LIST_SELECTOR, ETaskListSelectorPrivate))
+
+struct _ETaskListSelectorPrivate {
+ gint dummy_value;
+};
+
+enum {
+ DND_TARGET_TYPE_CALENDAR_LIST
+};
+
+static GtkTargetEntry drag_types[] = {
+ { (gchar *) "text/calendar", 0, DND_TARGET_TYPE_CALENDAR_LIST },
+ { (gchar *) "text/x-calendar", 0, DND_TARGET_TYPE_CALENDAR_LIST }
+};
+
+static gpointer parent_class;
+
+static gboolean
+task_list_selector_update_single_object (ECal *client,
+ icalcomponent *icalcomp)
+{
+ gchar *uid;
+ icalcomponent *tmp_icalcomp;
+
+ uid = (gchar *) icalcomponent_get_uid (icalcomp);
+
+ if (e_cal_get_object (client, uid, NULL, &tmp_icalcomp, NULL))
+ return e_cal_modify_object (
+ client, icalcomp, CALOBJ_MOD_ALL, NULL);
+
+ return e_cal_create_object (client, icalcomp, &uid, NULL);
+}
+
+static gboolean
+task_list_selector_update_objects (ECal *client,
+ icalcomponent *icalcomp)
+{
+ icalcomponent *subcomp;
+ icalcomponent_kind kind;
+
+ kind = icalcomponent_isa (icalcomp);
+ if (kind == ICAL_VTODO_COMPONENT || kind == ICAL_VEVENT_COMPONENT)
+ return task_list_selector_update_single_object (
+ client, icalcomp);
+ else if (kind != ICAL_VCALENDAR_COMPONENT)
+ return FALSE;
+
+ subcomp = icalcomponent_get_first_component (
+ icalcomp, ICAL_ANY_COMPONENT);
+ while (subcomp != NULL) {
+ gboolean success;
+
+ kind = icalcomponent_isa (subcomp);
+ if (kind == ICAL_VTIMEZONE_COMPONENT) {
+ icaltimezone *zone;
+
+ zone = icaltimezone_new ();
+ icaltimezone_set_component (zone, subcomp);
+
+ success = e_cal_add_timezone (client, zone, NULL);
+ icaltimezone_free (zone, 1);
+ if (!success)
+ return FALSE;
+ } else if (kind == ICAL_VTODO_COMPONENT ||
+ kind == ICAL_VEVENT_COMPONENT) {
+ success = task_list_selector_update_single_object (
+ client, subcomp);
+ if (!success)
+ return FALSE;
+ }
+
+ subcomp = icalcomponent_get_next_component (
+ icalcomp, ICAL_ANY_COMPONENT);
+ }
+
+ return TRUE;
+}
+
+static gboolean
+task_list_selector_process_data (ESourceSelector *selector,
+ ECal *client,
+ const gchar *source_uid,
+ icalcomponent *icalcomp,
+ GdkDragAction action)
+{
+ ESourceList *source_list;
+ ESource *source;
+ icalcomponent *tmp_icalcomp = NULL;
+ const gchar *uid;
+ gchar *old_uid = NULL;
+ gboolean success = FALSE;
+ gboolean read_only = TRUE;
+ GError *error = NULL;
+
+ /* FIXME Deal with GDK_ACTION_ASK. */
+ if (action == GDK_ACTION_COPY) {
+ old_uid = g_strdup (icalcomponent_get_uid (icalcomp));
+ uid = e_cal_component_gen_uid ();
+ icalcomponent_set_uid (icalcomp, uid);
+ }
+
+ uid = icalcomponent_get_uid (icalcomp);
+ if (old_uid == NULL)
+ old_uid = g_strdup (uid);
+
+ if (e_cal_get_object (client, uid, NULL, &tmp_icalcomp, &error)) {
+ icalcomponent_free (tmp_icalcomp);
+ success = TRUE;
+ goto exit;
+ }
+
+ if (error != NULL && error->code != E_CALENDAR_STATUS_OBJECT_NOT_FOUND) {
+ g_message (
+ "Failed to search the object in destination "
+ "task list: %s", error->message);
+ g_error_free (error);
+ goto exit;
+ }
+
+ success = task_list_selector_update_objects (client, icalcomp);
+
+ if (!success || action != GDK_ACTION_MOVE)
+ goto exit;
+
+ source_list = e_source_selector_get_source_list (selector);
+ source = e_source_list_peek_source_by_uid (source_list, source_uid);
+
+ if (!E_IS_SOURCE (source) || e_source_get_readonly (source))
+ goto exit;
+
+ client = auth_new_cal_from_source (source, E_CAL_SOURCE_TYPE_TODO);
+ if (client == NULL) {
+ g_message ("Cannot create source client to remove old task");
+ goto exit;
+ }
+
+ e_cal_is_read_only (client, &read_only, NULL);
+ if (!read_only && e_cal_open (client, TRUE, NULL))
+ e_cal_remove_object (client, old_uid, NULL);
+ else if (!read_only)
+ g_message ("Cannot open source client to remove old task");
+
+ g_object_unref (client);
+
+exit:
+ g_free (old_uid);
+
+ return success;
+}
+
+static gboolean
+task_list_selector_data_dropped (ESourceSelector *selector,
+ GtkSelectionData *selection_data,
+ ESource *destination,
+ GdkDragAction action,
+ guint info)
+{
+ ECal *client;
+ GSList *list, *iter;
+ gboolean success = FALSE;
+
+ client = auth_new_cal_from_source (
+ destination, E_CAL_SOURCE_TYPE_TODO);
+
+ if (client == NULL || !e_cal_open (client, TRUE, NULL))
+ goto exit;
+
+ list = cal_comp_selection_get_string_list (selection_data);
+
+ for (iter = list; iter != NULL; iter = iter->next) {
+ gchar *source_uid = iter->data;
+ icalcomponent *icalcomp;
+ gchar *component_string;
+
+ /* Each string is "source_uid\ncomponent_string". */
+ component_string = strchr (source_uid, '\n');
+ if (component_string == NULL)
+ continue;
+
+ *component_string++ = '\0';
+ icalcomp = icalparser_parse_string (component_string);
+ if (icalcomp == NULL)
+ continue;
+
+ success = task_list_selector_process_data (
+ selector, client, source_uid, icalcomp, action);
+
+ icalcomponent_free (icalcomp);
+ }
+
+ g_slist_foreach (list, (GFunc) g_free, NULL);
+ g_slist_free (list);
+
+exit:
+ if (client != NULL)
+ g_object_unref (client);
+
+ return success;
+}
+
+static void
+task_list_selector_class_init (ETaskListSelectorClass *class)
+{
+ ESourceSelectorClass *source_selector_class;
+
+ parent_class = g_type_class_peek_parent (class);
+ g_type_class_add_private (class, sizeof (ETaskListSelectorPrivate));
+
+ source_selector_class = E_SOURCE_SELECTOR_CLASS (class);
+ source_selector_class->data_dropped = task_list_selector_data_dropped;
+}
+
+static void
+task_list_selector_init (ETaskListSelector *selector)
+{
+ selector->priv = E_TASK_LIST_SELECTOR_GET_PRIVATE (selector);
+
+ gtk_drag_dest_set (
+ GTK_WIDGET (selector), GTK_DEST_DEFAULT_ALL,
+ drag_types, G_N_ELEMENTS (drag_types),
+ GDK_ACTION_COPY | GDK_ACTION_MOVE);
+}
+
+GType
+e_task_list_selector_get_type (void)
+{
+ static GType type = 0;
+
+ if (G_UNLIKELY (type == 0)) {
+ const GTypeInfo type_info = {
+ sizeof (ETaskListSelectorClass),
+ (GBaseInitFunc) NULL,
+ (GBaseFinalizeFunc) NULL,
+ (GClassInitFunc) task_list_selector_class_init,
+ (GClassFinalizeFunc) NULL,
+ NULL, /* class_data */
+ sizeof (ETaskListSelector),
+ 0, /* n_preallocs */
+ (GInstanceInitFunc) task_list_selector_init,
+ NULL /* value_table */
+ };
+
+ type = g_type_register_static (
+ E_TYPE_SOURCE_SELECTOR, "ETaskListSelector",
+ &type_info, 0);
+ }
+
+ return type;
+}
+
+GtkWidget *
+e_task_list_selector_new (ESourceList *source_list)
+{
+ g_return_val_if_fail (E_IS_SOURCE_LIST (source_list), NULL);
+
+ return g_object_new (
+ E_TYPE_TASK_LIST_SELECTOR,
+ "source-list", source_list, NULL);
+}
diff --git a/calendar/gui/e-task-list-selector.h b/calendar/gui/e-task-list-selector.h
new file mode 100644
index 0000000000..847a221ba4
--- /dev/null
+++ b/calendar/gui/e-task-list-selector.h
@@ -0,0 +1,71 @@
+/* -*- Mode: C; indent-tabs-mode: t; c-basic-offset: 8; tab-width: 8 -*- */
+/* e-task-list-selector.h
+ *
+ * Copyright (C) 1999-2008 Novell, Inc. (www.novell.com)
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of version 2 of the GNU General Public
+ * License as published by the Free Software Foundation.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public
+ * License along with this program; if not, write to the
+ * Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
+ * Boston, MA 02110-1301, USA.
+ */
+
+/* XXX This widget is nearly identical to EMemoListSelector. If
+ * ECalendarSelector ever learns how to move selections from
+ * one source to another, perhaps these ESourceSelector sub-
+ * classes could someday be combined. */
+
+#ifndef E_TASK_LIST_SELECTOR_H
+#define E_TASK_LIST_SELECTOR_H
+
+#include <libedataserver/e-source-list.h>
+#include <libedataserverui/e-source-selector.h>
+
+/* Standard GObject macros */
+#define E_TYPE_TASK_LIST_SELECTOR \
+ (e_task_list_selector_get_type ())
+#define E_TASK_LIST_SELECTOR(obj) \
+ (G_TYPE_CHECK_INSTANCE_CAST \
+ ((obj), E_TYPE_TASK_LIST_SELECTOR, ETaskListSelector))
+#define E_TASK_LIST_SELECTOR_CLASS(cls) \
+ (G_TYPE_CHECK_CLASS_CAST \
+ ((cls), E_TYPE_TASK_LIST_SELECTOR, ETaskListSelectorClass))
+#define E_IS_TASK_LIST_SELECTOR(obj) \
+ (G_TYPE_CHECK_INSTANCE_TYPE \
+ ((obj), E_TYPE_TASK_LIST_SELECTOR))
+#define E_IS_TASK_LIST_SELECTOR_CLASS(cls) \
+ (G_TYPE_CHECK_CLASS_TYPE \
+ ((cls), E_TYPE_TASK_LIST_SELECTOR))
+#define E_TASK_LIST_SELECTOR_GET_CLASS(obj) \
+ (G_TYPE_INSTANCE_GET_CLASS \
+ ((obj), E_TYPE_TASK_LIST_SELECTOR, ETaskListSelectorClass))
+
+G_BEGIN_DECLS
+
+typedef struct _ETaskListSelector ETaskListSelector;
+typedef struct _ETaskListSelectorClass ETaskListSelectorClass;
+typedef struct _ETaskListSelectorPrivate ETaskListSelectorPrivate;
+
+struct _ETaskListSelector {
+ ESourceSelector parent;
+ ETaskListSelectorPrivate *priv;
+};
+
+struct _ETaskListSelectorClass {
+ ESourceSelectorClass parent_class;
+};
+
+GType e_task_list_selector_get_type (void);
+GtkWidget * e_task_list_selector_new (ESourceList *source_list);
+
+G_END_DECLS
+
+#endif /* E_TASK_LIST_SELECTOR_H */
diff --git a/calendar/gui/e-tasks.c b/calendar/gui/e-tasks.c
index bf400590a8..2f24ebfbc2 100644
--- a/calendar/gui/e-tasks.c
+++ b/calendar/gui/e-tasks.c
@@ -72,9 +72,6 @@ struct _ETasksPrivate {
/* Calendar search bar for tasks */
GtkWidget *search_bar;
- /* Tasks menu */
- ECalMenu *tasks_menu;
-
/* Paned widget */
GtkWidget *paned;
@@ -85,18 +82,12 @@ struct _ETasksPrivate {
gchar *sexp;
guint update_timeout;
- /* View instance and the view menus handler */
- GalViewInstance *view_instance;
- GalViewMenus *view_menus;
-
GList *notifications;
};
static void setup_widgets (ETasks *tasks);
static void e_tasks_destroy (GtkObject *object);
-static void update_view (ETasks *tasks);
-static void categories_changed_cb (gpointer object, gpointer user_data);
static void backend_error_cb (ECal *client, const gchar *message, gpointer data);
/* Signal IDs */
@@ -107,125 +98,10 @@ enum {
LAST_SIGNAL
};
-enum DndTargetType {
- TARGET_VCALENDAR
-};
-
-static GtkTargetEntry list_drag_types[] = {
- { (gchar *) "text/calendar", 0, TARGET_VCALENDAR },
- { (gchar *) "text/x-calendar", 0, TARGET_VCALENDAR }
-};
-static const gint num_list_drag_types = sizeof (list_drag_types) / sizeof (list_drag_types[0]);
-
static guint e_tasks_signals[LAST_SIGNAL] = { 0 };
G_DEFINE_TYPE (ETasks, e_tasks, GTK_TYPE_TABLE)
-/* Callback used when the cursor changes in the table */
-static void
-table_cursor_change_cb (ETable *etable, gint row, gpointer data)
-{
- ETasks *tasks;
- ETasksPrivate *priv;
- ECalModel *model;
- ECalModelComponent *comp_data;
- ECalComponent *comp;
- const gchar *uid;
-
- gint n_selected;
-
- tasks = E_TASKS (data);
- priv = tasks->priv;
-
- n_selected = e_table_selected_count (etable);
-
- /* update the HTML widget */
- if (n_selected != 1) {
- e_cal_component_preview_clear (E_CAL_COMPONENT_PREVIEW (priv->preview));
-
- return;
- }
-
- model = e_calendar_table_get_model (E_CALENDAR_TABLE (priv->tasks_view));
-
- comp_data = e_cal_model_get_component_at (model, e_table_get_cursor_row (etable));
- comp = e_cal_component_new ();
- e_cal_component_set_icalcomponent (comp, icalcomponent_new_clone (comp_data->icalcomp));
-
- e_cal_component_preview_display (E_CAL_COMPONENT_PREVIEW (priv->preview), comp_data->client, comp);
-
- e_cal_component_get_uid (comp, &uid);
- if (priv->current_uid)
- g_free (priv->current_uid);
- priv->current_uid = g_strdup (uid);
-
- g_object_unref (comp);
-}
-
-ECalMenu *
-e_tasks_get_tasks_menu (ETasks *tasks)
-{
- g_return_val_if_fail (E_IS_TASKS (tasks), NULL);
-
- return tasks->priv->tasks_menu;
-}
-
-/* Callback used when the selection changes in the table. */
-static void
-table_selection_change_cb (ETable *etable, gpointer data)
-{
- ETasks *tasks;
- gint n_selected;
-
- tasks = E_TASKS (data);
-
- n_selected = e_table_selected_count (etable);
- g_signal_emit (tasks, e_tasks_signals[SELECTION_CHANGED], 0, n_selected);
-
- if (n_selected != 1)
- e_cal_component_preview_clear (E_CAL_COMPONENT_PREVIEW (tasks->priv->preview));
-}
-
-static void
-user_created_cb (GtkWidget *view, ETasks *tasks)
-{
- ETasksPrivate *priv;
- ECalendarTable *cal_table;
- ECal *ecal;
-
- priv = tasks->priv;
- cal_table = E_CALENDAR_TABLE (priv->tasks_view);
-
- if (cal_table->user_created_cal)
- ecal = cal_table->user_created_cal;
- else {
- ECalModel *model;
-
- model = e_calendar_table_get_model (E_CALENDAR_TABLE (priv->tasks_view));
- ecal = e_cal_model_get_default_client (model);
- }
-
- e_tasks_add_todo_source (tasks, e_cal_get_source (ecal));
-}
-
-/* Callback used when the sexp in the search bar changes */
-static void
-search_bar_sexp_changed_cb (CalSearchBar *cal_search, const gchar *sexp, gpointer data)
-{
- ETasks *tasks;
- ETasksPrivate *priv;
-
- tasks = E_TASKS (data);
- priv = tasks->priv;
-
- if (priv->sexp)
- g_free (priv->sexp);
-
- priv->sexp = g_strdup (sexp);
-
- update_view (tasks);
-}
-
/* Callback used when the selected category in the search bar changes */
static void
search_bar_category_changed_cb (CalSearchBar *cal_search, const gchar *category, gpointer data)
@@ -241,194 +117,6 @@ search_bar_category_changed_cb (CalSearchBar *cal_search, const gchar *category,
e_cal_model_set_default_category (model, category);
}
-static gboolean
-vpaned_resized_cb (GtkWidget *widget, GdkEventButton *event, ETasks *tasks)
-{
- calendar_config_set_task_vpane_pos (gtk_paned_get_position (GTK_PANED (widget)));
-
- return FALSE;
-}
-
-static void
-set_timezone (ETasks *tasks)
-{
- ETasksPrivate *priv;
- icaltimezone *zone;
- GList *l;
-
- priv = tasks->priv;
-
- zone = calendar_config_get_icaltimezone ();
- for (l = priv->clients_list; l != NULL; l = l->next) {
- ECal *client = l->data;
- /* FIXME Error checking */
- e_cal_set_default_timezone (client, zone, NULL);
- }
-
- if (priv->default_client)
- /* FIXME Error checking */
- e_cal_set_default_timezone (priv->default_client, zone, NULL);
-
- if (priv->preview)
- e_cal_component_preview_set_default_timezone (E_CAL_COMPONENT_PREVIEW (priv->preview), zone);
-}
-
-static void
-timezone_changed_cb (GConfClient *client, guint id, GConfEntry *entry, gpointer data)
-{
- ETasks *tasks = data;
-
- set_timezone (tasks);
-}
-
-static void
-update_view (ETasks *tasks)
-{
- ETasksPrivate *priv;
- ECalModel *model;
- gchar *real_sexp = NULL;
- gchar *new_sexp = NULL;
-
- priv = tasks->priv;
-
- model = e_calendar_table_get_model (E_CALENDAR_TABLE (priv->tasks_view));
-
- if ((new_sexp = calendar_config_get_hide_completed_tasks_sexp (FALSE)) != NULL) {
- real_sexp = g_strdup_printf ("(and %s %s)", new_sexp, priv->sexp);
- e_cal_model_set_search_query (model, real_sexp);
- g_free (new_sexp);
- g_free (real_sexp);
- } else
- e_cal_model_set_search_query (model, priv->sexp);
-
- e_cal_component_preview_clear (E_CAL_COMPONENT_PREVIEW (priv->preview));
-}
-
-static void
-process_completed_tasks (ETasks *tasks, gboolean config_changed)
-{
- ETasksPrivate *priv;
-
- g_return_if_fail (tasks != NULL);
- g_return_if_fail (E_IS_TASKS (tasks));
-
- priv = tasks->priv;
-
- e_calendar_table_process_completed_tasks (e_tasks_get_calendar_table (tasks), priv->clients_list, config_changed);
-}
-
-static gboolean
-update_view_cb (ETasks *tasks)
-{
- ECalModel *model;
-
- model = e_calendar_table_get_model (E_CALENDAR_TABLE (tasks->priv->tasks_view));
-
- process_completed_tasks (tasks, FALSE);
- e_cal_model_tasks_update_due_tasks (E_CAL_MODEL_TASKS (model));
-
- return TRUE;
-}
-
-static void
-config_hide_completed_tasks_changed_cb (GConfClient *client, guint id, GConfEntry *entry, gpointer data)
-{
- process_completed_tasks (data, TRUE);
- update_view (data);
-}
-
-static void
-model_row_changed_cb (ETableModel *etm, gint row, gpointer data)
-{
- ETasks *tasks;
- ETasksPrivate *priv;
- ECalModelComponent *comp_data;
-
- tasks = E_TASKS (data);
- priv = tasks->priv;
-
- if (priv->current_uid) {
- const gchar *uid;
-
- comp_data = e_cal_model_get_component_at (E_CAL_MODEL (etm), row);
- if (comp_data) {
- uid = icalcomponent_get_uid (comp_data->icalcomp);
- if (!strcmp (uid ? uid : "", priv->current_uid)) {
- ETable *etable;
-
- etable = e_table_scrolled_get_table (
- E_TABLE_SCROLLED (E_CALENDAR_TABLE (priv->tasks_view)->etable));
- table_cursor_change_cb (etable, 0, tasks);
- }
- }
- }
-}
-
-static void
-view_progress_cb (ECalModel *model, const gchar *message, gint percent, ECalSourceType type, ETasks *tasks)
-{
- e_calendar_table_set_status_message (E_CALENDAR_TABLE (e_tasks_get_calendar_table (tasks)),
- message, percent);
-}
-
-static void
-view_done_cb (ECalModel *model, ECalendarStatus status, ECalSourceType type, ETasks *tasks)
-{
- e_calendar_table_set_status_message (E_CALENDAR_TABLE (e_tasks_get_calendar_table (tasks)),
- NULL, -1);
-
-}
-
-static void
-config_preview_state_changed_cb (GConfClient *client, guint id, GConfEntry *entry, gpointer data)
-{
- gboolean state;
- GConfValue *value;
- ETasks *tasks = (ETasks *)data;
-
- g_return_if_fail (gconf_entry_get_key (entry) != NULL);
- g_return_if_fail ((value = gconf_entry_get_value (entry)) != NULL);
-
- state = gconf_value_get_bool (value);
- e_tasks_show_preview (tasks, state);
- bonobo_ui_component_set_prop (E_SEARCH_BAR (tasks->priv->search_bar)->ui_component, "/commands/ViewPreview", "state", state ? "1" : "0", NULL);
-}
-
-static void
-setup_config (ETasks *tasks)
-{
- ETasksPrivate *priv;
- guint not;
-
- priv = tasks->priv;
-
- /* Timezone */
- set_timezone (tasks);
-
- not = calendar_config_add_notification_timezone (timezone_changed_cb, tasks);
- priv->notifications = g_list_prepend (priv->notifications, GUINT_TO_POINTER (not));
-
- not = calendar_config_add_notification_hide_completed_tasks (config_hide_completed_tasks_changed_cb,
- tasks);
- priv->notifications = g_list_prepend (priv->notifications, GUINT_TO_POINTER (not));
-
- not = calendar_config_add_notification_hide_completed_tasks_units (config_hide_completed_tasks_changed_cb,
- tasks);
- priv->notifications = g_list_prepend (priv->notifications, GUINT_TO_POINTER (not));
-
- not = calendar_config_add_notification_hide_completed_tasks_value (config_hide_completed_tasks_changed_cb,
- tasks);
- priv->notifications = g_list_prepend (priv->notifications, GUINT_TO_POINTER (not));
-
- not = calendar_config_add_notification_preview_state (config_preview_state_changed_cb, tasks);
- priv->notifications = g_list_prepend (priv->notifications, GUINT_TO_POINTER (not));
-}
-
-struct AffectedComponents {
- ECalendarTable *cal_table;
- GSList *components; /* contains pointers to ECalModelComponent */
-};
-
/**
* get_selected_components_cb
* Helper function to fill list of selected components in ECalendarTable.
@@ -611,7 +299,6 @@ setup_widgets (ETasks *tasks)
G_CALLBACK (search_bar_sexp_changed_cb), tasks);
g_signal_connect (priv->search_bar, "category_changed",
G_CALLBACK (search_bar_category_changed_cb), tasks);
- categories_changed_cb (NULL, tasks);
gtk_table_attach (GTK_TABLE (tasks), priv->search_bar, 0, 1, 0, 1,
GTK_EXPAND | GTK_FILL | GTK_SHRINK, 0, 0, 0);
@@ -621,8 +308,6 @@ setup_widgets (ETasks *tasks)
priv->paned = gtk_vpaned_new ();
g_signal_connect (priv->paned, "realize", G_CALLBACK (pane_realized), tasks);
- g_signal_connect (G_OBJECT (priv->paned), "button_release_event",
- G_CALLBACK (vpaned_resized_cb), tasks);
gtk_table_attach (GTK_TABLE (tasks), priv->paned, 0, 1, 1, 2,
GTK_EXPAND | GTK_FILL, GTK_EXPAND | GTK_FILL, 0, 0);
gtk_widget_show (priv->paned);
@@ -661,12 +346,8 @@ setup_widgets (ETasks *tasks)
"table_drag_data_received", G_CALLBACK(table_drag_data_received_cb), editor);
*/
- g_signal_connect (etable, "cursor_change", G_CALLBACK (table_cursor_change_cb), tasks);
g_signal_connect (etable, "selection_change", G_CALLBACK (table_selection_change_cb), tasks);
- /* Timeout check to hide completed items */
- priv->update_timeout = g_timeout_add_full (G_PRIORITY_LOW, 60000, (GSourceFunc) update_view_cb, tasks, NULL);
-
/* create the task detail */
priv->preview = e_cal_component_preview_new ();
e_cal_component_preview_set_default_timezone (E_CAL_COMPONENT_PREVIEW (priv->preview), calendar_config_get_icaltimezone ());
@@ -675,15 +356,6 @@ setup_widgets (ETasks *tasks)
if (state)
gtk_widget_show (priv->preview);
-
- model = e_calendar_table_get_model (E_CALENDAR_TABLE (priv->tasks_view));
- g_signal_connect (G_OBJECT (model), "model_row_changed",
- G_CALLBACK (model_row_changed_cb), tasks);
-
- g_signal_connect (G_OBJECT (model), "cal_view_progress",
- G_CALLBACK (view_progress_cb), tasks);
- g_signal_connect (G_OBJECT (model), "cal_view_done",
- G_CALLBACK (view_done_cb), tasks);
}
/* Class initialization function for the gnome calendar */
@@ -733,29 +405,6 @@ e_tasks_class_init (ETasksClass *class)
class->source_removed = NULL;
}
-static void
-categories_changed_cb (gpointer object, gpointer user_data)
-{
- GList *cat_list;
- GPtrArray *cat_array;
- ETasksPrivate *priv;
- ETasks *tasks = user_data;
-
- priv = tasks->priv;
-
- cat_array = g_ptr_array_new ();
- cat_list = e_categories_get_list ();
- while (cat_list != NULL) {
- if (e_categories_is_searchable ((const gchar *) cat_list->data))
- g_ptr_array_add (cat_array, cat_list->data);
- cat_list = g_list_remove (cat_list, cat_list->data);
- }
-
- cal_search_bar_set_categories ((CalSearchBar *)priv->search_bar, cat_array);
-
- g_ptr_array_free (cat_array, TRUE);
-}
-
/* Object initialization function for the gnome calendar */
static void
e_tasks_init (ETasks *tasks)
@@ -765,20 +414,13 @@ e_tasks_init (ETasks *tasks)
priv = g_new0 (ETasksPrivate, 1);
tasks->priv = priv;
- e_categories_register_change_listener (G_CALLBACK (categories_changed_cb), tasks);
-
- setup_config (tasks);
setup_widgets (tasks);
priv->clients = g_hash_table_new_full (g_str_hash, g_str_equal, g_free, g_object_unref);
priv->query = NULL;
- priv->view_instance = NULL;
- priv->view_menus = NULL;
priv->current_uid = NULL;
priv->sexp = g_strdup ("#t");
priv->default_client = NULL;
- priv->tasks_menu = e_cal_menu_new ("org.gnome.evolution.tasks.view");
- update_view (tasks);
}
GtkWidget *
@@ -791,16 +433,6 @@ e_tasks_new (void)
return GTK_WIDGET (tasks);
}
-void
-e_tasks_set_ui_component (ETasks *tasks,
- BonoboUIComponent *ui_component)
-{
- g_return_if_fail (E_IS_TASKS (tasks));
- g_return_if_fail (ui_component == NULL || BONOBO_IS_UI_COMPONENT (ui_component));
-
- e_search_bar_set_ui_component (E_SEARCH_BAR (tasks->priv->search_bar), ui_component);
-}
-
static void
e_tasks_destroy (GtkObject *object)
{
@@ -816,8 +448,6 @@ e_tasks_destroy (GtkObject *object)
if (priv) {
GList *l;
- e_categories_unregister_change_listener (G_CALLBACK (categories_changed_cb), tasks);
-
/* disconnect from signals on all the clients */
for (l = priv->clients_list; l != NULL; l = l->next) {
g_signal_handlers_disconnect_matched (l->data, G_SIGNAL_MATCH_DATA,
@@ -841,11 +471,6 @@ e_tasks_destroy (GtkObject *object)
priv->sexp = NULL;
}
- if (priv->update_timeout) {
- g_source_remove (priv->update_timeout);
- priv->update_timeout = 0;
- }
-
if (priv->tasks_view_config) {
g_object_unref (priv->tasks_view_config);
priv->tasks_view_config = NULL;
@@ -882,160 +507,6 @@ set_status_message (ETasks *tasks, const gchar *message, ...)
e_calendar_table_set_status_message (E_CALENDAR_TABLE (priv->tasks_view), msg_string, -1);
}
-/* Callback from the calendar client when an error occurs in the backend */
-static void
-backend_error_cb (ECal *client, const gchar *message, gpointer data)
-{
- ETasks *tasks;
- GtkWidget *dialog;
- gchar *urinopwd;
-
- tasks = E_TASKS (data);
-
- urinopwd = get_uri_without_password (e_cal_get_uri (client));
-
- dialog = gtk_message_dialog_new (
- GTK_WINDOW (gtk_widget_get_toplevel (GTK_WIDGET (tasks))),
- GTK_DIALOG_DESTROY_WITH_PARENT,
- GTK_MESSAGE_ERROR,
- GTK_BUTTONS_OK,
- _("Error on %s:\n %s"),
- urinopwd, message);
- gtk_dialog_run (GTK_DIALOG (dialog));
- gtk_widget_destroy (dialog);
-
- g_free (urinopwd);
-}
-
-/* Callback from the calendar client when the backend dies */
-static void
-backend_died_cb (ECal *client, gpointer data)
-{
- ETasks *tasks;
- ETasksPrivate *priv;
- ESource *source;
-
- tasks = E_TASKS (data);
- priv = tasks->priv;
-
- source = g_object_ref (e_cal_get_source (client));
-
- priv->clients_list = g_list_remove (priv->clients_list, client);
- g_hash_table_remove (priv->clients, e_source_peek_uid (source));
-
- g_signal_emit (tasks, e_tasks_signals[SOURCE_REMOVED], 0, source);
-
- e_calendar_table_set_status_message (E_CALENDAR_TABLE (e_tasks_get_calendar_table (tasks)), NULL, -1);
-
- e_error_run (GTK_WINDOW (gtk_widget_get_toplevel (GTK_WIDGET (tasks))),
- "calendar:tasks-crashed", NULL);
-
- g_object_unref (source);
-}
-
-/* Callback from the calendar client when the calendar is opened */
-static void
-client_cal_opened_cb (ECal *ecal, ECalendarStatus status, ETasks *tasks)
-{
- ECalModel *model;
- ESource *source;
- ETasksPrivate *priv;
-
- priv = tasks->priv;
-
- source = e_cal_get_source (ecal);
-
- if (status == E_CALENDAR_STATUS_AUTHENTICATION_FAILED || status == E_CALENDAR_STATUS_AUTHENTICATION_REQUIRED)
- auth_cal_forget_password (ecal);
-
- switch (status) {
- case E_CALENDAR_STATUS_OK :
- g_signal_handlers_disconnect_matched (ecal, G_SIGNAL_MATCH_FUNC, 0, 0, NULL, client_cal_opened_cb, NULL);
-
- set_status_message (tasks, _("Loading tasks"));
- model = e_calendar_table_get_model (E_CALENDAR_TABLE (priv->tasks_view));
- e_cal_model_add_client (model, ecal);
-
- set_status_message (tasks, NULL);
- break;
- case E_CALENDAR_STATUS_AUTHENTICATION_FAILED:
- /* try to reopen calendar - it'll ask for a password once again */
- e_cal_open_async (ecal, FALSE);
- return;
- case E_CALENDAR_STATUS_BUSY :
- break;
- case E_CALENDAR_STATUS_REPOSITORY_OFFLINE:
- e_error_run (GTK_WINDOW (gtk_widget_get_toplevel (GTK_WIDGET (tasks))), "calendar:prompt-no-contents-offline-tasks", NULL);
- default :
- /* Make sure the source doesn't disappear on us */
- g_object_ref (source);
-
- priv->clients_list = g_list_remove (priv->clients_list, ecal);
- g_signal_handlers_disconnect_matched (ecal, G_SIGNAL_MATCH_DATA,
- 0, 0, NULL, NULL, tasks);
-
- /* Do this last because it unrefs the client */
- g_hash_table_remove (priv->clients, e_source_peek_uid (source));
-
- g_signal_emit (tasks, e_tasks_signals[SOURCE_REMOVED], 0, source);
-
- set_status_message (tasks, NULL);
- g_object_unref (source);
-
- break;
- }
-}
-
-static void
-default_client_cal_opened_cb (ECal *ecal, ECalendarStatus status, ETasks *tasks)
-{
- ECalModel *model;
- ESource *source;
- ETasksPrivate *priv;
-
- priv = tasks->priv;
-
- source = e_cal_get_source (ecal);
-
- if (status == E_CALENDAR_STATUS_AUTHENTICATION_FAILED || status == E_CALENDAR_STATUS_AUTHENTICATION_REQUIRED)
- auth_cal_forget_password (ecal);
-
- switch (status) {
- case E_CALENDAR_STATUS_OK :
- g_signal_handlers_disconnect_matched (ecal, G_SIGNAL_MATCH_FUNC, 0, 0, NULL, default_client_cal_opened_cb, NULL);
- model = e_calendar_table_get_model (E_CALENDAR_TABLE (priv->tasks_view));
-
- e_cal_model_set_default_client (model, ecal);
- set_status_message (tasks, NULL);
- break;
- case E_CALENDAR_STATUS_AUTHENTICATION_FAILED:
- /* try to reopen calendar - it'll ask for a password once again */
- e_cal_open_async (ecal, FALSE);
- return;
- case E_CALENDAR_STATUS_BUSY:
- break;
- default :
- /* Make sure the source doesn't disappear on us */
- g_object_ref (source);
-
- priv->clients_list = g_list_remove (priv->clients_list, ecal);
- g_signal_handlers_disconnect_matched (ecal, G_SIGNAL_MATCH_DATA,
- 0, 0, NULL, NULL, tasks);
-
- /* Do this last because it unrefs the client */
- g_hash_table_remove (priv->clients, e_source_peek_uid (source));
-
- g_signal_emit (tasks, e_tasks_signals[SOURCE_REMOVED], 0, source);
-
- set_status_message (tasks, NULL);
- g_object_unref (priv->default_client);
- priv->default_client = NULL;
- g_object_unref (source);
-
- break;
- }
-}
-
typedef void (*open_func) (ECal *, ECalendarStatus, ETasks *);
static gboolean
@@ -1099,104 +570,6 @@ e_tasks_new_task (ETasks *tasks)
gtk_window_present (GTK_WINDOW (editor));
}
-void
-e_tasks_show_preview (ETasks *tasks, gboolean state)
-{
- ETasksPrivate *priv;
-
- g_return_if_fail (tasks != NULL);
- g_return_if_fail (E_IS_TASKS (tasks));
- priv = tasks->priv;
-
- if (state) {
- ECalModel *model;
- ECalModelComponent *comp_data;
- ECalComponent *comp;
- ETable *etable;
- const gchar *uid;
- gint n_selected;
-
- etable = e_table_scrolled_get_table (E_TABLE_SCROLLED (E_CALENDAR_TABLE (priv->tasks_view)->etable));
- n_selected = e_table_selected_count (etable);
-
- if (n_selected != 1) {
- e_cal_component_preview_clear (E_CAL_COMPONENT_PREVIEW (priv->preview));
- } else {
- model = e_calendar_table_get_model (E_CALENDAR_TABLE (priv->tasks_view));
-
- comp_data = e_cal_model_get_component_at (model, e_table_get_cursor_row (etable));
- comp = e_cal_component_new ();
- e_cal_component_set_icalcomponent (comp, icalcomponent_new_clone (comp_data->icalcomp));
-
- e_cal_component_preview_display (E_CAL_COMPONENT_PREVIEW (priv->preview), comp_data->client, comp);
-
- e_cal_component_get_uid (comp, &uid);
- if (priv->current_uid)
- g_free (priv->current_uid);
- priv->current_uid = g_strdup (uid);
-
- g_object_unref (comp);
- }
- gtk_widget_show (priv->preview);
-
- } else {
- e_cal_component_preview_clear (E_CAL_COMPONENT_PREVIEW (priv->preview));
- gtk_widget_hide (priv->preview);
- }
-}
-
-gboolean
-e_tasks_add_todo_source (ETasks *tasks, ESource *source)
-{
- ETasksPrivate *priv;
- ECal *client;
- const gchar *uid;
-
- g_return_val_if_fail (tasks != NULL, FALSE);
- g_return_val_if_fail (E_IS_TASKS (tasks), FALSE);
- g_return_val_if_fail (E_IS_SOURCE (source), FALSE);
-
- priv = tasks->priv;
-
- uid = e_source_peek_uid (source);
- client = g_hash_table_lookup (priv->clients, uid);
- if (client) {
- /* We already have it */
-
- return TRUE;
- } else {
- ESource *default_source;
-
- if (priv->default_client) {
- default_source = e_cal_get_source (priv->default_client);
-
- /* We don't have it but the default client is it */
- if (!strcmp (e_source_peek_uid (default_source), uid))
- client = g_object_ref (priv->default_client);
- }
-
- /* Create a new one */
- if (!client) {
- client = auth_new_cal_from_source (source, E_CAL_SOURCE_TYPE_TODO);
- if (!client)
- return FALSE;
- }
- }
-
- g_signal_connect (G_OBJECT (client), "backend_error", G_CALLBACK (backend_error_cb), tasks);
- g_signal_connect (G_OBJECT (client), "backend_died", G_CALLBACK (backend_died_cb), tasks);
-
- /* add the client to internal structure */
- g_hash_table_insert (priv->clients, g_strdup (uid) , client);
- priv->clients_list = g_list_prepend (priv->clients_list, client);
-
- g_signal_emit (tasks, e_tasks_signals[SOURCE_ADDED], 0, source);
-
- open_ecal (tasks, client, FALSE, client_cal_opened_cb);
-
- return TRUE;
-}
-
gboolean
e_tasks_remove_todo_source (ETasks *tasks, ESource *source)
{
@@ -1260,68 +633,6 @@ e_tasks_set_default_source (ETasks *tasks, ESource *source)
return TRUE;
}
-ECal *
-e_tasks_get_default_client (ETasks *tasks)
-{
- ETasksPrivate *priv;
-
- g_return_val_if_fail (tasks != NULL, NULL);
- g_return_val_if_fail (E_IS_TASKS (tasks), NULL);
-
- priv = tasks->priv;
-
- return e_cal_model_get_default_client (e_calendar_table_get_model (E_CALENDAR_TABLE (priv->tasks_view)));
-}
-
-/**
- * e_tasks_complete_selected:
- * @tasks: A tasks control widget
- *
- * Marks the selected tasks complete
- **/
-void
-e_tasks_complete_selected (ETasks *tasks)
-{
- ETasksPrivate *priv;
- ECalendarTable *cal_table;
-
- g_return_if_fail (tasks != NULL);
- g_return_if_fail (E_IS_TASKS (tasks));
-
- priv = tasks->priv;
-
- cal_table = E_CALENDAR_TABLE (priv->tasks_view);
-
- set_status_message (tasks, _("Completing tasks..."));
- e_calendar_table_complete_selected (cal_table);
- set_status_message (tasks, NULL);
-}
-
-/**
- * e_tasks_delete_selected:
- * @tasks: A tasks control widget.
- *
- * Deletes the selected tasks in the task list.
- **/
-void
-e_tasks_delete_selected (ETasks *tasks)
-{
- ETasksPrivate *priv;
- ECalendarTable *cal_table;
-
- g_return_if_fail (tasks != NULL);
- g_return_if_fail (E_IS_TASKS (tasks));
-
- priv = tasks->priv;
-
- cal_table = E_CALENDAR_TABLE (priv->tasks_view);
- set_status_message (tasks, _("Deleting selected objects..."));
- e_calendar_table_delete_selected (cal_table);
- set_status_message (tasks, NULL);
-
- e_cal_component_preview_clear (E_CAL_COMPONENT_PREVIEW (priv->preview));
-}
-
/**
* e_tasks_expunge:
* @tasks: A tasks control widget
@@ -1373,126 +684,6 @@ e_tasks_delete_completed (ETasks *tasks)
g_free (sexp);
}
-/* Callback used from the view collection when we need to display a new view */
-static void
-display_view_cb (GalViewInstance *instance, GalView *view, gpointer data)
-{
- ETasks *tasks;
-
- tasks = E_TASKS (data);
-
- if (GAL_IS_VIEW_ETABLE (view)) {
- gal_view_etable_attach_table (GAL_VIEW_ETABLE (view), e_table_scrolled_get_table (E_TABLE_SCROLLED (E_CALENDAR_TABLE (tasks->priv->tasks_view)->etable)));
- }
-
- gtk_paned_set_position ((GtkPaned *)tasks->priv->paned, calendar_config_get_task_vpane_pos ());
-}
-
-/**
- * e_tasks_setup_view_menus:
- * @tasks: A tasks widget.
- * @uic: UI controller to use for the menus.
- *
- * Sets up the #GalView menus for a tasks control. This function should be
- * called from the Bonobo control activation callback for this tasks control.
- * Also, the menus should be discarded using e_tasks_discard_view_menus().
- **/
-void
-e_tasks_setup_view_menus (ETasks *tasks, BonoboUIComponent *uic)
-{
- ETasksPrivate *priv;
- GalViewFactory *factory;
- ETableSpecification *spec;
- gchar *dir0, *dir1, *filename;
- static GalViewCollection *collection = NULL;
-
- g_return_if_fail (tasks != NULL);
- g_return_if_fail (E_IS_TASKS (tasks));
- g_return_if_fail (uic != NULL);
- g_return_if_fail (BONOBO_IS_UI_COMPONENT (uic));
-
- priv = tasks->priv;
-
- g_return_if_fail (priv->view_instance == NULL);
-
- g_return_if_fail (priv->view_instance == NULL);
- g_return_if_fail (priv->view_menus == NULL);
-
- /* Create the view instance */
-
- if (collection == NULL) {
- collection = gal_view_collection_new ();
-
- gal_view_collection_set_title (collection, _("Tasks"));
-
- dir0 = g_build_filename (EVOLUTION_GALVIEWSDIR,
- "tasks",
- NULL);
- dir1 = g_build_filename (tasks_component_peek_base_directory (tasks_component_peek ()),
- "tasks", "views", NULL);
- gal_view_collection_set_storage_directories (collection,
- dir0,
- dir1);
- g_free (dir1);
- g_free (dir0);
-
- /* Create the views */
-
- spec = e_table_specification_new ();
- filename = g_build_filename (EVOLUTION_ETSPECDIR,
- "e-calendar-table.etspec",
- NULL);
- if (!e_table_specification_load_from_file (spec, filename))
- g_error ("Unable to load ETable specification file "
- "for tasks");
- g_free (filename);
-
- factory = gal_view_factory_etable_new (spec);
- g_object_unref (spec);
- gal_view_collection_add_factory (collection, factory);
- g_object_unref (factory);
-
- /* Load the collection and create the menus */
-
- gal_view_collection_load (collection);
- }
-
- 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), tasks);
- display_view_cb (priv->view_instance, gal_view_instance_get_current_view (priv->view_instance), tasks);
-}
-
-/**
- * e_tasks_discard_view_menus:
- * @tasks: A tasks widget.
- *
- * Discards the #GalView menus used by a tasks control. This function should be
- * called from the Bonobo control deactivation callback for this tasks control.
- * The menus should have been set up with e_tasks_setup_view_menus().
- **/
-void
-e_tasks_discard_view_menus (ETasks *tasks)
-{
- ETasksPrivate *priv;
-
- g_return_if_fail (tasks != NULL);
- g_return_if_fail (E_IS_TASKS (tasks));
-
- priv = tasks->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;
-}
-
void
e_tasks_open_task_id (ETasks *tasks,
const gchar *src_uid,
@@ -1531,39 +722,3 @@ e_tasks_open_task_id (ETasks *tasks,
return;
}
-
-/**
- * e_tasks_get_calendar_table:
- * @tasks: A tasks widget.
- *
- * Queries the #ECalendarTable contained in a tasks widget.
- *
- * Return value: The #ECalendarTable that the tasks widget uses to display its
- * information.
- **/
-ECalendarTable *
-e_tasks_get_calendar_table (ETasks *tasks)
-{
- ETasksPrivate *priv;
-
- g_return_val_if_fail (tasks != NULL, NULL);
- g_return_val_if_fail (E_IS_TASKS (tasks), NULL);
-
- priv = tasks->priv;
- return E_CALENDAR_TABLE (priv->tasks_view);
-}
-
-/**
- * e_tasks_get_preview:
- * @tasks: A tasks widget.
- *
- * Queries the #ECalComponentPreview contained in a tasks widget.
- **/
-GtkWidget *
-e_tasks_get_preview (ETasks *tasks)
-{
- g_return_val_if_fail (tasks != NULL, NULL);
- g_return_val_if_fail (E_IS_TASKS (tasks), NULL);
-
- return tasks->priv->preview;
-}
diff --git a/calendar/gui/e-tasks.h b/calendar/gui/e-tasks.h
index f9eacb7819..a37db26117 100644
--- a/calendar/gui/e-tasks.h
+++ b/calendar/gui/e-tasks.h
@@ -62,30 +62,15 @@ GtkWidget *e_tasks_construct (ETasks *tasks);
GtkWidget *e_tasks_new (void);
-void e_tasks_set_ui_component (ETasks *tasks,
- BonoboUIComponent *ui_component);
-
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_open_task_id (ETasks *tasks,
const gchar *src_uid,
const gchar *comp_uid,
const gchar *comp_rid);
void e_tasks_new_task (ETasks *tasks);
-void e_tasks_complete_selected (ETasks *tasks);
-void e_tasks_delete_selected (ETasks *tasks);
void e_tasks_delete_completed (ETasks *tasks);
-void e_tasks_show_preview (ETasks *tasks, gboolean state);
-void e_tasks_setup_view_menus (ETasks *tasks, BonoboUIComponent *uic);
-void e_tasks_discard_view_menus (ETasks *tasks);
-
-struct _ECalMenu *e_tasks_get_tasks_menu (ETasks *tasks);
-ECalendarTable *e_tasks_get_calendar_table (ETasks *tasks);
-GtkWidget *e_tasks_get_preview (ETasks *tasks);
-
#endif /* _E_TASKS_H_ */
diff --git a/calendar/gui/e-week-view-config.c b/calendar/gui/e-week-view-config.c
index 423a12a2d9..641857e133 100644
--- a/calendar/gui/e-week-view-config.c
+++ b/calendar/gui/e-week-view-config.c
@@ -108,7 +108,7 @@ e_week_view_config_class_init (EWeekViewConfigClass *klass)
gobject_class->dispose = e_week_view_config_dispose;
gobject_class->finalize = e_week_view_config_finalize;
- spec = g_param_spec_object ("view", NULL, NULL, e_week_view_get_type (),
+ spec = g_param_spec_object ("view", NULL, NULL, E_TYPE_WEEK_VIEW,
G_PARAM_READABLE | G_PARAM_WRITABLE | G_PARAM_CONSTRUCT);
g_object_class_install_property (gobject_class, PROP_VIEW, spec);
}
diff --git a/calendar/gui/e-week-view-main-item.c b/calendar/gui/e-week-view-main-item.c
index 21db0a8e27..ed4d14232b 100644
--- a/calendar/gui/e-week-view-main-item.c
+++ b/calendar/gui/e-week-view-main-item.c
@@ -29,7 +29,7 @@
#include <glib.h>
#include <glib/gi18n.h>
#include "e-week-view-main-item.h"
-#include "ea-calendar.h"
+/*#include "ea-calendar.h"*/ /* KILL-BONOBO */
#include "calendar-config.h"
static void e_week_view_main_item_set_property (GObject *object,
@@ -92,8 +92,10 @@ e_week_view_main_item_class_init (EWeekViewMainItemClass *class)
NULL,
G_PARAM_WRITABLE));
+#if 0 /* KILL-BONOBO */
/* init the accessibility support for e_week_view_main_item */
e_week_view_main_item_a11y_init ();
+#endif
}
static void
diff --git a/calendar/gui/e-week-view.c b/calendar/gui/e-week-view.c
index 2d5c80996b..bfa2ad780f 100644
--- a/calendar/gui/e-week-view.c
+++ b/calendar/gui/e-week-view.c
@@ -30,7 +30,7 @@
#endif
#include "e-week-view.h"
-#include "ea-calendar.h"
+/*#include "a11y/ea-calendar.h"*/ /* KILL-BONOBO */
#include <math.h>
#include <gdk/gdkkeysyms.h>
@@ -39,7 +39,7 @@
#include <text/e-text.h>
#include <misc/e-canvas-utils.h>
#include <misc/e-gui-utils.h>
-#include <misc/e-unicode.h>
+#include <e-util/e-unicode.h>
#include <e-util/e-categories-config.h>
#include <e-util/e-dialog-utils.h>
#include <e-util/e-util.h>
@@ -51,7 +51,6 @@
#include "comp-util.h"
#include "itip-utils.h"
#include <libecal/e-cal-time-util.h>
-#include "calendar-commands.h"
#include "calendar-config.h"
#include "print.h"
#include "goto.h"
@@ -169,7 +168,6 @@ static gboolean e_week_view_on_text_item_event (GnomeCanvasItem *item,
EWeekView *week_view);
static gboolean e_week_view_event_move (ECalendarView *cal_view, ECalViewMoveDirection direction);
static gint e_week_view_get_day_offset_of_event (EWeekView *week_view, time_t event_time);
-static void e_week_view_scroll_a_step (EWeekView *week_view, ECalViewMoveDirection direction);
static void e_week_view_change_event_time (EWeekView *week_view, time_t start_dt, time_t end_dt, gboolean is_all_day);
static gboolean e_week_view_on_jump_button_event (GnomeCanvasItem *item,
GdkEvent *event,
@@ -195,6 +193,69 @@ static gboolean e_week_view_layout_timeout_cb (gpointer data);
G_DEFINE_TYPE (EWeekView, e_week_view, E_TYPE_CALENDAR_VIEW)
+static gint map_left[] = {0, 1, 2, 0, 1, 2, 2};
+static gint map_right[] = {3, 4, 5, 3, 4, 5, 6};
+
+static void
+week_view_cursor_key_up (EWeekView *week_view)
+{
+ if (week_view->selection_start_day == -1)
+ return;
+
+ week_view->selection_start_day--;
+
+ if (week_view->selection_start_day < 0) {
+ e_week_view_scroll_a_step (week_view, E_CAL_VIEW_MOVE_UP);
+ week_view->selection_start_day = 6;
+ }
+
+ week_view->selection_end_day = week_view->selection_start_day;
+ g_signal_emit_by_name (week_view, "selected_time_changed");
+ gtk_widget_queue_draw (week_view->main_canvas);
+}
+
+static void
+week_view_cursor_key_down (EWeekView *week_view)
+{
+ if (week_view->selection_start_day == -1)
+ return;
+
+ week_view->selection_start_day++;
+
+ if (week_view->selection_start_day > 6) {
+ e_week_view_scroll_a_step (week_view, E_CAL_VIEW_MOVE_DOWN);
+ week_view->selection_start_day = 0;
+ }
+
+ week_view->selection_end_day = week_view->selection_start_day;
+ g_signal_emit_by_name (week_view, "selected_time_changed");
+ gtk_widget_queue_draw (week_view->main_canvas);
+}
+
+static void
+week_view_cursor_key_left (EWeekView *week_view)
+{
+ if (week_view->selection_start_day == -1)
+ return;
+
+ week_view->selection_start_day = map_left[week_view->selection_start_day];
+ week_view->selection_end_day = week_view->selection_start_day;
+ g_signal_emit_by_name (week_view, "selected_time_changed");
+ gtk_widget_queue_draw (week_view->main_canvas);
+}
+
+static void
+week_view_cursor_key_right (EWeekView *week_view)
+{
+ if (week_view->selection_start_day == -1)
+ return;
+
+ week_view->selection_start_day = map_right[week_view->selection_start_day];
+ week_view->selection_end_day = week_view->selection_start_day;
+ g_signal_emit_by_name (week_view, "selected_time_changed");
+ gtk_widget_queue_draw (week_view->main_canvas);
+}
+
static void
e_week_view_class_init (EWeekViewClass *class)
{
@@ -226,8 +287,15 @@ e_week_view_class_init (EWeekViewClass *class)
view_class->get_visible_time_range = e_week_view_get_visible_time_range;
view_class->paste_text = e_week_view_paste_text;
+ class->cursor_key_up = week_view_cursor_key_up;
+ class->cursor_key_down = week_view_cursor_key_down;
+ class->cursor_key_left = week_view_cursor_key_left;
+ class->cursor_key_right = week_view_cursor_key_right;
+
+#if 0 /* KILL-BONOBO */
/* init the accessibility support for e_week_view */
e_week_view_a11y_init ();
+#endif
}
static void
@@ -655,7 +723,7 @@ e_week_view_new (ECalModel *model)
{
GtkWidget *week_view;
- week_view = GTK_WIDGET (g_object_new (e_week_view_get_type (), NULL));
+ week_view = GTK_WIDGET (g_object_new (E_TYPE_WEEK_VIEW, NULL));
e_calendar_view_set_model ((ECalendarView *) week_view, model);
init_model ((EWeekView *) week_view, model);
@@ -1937,6 +2005,9 @@ set_text_as_bold (EWeekViewEvent *event, EWeekViewEventSpan *span)
break;
}
}
+ e_cal_component_free_attendee_list (attendees);
+ g_free (address);
+ g_object_unref (comp);
/* The attendee has not yet accepted the meeting, display the summary as bolded.
If the attendee is not present, it might have come through a mailing list.
@@ -3391,7 +3462,7 @@ e_week_view_get_day_offset_of_event (EWeekView *week_view, time_t event_time)
return (event_time - first_day) / (24 * 60 * 60);
}
-static void
+void
e_week_view_scroll_a_step (EWeekView *week_view, ECalViewMoveDirection direction)
{
GtkAdjustment *adj = GTK_RANGE (week_view->vscrollbar)->adjustment;
@@ -3592,7 +3663,8 @@ e_week_view_on_editing_stopped (EWeekView *week_view,
if (!e_cal_create_object (client, icalcomp, NULL, NULL))
g_message (G_STRLOC ": Could not create the object!");
else
- gnome_calendar_emit_user_created_signal (week_view, e_calendar_view_get_calendar (E_CALENDAR_VIEW (week_view)), client);
+ e_calendar_view_emit_user_created (
+ E_CALENDAR_VIEW (week_view));
/* we remove the object since we either got the update from the server or failed */
e_week_view_remove_event_cb (week_view, event_num, NULL);
@@ -3782,232 +3854,55 @@ e_week_view_is_one_day_event (EWeekView *week_view,
return FALSE;
}
-static gint map_left[] = {0, 1, 2, 0, 1, 2, 2};
-static gint map_right[] = {3, 4, 5, 3, 4, 5, 6};
-
-static void
-e_week_view_do_cursor_key_up (EWeekView *week_view)
-{
- if (week_view->selection_start_day == -1)
- return;
-
- week_view->selection_start_day--;
-
- if (week_view->selection_start_day < 0) {
- e_week_view_scroll_a_step (week_view, E_CAL_VIEW_MOVE_UP);
- week_view->selection_start_day = 6;
- }
-
- week_view->selection_end_day = week_view->selection_start_day;
- g_signal_emit_by_name (week_view, "selected_time_changed");
- gtk_widget_queue_draw (week_view->main_canvas);
-}
-
-static void
-e_week_view_do_cursor_key_down (EWeekView *week_view)
-{
- if (week_view->selection_start_day == -1)
- return;
-
- week_view->selection_start_day++;
-
- if (week_view->selection_start_day > 6) {
- e_week_view_scroll_a_step (week_view, E_CAL_VIEW_MOVE_DOWN);
- week_view->selection_start_day = 0;
- }
-
- week_view->selection_end_day = week_view->selection_start_day;
- g_signal_emit_by_name (week_view, "selected_time_changed");
- gtk_widget_queue_draw (week_view->main_canvas);
-}
-
static void
-e_week_view_do_cursor_key_left (EWeekView *week_view)
+e_week_view_cursor_key_up (EWeekView *week_view)
{
- if (week_view->selection_start_day == -1)
- return;
+ EWeekViewClass *week_view_class;
- week_view->selection_start_day = map_left[week_view->selection_start_day];
- week_view->selection_end_day = week_view->selection_start_day;
- g_signal_emit_by_name (week_view, "selected_time_changed");
- gtk_widget_queue_draw (week_view->main_canvas);
-}
+ week_view_class = E_WEEK_VIEW_GET_CLASS (week_view);
+ g_return_if_fail (week_view_class->cursor_key_up != NULL);
-static void
-e_week_view_do_cursor_key_right (EWeekView *week_view)
-{
- if (week_view->selection_start_day == -1)
- return;
-
- week_view->selection_start_day = map_right[week_view->selection_start_day];
- week_view->selection_end_day = week_view->selection_start_day;
- g_signal_emit_by_name (week_view, "selected_time_changed");
- gtk_widget_queue_draw (week_view->main_canvas);
-}
-
-static void
-e_month_view_do_cursor_key_up (EWeekView *week_view)
-{
- if (week_view->selection_start_day == -1)
- return;
-
- if (week_view->selection_start_day < 7) {
- /* no easy way to calculate new selection_start_day, therefore
- * calculate a time_t value and set_selected_time_range */
- time_t current;
- if (e_calendar_view_get_selected_time_range(&week_view->cal_view, &current, NULL)) {
- current = time_add_week(current,-1);
- e_week_view_scroll_a_step(week_view, E_CAL_VIEW_MOVE_PAGE_UP);
- e_week_view_set_selected_time_range_visible(week_view,current,current);
- }
- } else {
- week_view->selection_start_day -= 7;
- week_view->selection_end_day = week_view->selection_start_day;
- }
-
- g_signal_emit_by_name (week_view, "selected_time_changed");
- gtk_widget_queue_draw (week_view->main_canvas);
-}
-
-static void
-e_month_view_do_cursor_key_down (EWeekView *week_view)
-{
- gint weeks_shown = e_week_view_get_weeks_shown (week_view);
-
- if (week_view->selection_start_day == -1)
- return;
-
- if (week_view->selection_start_day >= (weeks_shown - 1) * 7) {
- /* no easy way to calculate new selection_start_day, therefore
- * calculate a time_t value and set_selected_time_range */
- time_t current;
- if (e_calendar_view_get_selected_time_range(&week_view->cal_view, &current, NULL)) {
- current = time_add_week(current,1);
- e_week_view_scroll_a_step(week_view, E_CAL_VIEW_MOVE_PAGE_DOWN);
- e_week_view_set_selected_time_range_visible(week_view,current,current);
- }
- } else {
- week_view->selection_start_day += 7;
- week_view->selection_end_day = week_view->selection_start_day;
- }
-
- g_signal_emit_by_name (week_view, "selected_time_changed");
- gtk_widget_queue_draw (week_view->main_canvas);
+ week_view_class->cursor_key_up (week_view);
}
static void
-e_month_view_do_cursor_key_left (EWeekView *week_view)
+e_week_view_cursor_key_down (EWeekView *week_view)
{
- if (week_view->selection_start_day == -1)
- return;
+ EWeekViewClass *week_view_class;
- if (week_view->selection_start_day == 0) {
- /* no easy way to calculate new selection_start_day, therefore
- * calculate a time_t value and set_selected_time_range */
- time_t current;
- if (e_calendar_view_get_selected_time_range(&week_view->cal_view, &current, NULL)) {
- current = time_add_day(current,-1);
- e_week_view_scroll_a_step(week_view, E_CAL_VIEW_MOVE_PAGE_UP);
- e_week_view_set_selected_time_range_visible(week_view,current,current);
- }
- } else {
- week_view->selection_start_day--;
- week_view->selection_end_day = week_view->selection_start_day;
- }
+ week_view_class = E_WEEK_VIEW_GET_CLASS (week_view);
+ g_return_if_fail (week_view_class->cursor_key_down != NULL);
- g_signal_emit_by_name (week_view, "selected_time_changed");
- gtk_widget_queue_draw (week_view->main_canvas);
+ week_view_class->cursor_key_down (week_view);
}
static void
-e_month_view_do_cursor_key_right (EWeekView *week_view)
+e_week_view_cursor_key_left (EWeekView *week_view)
{
- gint weeks_shown = e_week_view_get_weeks_shown (week_view);
+ EWeekViewClass *week_view_class;
- if (week_view->selection_start_day == -1)
- return;
+ week_view_class = E_WEEK_VIEW_GET_CLASS (week_view);
+ g_return_if_fail (week_view_class->cursor_key_left != NULL);
- if (week_view->selection_start_day == weeks_shown * 7 - 1) {
- /* no easy way to calculate new selection_start_day, therefore
- * calculate a time_t value and set_selected_time_range */
- time_t current;
- if (e_calendar_view_get_selected_time_range(&week_view->cal_view, &current, NULL)) {
- current = time_add_day(current,1);
- e_week_view_scroll_a_step(week_view, E_CAL_VIEW_MOVE_PAGE_DOWN);
- e_week_view_set_selected_time_range_visible(week_view,current,current);
- }
- } else {
- week_view->selection_start_day++;
- week_view->selection_end_day = week_view->selection_start_day;
- }
-
- g_signal_emit_by_name (week_view, "selected_time_changed");
- gtk_widget_queue_draw (week_view->main_canvas);
+ week_view_class->cursor_key_left (week_view);
}
static void
-e_week_view_cursor_key_up (EWeekView *week_view, GnomeCalendarViewType view_type)
+e_week_view_cursor_key_right (EWeekView *week_view)
{
- switch (view_type) {
- case GNOME_CAL_WEEK_VIEW:
- e_week_view_do_cursor_key_up (week_view);
- break;
- case GNOME_CAL_MONTH_VIEW:
- e_month_view_do_cursor_key_up (week_view);
- break;
- default:
- g_return_if_reached ();
- }
-}
+ EWeekViewClass *week_view_class;
-static void
-e_week_view_cursor_key_down (EWeekView *week_view, GnomeCalendarViewType view_type)
-{
- switch (view_type) {
- case GNOME_CAL_WEEK_VIEW:
- e_week_view_do_cursor_key_down (week_view);
- break;
- case GNOME_CAL_MONTH_VIEW:
- e_month_view_do_cursor_key_down (week_view);
- break;
- default:
- g_return_if_reached ();
- }
-}
-
-static void
-e_week_view_cursor_key_left (EWeekView *week_view, GnomeCalendarViewType view_type)
-{
- switch (view_type) {
- case GNOME_CAL_WEEK_VIEW:
- e_week_view_do_cursor_key_left (week_view);
- break;
- case GNOME_CAL_MONTH_VIEW:
- e_month_view_do_cursor_key_left (week_view);
- break;
- default:
- g_return_if_reached ();
- }
-}
+ week_view_class = E_WEEK_VIEW_GET_CLASS (week_view);
+ g_return_if_fail (week_view_class->cursor_key_right != NULL);
-static void
-e_week_view_cursor_key_right (EWeekView *week_view, GnomeCalendarViewType view_type)
-{
- switch (view_type) {
- case GNOME_CAL_WEEK_VIEW:
- e_week_view_do_cursor_key_right (week_view);
- break;
- case GNOME_CAL_MONTH_VIEW:
- e_month_view_do_cursor_key_right (week_view);
- break;
- default:
- g_return_if_reached ();
- }
+ week_view_class->cursor_key_right (week_view);
}
static gboolean
e_week_view_add_new_event_in_selected_range (EWeekView *week_view, const gchar *initial_text)
{
+#if 0 /* KILL-BONOBO */
+ EWeekView *week_view;
ECal *ecal;
ECalModel *model;
ECalComponent *comp;
@@ -4103,7 +3998,6 @@ e_week_view_do_key_press (GtkWidget *widget, GdkEventKey *event)
guint keyval;
gboolean stop_emission;
gboolean ret_val;
- GnomeCalendarViewType view_type;
g_return_val_if_fail (widget != NULL, FALSE);
g_return_val_if_fail (E_IS_WEEK_VIEW (widget), FALSE);
@@ -4123,7 +4017,6 @@ e_week_view_do_key_press (GtkWidget *widget, GdkEventKey *event)
#endif
/* Handle the cursor keys for moving the selection */
- view_type = gnome_calendar_get_view (e_calendar_view_get_calendar (E_CALENDAR_VIEW (week_view)));
stop_emission = FALSE;
if (!(event->state & GDK_SHIFT_MASK)
&& !(event->state & GDK_MOD1_MASK)) {
@@ -4142,16 +4035,16 @@ e_week_view_do_key_press (GtkWidget *widget, GdkEventKey *event)
e_week_view_scroll_a_step (week_view, E_CAL_VIEW_MOVE_PAGE_DOWN);
break;
case GDK_Up:
- e_week_view_cursor_key_up (week_view, view_type);
+ e_week_view_cursor_key_up (week_view);
break;
case GDK_Down:
- e_week_view_cursor_key_down (week_view, view_type);
+ e_week_view_cursor_key_down (week_view);
break;
case GDK_Left:
- e_week_view_cursor_key_left (week_view, view_type);
+ e_week_view_cursor_key_left (week_view);
break;
case GDK_Right:
- e_week_view_cursor_key_right (week_view, view_type);
+ e_week_view_cursor_key_right (week_view);
break;
default:
stop_emission = FALSE;
@@ -4196,6 +4089,7 @@ e_week_view_do_key_press (GtkWidget *widget, GdkEventKey *event)
g_free (initial_text);
return ret_val;
+#endif
}
static gint
@@ -4231,6 +4125,7 @@ e_week_view_get_adjust_days_for_move_right (EWeekView *week_view,gint current_da
static gboolean
e_week_view_key_press (GtkWidget *widget, GdkEventKey *event)
{
+#if 0 /* KILL-BONOBO */
gboolean handled = FALSE;
handled = e_week_view_do_key_press (widget, event);
@@ -4238,6 +4133,7 @@ e_week_view_key_press (GtkWidget *widget, GdkEventKey *event)
if (!handled)
handled = GTK_WIDGET_CLASS (e_week_view_parent_class)->key_press_event (widget, event);
return handled;
+#endif
}
static void
@@ -4257,9 +4153,11 @@ e_week_view_show_popup_menu (EWeekView *week_view,
week_view->popup_event_num = event_num;
+#if 0 /* KILL-BONOBO */
popup = e_calendar_view_create_popup_menu (E_CALENDAR_VIEW (week_view));
g_object_weak_ref (G_OBJECT (popup), popup_destroyed_cb, week_view);
gtk_menu_popup (popup, NULL, NULL, NULL, NULL, bevent?bevent->button:0, bevent?bevent->time:gtk_get_current_event_time());
+#endif
}
static gboolean
@@ -4274,6 +4172,7 @@ e_week_view_popup_menu (GtkWidget *widget)
void
e_week_view_jump_to_button_item (EWeekView *week_view, GnomeCanvasItem *item)
{
+#if 0 /* KILL-BONOBO */
gint day;
GnomeCalendar *calendar;
@@ -4289,6 +4188,7 @@ e_week_view_jump_to_button_item (EWeekView *week_view, GnomeCanvasItem *item)
return;
}
}
+#endif
}
static gboolean
diff --git a/calendar/gui/e-week-view.h b/calendar/gui/e-week-view.h
index b536e5d5a3..10b4c27f49 100644
--- a/calendar/gui/e-week-view.h
+++ b/calendar/gui/e-week-view.h
@@ -20,8 +20,8 @@
*
*/
-#ifndef _E_WEEK_VIEW_H_
-#define _E_WEEK_VIEW_H_
+#ifndef E_WEEK_VIEW_H
+#define E_WEEK_VIEW_H
#include <gtk/gtk.h>
#include <libgnomecanvas/gnome-canvas.h>
@@ -29,12 +29,29 @@
#include "e-calendar-view.h"
#include "gnome-cal.h"
-G_BEGIN_DECLS
-
/*
* EWeekView - displays the Week & Month views of the calendar.
*/
+/* Standard GObject macros */
+#define E_TYPE_WEEK_VIEW \
+ (e_week_view_get_type ())
+#define E_WEEK_VIEW(obj) \
+ (G_TYPE_CHECK_INSTANCE_CAST \
+ ((obj), E_TYPE_WEEK_VIEW, EWeekView))
+#define E_WEEK_VIEW_CLASS(cls) \
+ (G_TYPE_CHECK_CLASS_CAST \
+ ((cls), E_TYPE_WEEK_VIEW, EWeekViewClass))
+#define E_IS_WEEK_VIEW(obj) \
+ (G_TYPE_CHECK_INSTANCE_TYPE \
+ ((obj), E_TYPE_WEEK_VIEW))
+#define E_IS_WEEK_VIEW_CLASS(cls) \
+ (G_TYPE_CHECK_CLASS_TYPE \
+ ((cls), E_TYPE_WEEK_VIEW))
+#define E_WEEK_VIEW_GET_CLASS(obj) \
+ (G_TYPE_INSTANCE_GET_CLASS \
+ ((obj), E_TYPE_WEEK_VIEW, EWeekViewClass))
+
/* The maximum number of weeks we show. 5 is usually enough for 1 month,
but we allow 6 for longer selections. */
#define E_WEEK_VIEW_MAX_WEEKS 6
@@ -91,6 +108,8 @@ G_BEGIN_DECLS
reached anyway. */
#define E_WEEK_VIEW_MAX_ROWS_PER_CELL 127
+G_BEGIN_DECLS
+
/* These index our colors array. */
typedef enum
{
@@ -147,15 +166,10 @@ struct _EWeekViewEvent {
guint8 num_spans;
};
-#define E_WEEK_VIEW(obj) G_TYPE_CHECK_INSTANCE_CAST (obj, e_week_view_get_type (), EWeekView)
-#define E_WEEK_VIEW_CLASS(klass) G_TYPE_CHECK_CLASS_CAST (klass, e_week_view_get_type (), EWeekViewClass)
-#define E_IS_WEEK_VIEW(obj) G_TYPE_CHECK_INSTANCE_TYPE (obj, e_week_view_get_type ())
-
-typedef struct _EWeekView EWeekView;
-typedef struct _EWeekViewClass EWeekViewClass;
+typedef struct _EWeekView EWeekView;
+typedef struct _EWeekViewClass EWeekViewClass;
-struct _EWeekView
-{
+struct _EWeekView {
ECalendarView cal_view;
/* The top canvas where the dates are shown. */
@@ -342,110 +356,125 @@ struct _EWeekView
time_t before_click_dtend;
};
-struct _EWeekViewClass
-{
+struct _EWeekViewClass {
ECalendarViewClass parent_class;
+
+ void (*cursor_key_up) (EWeekView *week_view);
+ void (*cursor_key_down) (EWeekView *week_view);
+ void (*cursor_key_left) (EWeekView *week_view);
+ void (*cursor_key_right) (EWeekView *week_view);
};
-GType e_week_view_get_type (void);
-GtkWidget* e_week_view_new (ECalModel *model);
+GType e_week_view_get_type (void);
+GtkWidget * e_week_view_new (ECalModel *model);
/* The first day shown. Note that it will be rounded down to the start of a
week when set. The returned value will be invalid if no date has been set
yet. */
-void e_week_view_get_first_day_shown (EWeekView *week_view,
- GDate *date);
-void e_week_view_set_first_day_shown (EWeekView *week_view,
- GDate *date);
+void e_week_view_get_first_day_shown (EWeekView *week_view,
+ GDate *date);
+void e_week_view_set_first_day_shown (EWeekView *week_view,
+ GDate *date);
/* The selected time range. The EWeekView will show the corresponding
month and the days between start_time and end_time will be selected.
To select a single day, use the same value for start_time & end_time. */
-void e_week_view_set_selected_time_range_visible (EWeekView *week_view,
- time_t start_time,
- time_t end_time);
+void e_week_view_set_selected_time_range_visible
+ (EWeekView *week_view,
+ time_t start_time,
+ time_t end_time);
/* Whether to display 1 week or 1 month (5 weeks). It defaults to 1 week. */
-gboolean e_week_view_get_multi_week_view (EWeekView *week_view);
-void e_week_view_set_multi_week_view (EWeekView *week_view,
- gboolean multi_week_view);
+gboolean e_week_view_get_multi_week_view (EWeekView *week_view);
+void e_week_view_set_multi_week_view (EWeekView *week_view,
+ gboolean multi_week_view);
/* Whether to update the base date when the time range changes */
-gboolean e_week_view_get_update_base_date (EWeekView *week_view);
-void e_week_view_set_update_base_date (EWeekView *week_view, gboolean update_base_date);
+gboolean e_week_view_get_update_base_date(EWeekView *week_view);
+void e_week_view_set_update_base_date(EWeekView *week_view,
+ gboolean update_base_date);
/* The number of weeks shown in the multi-week view. */
-gint e_week_view_get_weeks_shown (EWeekView *week_view);
-void e_week_view_set_weeks_shown (EWeekView *week_view,
- gint weeks_shown);
+gint e_week_view_get_weeks_shown (EWeekView *week_view);
+void e_week_view_set_weeks_shown (EWeekView *week_view,
+ gint weeks_shown);
/* Whether the weekend (Sat/Sun) should be compressed into 1 cell in the Month
view. In the Week view they are always compressed. */
-gboolean e_week_view_get_compress_weekend (EWeekView *week_view);
-void e_week_view_set_compress_weekend (EWeekView *week_view,
- gboolean compress);
+gboolean e_week_view_get_compress_weekend(EWeekView *week_view);
+void e_week_view_set_compress_weekend(EWeekView *week_view,
+ gboolean compress);
/* Whether we display event end times. */
-gboolean e_week_view_get_show_event_end_times (EWeekView *week_view);
-void e_week_view_set_show_event_end_times (EWeekView *week_view,
- gboolean show);
+gboolean e_week_view_get_show_event_end_times
+ (EWeekView *week_view);
+void e_week_view_set_show_event_end_times
+ (EWeekView *week_view,
+ gboolean show);
/* The first day of the week, 0 (Monday) to 6 (Sunday). */
-gint e_week_view_get_week_start_day (EWeekView *week_view);
-void e_week_view_set_week_start_day (EWeekView *week_view,
- gint week_start_day);
+gint e_week_view_get_week_start_day (EWeekView *week_view);
+void e_week_view_set_week_start_day (EWeekView *week_view,
+ gint week_start_day);
-void e_week_view_delete_occurrence (EWeekView *week_view);
+void e_week_view_delete_occurrence (EWeekView *week_view);
/* Returns the number of selected events (0 or 1 at present). */
-gint e_week_view_get_num_events_selected (EWeekView *week_view);
+gint e_week_view_get_num_events_selected
+ (EWeekView *week_view);
/*
* Internal functions called by the associated canvas items.
*/
-void e_week_view_get_day_position (EWeekView *week_view,
- gint day,
- gint *day_x,
- gint *day_y,
- gint *day_w,
- gint *day_h);
-gboolean e_week_view_get_span_position (EWeekView *week_view,
- gint event_num,
- gint span_num,
- gint *span_x,
- gint *span_y,
- gint *span_w);
-gboolean e_week_view_is_one_day_event (EWeekView *week_view,
- gint event_num);
-gboolean e_week_view_start_editing_event (EWeekView *week_view,
- gint event_num,
- gint span_num,
- gchar *initial_text);
-void e_week_view_stop_editing_event (EWeekView *week_view);
-
-void e_week_view_show_popup_menu (EWeekView *week_view,
+void e_week_view_get_day_position (EWeekView *week_view,
+ gint day,
+ gint *day_x,
+ gint *day_y,
+ gint *day_w,
+ gint *day_h);
+gboolean e_week_view_get_span_position (EWeekView *week_view,
+ gint event_num,
+ gint span_num,
+ gint *span_x,
+ gint *span_y,
+ gint *span_w);
+gboolean e_week_view_is_one_day_event (EWeekView *week_view,
+ gint event_num);
+gboolean e_week_view_start_editing_event (EWeekView *week_view,
+ gint event_num,
+ gint span_num,
+ gchar *initial_text);
+void e_week_view_stop_editing_event (EWeekView *week_view);
+
+void e_week_view_show_popup_menu (EWeekView *week_view,
GdkEventButton *event,
- gint event_num);
-
-void e_week_view_convert_time_to_display (EWeekView *week_view,
- gint hour,
- gint *display_hour,
- const gchar **suffix,
- gint *suffix_width);
-gint e_week_view_get_time_string_width (EWeekView *week_view);
-
-gint e_week_view_event_sort_func (const void *arg1,
- const void *arg2);
-
-gboolean e_week_view_find_event_from_item (EWeekView *week_view,
- GnomeCanvasItem *item,
- gint *event_num_return,
- gint *span_num_return);
-
-gboolean e_week_view_is_jump_button_visible (EWeekView *week_view,
- gint day);
-void e_week_view_jump_to_button_item (EWeekView *week_view, GnomeCanvasItem *item);
+ gint event_num);
+
+void e_week_view_convert_time_to_display
+ (EWeekView *week_view,
+ gint hour,
+ gint *display_hour,
+ const gchar **suffix,
+ gint *suffix_width);
+gint e_week_view_get_time_string_width
+ (EWeekView *week_view);
+
+gint e_week_view_event_sort_func (gconstpointer arg1,
+ gconstpointer arg2);
+
+gboolean e_week_view_find_event_from_item (EWeekView *week_view,
+ GnomeCanvasItem *item,
+ gint *event_num_return,
+ gint *span_num_return);
+
+gboolean e_week_view_is_jump_button_visible
+ (EWeekView *week_view,
+ gint day);
+void e_week_view_jump_to_button_item (EWeekView *week_view,
+ GnomeCanvasItem *item);
+void e_week_view_scroll_a_step (EWeekView *week_view,
+ ECalViewMoveDirection direction);
G_END_DECLS
-#endif /* _E_WEEK_VIEW_H_ */
+#endif /* E_WEEK_VIEW_H */
diff --git a/calendar/gui/ea-cal-view-event.c b/calendar/gui/ea-cal-view-event.c
new file mode 100644
index 0000000000..5f0af90261
--- /dev/null
+++ b/calendar/gui/ea-cal-view-event.c
@@ -0,0 +1,568 @@
+/*
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2 of the License, or (at your option) version 3.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with the program; if not, see <http://www.gnu.org/licenses/>
+ *
+ *
+ * Authors:
+ * Bolian Yin <bolian.yin@sun.com>
+ *
+ * Copyright (C) 1999-2008 Novell, Inc. (www.novell.com)
+ *
+ */
+
+#include "ea-cal-view-event.h"
+#include "ea-calendar-helpers.h"
+#include "ea-day-view.h"
+#include "ea-week-view.h"
+#include <text/e-text.h>
+#include <glib/gi18n.h>
+
+static void ea_cal_view_event_class_init (EaCalViewEventClass *klass);
+static void ea_cal_view_event_init (EaCalViewEvent *a11y);
+
+static void ea_cal_view_event_dispose (GObject *object);
+static G_CONST_RETURN gchar * ea_cal_view_event_get_name (AtkObject *accessible);
+static G_CONST_RETURN gchar * ea_cal_view_event_get_description (AtkObject *accessible);
+static AtkObject* ea_cal_view_event_get_parent (AtkObject *accessible);
+static gint ea_cal_view_event_get_index_in_parent (AtkObject *accessible);
+static AtkStateSet *ea_cal_view_event_ref_state_set (AtkObject *accessible);
+
+/* component interface */
+static void atk_component_interface_init (AtkComponentIface *iface);
+static void ea_cal_view_get_extents (AtkComponent *component,
+ gint *x, gint *y, gint *width, gint *height,
+ AtkCoordType coord_type);
+/* action interface */
+static void atk_action_interface_init (AtkActionIface *iface);
+static gboolean ea_cal_view_event_do_action (AtkAction *action, gint i);
+static gint ea_cal_view_event_get_n_actions (AtkAction *action);
+static G_CONST_RETURN gchar * ea_cal_view_event_action_get_name (AtkAction *action, gint i);
+
+#ifdef ACC_DEBUG
+static gint n_ea_cal_view_event_created = 0, n_ea_cal_view_event_destroyed = 0;
+static void ea_cal_view_finalize (GObject *object);
+#endif
+
+static gpointer parent_class = NULL;
+
+GType
+ea_cal_view_event_get_type (void)
+{
+ static GType type = 0;
+ AtkObjectFactory *factory;
+ GTypeQuery query;
+ GType derived_atk_type;
+
+ if (!type) {
+ static GTypeInfo tinfo = {
+ sizeof (EaCalViewEventClass),
+ (GBaseInitFunc) NULL, /* base init */
+ (GBaseFinalizeFunc) NULL, /* base finalize */
+ (GClassInitFunc) ea_cal_view_event_class_init, /* class init */
+ (GClassFinalizeFunc) NULL, /* class finalize */
+ NULL, /* class data */
+ sizeof (EaCalViewEvent), /* instance size */
+ 0, /* nb preallocs */
+ (GInstanceInitFunc) ea_cal_view_event_init, /* instance init */
+ NULL /* value table */
+ };
+
+ static const GInterfaceInfo atk_component_info = {
+ (GInterfaceInitFunc) atk_component_interface_init,
+ (GInterfaceFinalizeFunc) NULL,
+ NULL
+ };
+
+ static const GInterfaceInfo atk_action_info = {
+ (GInterfaceInitFunc) atk_action_interface_init,
+ (GInterfaceFinalizeFunc) NULL,
+ NULL
+ };
+
+ /*
+ * Figure out the size of the class and instance
+ * we are run-time deriving from (atk object for E_TEXT, in this case)
+ */
+
+ factory = atk_registry_get_factory (atk_get_default_registry (),
+ E_TYPE_TEXT);
+ derived_atk_type = atk_object_factory_get_accessible_type (factory);
+ g_type_query (derived_atk_type, &query);
+
+ tinfo.class_size = query.class_size;
+ tinfo.instance_size = query.instance_size;
+
+ /* we inherit the component, text and other interfaces from E_TEXT */
+ type = g_type_register_static (derived_atk_type,
+ "EaCalViewEvent", &tinfo, 0);
+ g_type_add_interface_static (type, ATK_TYPE_COMPONENT,
+ &atk_component_info);
+ g_type_add_interface_static (type, ATK_TYPE_ACTION,
+ &atk_action_info);
+
+ }
+
+ return type;
+}
+
+static void
+ea_cal_view_event_class_init (EaCalViewEventClass *klass)
+{
+ AtkObjectClass *class = ATK_OBJECT_CLASS (klass);
+ GObjectClass *gobject_class = G_OBJECT_CLASS (klass);
+#ifdef ACC_DEBUG
+ gobject_class->finalize = ea_cal_view_finalize;
+#endif
+
+ parent_class = g_type_class_peek_parent (klass);
+
+ gobject_class->dispose = ea_cal_view_event_dispose;
+
+ class->get_name = ea_cal_view_event_get_name;
+ class->get_description = ea_cal_view_event_get_description;
+ class->get_parent = ea_cal_view_event_get_parent;
+ class->get_index_in_parent = ea_cal_view_event_get_index_in_parent;
+ class->ref_state_set = ea_cal_view_event_ref_state_set;
+
+}
+
+static void
+ea_cal_view_event_init (EaCalViewEvent *a11y)
+{
+ a11y->state_set = atk_state_set_new ();
+ atk_state_set_add_state (a11y->state_set, ATK_STATE_TRANSIENT);
+ atk_state_set_add_state (a11y->state_set, ATK_STATE_ENABLED);
+ atk_state_set_add_state (a11y->state_set, ATK_STATE_SENSITIVE);
+ atk_state_set_add_state (a11y->state_set, ATK_STATE_SELECTABLE);
+ atk_state_set_add_state (a11y->state_set, ATK_STATE_SHOWING);
+ atk_state_set_add_state (a11y->state_set, ATK_STATE_FOCUSABLE);
+}
+
+#ifdef ACC_DEBUG
+static void ea_cal_view_finalize (GObject *object)
+{
+ G_OBJECT_CLASS (parent_class)->finalize (object);
+
+ ++n_ea_cal_view_event_destroyed;
+ printf ("ACC_DEBUG: n_ea_cal_view_event_destroyed = %d\n",
+ n_ea_cal_view_event_destroyed);
+}
+#endif
+
+AtkObject*
+ea_cal_view_event_new (GObject *obj)
+{
+ AtkObject *atk_obj = NULL;
+ GObject *target_obj;
+ ECalendarView *cal_view;
+
+ g_return_val_if_fail (E_IS_TEXT (obj), NULL);
+ cal_view = ea_calendar_helpers_get_cal_view_from (GNOME_CANVAS_ITEM (obj));
+ if (!cal_view)
+ return NULL;
+
+ if (E_IS_WEEK_VIEW (cal_view)) {
+ gint event_num, span_num;
+ EWeekViewEvent *week_view_event;
+ EWeekViewEventSpan *event_span;
+ EWeekView *week_view = E_WEEK_VIEW (cal_view);
+
+ /* for week view, we need to check if a atkobject exists for
+ * the first span of the same event
+ */
+ if (!e_week_view_find_event_from_item (week_view,
+ GNOME_CANVAS_ITEM (obj),
+ &event_num,
+ &span_num))
+ return NULL;
+ week_view_event = &g_array_index (week_view->events,
+ EWeekViewEvent,
+ event_num);
+ /* get the first span */
+ event_span = &g_array_index (week_view->spans,
+ EWeekViewEventSpan,
+ week_view_event->spans_index);
+ target_obj = G_OBJECT (event_span->text_item);
+ atk_obj = g_object_get_data (target_obj, "accessible-object");
+
+ }
+ else
+ target_obj = obj;
+
+ if (!atk_obj) {
+ static AtkRole event_role = ATK_ROLE_INVALID;
+ atk_obj = ATK_OBJECT (g_object_new (EA_TYPE_CAL_VIEW_EVENT,
+ NULL));
+ atk_object_initialize (atk_obj, target_obj);
+ if (event_role == ATK_ROLE_INVALID)
+ event_role = atk_role_register ("Calendar Event");
+ atk_obj->role = event_role;
+#ifdef ACC_DEBUG
+ ++n_ea_cal_view_event_created;
+ printf ("ACC_DEBUG: n_ea_cal_view_event_created = %d\n",
+ n_ea_cal_view_event_created);
+#endif
+ }
+
+ /* the registered factory for E_TEXT is cannot create a EaCalViewEvent,
+ * we should save the EaCalViewEvent object in it.
+ */
+ g_object_set_data (obj, "accessible-object", atk_obj);
+
+ return atk_obj;
+}
+
+static void
+ea_cal_view_event_dispose (GObject *object)
+{
+ EaCalViewEvent *a11y = EA_CAL_VIEW_EVENT (object);
+
+ if (a11y->state_set) {
+ g_object_unref (a11y->state_set);
+ a11y->state_set = NULL;
+ }
+
+ if (G_OBJECT_CLASS(parent_class)->dispose)
+ G_OBJECT_CLASS(parent_class)->dispose (object);
+}
+
+static G_CONST_RETURN gchar *
+ea_cal_view_event_get_name (AtkObject *accessible)
+{
+ AtkGObjectAccessible *atk_gobj;
+ GObject *g_obj;
+ ECalendarViewEvent *event;
+ gchar *name_string;
+ const gchar *alarm_string;
+ const gchar *recur_string;
+ const gchar *meeting_string;
+ gchar *summary_string;
+ const gchar *summary;
+
+ g_return_val_if_fail (EA_IS_CAL_VIEW_EVENT (accessible), NULL);
+
+ atk_gobj = ATK_GOBJECT_ACCESSIBLE (accessible);
+ g_obj = atk_gobject_accessible_get_object (atk_gobj);
+ if (!g_obj || !E_IS_TEXT (g_obj))
+ return NULL;
+ event = ea_calendar_helpers_get_cal_view_event_from (GNOME_CANVAS_ITEM(g_obj));
+
+ alarm_string = recur_string = meeting_string = "";
+ if (event && event->comp_data) {
+ if (e_cal_util_component_has_alarms (event->comp_data->icalcomp))
+ alarm_string = _("It has alarms.");
+
+ if (e_cal_util_component_has_recurrences (event->comp_data->icalcomp))
+ recur_string = _("It has recurrences.");
+
+ if (e_cal_util_component_has_organizer (event->comp_data->icalcomp))
+ meeting_string = _("It is a meeting.");
+
+ }
+
+ summary = icalcomponent_get_summary (event->comp_data->icalcomp);
+ if (summary)
+ summary_string = g_strdup_printf (_("Calendar Event: Summary is %s."), summary);
+ else
+ summary_string = g_strdup (_("Calendar Event: It has no summary."));
+
+ name_string = g_strdup_printf ("%s %s %s %s", summary_string, alarm_string, recur_string, meeting_string);
+ g_free (summary_string);
+
+ ATK_OBJECT_CLASS (parent_class)->set_name (accessible, name_string);
+#ifdef ACC_DEBUG
+ printf("EvoAcc: name for event accobj=%p, is %s\n",
+ (gpointer)accessible, new_name);
+#endif
+ g_free (name_string);
+ return accessible->name;
+}
+
+static G_CONST_RETURN gchar *
+ea_cal_view_event_get_description (AtkObject *accessible)
+{
+ if (accessible->description)
+ return accessible->description;
+
+ return _("calendar view event");
+}
+
+static AtkObject *
+ea_cal_view_event_get_parent (AtkObject *accessible)
+{
+ AtkGObjectAccessible *atk_gobj;
+ GObject *g_obj;
+ GnomeCanvasItem *canvas_item;
+ ECalendarView *cal_view;
+
+ g_return_val_if_fail (EA_IS_CAL_VIEW_EVENT (accessible), NULL);
+ atk_gobj = ATK_GOBJECT_ACCESSIBLE (accessible);
+
+ g_obj = atk_gobject_accessible_get_object (atk_gobj);
+ if (g_obj == NULL)
+ /* Object is defunct */
+ return NULL;
+ canvas_item = GNOME_CANVAS_ITEM (g_obj);
+
+ cal_view = ea_calendar_helpers_get_cal_view_from (canvas_item);
+
+ if (!cal_view)
+ return NULL;
+
+ return gtk_widget_get_accessible (GTK_WIDGET (cal_view));
+}
+
+static gint
+ea_cal_view_event_get_index_in_parent (AtkObject *accessible)
+{
+ GObject *g_obj;
+ GnomeCanvasItem *canvas_item;
+ ECalendarView *cal_view;
+ ECalendarViewEvent *cal_view_event;
+
+ g_return_val_if_fail (EA_IS_CAL_VIEW_EVENT (accessible), -1);
+ g_obj = atk_gobject_accessible_get_object (ATK_GOBJECT_ACCESSIBLE(accessible));
+ if (!g_obj)
+ /* defunct object*/
+ return -1;
+
+ canvas_item = GNOME_CANVAS_ITEM (g_obj);
+ cal_view = ea_calendar_helpers_get_cal_view_from (canvas_item);
+ if (!cal_view)
+ return -1;
+
+ cal_view_event = ea_calendar_helpers_get_cal_view_event_from (canvas_item);
+ if (!cal_view_event)
+ return -1;
+
+ if (E_IS_DAY_VIEW (cal_view)) {
+ gint day, event_num, num_before;
+ EDayViewEvent *day_view_event;
+ EDayView *day_view = E_DAY_VIEW (cal_view);
+
+ /* the long event comes first in the order */
+ for (event_num = day_view->long_events->len - 1; event_num >= 0;
+ --event_num) {
+ day_view_event = &g_array_index (day_view->long_events,
+ EDayViewEvent, event_num);
+ if (cal_view_event == (ECalendarViewEvent*)day_view_event)
+ return event_num;
+
+ }
+ num_before = day_view->long_events->len;
+
+ for (day = 0; day < day_view->days_shown; ++day) {
+ for (event_num = day_view->events[day]->len - 1; event_num >= 0;
+ --event_num) {
+ day_view_event = &g_array_index (day_view->events[day],
+ EDayViewEvent, event_num);
+ if (cal_view_event == (ECalendarViewEvent*)day_view_event)
+ return num_before + event_num;
+ }
+ num_before += day_view->events[day]->len;
+ }
+ }
+ else if (E_IS_WEEK_VIEW (cal_view)) {
+ AtkObject *atk_parent, *atk_child;
+ gint index = 0;
+
+ atk_parent = atk_object_get_parent (accessible);
+ while ((atk_child = atk_object_ref_accessible_child (atk_parent,
+ index)) != NULL) {
+ if (atk_child == accessible) {
+ g_object_unref (atk_child);
+ return index;
+ }
+ g_object_unref (atk_child);
+ ++index;
+ }
+ }
+ else {
+ g_return_val_if_reached (-1);
+ }
+ return -1;
+}
+
+static AtkStateSet *
+ea_cal_view_event_ref_state_set (AtkObject *accessible)
+{
+ EaCalViewEvent *atk_event = EA_CAL_VIEW_EVENT (accessible);
+
+ g_return_val_if_fail (atk_event->state_set, NULL);
+
+ g_object_ref (atk_event->state_set);
+
+ return atk_event->state_set;
+}
+
+/* Atk Component Interface */
+
+static void
+atk_component_interface_init (AtkComponentIface *iface)
+{
+ g_return_if_fail (iface != NULL);
+
+ iface->get_extents = ea_cal_view_get_extents;
+}
+
+static void
+ea_cal_view_get_extents (AtkComponent *component,
+ gint *x,
+ gint *y,
+ gint *width,
+ gint *height,
+ AtkCoordType coord_type)
+{
+ GObject *g_obj;
+ GnomeCanvasItem *canvas_item;
+ gint x_window, y_window;
+ gint scroll_x, scroll_y;
+ ECalendarView *cal_view;
+ gint item_x, item_y, item_w, item_h;
+ GtkWidget *canvas = NULL;
+
+ g_return_if_fail (EA_IS_CAL_VIEW_EVENT (component));
+
+ g_obj = atk_gobject_accessible_get_object (ATK_GOBJECT_ACCESSIBLE(component));
+ if (!g_obj)
+ /* defunct object*/
+ return;
+ g_return_if_fail (E_IS_TEXT (g_obj));
+
+ canvas_item = GNOME_CANVAS_ITEM (g_obj);
+ cal_view = ea_calendar_helpers_get_cal_view_from (canvas_item);
+ if (!cal_view)
+ return;
+
+ if (E_IS_DAY_VIEW (cal_view)) {
+ gint day, event_num;
+
+ if (!e_day_view_find_event_from_item (E_DAY_VIEW (cal_view),
+ canvas_item,
+ &day, &event_num))
+ return;
+ if (day == E_DAY_VIEW_LONG_EVENT) {
+ gint start_day, end_day;
+ if (!e_day_view_get_long_event_position (E_DAY_VIEW (cal_view),
+ event_num,
+ &start_day,
+ &end_day,
+ &item_x,
+ &item_y,
+ &item_w,
+ &item_h))
+ return;
+ canvas = E_DAY_VIEW (cal_view)->top_canvas;
+ }
+ else {
+ if (!e_day_view_get_event_position (E_DAY_VIEW (cal_view), day,
+ event_num,
+ &item_x, &item_y,
+ &item_w, &item_h))
+
+ return;
+ canvas = E_DAY_VIEW (cal_view)->main_canvas;
+ }
+ }
+ else if (E_IS_WEEK_VIEW (cal_view)) {
+ gint event_num, span_num;
+ if (!e_week_view_find_event_from_item (E_WEEK_VIEW (cal_view),
+ canvas_item, &event_num,
+ &span_num))
+ return;
+
+ if (!e_week_view_get_span_position (E_WEEK_VIEW (cal_view),
+ event_num, span_num,
+ &item_x, &item_y, &item_w))
+ return;
+ item_h = E_WEEK_VIEW_ICON_HEIGHT;
+ canvas = E_WEEK_VIEW (cal_view)->main_canvas;
+ }
+ else
+ return;
+
+ if (!canvas)
+ return;
+
+ gdk_window_get_origin (canvas->window,
+ &x_window, &y_window);
+ gnome_canvas_get_scroll_offsets (GNOME_CANVAS (canvas), &scroll_x, &scroll_y);
+
+ *x = item_x + x_window - scroll_x;
+ *y = item_y + y_window - scroll_y;
+ *width = item_w;
+ *height = item_h;
+
+ if (coord_type == ATK_XY_WINDOW) {
+ GdkWindow *window;
+ gint x_toplevel, y_toplevel;
+
+ window = gdk_window_get_toplevel (GTK_WIDGET (cal_view)->window);
+ gdk_window_get_origin (window, &x_toplevel, &y_toplevel);
+
+ *x -= x_toplevel;
+ *y -= y_toplevel;
+ }
+
+#ifdef ACC_DEBUG
+ printf ("Event Bounds (%d, %d, %d, %d)\n", *x, *y, *width, *height);
+#endif
+}
+
+#define CAL_VIEW_EVENT_ACTION_NUM 1
+
+static const gchar * action_name [CAL_VIEW_EVENT_ACTION_NUM] = {
+ N_("Grab Focus")
+};
+
+static void
+atk_action_interface_init (AtkActionIface *iface)
+{
+ g_return_if_fail (iface != NULL);
+
+ iface->do_action = ea_cal_view_event_do_action;
+ iface->get_n_actions = ea_cal_view_event_get_n_actions;
+ iface->get_name = ea_cal_view_event_action_get_name;
+}
+
+static gboolean
+ea_cal_view_event_do_action (AtkAction *action, gint i)
+{
+ AtkGObjectAccessible *atk_gobj;
+ AtkComponent *atk_comp;
+
+ atk_gobj = ATK_GOBJECT_ACCESSIBLE (action);
+
+ if (i == 0) {
+ atk_comp = (AtkComponent *)atk_gobj;
+ return atk_component_grab_focus (atk_comp);
+ }
+
+ return FALSE;
+
+}
+
+static gint
+ea_cal_view_event_get_n_actions (AtkAction *action)
+{
+ return CAL_VIEW_EVENT_ACTION_NUM;
+}
+
+static G_CONST_RETURN gchar *
+ea_cal_view_event_action_get_name (AtkAction *action, gint i)
+{
+ if (i >= 0 && i < CAL_VIEW_EVENT_ACTION_NUM)
+ return action_name [i];
+ return NULL;
+}
+
diff --git a/calendar/gui/ea-cal-view-event.h b/calendar/gui/ea-cal-view-event.h
new file mode 100644
index 0000000000..b4b193de2d
--- /dev/null
+++ b/calendar/gui/ea-cal-view-event.h
@@ -0,0 +1,57 @@
+/*
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2 of the License, or (at your option) version 3.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with the program; if not, see <http://www.gnu.org/licenses/>
+ *
+ *
+ * Authors:
+ * Bolian Yin <bolian.yin@sun.com>
+ *
+ * Copyright (C) 1999-2008 Novell, Inc. (www.novell.com)
+ *
+ */
+
+#ifndef __EA_CAL_VIEW_EVENT_H__
+#define __EA_CAL_VIEW_EVENT_H__
+
+#include <atk/atkgobjectaccessible.h>
+
+G_BEGIN_DECLS
+
+#define EA_TYPE_CAL_VIEW_EVENT (ea_cal_view_event_get_type ())
+#define EA_CAL_VIEW_EVENT(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), EA_TYPE_CAL_VIEW_EVENT, EaCalViewEvent))
+#define EA_CAL_VIEW_EVENT_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), EA_TYPE_CAL_VIEW_EVENT, EaCalViewEventClass))
+#define EA_IS_CAL_VIEW_EVENT(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), EA_TYPE_CAL_VIEW_EVENT))
+#define EA_IS_CAL_VIEW_EVENT_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), EA_TYPE_CAL_VIEW_EVENT))
+#define EA_CAL_VIEW_EVENT_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), EA_TYPE_CAL_VIEW_EVENT, EaCalViewEventClass))
+
+typedef struct _EaCalViewEvent EaCalViewEvent;
+typedef struct _EaCalViewEventClass EaCalViewEventClass;
+
+struct _EaCalViewEvent
+{
+ AtkGObjectAccessible parent;
+ AtkStateSet *state_set;
+};
+
+GType ea_cal_view_event_get_type (void);
+
+struct _EaCalViewEventClass
+{
+ AtkGObjectAccessibleClass parent_class;
+};
+
+AtkObject *ea_cal_view_event_new (GObject *obj);
+
+G_END_DECLS
+
+#endif /* __EA_CAL_VIEW_EVENT_H__ */
diff --git a/calendar/gui/ea-cal-view.c b/calendar/gui/ea-cal-view.c
new file mode 100644
index 0000000000..410833a9ed
--- /dev/null
+++ b/calendar/gui/ea-cal-view.c
@@ -0,0 +1,425 @@
+/*
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2 of the License, or (at your option) version 3.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with the program; if not, see <http://www.gnu.org/licenses/>
+ *
+ *
+ * Authors:
+ * Bolian Yin <bolian.yin@sun.com>
+ *
+ * Copyright (C) 1999-2008 Novell, Inc. (www.novell.com)
+ *
+ */
+
+#include "ea-cal-view.h"
+#include "ea-calendar-helpers.h"
+#include "e-day-view.h"
+#include "e-week-view.h"
+#include "goto.h"
+#include <glib.h>
+#include <glib/gi18n.h>
+
+static void ea_cal_view_class_init (EaCalViewClass *klass);
+
+static AtkObject* ea_cal_view_get_parent (AtkObject *accessible);
+static void ea_cal_view_real_initialize (AtkObject *accessible, gpointer data);
+
+static void ea_cal_view_event_changed_cb (ECalendarView *cal_view,
+ ECalendarViewEvent *event, gpointer data);
+static void ea_cal_view_event_added_cb (ECalendarView *cal_view,
+ ECalendarViewEvent *event, gpointer data);
+
+static gboolean idle_dates_changed (gpointer data);
+static void ea_cal_view_dates_change_cb (GnomeCalendar *gcal, gpointer data);
+
+static void atk_action_interface_init (AtkActionIface *iface);
+static gboolean action_interface_do_action (AtkAction *action, gint i);
+static gint action_interface_get_n_actions (AtkAction *action);
+static G_CONST_RETURN gchar *
+action_interface_get_description(AtkAction *action, gint i);
+static G_CONST_RETURN gchar *
+action_interface_get_keybinding (AtkAction *action, gint i);
+static G_CONST_RETURN gchar *
+action_interface_action_get_name(AtkAction *action, gint i);
+
+static gpointer parent_class = NULL;
+
+GType
+ea_cal_view_get_type (void)
+{
+ static GType type = 0;
+ AtkObjectFactory *factory;
+ GTypeQuery query;
+ GType derived_atk_type;
+
+ if (!type) {
+ static GTypeInfo tinfo = {
+ sizeof (EaCalViewClass),
+ (GBaseInitFunc) NULL, /* base init */
+ (GBaseFinalizeFunc) NULL, /* base finalize */
+ (GClassInitFunc) ea_cal_view_class_init, /* class init */
+ (GClassFinalizeFunc) NULL, /* class finalize */
+ NULL, /* class data */
+ sizeof (EaCalView), /* instance size */
+ 0, /* nb preallocs */
+ (GInstanceInitFunc) NULL, /* instance init */
+ NULL /* value table */
+ };
+
+ static const GInterfaceInfo atk_action_info = {
+ (GInterfaceInitFunc) atk_action_interface_init,
+ (GInterfaceFinalizeFunc) NULL,
+ NULL
+ };
+
+ /*
+ * Figure out the size of the class and instance
+ * we are run-time deriving from (GailWidget, in this case)
+ */
+
+ factory = atk_registry_get_factory (atk_get_default_registry (),
+ GTK_TYPE_WIDGET);
+ derived_atk_type = atk_object_factory_get_accessible_type (factory);
+ g_type_query (derived_atk_type, &query);
+
+ tinfo.class_size = query.class_size;
+ tinfo.instance_size = query.instance_size;
+
+ type = g_type_register_static (derived_atk_type,
+ "EaCalView", &tinfo, 0);
+ g_type_add_interface_static (type, ATK_TYPE_ACTION,
+ &atk_action_info);
+ }
+
+ return type;
+}
+
+static void
+ea_cal_view_class_init (EaCalViewClass *klass)
+{
+ AtkObjectClass *class = ATK_OBJECT_CLASS (klass);
+
+ parent_class = g_type_class_peek_parent (klass);
+
+ class->get_parent = ea_cal_view_get_parent;
+ class->initialize = ea_cal_view_real_initialize;
+}
+
+AtkObject*
+ea_cal_view_new (GtkWidget *widget)
+{
+ GObject *object;
+ AtkObject *accessible;
+
+ g_return_val_if_fail (E_IS_CALENDAR_VIEW (widget), NULL);
+
+ object = g_object_new (EA_TYPE_CAL_VIEW, NULL);
+
+ accessible = ATK_OBJECT (object);
+ atk_object_initialize (accessible, widget);
+
+ return accessible;
+}
+
+static void
+ea_cal_view_real_initialize (AtkObject *accessible, gpointer data)
+{
+ ECalendarView *cal_view;
+ GnomeCalendar *gcal;
+ static AtkRole role = ATK_ROLE_INVALID;
+
+ g_return_if_fail (EA_IS_CAL_VIEW (accessible));
+ g_return_if_fail (E_IS_CALENDAR_VIEW (data));
+
+ ATK_OBJECT_CLASS (parent_class)->initialize (accessible, data);
+ if (role == ATK_ROLE_INVALID)
+ role = atk_role_register ("Calendar View");
+ accessible->role = role;
+ cal_view = E_CALENDAR_VIEW (data);
+
+ /* add listener for event_changed, event_added
+ * we don't need to listen on event_removed. When the e_text
+ * of the event is removed, the cal_view_event will go to the state
+ * of "defunct" (changed by weak ref callback of atkgobjectaccessible
+ */
+ g_signal_connect (G_OBJECT(cal_view), "event_changed",
+ G_CALLBACK (ea_cal_view_event_changed_cb), NULL);
+ g_signal_connect (G_OBJECT(cal_view), "event_added",
+ G_CALLBACK (ea_cal_view_event_added_cb), NULL);
+
+ /* listen for date changes of calendar */
+ gcal = e_calendar_view_get_calendar (cal_view);
+
+ if (gcal)
+ g_signal_connect (gcal, "dates_shown_changed",
+ G_CALLBACK (ea_cal_view_dates_change_cb),
+ accessible);
+}
+
+static AtkObject*
+ea_cal_view_get_parent (AtkObject *accessible)
+{
+ ECalendarView *cal_view;
+ GnomeCalendar *gnomeCalendar;
+
+ g_return_val_if_fail (EA_IS_CAL_VIEW (accessible), NULL);
+
+ if (!GTK_ACCESSIBLE (accessible)->widget)
+ return NULL;
+ cal_view = E_CALENDAR_VIEW (GTK_ACCESSIBLE (accessible)->widget);
+
+ gnomeCalendar = e_calendar_view_get_calendar (cal_view);
+
+ return gtk_widget_get_accessible (GTK_WIDGET(gnomeCalendar));
+}
+
+static void
+ea_cal_view_event_changed_cb (ECalendarView *cal_view, ECalendarViewEvent *event,
+ gpointer data)
+{
+ AtkObject *atk_obj;
+ AtkObject *event_atk_obj = NULL;
+
+ g_return_if_fail (E_IS_CALENDAR_VIEW (cal_view));
+
+ atk_obj = gtk_widget_get_accessible (GTK_WIDGET(cal_view));
+ if (!EA_IS_CAL_VIEW (atk_obj))
+ return;
+
+ if ((E_IS_DAY_VIEW (cal_view)) && event && event->canvas_item) {
+ event_atk_obj =
+ ea_calendar_helpers_get_accessible_for (event->canvas_item);
+ }
+ else if ((E_IS_WEEK_VIEW (cal_view)) && event) {
+ EWeekViewEventSpan *span;
+ EWeekViewEvent *week_view_event = (EWeekViewEvent *)event;
+ EWeekView *week_view = E_WEEK_VIEW (cal_view);
+ /* get the first span of the event */
+ span = &g_array_index (week_view->spans, EWeekViewEventSpan,
+ week_view_event->spans_index);
+ if (span && span->text_item)
+ event_atk_obj = ea_calendar_helpers_get_accessible_for (span->text_item);
+ }
+ if (event_atk_obj) {
+#ifdef ACC_DEBUG
+ printf ("AccDebug: event=%p changed\n", (gpointer)event);
+#endif
+ g_object_notify (G_OBJECT(event_atk_obj), "accessible-name");
+ g_signal_emit_by_name (event_atk_obj, "visible_data_changed");
+ }
+
+}
+
+static void
+ea_cal_view_event_added_cb (ECalendarView *cal_view, ECalendarViewEvent *event,
+ gpointer data)
+{
+ AtkObject *atk_obj;
+ AtkObject *event_atk_obj = NULL;
+ gint index;
+
+ g_return_if_fail (E_IS_CALENDAR_VIEW (cal_view));
+
+ atk_obj = gtk_widget_get_accessible (GTK_WIDGET(cal_view));
+ if (!EA_IS_CAL_VIEW (atk_obj))
+ return;
+
+ if ((E_IS_DAY_VIEW (cal_view)) && event && event->canvas_item) {
+ event_atk_obj =
+ ea_calendar_helpers_get_accessible_for (event->canvas_item);
+ }
+ else if ((E_IS_WEEK_VIEW (cal_view)) && event) {
+ EWeekViewEventSpan *span;
+ EWeekViewEvent *week_view_event = (EWeekViewEvent *)event;
+ EWeekView *week_view = E_WEEK_VIEW (cal_view);
+ /* get the first span of the event */
+ span = &g_array_index (week_view->spans, EWeekViewEventSpan,
+ week_view_event->spans_index);
+ if (span && span->text_item)
+ event_atk_obj = ea_calendar_helpers_get_accessible_for (span->text_item);
+
+ }
+ if (event_atk_obj) {
+ index = atk_object_get_index_in_parent (event_atk_obj);
+ if (index < 0)
+ return;
+#ifdef ACC_DEBUG
+ printf ("AccDebug: event=%p added\n", (gpointer)event);
+#endif
+ g_signal_emit_by_name (atk_obj, "children_changed::add",
+ index, event_atk_obj, NULL);
+ }
+}
+
+static gboolean
+idle_dates_changed (gpointer data)
+{
+ AtkObject *ea_cal_view;
+
+ g_return_val_if_fail (data, FALSE);
+ g_return_val_if_fail (EA_IS_CAL_VIEW (data), FALSE);
+
+ ea_cal_view = ATK_OBJECT(data);
+
+ if (ea_cal_view->name) {
+ g_free (ea_cal_view->name);
+ ea_cal_view->name = NULL;
+ }
+ g_object_notify (G_OBJECT (ea_cal_view), "accessible-name");
+ g_signal_emit_by_name (ea_cal_view, "visible_data_changed");
+ g_signal_emit_by_name (ea_cal_view, "children_changed", NULL, NULL, NULL);
+#ifdef ACC_DEBUG
+ printf ("AccDebug: cal view date changed\n");
+#endif
+
+ return FALSE;
+}
+
+static void
+ea_cal_view_dates_change_cb (GnomeCalendar *gcal, gpointer data)
+{
+ g_idle_add (idle_dates_changed, data);
+}
+
+/* atk action interface */
+
+#define CAL_VIEW_ACTION_NUM 5
+
+static const gchar * action_name [CAL_VIEW_ACTION_NUM] = {
+ N_("New Appointment"),
+ N_("New All Day Event"),
+ N_("New Meeting"),
+ N_("Go to Today"),
+ N_("Go to Date")
+};
+
+static void
+atk_action_interface_init (AtkActionIface *iface)
+{
+ g_return_if_fail (iface != NULL);
+
+ iface->do_action = action_interface_do_action;
+ iface->get_n_actions = action_interface_get_n_actions;
+ iface->get_description = action_interface_get_description;
+ iface->get_keybinding = action_interface_get_keybinding;
+ iface->get_name = action_interface_action_get_name;
+}
+
+static gboolean
+action_interface_do_action (AtkAction *action, gint index)
+{
+ GtkWidget *widget;
+ gboolean return_value = TRUE;
+ time_t dtstart, dtend;
+ ECalendarView *cal_view;
+
+ widget = GTK_ACCESSIBLE (action)->widget;
+ if (widget == NULL)
+ /*
+ * State is defunct
+ */
+ return FALSE;
+
+ if (!GTK_WIDGET_IS_SENSITIVE (widget) || !GTK_WIDGET_VISIBLE (widget))
+ return FALSE;
+
+ cal_view = E_CALENDAR_VIEW (widget);
+ switch (index) {
+ case 0:
+ /* New Appointment */
+ e_calendar_view_new_appointment (cal_view);
+ break;
+ case 1:
+ /* New All Day Event */
+ e_calendar_view_get_selected_time_range (cal_view,
+ &dtstart, &dtend);
+ e_calendar_view_new_appointment_for (cal_view,
+ dtstart, dtend, TRUE, FALSE);
+ break;
+ case 2:
+ /* New Meeting */
+ e_calendar_view_get_selected_time_range (cal_view,
+ &dtstart, &dtend);
+ e_calendar_view_new_appointment_for (cal_view,
+ dtstart, dtend, FALSE, TRUE);
+ break;
+ case 3:
+ /* Go to today */
+ break;
+ calendar_goto_today (e_calendar_view_get_calendar (cal_view));
+ case 4:
+ /* Go to date */
+ goto_dialog (e_calendar_view_get_calendar (cal_view));
+ break;
+ default:
+ return_value = FALSE;
+ break;
+ }
+ return return_value;
+}
+
+static gint
+action_interface_get_n_actions (AtkAction *action)
+{
+ return CAL_VIEW_ACTION_NUM;
+}
+
+static G_CONST_RETURN gchar *
+action_interface_get_description(AtkAction *action, gint index)
+{
+ return action_interface_action_get_name (action, index);
+}
+
+static G_CONST_RETURN gchar *
+action_interface_get_keybinding (AtkAction *action, gint index)
+{
+ GtkWidget *widget;
+
+ widget = GTK_ACCESSIBLE (action)->widget;
+ if (widget == NULL)
+ /*
+ * State is defunct
+ */
+ return NULL;
+
+ if (!GTK_WIDGET_IS_SENSITIVE (widget) || !GTK_WIDGET_VISIBLE (widget))
+ return NULL;
+
+ switch (index) {
+ case 0:
+ /* New Appointment */
+ return "<Alt>fna;<Control>n";
+ case 1:
+ /* New Event */
+ return "<Alt>fnd;<Shift><Control>d";
+ case 2:
+ /* New Meeting */
+ return "<Alt>fne;<Shift><Control>e";
+ case 3:
+ /* Go to today */
+ return "<Alt>vt;<Alt><Control>t";
+ case 4:
+ /* Go to date */
+ return "<Alt>vd;<Alt><Control>g";
+ default:
+ break;
+ }
+ return NULL;
+}
+
+static G_CONST_RETURN gchar *
+action_interface_action_get_name(AtkAction *action, gint i)
+{
+ if (i >= 0 && i < CAL_VIEW_ACTION_NUM)
+ return action_name [i];
+ return NULL;
+}
diff --git a/calendar/gui/ea-cal-view.h b/calendar/gui/ea-cal-view.h
new file mode 100644
index 0000000000..959f7816b5
--- /dev/null
+++ b/calendar/gui/ea-cal-view.h
@@ -0,0 +1,58 @@
+/*
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2 of the License, or (at your option) version 3.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with the program; if not, see <http://www.gnu.org/licenses/>
+ *
+ *
+ * Authors:
+ * Bolian Yin <bolian.yin@sun.com>
+ *
+ * Copyright (C) 1999-2008 Novell, Inc. (www.novell.com)
+ *
+ */
+
+#ifndef __EA_CAL_VIEW_H__
+#define __EA_CAL_VIEW_H__
+
+#include <gtk/gtk.h>
+#include "e-calendar-view.h"
+
+G_BEGIN_DECLS
+
+#define EA_TYPE_CAL_VIEW (ea_cal_view_get_type ())
+#define EA_CAL_VIEW(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), EA_TYPE_CAL_VIEW, EaCalView))
+#define EA_CAL_VIEW_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), EA_TYPE_CAL_VIEW, EaCalViewClass))
+#define EA_IS_CAL_VIEW(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), EA_TYPE_CAL_VIEW))
+#define EA_IS_CAL_VIEW_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), EA_TYPE_CAL_VIEW))
+#define EA_CAL_VIEW_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), EA_TYPE_CAL_VIEW, EaCalViewClass))
+
+typedef struct _EaCalView EaCalView;
+typedef struct _EaCalViewClass EaCalViewClass;
+
+struct _EaCalView
+{
+ GtkAccessible parent;
+};
+
+GType ea_cal_view_get_type (void);
+
+struct _EaCalViewClass
+{
+ GtkAccessibleClass parent_class;
+};
+
+AtkObject* ea_cal_view_new (GtkWidget *widget);
+
+G_END_DECLS
+
+#endif /* __EA_CAL_VIEW_H__ */
diff --git a/calendar/gui/ea-calendar-helpers.c b/calendar/gui/ea-calendar-helpers.c
new file mode 100644
index 0000000000..f07cdfa086
--- /dev/null
+++ b/calendar/gui/ea-calendar-helpers.c
@@ -0,0 +1,156 @@
+/*
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2 of the License, or (at your option) version 3.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with the program; if not, see <http://www.gnu.org/licenses/>
+ *
+ *
+ * Authors:
+ * Bolian Yin <bolian.yin@sun.com>
+ *
+ * Copyright (C) 1999-2008 Novell, Inc. (www.novell.com)
+ *
+ */
+
+#include "ea-calendar-helpers.h"
+#include "ea-cal-view-event.h"
+#include "ea-jump-button.h"
+#include "e-day-view.h"
+#include "e-week-view.h"
+
+#include <text/e-text.h>
+#include <libgnomecanvas/gnome-canvas-pixbuf.h>
+
+/**
+ * ea_calendar_helpers_get_accessible_for
+ * @canvas_item: the canvas item for a event or a jump button
+ * @returns: the atk object for the canvas_item
+ *
+ **/
+AtkObject *
+ea_calendar_helpers_get_accessible_for (GnomeCanvasItem *canvas_item)
+{
+ AtkObject *atk_obj = NULL;
+ GObject *g_obj;
+
+ g_return_val_if_fail ((E_IS_TEXT (canvas_item)) || (GNOME_IS_CANVAS_ITEM (canvas_item)), NULL);;
+
+ g_obj = G_OBJECT (canvas_item);
+ /* we cannot use atk_gobject_accessible_for_object here,
+ * EaDayViewEvent/EaWeekViewEvent cannot be created by the
+ * registered facotry of E_TEXT
+ */
+ atk_obj = g_object_get_data (g_obj, "accessible-object");
+ if (!atk_obj) {
+ if (E_IS_TEXT (canvas_item)) {
+ atk_obj = ea_cal_view_event_new (g_obj);
+ }
+ else if (GNOME_IS_CANVAS_PIXBUF(canvas_item)) {
+ atk_obj = ea_jump_button_new (g_obj);
+ }
+ else
+ return NULL;
+ }
+ return atk_obj;
+}
+
+/**
+ * ea_calendar_helpers_get_view_widget_from:
+ * @canvas_item: the canvas item for a event or a jump button
+ * @returns: the cal view widget if exists
+ *
+ * Get the cal view widget contains the canvas_item.
+ *
+ **/
+ECalendarView *
+ea_calendar_helpers_get_cal_view_from (GnomeCanvasItem *canvas_item)
+{
+ GnomeCanvas *canvas;
+ GtkWidget *view_widget = NULL;
+
+ g_return_val_if_fail (canvas_item, NULL);
+ g_return_val_if_fail ((E_IS_TEXT (canvas_item)) || (GNOME_IS_CANVAS_ITEM (canvas_item)), NULL);
+
+ /* canvas_item is the e_text for the event */
+ /* canvas_item->canvas is the ECanvas for day view */
+ /* parent of canvas_item->canvas is the EDayView or EWeekView widget */
+ canvas = canvas_item->canvas;
+ view_widget = gtk_widget_get_parent (GTK_WIDGET(canvas));
+ if (!view_widget || !E_IS_CALENDAR_VIEW (view_widget))
+ return NULL;
+
+ return E_CALENDAR_VIEW (view_widget);
+}
+
+/**
+ * ea_calendar_helpers_get_cal_view_event_from
+ * @canvas_item: the cavas_item (e_text) for the event
+ * @returns: the ECalendarViewEvent
+ *
+ * Get the ECalendarViewEvent for the canvas_item.
+ *
+ **/
+ECalendarViewEvent *
+ea_calendar_helpers_get_cal_view_event_from (GnomeCanvasItem *canvas_item)
+{
+ ECalendarView *cal_view;
+ gboolean event_found;
+ ECalendarViewEvent *cal_view_event;
+
+ g_return_val_if_fail (E_IS_TEXT (canvas_item), NULL);
+
+ cal_view = ea_calendar_helpers_get_cal_view_from (canvas_item);
+
+ if (!cal_view)
+ return NULL;
+
+ if (E_IS_DAY_VIEW (cal_view)) {
+ gint event_day, event_num;
+ EDayViewEvent *day_view_event;
+ EDayView *day_view = E_DAY_VIEW (cal_view);
+ event_found = e_day_view_find_event_from_item (day_view, canvas_item,
+ &event_day, &event_num);
+ if (!event_found)
+ return NULL;
+ if (event_day == E_DAY_VIEW_LONG_EVENT) {
+ /* a long event */
+ day_view_event = &g_array_index (day_view->long_events,
+ EDayViewEvent, event_num);
+ }
+ else {
+ /* a main canvas event */
+ day_view_event = &g_array_index (day_view->events[event_day],
+ EDayViewEvent, event_num);
+ }
+ cal_view_event = (ECalendarViewEvent *) day_view_event;
+ }
+ else if (E_IS_WEEK_VIEW (cal_view)) {
+ gint event_num, span_num;
+ EWeekViewEvent *week_view_event;
+ EWeekView *week_view = E_WEEK_VIEW (cal_view);
+ event_found = e_week_view_find_event_from_item (week_view,
+ canvas_item,
+ &event_num,
+ &span_num);
+ if (!event_found)
+ return NULL;
+
+ week_view_event = &g_array_index (week_view->events, EWeekViewEvent,
+ event_num);
+
+ cal_view_event = (ECalendarViewEvent *)week_view_event;
+ }
+ else {
+ g_return_val_if_reached (NULL);
+ }
+ return cal_view_event;
+}
diff --git a/calendar/gui/itip-bonobo-control.h b/calendar/gui/ea-calendar-helpers.h
index c79b8f7d09..a4045cd7af 100644
--- a/calendar/gui/itip-bonobo-control.h
+++ b/calendar/gui/ea-calendar-helpers.h
@@ -1,7 +1,5 @@
/*
*
- * Evolution calendar - Control for displaying iTIP mail messages
- *
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
@@ -17,18 +15,27 @@
*
*
* Authors:
- * Jesse Pavel <jpavel@ximian.com>
- * JP Rosevear <jpr@ximian.com>
+ * Bolian Yin <bolian.yin@sun.com>
*
* Copyright (C) 1999-2008 Novell, Inc. (www.novell.com)
*
*/
-#ifndef __ITIP_CONTROL_FACTORY_H__
-#define __ITIP_CONTROL_FACTORY_H__
+/* Evolution Accessibility
+ */
+
+#ifndef _EA_CALENDAR_HELPERS_H__
+#define _EA_CALENDAR_HELPERS_H__
+
+#include "ea-cal-view.h"
+
+AtkObject *
+ea_calendar_helpers_get_accessible_for (GnomeCanvasItem *canvas_item);
-#include <bonobo/bonobo-control.h>
+ECalendarView *
+ea_calendar_helpers_get_cal_view_from (GnomeCanvasItem *canvas_item);
-BonoboControl *itip_bonobo_control_new (void);
+ECalendarViewEvent *
+ea_calendar_helpers_get_cal_view_event_from (GnomeCanvasItem *canvas_item);
-#endif /* __ITIP_CONTROL_H__ */
+#endif /* _EA_CALENDAR_HELPERS_H__ */
diff --git a/calendar/gui/ea-calendar.c b/calendar/gui/ea-calendar.c
new file mode 100644
index 0000000000..dcdf8bd650
--- /dev/null
+++ b/calendar/gui/ea-calendar.c
@@ -0,0 +1,203 @@
+/*
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2 of the License, or (at your option) version 3.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with the program; if not, see <http://www.gnu.org/licenses/>
+ *
+ *
+ * Authors:
+ * Bolian Yin <bolian.yin@sun.com>
+ *
+ * Copyright (C) 1999-2008 Novell, Inc. (www.novell.com)
+ *
+ */
+
+#include <text/e-text.h>
+#include <libgnomecanvas/gnome-canvas-pixbuf.h>
+#include "ea-calendar-helpers.h"
+#include "a11y/ea-factory.h"
+#include "ea-calendar.h"
+
+#include "calendar/gui/ea-cal-view.h"
+#include "calendar/gui/ea-cal-view-event.h"
+#include "calendar/gui/ea-day-view.h"
+#include "calendar/gui/ea-day-view-main-item.h"
+#include "calendar/gui/ea-week-view.h"
+#include "calendar/gui/ea-week-view-main-item.h"
+#include "calendar/gui/ea-gnome-calendar.h"
+
+EA_FACTORY (EA_TYPE_CAL_VIEW, ea_cal_view, ea_cal_view_new)
+EA_FACTORY (EA_TYPE_DAY_VIEW, ea_day_view, ea_day_view_new)
+EA_FACTORY_GOBJECT (EA_TYPE_DAY_VIEW_MAIN_ITEM, ea_day_view_main_item, ea_day_view_main_item_new)
+EA_FACTORY (EA_TYPE_WEEK_VIEW, ea_week_view, ea_week_view_new)
+EA_FACTORY_GOBJECT (EA_TYPE_WEEK_VIEW_MAIN_ITEM, ea_week_view_main_item, ea_week_view_main_item_new)
+EA_FACTORY (EA_TYPE_GNOME_CALENDAR, ea_gnome_calendar, ea_gnome_calendar_new)
+
+static gboolean ea_calendar_focus_watcher (GSignalInvocationHint *ihint,
+ guint n_param_values,
+ const GValue *param_values,
+ gpointer data);
+
+static gpointer e_text_type, pixbuf_type, e_day_view_type, e_week_view_type;
+static gpointer e_day_view_main_item_type, e_week_view_main_item_type;
+
+void
+gnome_calendar_a11y_init (void)
+{
+ /* we only add focus watcher when accessibility is enabled
+ */
+ if (atk_get_root ()) {
+ EA_SET_FACTORY (gnome_calendar_get_type(), ea_gnome_calendar);
+
+ /* force loading some types */
+ e_text_type = g_type_class_ref (E_TYPE_TEXT);
+ pixbuf_type = g_type_class_ref (GNOME_TYPE_CANVAS_PIXBUF);
+ e_day_view_type = g_type_class_ref (e_day_view_get_type ());
+ e_week_view_type = g_type_class_ref (E_TYPE_WEEK_VIEW);
+ e_day_view_main_item_type = g_type_class_ref (e_day_view_main_item_get_type ());
+ e_week_view_main_item_type = g_type_class_ref (e_week_view_main_item_get_type ());
+
+ g_signal_add_emission_hook (g_signal_lookup ("event", E_TYPE_TEXT),
+ 0, ea_calendar_focus_watcher,
+ NULL, (GDestroyNotify) NULL);
+ g_signal_add_emission_hook (g_signal_lookup ("event", GNOME_TYPE_CANVAS_PIXBUF),
+ 0, ea_calendar_focus_watcher,
+ NULL, (GDestroyNotify) NULL);
+ g_signal_add_emission_hook (g_signal_lookup ("event-after",
+ e_day_view_get_type()),
+ 0, ea_calendar_focus_watcher,
+ NULL, (GDestroyNotify) NULL);
+ g_signal_add_emission_hook (g_signal_lookup ("event",
+ e_day_view_main_item_get_type()),
+ 0, ea_calendar_focus_watcher,
+ NULL, (GDestroyNotify) NULL);
+ g_signal_add_emission_hook (g_signal_lookup ("event-after",
+ E_TYPE_WEEK_VIEW),
+ 0, ea_calendar_focus_watcher,
+ NULL, (GDestroyNotify) NULL);
+ g_signal_add_emission_hook (g_signal_lookup ("event",
+ e_week_view_main_item_get_type()),
+ 0, ea_calendar_focus_watcher,
+ NULL, (GDestroyNotify) NULL);
+
+ }
+}
+
+void
+e_cal_view_a11y_init (void)
+{
+ EA_SET_FACTORY (e_calendar_view_get_type(), ea_cal_view);
+}
+
+void
+e_day_view_a11y_init (void)
+{
+ EA_SET_FACTORY (e_day_view_get_type(), ea_day_view);
+}
+
+void
+e_day_view_main_item_a11y_init (void)
+{
+ EA_SET_FACTORY (e_day_view_main_item_get_type (), ea_day_view_main_item);
+}
+
+void
+e_week_view_a11y_init (void)
+{
+ EA_SET_FACTORY (E_TYPE_WEEK_VIEW, ea_week_view);
+}
+
+void
+e_week_view_main_item_a11y_init (void)
+{
+ EA_SET_FACTORY (e_week_view_main_item_get_type (), ea_week_view_main_item);
+}
+
+static gboolean
+ea_calendar_focus_watcher (GSignalInvocationHint *ihint,
+ guint n_param_values,
+ const GValue *param_values,
+ gpointer data)
+{
+ GObject *object;
+ GdkEvent *event;
+ AtkObject *ea_event = NULL;
+
+ object = g_value_get_object (param_values + 0);
+ event = g_value_get_boxed (param_values + 1);
+
+ if ((E_IS_TEXT (object)) || (GNOME_IS_CANVAS_PIXBUF (object))) {
+ /* "event" signal on canvas item
+ */
+ GnomeCanvasItem *canvas_item;
+
+ canvas_item = GNOME_CANVAS_ITEM (object);
+ if (event->type == GDK_FOCUS_CHANGE) {
+ if (event->focus_change.in) {
+ ea_event =
+ ea_calendar_helpers_get_accessible_for (canvas_item);
+ if (!ea_event)
+ /* not canvas item we want */
+ return TRUE;
+
+ }
+ atk_focus_tracker_notify (ea_event);
+ }
+ }
+ else if (E_IS_DAY_VIEW (object)) {
+ EDayView *day_view = E_DAY_VIEW (object);
+ if (event->type == GDK_FOCUS_CHANGE) {
+ if (event->focus_change.in) {
+ /* give main item chance to emit focus */
+ gnome_canvas_item_grab_focus (day_view->main_canvas_item);
+ }
+ }
+ }
+ else if (E_IS_DAY_VIEW_MAIN_ITEM (object)) {
+ if (event->type == GDK_FOCUS_CHANGE) {
+ if (event->focus_change.in) {
+ /* we should emit focus on main item */
+ ea_event = atk_gobject_accessible_for_object (object);
+ }
+ else
+ /* focus out */
+ ea_event = NULL;
+#ifdef ACC_DEBUG
+ printf ("EvoAcc: focus notify on day main item %p\n", (gpointer)object);
+#endif
+ atk_focus_tracker_notify (ea_event);
+ }
+ } else if (E_IS_WEEK_VIEW (object)) {
+ EWeekView *week_view = E_WEEK_VIEW (object);
+ if (event->type == GDK_FOCUS_CHANGE) {
+ if (event->focus_change.in) {
+ /* give main item chance to emit focus */
+ gnome_canvas_item_grab_focus (week_view->main_canvas_item);
+ }
+ }
+ }
+ else if (E_IS_WEEK_VIEW_MAIN_ITEM (object)) {
+ if (event->type == GDK_FOCUS_CHANGE) {
+ if (event->focus_change.in) {
+ /* we should emit focus on main item */
+ ea_event = atk_gobject_accessible_for_object (object);
+ }
+ else
+ /* focus out */
+ ea_event = NULL;
+#ifdef ACC_DEBUG
+ printf ("EvoAcc: focus notify on week main item %p\n", (gpointer)object);
+#endif
+ atk_focus_tracker_notify (ea_event);
+ }
+ }
+ return TRUE;
+}
diff --git a/calendar/gui/control-factory.h b/calendar/gui/ea-calendar.h
index c79d70b5ba..b2238ffdbc 100644
--- a/calendar/gui/control-factory.h
+++ b/calendar/gui/ea-calendar.h
@@ -15,17 +15,23 @@
*
*
* Authors:
- * Ettore Perazzoli <ettore@ximian.com>
+ * Bolian Yin <bolian.yin@sun.com>
*
* Copyright (C) 1999-2008 Novell, Inc. (www.novell.com)
*
*/
-#ifndef _CONTROL_FACTORY_H_
-#define _CONTROL_FACTORY_H_
+/* Evolution Accessibility
+*/
-#include <bonobo/bonobo-control.h>
+#ifndef _EA_CALENDAR_H__
+#define _EA_CALENDAR_H__
-BonoboControl *control_factory_new_control (void);
+void gnome_calendar_a11y_init (void);
+void e_cal_view_a11y_init (void);
+void e_day_view_a11y_init (void);
+void e_day_view_main_item_a11y_init (void);
+void e_week_view_a11y_init (void);
+void e_week_view_main_item_a11y_init (void);
-#endif /* _CONTROL_FACTORY_H_ */
+#endif /* _EA_CALENDAR_H__ */
diff --git a/calendar/gui/ea-day-view-cell.c b/calendar/gui/ea-day-view-cell.c
new file mode 100644
index 0000000000..2d42a47fc6
--- /dev/null
+++ b/calendar/gui/ea-day-view-cell.c
@@ -0,0 +1,395 @@
+/*
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2 of the License, or (at your option) version 3.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with the program; if not, see <http://www.gnu.org/licenses/>
+ *
+ *
+ * Authors:
+ * Bolian Yin <bolian.yin@sun.com>
+ *
+ * Copyright (C) 1999-2008 Novell, Inc. (www.novell.com)
+ *
+ */
+
+#include "ea-day-view-cell.h"
+#include "ea-day-view-main-item.h"
+#include "ea-day-view.h"
+#include "a11y/ea-factory.h"
+
+/* EDayViewCell */
+
+static void e_day_view_cell_class_init (EDayViewCellClass *class);
+
+EA_FACTORY_GOBJECT (EA_TYPE_DAY_VIEW_CELL, ea_day_view_cell, ea_day_view_cell_new)
+
+GType
+e_day_view_cell_get_type (void)
+{
+ static GType type = 0;
+
+ if (!type) {
+ static GTypeInfo tinfo = {
+ sizeof (EDayViewCellClass),
+ (GBaseInitFunc) NULL, /* base init */
+ (GBaseFinalizeFunc) NULL, /* base finalize */
+ (GClassInitFunc) e_day_view_cell_class_init, /* class init */
+ (GClassFinalizeFunc) NULL, /* class finalize */
+ NULL, /* class data */
+ sizeof (EDayViewCell), /* instance size */
+ 0, /* nb preallocs */
+ (GInstanceInitFunc) NULL, /* instance init */
+ NULL /* value table */
+ };
+
+ type = g_type_register_static (G_TYPE_OBJECT,
+ "EDayViewCell", &tinfo, 0);
+ }
+
+ return type;
+}
+
+static void
+e_day_view_cell_class_init (EDayViewCellClass *class)
+{
+ EA_SET_FACTORY (e_day_view_cell_get_type (), ea_day_view_cell);
+}
+
+EDayViewCell *
+e_day_view_cell_new (EDayView *day_view, gint row, gint column)
+{
+ GObject *object;
+ EDayViewCell *cell;
+
+ g_return_val_if_fail (E_IS_DAY_VIEW (day_view), NULL);
+
+ object = g_object_new (E_TYPE_DAY_VIEW_CELL, NULL);
+ cell = E_DAY_VIEW_CELL (object);
+ cell->day_view = day_view;
+ cell->row = row;
+ cell->column = column;
+
+#ifdef ACC_DEBUG
+ printf ("EvoAcc: e_day_view_cell created %p\n", (gpointer)cell);
+#endif
+
+ return cell;
+}
+
+/* EaDayViewCell */
+
+static void ea_day_view_cell_class_init (EaDayViewCellClass *klass);
+
+static G_CONST_RETURN gchar * ea_day_view_cell_get_name (AtkObject *accessible);
+static G_CONST_RETURN gchar * ea_day_view_cell_get_description (AtkObject *accessible);
+static AtkStateSet* ea_day_view_cell_ref_state_set (AtkObject *obj);
+static AtkObject * ea_day_view_cell_get_parent (AtkObject *accessible);
+static gint ea_day_view_cell_get_index_in_parent (AtkObject *accessible);
+
+/* component interface */
+static void atk_component_interface_init (AtkComponentIface *iface);
+static void component_interface_get_extents (AtkComponent *component,
+ gint *x, gint *y,
+ gint *width, gint *height,
+ AtkCoordType coord_type);
+static gboolean component_interface_grab_focus (AtkComponent *component);
+
+static gpointer parent_class = NULL;
+
+#ifdef ACC_DEBUG
+static gint n_ea_day_view_cell_created = 0, n_ea_day_view_cell_destroyed = 0;
+static void ea_day_view_cell_finalize (GObject *object);
+#endif
+
+GType
+ea_day_view_cell_get_type (void)
+{
+ static GType type = 0;
+
+ if (!type) {
+ static GTypeInfo tinfo = {
+ sizeof (EaDayViewCellClass),
+ (GBaseInitFunc) NULL, /* base init */
+ (GBaseFinalizeFunc) NULL, /* base finalize */
+ (GClassInitFunc) ea_day_view_cell_class_init, /* class init */
+ (GClassFinalizeFunc) NULL, /* class finalize */
+ NULL, /* class data */
+ sizeof (EaDayViewCell), /* instance size */
+ 0, /* nb preallocs */
+ (GInstanceInitFunc) NULL, /* instance init */
+ NULL /* value table */
+ };
+
+ static const GInterfaceInfo atk_component_info = {
+ (GInterfaceInitFunc) atk_component_interface_init,
+ (GInterfaceFinalizeFunc) NULL,
+ NULL
+ };
+
+ type = g_type_register_static (ATK_TYPE_GOBJECT_ACCESSIBLE,
+ "EaDayViewCell", &tinfo, 0);
+ g_type_add_interface_static (type, ATK_TYPE_COMPONENT,
+ &atk_component_info);
+ }
+
+ return type;
+}
+
+static void
+ea_day_view_cell_class_init (EaDayViewCellClass *klass)
+{
+ AtkObjectClass *class = ATK_OBJECT_CLASS (klass);
+
+#ifdef ACC_DEBUG
+ GObjectClass *gobject_class = G_OBJECT_CLASS (klass);
+ gobject_class->finalize = ea_day_view_cell_finalize;
+#endif
+
+ parent_class = g_type_class_peek_parent (klass);
+
+ class->get_name = ea_day_view_cell_get_name;
+ class->get_description = ea_day_view_cell_get_description;
+ class->ref_state_set = ea_day_view_cell_ref_state_set;
+
+ class->get_parent = ea_day_view_cell_get_parent;
+ class->get_index_in_parent = ea_day_view_cell_get_index_in_parent;
+}
+
+AtkObject*
+ea_day_view_cell_new (GObject *obj)
+{
+ gpointer object;
+ AtkObject *atk_object;
+
+ g_return_val_if_fail (E_IS_DAY_VIEW_CELL (obj), NULL);
+
+ object = g_object_new (EA_TYPE_DAY_VIEW_CELL, NULL);
+ atk_object = ATK_OBJECT (object);
+ atk_object_initialize (atk_object, obj);
+ atk_object->role = ATK_ROLE_UNKNOWN;
+
+#ifdef ACC_DEBUG
+ ++n_ea_day_view_cell_created;
+ printf ("ACC_DEBUG: n_ea_day_view_cell_created = %d\n",
+ n_ea_day_view_cell_created);
+#endif
+ return atk_object;
+}
+
+#ifdef ACC_DEBUG
+static void ea_day_view_cell_finalize (GObject *object)
+{
+ G_OBJECT_CLASS (parent_class)->finalize (object);
+
+ ++n_ea_day_view_cell_destroyed;
+ printf ("ACC_DEBUG: n_ea_day_view_cell_destroyed = %d\n",
+ n_ea_day_view_cell_destroyed);
+}
+#endif
+
+static G_CONST_RETURN gchar *
+ea_day_view_cell_get_name (AtkObject *accessible)
+{
+ AtkGObjectAccessible *atk_gobj;
+ GObject *g_obj;
+ EDayViewCell *cell;
+
+ g_return_val_if_fail (EA_IS_DAY_VIEW_CELL (accessible), NULL);
+
+ if (!accessible->name) {
+ AtkObject *ea_main_item;
+ GnomeCanvasItem *main_item;
+ gchar *new_name = g_strdup ("");
+ const gchar *row_label, *column_label;
+
+ atk_gobj = ATK_GOBJECT_ACCESSIBLE (accessible);
+ g_obj = atk_gobject_accessible_get_object (atk_gobj);
+ if (!g_obj)
+ return NULL;
+
+ cell = E_DAY_VIEW_CELL (g_obj);
+ main_item = cell->day_view->main_canvas_item;
+ ea_main_item = atk_gobject_accessible_for_object (G_OBJECT (main_item));
+ column_label = atk_table_get_column_description (ATK_TABLE (ea_main_item),
+ cell->column);
+ row_label = atk_table_get_row_description (ATK_TABLE (ea_main_item),
+ cell->row);
+ new_name = g_strconcat (column_label, " ", row_label, NULL);
+ ATK_OBJECT_CLASS (parent_class)->set_name (accessible, new_name);
+ g_free (new_name);
+ }
+ return accessible->name;
+}
+
+static G_CONST_RETURN gchar *
+ea_day_view_cell_get_description (AtkObject *accessible)
+{
+ return ea_day_view_cell_get_name (accessible);
+}
+
+static AtkStateSet*
+ea_day_view_cell_ref_state_set (AtkObject *obj)
+{
+ AtkStateSet *state_set;
+ GObject *g_obj;
+ AtkObject *parent;
+ gint x, y, width, height;
+ gint parent_x, parent_y, parent_width, parent_height;
+
+ state_set = ATK_OBJECT_CLASS (parent_class)->ref_state_set (obj);
+ g_obj = atk_gobject_accessible_get_object (ATK_GOBJECT_ACCESSIBLE(obj));
+ if (!g_obj)
+ return state_set;
+
+ atk_state_set_add_state (state_set, ATK_STATE_SELECTABLE);
+
+ parent = atk_object_get_parent (obj);
+ atk_component_get_extents (ATK_COMPONENT (obj), &x, &y,
+ &width, &height, ATK_XY_WINDOW);
+ atk_component_get_extents (ATK_COMPONENT (parent), &parent_x, &parent_y,
+ &parent_width, &parent_height, ATK_XY_WINDOW);
+
+ if (x + width < parent_x || x > parent_x + parent_width ||
+ y + height < parent_y || y > parent_y + parent_height)
+ /* the cell is out of the main canvas */
+ ;
+ else
+ atk_state_set_add_state (state_set, ATK_STATE_VISIBLE);
+
+ return state_set;
+}
+
+static AtkObject *
+ea_day_view_cell_get_parent (AtkObject *accessible)
+{
+ AtkGObjectAccessible *atk_gobj;
+ GObject *g_obj;
+ EDayViewCell *cell;
+
+ g_return_val_if_fail (EA_IS_DAY_VIEW_CELL (accessible), NULL);
+
+ atk_gobj = ATK_GOBJECT_ACCESSIBLE (accessible);
+ g_obj = atk_gobject_accessible_get_object (atk_gobj);
+ if (!g_obj)
+ return NULL;
+
+ cell = E_DAY_VIEW_CELL (g_obj);
+ return atk_gobject_accessible_for_object (G_OBJECT (cell->day_view->main_canvas_item));
+}
+
+static gint
+ea_day_view_cell_get_index_in_parent (AtkObject *accessible)
+{
+ AtkGObjectAccessible *atk_gobj;
+ GObject *g_obj;
+ EDayViewCell *cell;
+ AtkObject *parent;
+
+ g_return_val_if_fail (EA_IS_DAY_VIEW_CELL (accessible), -1);
+
+ atk_gobj = ATK_GOBJECT_ACCESSIBLE (accessible);
+ g_obj = atk_gobject_accessible_get_object (atk_gobj);
+ if (!g_obj)
+ return -1;
+
+ cell = E_DAY_VIEW_CELL (g_obj);
+ parent = atk_object_get_parent (accessible);
+ return atk_table_get_index_at (ATK_TABLE (parent),
+ cell->row, cell->column);
+}
+
+/* Atk Component Interface */
+
+static void
+atk_component_interface_init (AtkComponentIface *iface)
+{
+ g_return_if_fail (iface != NULL);
+
+ iface->get_extents = component_interface_get_extents;
+ iface->grab_focus = component_interface_grab_focus;
+}
+
+static void
+component_interface_get_extents (AtkComponent *component,
+ gint *x, gint *y, gint *width, gint *height,
+ AtkCoordType coord_type)
+{
+ GObject *g_obj;
+ AtkObject *atk_obj;
+ EDayViewCell *cell;
+ EDayView *day_view;
+ GtkWidget *main_canvas;
+ gint day_view_width, day_view_height;
+ gint scroll_x, scroll_y;
+
+ *x = *y = *width = *height = 0;
+
+ g_return_if_fail (EA_IS_DAY_VIEW_CELL (component));
+
+ g_obj = atk_gobject_accessible_get_object (ATK_GOBJECT_ACCESSIBLE(component));
+ if (!g_obj)
+ /* defunct object*/
+ return;
+
+ cell = E_DAY_VIEW_CELL (g_obj);
+ day_view = cell->day_view;
+ main_canvas = cell->day_view->main_canvas;
+
+ atk_obj = atk_gobject_accessible_for_object (G_OBJECT (main_canvas));
+ atk_component_get_extents (ATK_COMPONENT (atk_obj),
+ x, y,
+ &day_view_width, &day_view_height,
+ coord_type);
+ gnome_canvas_get_scroll_offsets (GNOME_CANVAS (day_view->main_canvas),
+ &scroll_x, &scroll_y);
+ *x += day_view->day_offsets[cell->column] - scroll_x;
+ *y += day_view->row_height * cell->row
+ - scroll_y;
+ *width = day_view->day_widths[cell->column];
+ *height = day_view->row_height;
+}
+
+static gboolean
+component_interface_grab_focus (AtkComponent *comp)
+{
+ GObject *g_obj;
+ EDayViewCell *cell;
+ EDayView *day_view;
+ GtkWidget *toplevel;
+
+ g_return_val_if_fail (EA_IS_DAY_VIEW_CELL (comp), FALSE);
+
+ g_obj = atk_gobject_accessible_get_object (ATK_GOBJECT_ACCESSIBLE (comp));
+ if (!g_obj)
+ return FALSE;
+
+ cell = E_DAY_VIEW_CELL (g_obj);
+ day_view = cell->day_view;
+
+ day_view->selection_start_day = cell->column;
+ day_view->selection_end_day = cell->column;
+ day_view->selection_start_row = cell->row;
+ day_view->selection_end_row = cell->row;
+
+ e_day_view_ensure_rows_visible (day_view,
+ day_view->selection_start_row,
+ day_view->selection_end_row);
+ e_day_view_update_calendar_selection_time (day_view);
+ gtk_widget_queue_draw (day_view->main_canvas);
+
+ toplevel = gtk_widget_get_toplevel (GTK_WIDGET (day_view));
+ if (GTK_WIDGET_TOPLEVEL (toplevel))
+ gtk_window_present (GTK_WINDOW (toplevel));
+
+ return TRUE;
+}
+
diff --git a/calendar/gui/ea-day-view-cell.h b/calendar/gui/ea-day-view-cell.h
new file mode 100644
index 0000000000..669fb1abae
--- /dev/null
+++ b/calendar/gui/ea-day-view-cell.h
@@ -0,0 +1,85 @@
+/*
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2 of the License, or (at your option) version 3.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with the program; if not, see <http://www.gnu.org/licenses/>
+ *
+ *
+ * Authors:
+ * Bolian Yin <bolian.yin@sun.com>
+ *
+ * Copyright (C) 1999-2008 Novell, Inc. (www.novell.com)
+ *
+ */
+
+#ifndef __EA_DAY_VIEW_CELL_H__
+#define __EA_DAY_VIEW_CELL_H__
+
+#include <atk/atkgobjectaccessible.h>
+#include "e-day-view.h"
+
+G_BEGIN_DECLS
+
+#define E_TYPE_DAY_VIEW_CELL (e_day_view_cell_get_type ())
+#define E_DAY_VIEW_CELL(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), E_TYPE_DAY_VIEW_CELL, EDayViewCell))
+#define E_DAY_VIEW_CELL_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), E_TYPE_DAY_VIEW_CELL, EDayViewCellClass))
+#define E_IS_DAY_VIEW_CELL(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), E_TYPE_DAY_VIEW_CELL))
+#define E_IS_DAY_VIEW_CELL_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), E_TYPE_DAY_VIEW_CELL))
+#define E_DAY_VIEW_CELL_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), E_TYPE_DAY_VIEW_CELL, EDayViewCellClass))
+
+typedef struct _EDayViewCell EDayViewCell;
+typedef struct _EDayViewCellClass EDayViewCellClass;
+
+struct _EDayViewCell
+{
+ GObject parent;
+ EDayView *day_view;
+ gint row;
+ gint column;
+};
+
+GType e_day_view_cell_get_type (void);
+
+struct _EDayViewCellClass
+{
+ GObjectClass parent_class;
+};
+
+EDayViewCell * e_day_view_cell_new (EDayView *day_view, gint row, gint column);
+
+#define EA_TYPE_DAY_VIEW_CELL (ea_day_view_cell_get_type ())
+#define EA_DAY_VIEW_CELL(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), EA_TYPE_DAY_VIEW_CELL, EaDayViewCell))
+#define EA_DAY_VIEW_CELL_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), EA_TYPE_DAY_VIEW_CELL, EaDayViewCellClass))
+#define EA_IS_DAY_VIEW_CELL(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), EA_TYPE_DAY_VIEW_CELL))
+#define EA_IS_DAY_VIEW_CELL_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), EA_TYPE_DAY_VIEW_CELL))
+#define EA_DAY_VIEW_CELL_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), EA_TYPE_DAY_VIEW_CELL, EaDayViewCellClass))
+
+typedef struct _EaDayViewCell EaDayViewCell;
+typedef struct _EaDayViewCellClass EaDayViewCellClass;
+
+struct _EaDayViewCell
+{
+ AtkGObjectAccessible parent;
+};
+
+GType ea_day_view_cell_get_type (void);
+
+struct _EaDayViewCellClass
+{
+ AtkGObjectAccessibleClass parent_class;
+};
+
+AtkObject* ea_day_view_cell_new (GObject *gobj);
+
+G_END_DECLS
+
+#endif /* __EA_DAY_VIEW_CELL_H__ */
diff --git a/calendar/gui/ea-day-view-main-item.c b/calendar/gui/ea-day-view-main-item.c
new file mode 100644
index 0000000000..89b6f1a57b
--- /dev/null
+++ b/calendar/gui/ea-day-view-main-item.c
@@ -0,0 +1,1288 @@
+/*
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2 of the License, or (at your option) version 3.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with the program; if not, see <http://www.gnu.org/licenses/>
+ *
+ *
+ * Authors:
+ * Bolian Yin <bolian.yin@sun.com>
+ *
+ * Copyright (C) 1999-2008 Novell, Inc. (www.novell.com)
+ *
+ */
+
+#include "ea-day-view-main-item.h"
+#include "e-day-view-top-item.h"
+#include "ea-day-view.h"
+#include "ea-day-view-cell.h"
+#include "ea-cell-table.h"
+#include <glib/gi18n.h>
+
+/* EaDayViewMainItem */
+static void ea_day_view_main_item_class_init (EaDayViewMainItemClass *klass);
+
+static void ea_day_view_main_item_finalize (GObject *object);
+static G_CONST_RETURN gchar * ea_day_view_main_item_get_name (AtkObject *accessible);
+static G_CONST_RETURN gchar * ea_day_view_main_item_get_description (AtkObject *accessible);
+
+static gint ea_day_view_main_item_get_n_children (AtkObject *obj);
+static AtkObject* ea_day_view_main_item_ref_child (AtkObject *obj,
+ gint i);
+static AtkObject * ea_day_view_main_item_get_parent (AtkObject *accessible);
+static gint ea_day_view_main_item_get_index_in_parent (AtkObject *accessible);
+
+/* callbacks */
+static void ea_day_view_main_item_dates_change_cb (GnomeCalendar *gcal, gpointer data);
+static void ea_day_view_main_item_time_change_cb (EDayView *day_view, gpointer data);
+
+/* component interface */
+static void atk_component_interface_init (AtkComponentIface *iface);
+static void component_interface_get_extents (AtkComponent *component,
+ gint *x, gint *y,
+ gint *width, gint *height,
+ AtkCoordType coord_type);
+/* atk table interface */
+static void atk_table_interface_init (AtkTableIface *iface);
+static gint table_interface_get_index_at (AtkTable *table,
+ gint row,
+ gint column);
+static gint table_interface_get_column_at_index (AtkTable *table,
+ gint index);
+static gint table_interface_get_row_at_index (AtkTable *table,
+ gint index);
+static AtkObject* table_interface_ref_at (AtkTable *table,
+ gint row,
+ gint column);
+static gint table_interface_get_n_rows (AtkTable *table);
+static gint table_interface_get_n_columns (AtkTable *table);
+static gint table_interface_get_column_extent_at (AtkTable *table,
+ gint row,
+ gint column);
+static gint table_interface_get_row_extent_at (AtkTable *table,
+ gint row,
+ gint column);
+
+static gboolean table_interface_is_row_selected (AtkTable *table,
+ gint row);
+static gboolean table_interface_is_column_selected (AtkTable *table,
+ gint row);
+static gboolean table_interface_is_selected (AtkTable *table,
+ gint row,
+ gint column);
+static gint table_interface_get_selected_rows (AtkTable *table,
+ gint **rows_selected);
+static gint table_interface_get_selected_columns (AtkTable *table,
+ gint **columns_selected);
+static gboolean table_interface_add_row_selection (AtkTable *table, gint row);
+static gboolean table_interface_remove_row_selection (AtkTable *table,
+ gint row);
+static gboolean table_interface_add_column_selection (AtkTable *table,
+ gint column);
+static gboolean table_interface_remove_column_selection (AtkTable *table,
+ gint column);
+static AtkObject* table_interface_get_row_header (AtkTable *table, gint row);
+static AtkObject* table_interface_get_column_header (AtkTable *table,
+ gint in_col);
+static AtkObject* table_interface_get_caption (AtkTable *table);
+
+static G_CONST_RETURN gchar *
+table_interface_get_column_description (AtkTable *table, gint in_col);
+
+static G_CONST_RETURN gchar *
+table_interface_get_row_description (AtkTable *table, gint row);
+
+static AtkObject* table_interface_get_summary (AtkTable *table);
+
+/* atk selection interface */
+static void atk_selection_interface_init (AtkSelectionIface *iface);
+static gboolean selection_interface_add_selection (AtkSelection *selection,
+ gint i);
+static gboolean selection_interface_clear_selection (AtkSelection *selection);
+static AtkObject* selection_interface_ref_selection (AtkSelection *selection,
+ gint i);
+static gint selection_interface_get_selection_count (AtkSelection *selection);
+static gboolean selection_interface_is_child_selected (AtkSelection *selection,
+ gint i);
+
+/* helpers */
+static EaCellTable *
+ea_day_view_main_item_get_cell_data (EaDayViewMainItem *ea_main_item);
+
+static void
+ea_day_view_main_item_destory_cell_data (EaDayViewMainItem *ea_main_item);
+
+static gint
+ea_day_view_main_item_get_child_index_at (EaDayViewMainItem *ea_main_item,
+ gint row, gint column);
+static gint
+ea_day_view_main_item_get_row_at_index (EaDayViewMainItem *ea_main_item,
+ gint index);
+static gint
+ea_day_view_main_item_get_column_at_index (EaDayViewMainItem *ea_main_item,
+ gint index);
+static gint
+ea_day_view_main_item_get_row_label (EaDayViewMainItem *ea_main_item,
+ gint row, gchar *buffer,
+ gint buffer_size);
+
+#ifdef ACC_DEBUG
+static gint n_ea_day_view_main_item_created = 0;
+static gint n_ea_day_view_main_item_destroyed = 0;
+#endif
+
+static gpointer parent_class = NULL;
+
+GType
+ea_day_view_main_item_get_type (void)
+{
+ static GType type = 0;
+ AtkObjectFactory *factory;
+ GTypeQuery query;
+ GType derived_atk_type;
+
+ if (!type) {
+ static GTypeInfo tinfo = {
+ sizeof (EaDayViewMainItemClass),
+ (GBaseInitFunc) NULL, /* base init */
+ (GBaseFinalizeFunc) NULL, /* base finalize */
+ (GClassInitFunc) ea_day_view_main_item_class_init,
+ (GClassFinalizeFunc) NULL, /* class finalize */
+ NULL, /* class data */
+ sizeof (EaDayViewMainItem), /* instance size */
+ 0, /* nb preallocs */
+ (GInstanceInitFunc) NULL, /* instance init */
+ NULL /* value table */
+ };
+
+ static const GInterfaceInfo atk_component_info = {
+ (GInterfaceInitFunc) atk_component_interface_init,
+ (GInterfaceFinalizeFunc) NULL,
+ NULL
+ };
+
+ static const GInterfaceInfo atk_table_info = {
+ (GInterfaceInitFunc) atk_table_interface_init,
+ (GInterfaceFinalizeFunc) NULL,
+ NULL
+ };
+ static const GInterfaceInfo atk_selection_info = {
+ (GInterfaceInitFunc) atk_selection_interface_init,
+ (GInterfaceFinalizeFunc) NULL,
+ NULL
+ };
+
+ /*
+ * Figure out the size of the class and instance
+ * we are run-time deriving from (GailCanvasItem, in this case)
+ *
+ */
+
+ factory = atk_registry_get_factory (atk_get_default_registry (),
+ e_day_view_main_item_get_type());
+ derived_atk_type = atk_object_factory_get_accessible_type (factory);
+ g_type_query (derived_atk_type, &query);
+
+ tinfo.class_size = query.class_size;
+ tinfo.instance_size = query.instance_size;
+
+ type = g_type_register_static (derived_atk_type,
+ "EaDayViewMainItem", &tinfo, 0);
+ g_type_add_interface_static (type, ATK_TYPE_COMPONENT,
+ &atk_component_info);
+ g_type_add_interface_static (type, ATK_TYPE_TABLE,
+ &atk_table_info);
+ g_type_add_interface_static (type, ATK_TYPE_SELECTION,
+ &atk_selection_info);
+ }
+
+ return type;
+}
+
+static void
+ea_day_view_main_item_class_init (EaDayViewMainItemClass *klass)
+{
+ GObjectClass *gobject_class = G_OBJECT_CLASS (klass);
+ AtkObjectClass *class = ATK_OBJECT_CLASS (klass);
+
+ gobject_class->finalize = ea_day_view_main_item_finalize;
+ parent_class = g_type_class_peek_parent (klass);
+
+ class->get_name = ea_day_view_main_item_get_name;
+ class->get_description = ea_day_view_main_item_get_description;
+
+ class->get_n_children = ea_day_view_main_item_get_n_children;
+ class->ref_child = ea_day_view_main_item_ref_child;
+ class->get_parent = ea_day_view_main_item_get_parent;
+ class->get_index_in_parent = ea_day_view_main_item_get_index_in_parent;
+}
+
+AtkObject*
+ea_day_view_main_item_new (GObject *obj)
+{
+ AtkObject *accessible;
+ GnomeCalendar *gcal;
+ EDayViewMainItem *main_item;
+
+ g_return_val_if_fail (E_IS_DAY_VIEW_MAIN_ITEM (obj), NULL);
+
+ accessible = ATK_OBJECT (g_object_new (EA_TYPE_DAY_VIEW_MAIN_ITEM,
+ NULL));
+
+ atk_object_initialize (accessible, obj);
+ accessible->role = ATK_ROLE_TABLE;
+
+#ifdef ACC_DEBUG
+ ++n_ea_day_view_main_item_created;
+ printf ("ACC_DEBUG: n_ea_day_view_main_item_created = %d\n",
+ n_ea_day_view_main_item_created);
+#endif
+ main_item = E_DAY_VIEW_MAIN_ITEM (obj);
+ g_signal_connect (main_item->day_view, "selected_time_changed",
+ G_CALLBACK (ea_day_view_main_item_time_change_cb),
+ accessible);
+
+ /* listen for date changes of calendar */
+ gcal = e_calendar_view_get_calendar (E_CALENDAR_VIEW (main_item->day_view));
+ if (gcal)
+ g_signal_connect (gcal, "dates_shown_changed",
+ G_CALLBACK (ea_day_view_main_item_dates_change_cb),
+ accessible);
+
+ return accessible;
+}
+
+static void
+ea_day_view_main_item_finalize (GObject *object)
+{
+ EaDayViewMainItem *ea_main_item;
+
+ g_return_if_fail (EA_IS_DAY_VIEW_MAIN_ITEM (object));
+
+ ea_main_item = EA_DAY_VIEW_MAIN_ITEM (object);
+
+ /* Free the allocated cell data */
+ ea_day_view_main_item_destory_cell_data (ea_main_item);
+
+ G_OBJECT_CLASS (parent_class)->finalize (object);
+#ifdef ACC_DEBUG
+ ++n_ea_day_view_main_item_destroyed;
+ printf ("ACC_DEBUG: n_ea_day_view_main_item_destroyed = %d\n",
+ n_ea_day_view_main_item_destroyed);
+#endif
+}
+
+static G_CONST_RETURN gchar *
+ea_day_view_main_item_get_name (AtkObject *accessible)
+{
+ AtkObject *parent;
+ g_return_val_if_fail (EA_IS_DAY_VIEW_MAIN_ITEM (accessible), NULL);
+ parent = atk_object_get_parent (accessible);
+
+ if (!parent)
+ return NULL;
+
+ return atk_object_get_name (parent);
+}
+
+static G_CONST_RETURN gchar *
+ea_day_view_main_item_get_description (AtkObject *accessible)
+{
+ return _("a table to view and select the current time range");
+}
+
+static gint
+ea_day_view_main_item_get_n_children (AtkObject *accessible)
+{
+ AtkGObjectAccessible *atk_gobj;
+ GObject *g_obj;
+ EDayViewMainItem *main_item;
+ EDayView *day_view;
+
+ g_return_val_if_fail (EA_IS_DAY_VIEW_MAIN_ITEM (accessible), -1);
+
+ atk_gobj = ATK_GOBJECT_ACCESSIBLE (accessible);
+ g_obj = atk_gobject_accessible_get_object (atk_gobj);
+ if (!g_obj)
+ return -1;
+
+ main_item = E_DAY_VIEW_MAIN_ITEM (g_obj);
+ day_view = main_item->day_view;
+
+ return day_view->rows * day_view->days_shown;
+}
+
+static AtkObject *
+ea_day_view_main_item_ref_child (AtkObject *accessible, gint index)
+{
+ AtkGObjectAccessible *atk_gobj;
+ GObject *g_obj;
+ EDayViewMainItem *main_item;
+ EDayView *day_view;
+ gint n_children;
+ EDayViewCell *cell;
+ EaCellTable *cell_data;
+ EaDayViewMainItem *ea_main_item;
+
+ g_return_val_if_fail (EA_IS_DAY_VIEW_MAIN_ITEM (accessible), NULL);
+
+ atk_gobj = ATK_GOBJECT_ACCESSIBLE (accessible);
+ g_obj = atk_gobject_accessible_get_object (atk_gobj);
+ if (!g_obj)
+ return NULL;
+
+ main_item = E_DAY_VIEW_MAIN_ITEM (g_obj);
+ day_view = main_item->day_view;
+
+ n_children = ea_day_view_main_item_get_n_children (accessible);
+ if (index < 0 || index >= n_children)
+ return NULL;
+
+ ea_main_item = EA_DAY_VIEW_MAIN_ITEM (accessible);
+ cell_data = ea_day_view_main_item_get_cell_data (ea_main_item);
+ if (!cell_data)
+ return NULL;
+
+ cell = ea_cell_table_get_cell_at_index (cell_data, index);
+ if (!cell) {
+ gint row, column;
+
+ row = ea_day_view_main_item_get_row_at_index (ea_main_item, index);
+ column = ea_day_view_main_item_get_column_at_index (ea_main_item, index);
+ cell = e_day_view_cell_new (day_view, row, column);
+ ea_cell_table_set_cell_at_index (cell_data, index, cell);
+ g_object_unref (cell);
+ }
+ return g_object_ref (atk_gobject_accessible_for_object (G_OBJECT(cell)));
+}
+
+static AtkObject *
+ea_day_view_main_item_get_parent (AtkObject *accessible)
+{
+ AtkGObjectAccessible *atk_gobj;
+ GObject *g_obj;
+ EDayViewMainItem *main_item;
+
+ g_return_val_if_fail (EA_IS_DAY_VIEW_MAIN_ITEM (accessible), NULL);
+
+ atk_gobj = ATK_GOBJECT_ACCESSIBLE (accessible);
+ g_obj = atk_gobject_accessible_get_object (atk_gobj);
+ if (!g_obj)
+ return NULL;
+
+ main_item = E_DAY_VIEW_MAIN_ITEM (g_obj);
+ return gtk_widget_get_accessible (GTK_WIDGET (main_item->day_view));
+}
+
+static gint
+ea_day_view_main_item_get_index_in_parent (AtkObject *accessible)
+{
+ AtkGObjectAccessible *atk_gobj;
+ GObject *g_obj;
+
+ g_return_val_if_fail (EA_IS_DAY_VIEW_MAIN_ITEM (accessible), -1);
+
+ atk_gobj = ATK_GOBJECT_ACCESSIBLE (accessible);
+ g_obj = atk_gobject_accessible_get_object (atk_gobj);
+ if (!g_obj)
+ return -1;
+
+ /* always the first child of ea-day-view */
+ return 0;
+}
+
+/* callbacks */
+
+static void
+ea_day_view_main_item_dates_change_cb (GnomeCalendar *gcal, gpointer data)
+{
+ EaDayViewMainItem *ea_main_item;
+
+ g_return_if_fail (GNOME_IS_CALENDAR (gcal));
+ g_return_if_fail (data);
+ g_return_if_fail (EA_IS_DAY_VIEW_MAIN_ITEM (data));
+
+ ea_main_item = EA_DAY_VIEW_MAIN_ITEM (data);
+
+#ifdef ACC_DEBUG
+ printf ("EvoAcc: ea_day_view_main_item update cb\n");
+#endif
+
+ ea_day_view_main_item_destory_cell_data (ea_main_item);
+}
+
+static void
+ea_day_view_main_item_time_change_cb (EDayView *day_view, gpointer data)
+{
+ EaDayViewMainItem *ea_main_item;
+ AtkObject *item_cell = NULL;
+
+ g_return_if_fail (E_IS_DAY_VIEW (day_view));
+ g_return_if_fail (data);
+ g_return_if_fail (EA_IS_DAY_VIEW_MAIN_ITEM (data));
+
+ ea_main_item = EA_DAY_VIEW_MAIN_ITEM (data);
+
+#ifdef ACC_DEBUG
+ printf ("EvoAcc: ea_day_view_main_item time changed cb\n");
+#endif
+ /* only deal with the first selected child, for now */
+ item_cell = atk_selection_ref_selection (ATK_SELECTION (ea_main_item),
+ 0);
+ if (item_cell) {
+ AtkStateSet *state_set;
+ state_set = atk_object_ref_state_set (item_cell);
+ atk_state_set_add_state (state_set, ATK_STATE_FOCUSED);
+ g_object_unref (state_set);
+
+ g_signal_emit_by_name (ea_main_item,
+ "active-descendant-changed",
+ item_cell);
+ g_signal_emit_by_name (data, "selection_changed");
+
+ atk_focus_tracker_notify (item_cell);
+ g_object_unref (item_cell);
+ }
+
+}
+
+/* helpers */
+
+static gint
+ea_day_view_main_item_get_child_index_at (EaDayViewMainItem *ea_main_item,
+ gint row, gint column)
+{
+ AtkGObjectAccessible *atk_gobj;
+ GObject *g_obj;
+ EDayViewMainItem *main_item;
+ EDayView *day_view;
+
+ g_return_val_if_fail (ea_main_item, -1);
+
+ atk_gobj = ATK_GOBJECT_ACCESSIBLE (ea_main_item);
+ g_obj = atk_gobject_accessible_get_object (atk_gobj);
+ if (!g_obj)
+ return -1;
+
+ main_item = E_DAY_VIEW_MAIN_ITEM (g_obj);
+ day_view = main_item->day_view;
+
+ if (row >= 0 && row < day_view->rows &&
+ column >= 0 && column < day_view->days_shown)
+ return column * day_view->rows + row;
+ return -1;
+}
+
+static gint
+ea_day_view_main_item_get_row_at_index (EaDayViewMainItem *ea_main_item,
+ gint index)
+{
+ AtkGObjectAccessible *atk_gobj;
+ GObject *g_obj;
+ EDayViewMainItem *main_item;
+ EDayView *day_view;
+ gint n_children;
+
+ g_return_val_if_fail (ea_main_item, -1);
+
+ atk_gobj = ATK_GOBJECT_ACCESSIBLE (ea_main_item);
+ g_obj = atk_gobject_accessible_get_object (atk_gobj);
+ if (!g_obj)
+ return -1;
+
+ main_item = E_DAY_VIEW_MAIN_ITEM (g_obj);
+ day_view = main_item->day_view;
+
+ n_children = ea_day_view_main_item_get_n_children (ATK_OBJECT (ea_main_item));
+ if (index >= 0 && index < n_children)
+ return index % day_view->rows;
+ return -1;
+}
+
+static gint
+ea_day_view_main_item_get_column_at_index (EaDayViewMainItem *ea_main_item,
+ gint index)
+{
+ AtkGObjectAccessible *atk_gobj;
+ GObject *g_obj;
+ EDayViewMainItem *main_item;
+ EDayView *day_view;
+ gint n_children;
+
+ g_return_val_if_fail (ea_main_item, -1);
+
+ atk_gobj = ATK_GOBJECT_ACCESSIBLE (ea_main_item);
+ g_obj = atk_gobject_accessible_get_object (atk_gobj);
+ if (!g_obj)
+ return -1;
+
+ main_item = E_DAY_VIEW_MAIN_ITEM (g_obj);
+ day_view = main_item->day_view;
+
+ n_children = ea_day_view_main_item_get_n_children (ATK_OBJECT (ea_main_item));
+ if (index >= 0 && index < n_children)
+ return index / day_view->rows;
+ return -1;
+}
+
+static gint
+ea_day_view_main_item_get_row_label (EaDayViewMainItem *ea_main_item,
+ gint row, gchar *buffer, gint buffer_size)
+{
+ AtkGObjectAccessible *atk_gobj;
+ GObject *g_obj;
+ EDayViewMainItem *main_item;
+ EDayView *day_view;
+ const gchar *suffix;
+ gint hour, minute, suffix_width;
+
+ g_return_val_if_fail (ea_main_item, 0);
+
+ atk_gobj = ATK_GOBJECT_ACCESSIBLE (ea_main_item);
+ g_obj = atk_gobject_accessible_get_object (atk_gobj);
+ if (!g_obj)
+ return 0;
+
+ main_item = E_DAY_VIEW_MAIN_ITEM (g_obj);
+ day_view = main_item->day_view;
+
+ hour = day_view->first_hour_shown;
+ minute = day_view->first_minute_shown;
+ minute += row * day_view->mins_per_row;
+ hour = (hour + minute / 60) % 24;
+ minute %= 60;
+
+ e_day_view_convert_time_to_display (day_view, hour, &hour,
+ &suffix, &suffix_width);
+ return g_snprintf (buffer, buffer_size, "%i:%02i %s",
+ hour, minute, suffix);
+}
+
+static EaCellTable *
+ea_day_view_main_item_get_cell_data (EaDayViewMainItem *ea_main_item)
+{
+ AtkGObjectAccessible *atk_gobj;
+ GObject *g_obj;
+ EDayViewMainItem *main_item;
+ EDayView *day_view;
+ EaCellTable *cell_data;
+
+ g_return_val_if_fail (ea_main_item, NULL);
+
+ atk_gobj = ATK_GOBJECT_ACCESSIBLE (ea_main_item);
+ g_obj = atk_gobject_accessible_get_object (atk_gobj);
+ if (!g_obj)
+ return NULL;
+
+ main_item = E_DAY_VIEW_MAIN_ITEM (g_obj);
+ day_view = main_item->day_view;
+
+ cell_data = g_object_get_data (G_OBJECT(ea_main_item),
+ "ea-day-view-cell-table");
+ if (!cell_data) {
+ cell_data = ea_cell_table_create (day_view->rows,
+ day_view->days_shown, TRUE);
+ g_object_set_data (G_OBJECT(ea_main_item),
+ "ea-day-view-cell-table", cell_data);
+ }
+ return cell_data;
+}
+
+static void
+ea_day_view_main_item_destory_cell_data (EaDayViewMainItem *ea_main_item)
+{
+ EaCellTable *cell_data;
+
+ g_return_if_fail (ea_main_item);
+
+ cell_data = g_object_get_data (G_OBJECT(ea_main_item),
+ "ea-day-view-cell-table");
+ if (cell_data) {
+ g_object_set_data (G_OBJECT(ea_main_item),
+ "ea-day-view-cell-table", NULL);
+ ea_cell_table_destroy (cell_data);
+ }
+}
+
+/* Atk Component Interface */
+
+static void
+atk_component_interface_init (AtkComponentIface *iface)
+{
+ g_return_if_fail (iface != NULL);
+
+ iface->get_extents = component_interface_get_extents;
+}
+
+static void
+component_interface_get_extents (AtkComponent *component,
+ gint *x, gint *y, gint *width, gint *height,
+ AtkCoordType coord_type)
+{
+ GObject *g_obj;
+ AtkObject *ea_canvas;
+ EDayViewMainItem *main_item;
+ EDayView *day_view;
+
+ *x = *y = *width = *height = 0;
+
+ g_return_if_fail (EA_IS_DAY_VIEW_MAIN_ITEM (component));
+
+ g_obj = atk_gobject_accessible_get_object (ATK_GOBJECT_ACCESSIBLE(component));
+ if (!g_obj)
+ /* defunct object*/
+ return;
+ main_item = E_DAY_VIEW_MAIN_ITEM (g_obj);
+ day_view = main_item->day_view;
+
+ ea_canvas = gtk_widget_get_accessible (day_view->main_canvas);
+ atk_component_get_extents (ATK_COMPONENT (ea_canvas), x, y,
+ width, height, coord_type);
+}
+
+/* atk table interface */
+
+static void
+atk_table_interface_init (AtkTableIface *iface)
+{
+ g_return_if_fail (iface != NULL);
+
+ iface->ref_at = table_interface_ref_at;
+
+ iface->get_n_rows = table_interface_get_n_rows;
+ iface->get_n_columns = table_interface_get_n_columns;
+ iface->get_index_at = table_interface_get_index_at;
+ iface->get_column_at_index = table_interface_get_column_at_index;
+ iface->get_row_at_index = table_interface_get_row_at_index;
+ iface->get_column_extent_at = table_interface_get_column_extent_at;
+ iface->get_row_extent_at = table_interface_get_row_extent_at;
+
+ iface->is_selected = table_interface_is_selected;
+ iface->get_selected_rows = table_interface_get_selected_rows;
+ iface->get_selected_columns = table_interface_get_selected_columns;
+ iface->is_row_selected = table_interface_is_row_selected;
+ iface->is_column_selected = table_interface_is_column_selected;
+ iface->add_row_selection = table_interface_add_row_selection;
+ iface->remove_row_selection = table_interface_remove_row_selection;
+ iface->add_column_selection = table_interface_add_column_selection;
+ iface->remove_column_selection = table_interface_remove_column_selection;
+
+ iface->get_row_header = table_interface_get_row_header;
+ iface->get_column_header = table_interface_get_column_header;
+ iface->get_caption = table_interface_get_caption;
+ iface->get_summary = table_interface_get_summary;
+ iface->get_row_description = table_interface_get_row_description;
+ iface->get_column_description = table_interface_get_column_description;
+}
+
+static AtkObject*
+table_interface_ref_at (AtkTable *table,
+ gint row,
+ gint column)
+{
+ gint index;
+
+ EaDayViewMainItem* ea_main_item = EA_DAY_VIEW_MAIN_ITEM (table);
+ index = ea_day_view_main_item_get_child_index_at (ea_main_item,
+ row, column);
+ return ea_day_view_main_item_ref_child (ATK_OBJECT (ea_main_item), index);
+}
+
+static gint
+table_interface_get_n_rows (AtkTable *table)
+{
+ AtkGObjectAccessible *atk_gobj;
+ GObject *g_obj;
+ EDayViewMainItem *main_item;
+ EDayView *day_view;
+ EaDayViewMainItem* ea_main_item = EA_DAY_VIEW_MAIN_ITEM (table);
+
+ atk_gobj = ATK_GOBJECT_ACCESSIBLE (ea_main_item);
+ g_obj = atk_gobject_accessible_get_object (atk_gobj);
+ if (!g_obj)
+ return -1;
+
+ main_item = E_DAY_VIEW_MAIN_ITEM (g_obj);
+ day_view = main_item->day_view;
+
+ return day_view->rows;
+}
+
+static gint
+table_interface_get_n_columns (AtkTable *table)
+{
+ AtkGObjectAccessible *atk_gobj;
+ GObject *g_obj;
+ EDayViewMainItem *main_item;
+ EDayView *day_view;
+ EaDayViewMainItem* ea_main_item = EA_DAY_VIEW_MAIN_ITEM (table);
+
+ atk_gobj = ATK_GOBJECT_ACCESSIBLE (ea_main_item);
+ g_obj = atk_gobject_accessible_get_object (atk_gobj);
+ if (!g_obj)
+ return -1;
+
+ main_item = E_DAY_VIEW_MAIN_ITEM (g_obj);
+ day_view = main_item->day_view;
+
+ return day_view->days_shown;
+}
+
+static gint
+table_interface_get_index_at (AtkTable *table,
+ gint row,
+ gint column)
+{
+ EaDayViewMainItem* ea_main_item = EA_DAY_VIEW_MAIN_ITEM (table);
+ return ea_day_view_main_item_get_child_index_at (ea_main_item,
+ row, column);
+}
+
+static gint
+table_interface_get_column_at_index (AtkTable *table,
+ gint index)
+{
+ EaDayViewMainItem* ea_main_item = EA_DAY_VIEW_MAIN_ITEM (table);
+ return ea_day_view_main_item_get_column_at_index (ea_main_item, index);
+}
+
+static gint
+table_interface_get_row_at_index (AtkTable *table,
+ gint index)
+{
+ EaDayViewMainItem* ea_main_item = EA_DAY_VIEW_MAIN_ITEM (table);
+ return ea_day_view_main_item_get_row_at_index (ea_main_item, index);
+}
+
+static gint
+table_interface_get_column_extent_at (AtkTable *table,
+ gint row,
+ gint column)
+{
+ gint index;
+ gint width = 0, height = 0;
+ AtkObject *child;
+ EaDayViewMainItem* ea_main_item = EA_DAY_VIEW_MAIN_ITEM (table);
+
+ index = ea_day_view_main_item_get_child_index_at (ea_main_item,
+ row, column);
+ child = atk_object_ref_accessible_child (ATK_OBJECT (ea_main_item),
+ index);
+ if (child)
+ atk_component_get_size (ATK_COMPONENT (child),
+ &width, &height);
+
+ return width;
+}
+
+static gint
+table_interface_get_row_extent_at (AtkTable *table,
+ gint row,
+ gint column)
+{
+ gint index;
+ gint width = 0, height = 0;
+ AtkObject *child;
+ EaDayViewMainItem* ea_main_item = EA_DAY_VIEW_MAIN_ITEM (table);
+
+ index = ea_day_view_main_item_get_child_index_at (ea_main_item,
+ row, column);
+ child = atk_object_ref_accessible_child (ATK_OBJECT (ea_main_item),
+ index);
+ if (child)
+ atk_component_get_size (ATK_COMPONENT (child),
+ &width, &height);
+
+ return height;
+}
+
+static gboolean
+table_interface_is_row_selected (AtkTable *table,
+ gint row)
+{
+ AtkGObjectAccessible *atk_gobj;
+ GObject *g_obj;
+ EDayViewMainItem *main_item;
+ EDayView *day_view;
+ EaDayViewMainItem* ea_main_item = EA_DAY_VIEW_MAIN_ITEM (table);
+
+ atk_gobj = ATK_GOBJECT_ACCESSIBLE (ea_main_item);
+ g_obj = atk_gobject_accessible_get_object (atk_gobj);
+ if (!g_obj)
+ return FALSE;
+
+ main_item = E_DAY_VIEW_MAIN_ITEM (g_obj);
+ day_view = main_item->day_view;
+
+ if (day_view->selection_start_day == -1)
+ /* no selection */
+ return FALSE;
+ if (day_view->selection_start_day != day_view->selection_end_day)
+ /* all row is selected */
+ return TRUE;
+ if (row >= day_view->selection_start_row &&
+ row <= day_view->selection_end_row)
+ return TRUE;
+ return FALSE;
+}
+
+static gboolean
+table_interface_is_selected (AtkTable *table,
+ gint row,
+ gint column)
+{
+ return table_interface_is_row_selected (table, row) &&
+ table_interface_is_column_selected (table, column);
+}
+
+static gboolean
+table_interface_is_column_selected (AtkTable *table,
+ gint column)
+{
+ AtkGObjectAccessible *atk_gobj;
+ GObject *g_obj;
+ EDayViewMainItem *main_item;
+ EDayView *day_view;
+ EaDayViewMainItem* ea_main_item = EA_DAY_VIEW_MAIN_ITEM (table);
+
+ atk_gobj = ATK_GOBJECT_ACCESSIBLE (ea_main_item);
+ g_obj = atk_gobject_accessible_get_object (atk_gobj);
+ if (!g_obj)
+ return FALSE;
+
+ main_item = E_DAY_VIEW_MAIN_ITEM (g_obj);
+ day_view = main_item->day_view;
+
+ if (column >= day_view->selection_start_day &&
+ column <= day_view->selection_end_day)
+ return TRUE;
+ return FALSE;
+}
+
+static gint
+table_interface_get_selected_rows (AtkTable *table,
+ gint **rows_selected)
+{
+ AtkGObjectAccessible *atk_gobj;
+ GObject *g_obj;
+ EDayViewMainItem *main_item;
+ EDayView *day_view;
+ EaDayViewMainItem* ea_main_item = EA_DAY_VIEW_MAIN_ITEM (table);
+ gint start_row = -1, n_rows = 0;
+
+ atk_gobj = ATK_GOBJECT_ACCESSIBLE (ea_main_item);
+ g_obj = atk_gobject_accessible_get_object (atk_gobj);
+ if (!g_obj)
+ return -1;
+
+ main_item = E_DAY_VIEW_MAIN_ITEM (g_obj);
+ day_view = main_item->day_view;
+
+ if (day_view->selection_start_day == -1)
+ return 0;
+
+ if (day_view->selection_start_day != day_view->selection_end_day) {
+ /* all the rows should be selected */
+ n_rows = day_view->rows;
+ start_row = 0;
+ }
+ else if (day_view->selection_start_row != -1) {
+ start_row = day_view->selection_start_row;
+ n_rows = day_view->selection_end_row - start_row + 1;
+ }
+ if (n_rows > 0 && start_row != -1 && rows_selected) {
+ gint index;
+
+ *rows_selected = (gint *) g_malloc (n_rows * sizeof (gint));
+ for (index = 0; index < n_rows; ++index)
+ (*rows_selected)[index] = start_row + index;
+ }
+ return n_rows;
+}
+
+static gint
+table_interface_get_selected_columns (AtkTable *table,
+ gint **columns_selected)
+{
+ AtkGObjectAccessible *atk_gobj;
+ GObject *g_obj;
+ EDayViewMainItem *main_item;
+ EDayView *day_view;
+ EaDayViewMainItem* ea_main_item = EA_DAY_VIEW_MAIN_ITEM (table);
+ gint start_column = -1, n_columns = 0;
+
+ atk_gobj = ATK_GOBJECT_ACCESSIBLE (ea_main_item);
+ g_obj = atk_gobject_accessible_get_object (atk_gobj);
+ if (!g_obj)
+ return -1;
+
+ main_item = E_DAY_VIEW_MAIN_ITEM (g_obj);
+ day_view = main_item->day_view;
+
+ if (day_view->selection_start_day == -1)
+ return 0;
+
+ start_column = day_view->selection_start_day;
+ n_columns = day_view->selection_end_day - start_column + 1;
+ if (n_columns > 0 && start_column != -1 && columns_selected) {
+ gint index;
+
+ *columns_selected = (gint *) g_malloc (n_columns * sizeof (gint));
+ for (index = 0; index < n_columns; ++index)
+ (*columns_selected)[index] = start_column + index;
+ }
+ return n_columns;
+}
+
+static gboolean
+table_interface_add_row_selection (AtkTable *table,
+ gint row)
+{
+ AtkGObjectAccessible *atk_gobj;
+ GObject *g_obj;
+ EDayViewMainItem *main_item;
+ EDayView *day_view;
+ EaDayViewMainItem* ea_main_item = EA_DAY_VIEW_MAIN_ITEM (table);
+
+ atk_gobj = ATK_GOBJECT_ACCESSIBLE (ea_main_item);
+ g_obj = atk_gobject_accessible_get_object (atk_gobj);
+ if (!g_obj)
+ return FALSE;
+
+ main_item = E_DAY_VIEW_MAIN_ITEM (g_obj);
+ day_view = main_item->day_view;
+
+ /* FIXME: we need multi-selection */
+
+ day_view->selection_start_day = 0;
+ day_view->selection_end_day = 0;
+ day_view->selection_start_row = row;
+ day_view->selection_end_row = row;
+
+ e_day_view_ensure_rows_visible (day_view,
+ day_view->selection_start_row,
+ day_view->selection_end_row);
+ e_day_view_update_calendar_selection_time (day_view);
+ gtk_widget_queue_draw (day_view->main_canvas);
+ return TRUE;
+}
+
+static gboolean
+table_interface_remove_row_selection (AtkTable *table,
+ gint row)
+{
+ return FALSE;
+}
+
+static gboolean
+table_interface_add_column_selection (AtkTable *table,
+ gint column)
+{
+ AtkGObjectAccessible *atk_gobj;
+ GObject *g_obj;
+ EDayViewMainItem *main_item;
+ EDayView *day_view;
+ EaDayViewMainItem* ea_main_item = EA_DAY_VIEW_MAIN_ITEM (table);
+
+ atk_gobj = ATK_GOBJECT_ACCESSIBLE (ea_main_item);
+ g_obj = atk_gobject_accessible_get_object (atk_gobj);
+ if (!g_obj)
+ return FALSE;
+
+ main_item = E_DAY_VIEW_MAIN_ITEM (g_obj);
+ day_view = main_item->day_view;
+
+ /* FIXME: we need multi-selection */
+
+ day_view->selection_start_day = column;
+ day_view->selection_end_day = column;
+ day_view->selection_start_row = 0;
+ day_view->selection_end_row = day_view->rows;
+
+ e_day_view_update_calendar_selection_time (day_view);
+ gtk_widget_queue_draw (day_view->main_canvas);
+ return TRUE;
+}
+
+static gboolean
+table_interface_remove_column_selection (AtkTable *table,
+ gint column)
+{
+ /* FIXME: NOT IMPLEMENTED */
+ return FALSE;
+}
+
+static AtkObject*
+table_interface_get_row_header (AtkTable *table,
+ gint row)
+{
+ /* FIXME: NOT IMPLEMENTED */
+ return NULL;
+}
+
+static AtkObject*
+table_interface_get_column_header (AtkTable *table,
+ gint in_col)
+{
+ /* FIXME: NOT IMPLEMENTED */
+ return NULL;
+}
+
+static AtkObject*
+table_interface_get_caption (AtkTable *table)
+{
+ /* FIXME: NOT IMPLEMENTED */
+ return NULL;
+}
+
+static G_CONST_RETURN gchar *
+table_interface_get_column_description (AtkTable *table,
+ gint in_col)
+{
+ AtkGObjectAccessible *atk_gobj;
+ GObject *g_obj;
+ EDayViewMainItem *main_item;
+ EDayView *day_view;
+ EaDayViewMainItem* ea_main_item = EA_DAY_VIEW_MAIN_ITEM (table);
+ const gchar *description;
+ EaCellTable *cell_data;
+
+ atk_gobj = ATK_GOBJECT_ACCESSIBLE (ea_main_item);
+ g_obj = atk_gobject_accessible_get_object (atk_gobj);
+ if (!g_obj)
+ return NULL;
+
+ main_item = E_DAY_VIEW_MAIN_ITEM (g_obj);
+ day_view = main_item->day_view;
+
+ if (in_col < 0 || in_col >= day_view->days_shown)
+ return NULL;
+ cell_data = ea_day_view_main_item_get_cell_data (ea_main_item);
+ if (!cell_data)
+ return NULL;
+
+ description = ea_cell_table_get_column_label (cell_data, in_col);
+ if (!description) {
+ gchar buffer[128];
+ e_day_view_top_item_get_day_label (day_view, in_col, buffer, 128);
+ ea_cell_table_set_column_label (cell_data, in_col, buffer);
+ description = ea_cell_table_get_column_label (cell_data, in_col);
+ }
+ return description;
+}
+
+static G_CONST_RETURN gchar *
+table_interface_get_row_description (AtkTable *table,
+ gint row)
+{
+ AtkGObjectAccessible *atk_gobj;
+ GObject *g_obj;
+ EaDayViewMainItem* ea_main_item = EA_DAY_VIEW_MAIN_ITEM (table);
+ const gchar *description;
+ EaCellTable *cell_data;
+
+ atk_gobj = ATK_GOBJECT_ACCESSIBLE (ea_main_item);
+ g_obj = atk_gobject_accessible_get_object (atk_gobj);
+ if (!g_obj)
+ return NULL;
+
+ if (row < 0 || row >= 12 * 24)
+ return NULL;
+ cell_data = ea_day_view_main_item_get_cell_data (ea_main_item);
+ if (!cell_data)
+ return NULL;
+
+ description = ea_cell_table_get_row_label (cell_data, row);
+ if (!description) {
+ gchar buffer[128];
+ ea_day_view_main_item_get_row_label (ea_main_item, row, buffer, sizeof (buffer));
+ ea_cell_table_set_row_label (cell_data, row, buffer);
+ description = ea_cell_table_get_row_label (cell_data,
+ row);
+ }
+ return description;
+}
+
+static AtkObject*
+table_interface_get_summary (AtkTable *table)
+{
+ /* FIXME: NOT IMPLEMENTED */
+ return NULL;
+}
+
+/* atkselection interface */
+
+static void
+atk_selection_interface_init (AtkSelectionIface *iface)
+{
+ g_return_if_fail (iface != NULL);
+
+ iface->add_selection = selection_interface_add_selection;
+ iface->clear_selection = selection_interface_clear_selection;
+ iface->ref_selection = selection_interface_ref_selection;
+ iface->get_selection_count = selection_interface_get_selection_count;
+ iface->is_child_selected = selection_interface_is_child_selected;
+}
+
+static gboolean
+selection_interface_add_selection (AtkSelection *selection, gint i)
+{
+ AtkGObjectAccessible *atk_gobj;
+ GObject *g_obj;
+ EDayViewMainItem *main_item;
+ EDayView *day_view;
+ EaDayViewMainItem* ea_main_item = EA_DAY_VIEW_MAIN_ITEM (selection);
+ gint column, row;
+
+ atk_gobj = ATK_GOBJECT_ACCESSIBLE (ea_main_item);
+ g_obj = atk_gobject_accessible_get_object (atk_gobj);
+ if (!g_obj)
+ return FALSE;
+
+ main_item = E_DAY_VIEW_MAIN_ITEM (g_obj);
+ day_view = main_item->day_view;
+
+ row = ea_day_view_main_item_get_row_at_index (ea_main_item, i);
+ column = ea_day_view_main_item_get_column_at_index (ea_main_item, i);
+
+ if (row == -1 || column == -1)
+ return FALSE;
+
+ /*FIXME: multi-selection is needed */
+ day_view->selection_start_day = column;
+ day_view->selection_end_day = column;
+ day_view->selection_start_row = row;
+ day_view->selection_end_row = row;
+
+ e_day_view_ensure_rows_visible (day_view,
+ day_view->selection_start_row,
+ day_view->selection_end_row);
+ e_day_view_update_calendar_selection_time (day_view);
+ gtk_widget_queue_draw (day_view->main_canvas);
+ return TRUE;
+}
+
+static gboolean
+selection_interface_clear_selection (AtkSelection *selection)
+{
+ AtkGObjectAccessible *atk_gobj;
+ GObject *g_obj;
+ EDayViewMainItem *main_item;
+ EDayView *day_view;
+ EaDayViewMainItem* ea_main_item = EA_DAY_VIEW_MAIN_ITEM (selection);
+
+ atk_gobj = ATK_GOBJECT_ACCESSIBLE (ea_main_item);
+ g_obj = atk_gobject_accessible_get_object (atk_gobj);
+ if (!g_obj)
+ return FALSE;
+
+ main_item = E_DAY_VIEW_MAIN_ITEM (g_obj);
+ day_view = main_item->day_view;
+
+ day_view->selection_start_row = -1;
+ day_view->selection_start_day = -1;
+ day_view->selection_end_row = -1;
+ day_view->selection_end_day = -1;
+
+ e_day_view_update_calendar_selection_time (day_view);
+ gtk_widget_queue_draw (day_view->main_canvas);
+
+ return TRUE;
+}
+
+static AtkObject*
+selection_interface_ref_selection (AtkSelection *selection, gint i)
+{
+ gint count;
+ GObject *g_obj;
+ EDayView *day_view;
+ EaDayViewMainItem* ea_main_item = EA_DAY_VIEW_MAIN_ITEM (selection);
+ gint start_index;
+
+ count = selection_interface_get_selection_count (selection);
+ if (i < 0 || i >=count)
+ return NULL;
+
+ g_obj = atk_gobject_accessible_get_object (ATK_GOBJECT_ACCESSIBLE (ea_main_item));
+ day_view = E_DAY_VIEW_MAIN_ITEM (g_obj)->day_view;
+ start_index = ea_day_view_main_item_get_child_index_at (ea_main_item,
+ day_view->selection_start_row,
+ day_view->selection_start_day);
+
+ return ea_day_view_main_item_ref_child (ATK_OBJECT (selection), start_index + i);
+}
+
+static gint
+selection_interface_get_selection_count (AtkSelection *selection)
+{
+ AtkGObjectAccessible *atk_gobj;
+ GObject *g_obj;
+ EDayViewMainItem *main_item;
+ EDayView *day_view;
+ EaDayViewMainItem* ea_main_item = EA_DAY_VIEW_MAIN_ITEM (selection);
+ gint start_index, end_index;
+
+ atk_gobj = ATK_GOBJECT_ACCESSIBLE (ea_main_item);
+ g_obj = atk_gobject_accessible_get_object (atk_gobj);
+ if (!g_obj)
+ return 0;
+
+ main_item = E_DAY_VIEW_MAIN_ITEM (g_obj);
+ day_view = main_item->day_view;
+
+ if (day_view->selection_start_day == -1 ||
+ day_view->selection_start_row == -1)
+ return 0;
+ start_index = ea_day_view_main_item_get_child_index_at (ea_main_item,
+ day_view->selection_start_row,
+ day_view->selection_start_day);
+ end_index = ea_day_view_main_item_get_child_index_at (ea_main_item,
+ day_view->selection_end_row,
+ day_view->selection_end_day);
+
+ return end_index - start_index + 1;
+}
+
+static gboolean
+selection_interface_is_child_selected (AtkSelection *selection, gint i)
+{
+ AtkGObjectAccessible *atk_gobj;
+ GObject *g_obj;
+ EDayViewMainItem *main_item;
+ EDayView *day_view;
+ EaDayViewMainItem* ea_main_item = EA_DAY_VIEW_MAIN_ITEM (selection);
+ gint column, row;
+
+ atk_gobj = ATK_GOBJECT_ACCESSIBLE (ea_main_item);
+ g_obj = atk_gobject_accessible_get_object (atk_gobj);
+ if (!g_obj)
+ return FALSE;
+
+ main_item = E_DAY_VIEW_MAIN_ITEM (g_obj);
+ day_view = main_item->day_view;
+
+ row = ea_day_view_main_item_get_row_at_index (ea_main_item, i);
+ column = ea_day_view_main_item_get_column_at_index (ea_main_item, i);
+
+ if (column < day_view->selection_start_day ||
+ column > day_view->selection_end_day)
+ return FALSE;
+
+ if ((column == day_view->selection_start_day ||
+ column == day_view->selection_end_day) &&
+ (row < day_view->selection_start_row ||
+ row > day_view->selection_end_row))
+ return FALSE;
+
+ /* if comes here, the cell is selected */
+ return TRUE;
+}
diff --git a/calendar/gui/ea-day-view-main-item.h b/calendar/gui/ea-day-view-main-item.h
new file mode 100644
index 0000000000..c782e6acc8
--- /dev/null
+++ b/calendar/gui/ea-day-view-main-item.h
@@ -0,0 +1,58 @@
+/*
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2 of the License, or (at your option) version 3.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with the program; if not, see <http://www.gnu.org/licenses/>
+ *
+ *
+ * Authors:
+ * Bolian Yin <bolian.yin@sun.com>
+ *
+ * Copyright (C) 1999-2008 Novell, Inc. (www.novell.com)
+ *
+ */
+
+#ifndef __EA_DAY_VIEW_MAIN_ITEM_H__
+#define __EA_DAY_VIEW_MAIN_ITEM_H__
+
+#include <atk/atkgobjectaccessible.h>
+#include "e-day-view-main-item.h"
+
+G_BEGIN_DECLS
+
+#define EA_TYPE_DAY_VIEW_MAIN_ITEM (ea_day_view_main_item_get_type ())
+#define EA_DAY_VIEW_MAIN_ITEM(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), EA_TYPE_DAY_VIEW_MAIN_ITEM, EaDayViewMainItem))
+#define EA_DAY_VIEW_MAIN_ITEM_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), EA_TYPE_DAY_VIEW_MAIN_ITEM, EaDayViewMainItemClass))
+#define EA_IS_DAY_VIEW_MAIN_ITEM(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), EA_TYPE_DAY_VIEW_MAIN_ITEM))
+#define EA_IS_DAY_VIEW_MAIN_ITEM_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), EA_TYPE_DAY_VIEW_MAIN_ITEM))
+#define EA_DAY_VIEW_MAIN_ITEM_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), EA_TYPE_DAY_VIEW_MAIN_ITEM, EaDayViewMainItemClass))
+
+typedef struct _EaDayViewMainItem EaDayViewMainItem;
+typedef struct _EaDayViewMainItemClass EaDayViewMainItemClass;
+
+struct _EaDayViewMainItem
+{
+ AtkGObjectAccessible parent;
+};
+
+GType ea_day_view_main_item_get_type (void);
+
+struct _EaDayViewMainItemClass
+{
+ AtkGObjectAccessibleClass parent_class;
+};
+
+AtkObject* ea_day_view_main_item_new (GObject *obj);
+
+G_END_DECLS
+
+#endif /* __EA_DAY_VIEW_MAIN_ITEM_H__ */
diff --git a/calendar/gui/ea-day-view.c b/calendar/gui/ea-day-view.c
new file mode 100644
index 0000000000..1e6842905f
--- /dev/null
+++ b/calendar/gui/ea-day-view.c
@@ -0,0 +1,276 @@
+/*
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2 of the License, or (at your option) version 3.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with the program; if not, see <http://www.gnu.org/licenses/>
+ *
+ *
+ * Authors:
+ * Bolian Yin <bolian.yin@sun.com>
+ *
+ * Copyright (C) 1999-2008 Novell, Inc. (www.novell.com)
+ *
+ */
+
+#include "ea-day-view.h"
+#include "ea-cal-view-event.h"
+
+#include "ea-calendar-helpers.h"
+#include "ea-gnome-calendar.h"
+#include <glib.h>
+#include <glib/gi18n.h>
+
+static void ea_day_view_class_init (EaDayViewClass *klass);
+
+static G_CONST_RETURN gchar * ea_day_view_get_name (AtkObject *accessible);
+static G_CONST_RETURN gchar * ea_day_view_get_description (AtkObject *accessible);
+static gint ea_day_view_get_n_children (AtkObject *obj);
+static AtkObject* ea_day_view_ref_child (AtkObject *obj,
+ gint i);
+static gpointer parent_class = NULL;
+
+GType
+ea_day_view_get_type (void)
+{
+ static GType type = 0;
+ AtkObjectFactory *factory;
+ GTypeQuery query;
+ GType derived_atk_type;
+
+ if (!type) {
+ static GTypeInfo tinfo = {
+ sizeof (EaDayViewClass),
+ (GBaseInitFunc) NULL, /* base init */
+ (GBaseFinalizeFunc) NULL, /* base finalize */
+ (GClassInitFunc) ea_day_view_class_init, /* class init */
+ (GClassFinalizeFunc) NULL, /* class finalize */
+ NULL, /* class data */
+ sizeof (EaDayView), /* instance size */
+ 0, /* nb preallocs */
+ (GInstanceInitFunc) NULL, /* instance init */
+ NULL /* value table */
+ };
+
+ /*
+ * Figure out the size of the class and instance
+ * we are run-time deriving from (EaCalView, in this case)
+ *
+ * Note: we must still use run-time deriving here, because
+ * our parent class EaCalView is run-time deriving.
+ */
+
+ factory = atk_registry_get_factory (atk_get_default_registry (),
+ e_calendar_view_get_type());
+ derived_atk_type = atk_object_factory_get_accessible_type (factory);
+ g_type_query (derived_atk_type, &query);
+
+ tinfo.class_size = query.class_size;
+ tinfo.instance_size = query.instance_size;
+
+ type = g_type_register_static (derived_atk_type,
+ "EaDayView", &tinfo, 0);
+ }
+
+ return type;
+}
+
+static void
+ea_day_view_class_init (EaDayViewClass *klass)
+{
+ AtkObjectClass *class = ATK_OBJECT_CLASS (klass);
+
+ parent_class = g_type_class_peek_parent (klass);
+
+ class->get_name = ea_day_view_get_name;
+ class->get_description = ea_day_view_get_description;
+
+ class->get_n_children = ea_day_view_get_n_children;
+ class->ref_child = ea_day_view_ref_child;
+}
+
+AtkObject*
+ea_day_view_new (GtkWidget *widget)
+{
+ GObject *object;
+ AtkObject *accessible;
+
+ g_return_val_if_fail (E_IS_DAY_VIEW (widget), NULL);
+
+ object = g_object_new (EA_TYPE_DAY_VIEW, NULL);
+
+ accessible = ATK_OBJECT (object);
+ atk_object_initialize (accessible, widget);
+
+#ifdef ACC_DEBUG
+ printf ("EvoAcc: ea_day_view created %p\n", (gpointer)accessible);
+#endif
+
+ return accessible;
+}
+
+static G_CONST_RETURN gchar *
+ea_day_view_get_name (AtkObject *accessible)
+{
+ EDayView *day_view;
+ GnomeCalendar *gcal;
+ const gchar *label_text;
+ GnomeCalendarViewType view_type;
+ gint n_events;
+ gchar *event_str, *name_str;
+
+ g_return_val_if_fail (EA_IS_DAY_VIEW (accessible), NULL);
+
+ if (!GTK_ACCESSIBLE (accessible)->widget)
+ return NULL;
+
+ day_view = E_DAY_VIEW (GTK_ACCESSIBLE (accessible)->widget);
+ gcal = e_calendar_view_get_calendar (E_CALENDAR_VIEW (day_view));
+ if (!GTK_WIDGET_VISIBLE (GTK_WIDGET (gcal)))
+ return NULL;
+
+ label_text = ea_gnome_calendar_get_label_description (gcal);
+
+ n_events = atk_object_get_n_accessible_children (accessible);
+ /* the child main item is always there */
+ --n_events;
+ if (n_events >= 1)
+ /* To translators: Here, "It" is either like "Work Week View: July
+ 10th - July 14th, 2006." or "Day View: Thursday July 13th, 2006." */
+ event_str = g_strdup_printf (ngettext ("It has %d event.", "It has %d events.", n_events), n_events);
+ else
+ /* To translators: Here, "It" is either like "Work Week View: July
+ 10th - July 14th, 2006." or "Day View: Thursday July 13th, 2006." */
+ event_str = g_strdup (_("It has no events."));
+
+ view_type = gnome_calendar_get_view (gcal);
+ if (view_type == GNOME_CAL_WORK_WEEK_VIEW)
+ /* To translators: First %s is the week, for example "July 10th -
+ July 14th, 2006". Second %s is the number of events in this work
+ week, for example "It has %d event/events." or "It has no events." */
+ name_str = g_strdup_printf (_("Work Week View: %s. %s"),
+ label_text, event_str);
+ else
+ /* To translators: First %s is the day, for example "Thursday July
+ 13th, 2006". Second %s is the number of events on this day, for
+ example "It has %d event/events." or "It has no events." */
+ name_str = g_strdup_printf (_("Day View: %s. %s"),
+ label_text, event_str);
+
+ ATK_OBJECT_CLASS (parent_class)->set_name (accessible, name_str);
+ g_free (name_str);
+ g_free (event_str);
+
+ return accessible->name;
+}
+
+static G_CONST_RETURN gchar *
+ea_day_view_get_description (AtkObject *accessible)
+{
+ EDayView *day_view;
+
+ g_return_val_if_fail (EA_IS_DAY_VIEW (accessible), NULL);
+
+ if (!GTK_ACCESSIBLE (accessible)->widget)
+ return NULL;
+ day_view = E_DAY_VIEW (GTK_ACCESSIBLE (accessible)->widget);
+
+ if (accessible->description)
+ return accessible->description;
+ else {
+ GnomeCalendar *gcal;
+ GnomeCalendarViewType view_type;
+
+ gcal = e_calendar_view_get_calendar (E_CALENDAR_VIEW (day_view));
+ view_type = gnome_calendar_get_view (gcal);
+
+ if (view_type == GNOME_CAL_WORK_WEEK_VIEW)
+ return _("calendar view for a work week");
+ else
+ return _("calendar view for one or more days");
+ }
+}
+
+static gint
+ea_day_view_get_n_children (AtkObject *accessible)
+{
+ EDayView *day_view;
+ gint day;
+ gint child_num = 0;
+
+ g_return_val_if_fail (EA_IS_DAY_VIEW (accessible), -1);
+
+ if (!GTK_ACCESSIBLE (accessible)->widget)
+ return -1;
+
+ day_view = E_DAY_VIEW (GTK_ACCESSIBLE (accessible)->widget);
+
+ child_num += day_view->long_events->len;
+
+ for (day = 0; day < day_view->days_shown; day++) {
+ child_num += day_view->events[day]->len;
+ }
+
+ /* "+1" for the main item */
+ return child_num + 1;
+}
+
+static AtkObject *
+ea_day_view_ref_child (AtkObject *accessible, gint index)
+{
+ EDayView *day_view;
+ gint child_num;
+ gint day;
+ AtkObject *atk_object = NULL;
+ EDayViewEvent *event = NULL;
+
+ g_return_val_if_fail (EA_IS_DAY_VIEW (accessible), NULL);
+
+ child_num = atk_object_get_n_accessible_children (accessible);
+ if (child_num <= 0 || index < 0 || index >= child_num)
+ return NULL;
+
+ if (!GTK_ACCESSIBLE (accessible)->widget)
+ return NULL;
+ day_view = E_DAY_VIEW (GTK_ACCESSIBLE (accessible)->widget);
+
+ if (index == 0) {
+ /* index == 0 is the main item */
+ atk_object = atk_gobject_accessible_for_object (G_OBJECT (day_view->main_canvas_item));
+ g_object_ref (atk_object);
+ }
+ else {
+ --index;
+ /* a long event */
+ if (index < day_view->long_events->len) {
+ event = &g_array_index (day_view->long_events,
+ EDayViewEvent, index);
+ }
+ else {
+ index -= day_view->long_events->len;
+ day = 0;
+ while (index >= day_view->events[day]->len) {
+ index -= day_view->events[day]->len;
+ ++day;
+ }
+
+ event = &g_array_index (day_view->events[day],
+ EDayViewEvent, index);
+ }
+ if (event && event->canvas_item) {
+ /* Not use atk_gobject_accessible_for_object here,
+ * we need to do special thing here
+ */
+ atk_object = ea_calendar_helpers_get_accessible_for (event->canvas_item);
+ g_object_ref (atk_object);
+ }
+ }
+ return atk_object;
+}
diff --git a/calendar/gui/ea-day-view.h b/calendar/gui/ea-day-view.h
new file mode 100644
index 0000000000..33399f6600
--- /dev/null
+++ b/calendar/gui/ea-day-view.h
@@ -0,0 +1,57 @@
+/*
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2 of the License, or (at your option) version 3.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with the program; if not, see <http://www.gnu.org/licenses/>
+ *
+ *
+ * Authors:
+ * Bolian Yin <bolian.yin@sun.com>
+ *
+ * Copyright (C) 1999-2008 Novell, Inc. (www.novell.com)
+ *
+ */
+
+#ifndef __EA_DAY_VIEW_H__
+#define __EA_DAY_VIEW_H__
+
+#include "ea-cal-view.h"
+#include "e-day-view.h"
+
+G_BEGIN_DECLS
+
+#define EA_TYPE_DAY_VIEW (ea_day_view_get_type ())
+#define EA_DAY_VIEW(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), EA_TYPE_DAY_VIEW, EaDayView))
+#define EA_DAY_VIEW_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), EA_TYPE_DAY_VIEW, EaDayViewClass))
+#define EA_IS_DAY_VIEW(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), EA_TYPE_DAY_VIEW))
+#define EA_IS_DAY_VIEW_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), EA_TYPE_DAY_VIEW))
+#define EA_DAY_VIEW_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), EA_TYPE_DAY_VIEW, EaDayViewClass))
+
+typedef struct _EaDayView EaDayView;
+typedef struct _EaDayViewClass EaDayViewClass;
+
+struct _EaDayView
+{
+ EaCalView parent;
+};
+
+GType ea_day_view_get_type (void);
+
+struct _EaDayViewClass
+{
+ EaCalViewClass parent_class;
+};
+
+AtkObject* ea_day_view_new (GtkWidget *widget);
+
+G_END_DECLS
+
+#endif /* __EA_DAY_VIEW_H__ */
diff --git a/calendar/gui/ea-gnome-calendar.c b/calendar/gui/ea-gnome-calendar.c
new file mode 100644
index 0000000000..73dae8f891
--- /dev/null
+++ b/calendar/gui/ea-gnome-calendar.c
@@ -0,0 +1,313 @@
+/*
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2 of the License, or (at your option) version 3.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with the program; if not, see <http://www.gnu.org/licenses/>
+ *
+ *
+ * Authors:
+ * Bolian Yin <bolian.yin@sun.com>
+ *
+ * Copyright (C) 1999-2008 Novell, Inc. (www.novell.com)
+ *
+ */
+
+#include "ea-gnome-calendar.h"
+#include "e-calendar-view.h"
+#include <string.h>
+#include <gtk/gtk.h>
+#include <libecal/e-cal-time-util.h>
+#include <libedataserver/e-data-server-util.h>
+#include <glib/gi18n.h>
+
+static void ea_gnome_calendar_class_init (EaGnomeCalendarClass *klass);
+
+static G_CONST_RETURN gchar * ea_gnome_calendar_get_name (AtkObject *accessible);
+static G_CONST_RETURN gchar * ea_gnome_calendar_get_description (AtkObject *accessible);
+static gint ea_gnome_calendar_get_n_children (AtkObject* obj);
+static AtkObject * ea_gnome_calendar_ref_child (AtkObject *obj, gint i);
+
+static void ea_gcal_dates_change_cb (GnomeCalendar *gcal, gpointer data);
+
+static gpointer parent_class = NULL;
+
+GType
+ea_gnome_calendar_get_type (void)
+{
+ static GType type = 0;
+ AtkObjectFactory *factory;
+ GTypeQuery query;
+ GType derived_atk_type;
+
+ if (!type) {
+ static GTypeInfo tinfo = {
+ sizeof (EaGnomeCalendarClass),
+ (GBaseInitFunc) NULL, /* base init */
+ (GBaseFinalizeFunc) NULL, /* base finalize */
+ (GClassInitFunc) ea_gnome_calendar_class_init, /* class init */
+ (GClassFinalizeFunc) NULL, /* class finalize */
+ NULL, /* class data */
+ sizeof (EaGnomeCalendar), /* instance size */
+ 0, /* nb preallocs */
+ (GInstanceInitFunc) NULL, /* instance init */
+ NULL /* value table */
+ };
+
+ /*
+ * Figure out the size of the class and instance
+ * we are run-time deriving from (GailWidget, in this case)
+ */
+
+ factory = atk_registry_get_factory (atk_get_default_registry (),
+ GTK_TYPE_WIDGET);
+ derived_atk_type = atk_object_factory_get_accessible_type (factory);
+ g_type_query (derived_atk_type, &query);
+ tinfo.class_size = query.class_size;
+ tinfo.instance_size = query.instance_size;
+
+ type = g_type_register_static (derived_atk_type,
+ "EaGnomeCalendar", &tinfo, 0);
+
+ }
+
+ return type;
+}
+
+static void
+ea_gnome_calendar_class_init (EaGnomeCalendarClass *klass)
+{
+ AtkObjectClass *class = ATK_OBJECT_CLASS (klass);
+
+ parent_class = g_type_class_peek_parent (klass);
+
+ class->get_name = ea_gnome_calendar_get_name;
+ class->get_description = ea_gnome_calendar_get_description;
+
+ class->get_n_children = ea_gnome_calendar_get_n_children;
+ class->ref_child = ea_gnome_calendar_ref_child;
+}
+
+AtkObject*
+ea_gnome_calendar_new (GtkWidget *widget)
+{
+ GObject *object;
+ AtkObject *accessible;
+ GnomeCalendar *gcal;
+
+ g_return_val_if_fail (GNOME_IS_CALENDAR (widget), NULL);
+
+ object = g_object_new (EA_TYPE_GNOME_CALENDAR, NULL);
+
+ accessible = ATK_OBJECT (object);
+ atk_object_initialize (accessible, widget);
+
+ accessible->role = ATK_ROLE_FILLER;
+
+ gcal = GNOME_CALENDAR (widget);
+
+ /* listen on view type change
+ */
+ g_signal_connect (widget, "dates_shown_changed",
+ G_CALLBACK (ea_gcal_dates_change_cb),
+ accessible);
+
+#ifdef ACC_DEBUG
+ printf ("EvoAcc: ea-gnome-calendar created: %p\n", (gpointer)accessible);
+#endif
+
+ return accessible;
+}
+
+const gchar *
+ea_gnome_calendar_get_label_description (GnomeCalendar *gcal)
+{
+ icaltimezone *zone;
+ struct icaltimetype start_tt, end_tt;
+ time_t start_time, end_time;
+ struct tm start_tm, end_tm;
+ static gchar buffer[512];
+ gchar end_buffer[256];
+ GnomeCalendarViewType view;
+
+ gnome_calendar_get_visible_time_range (gcal, &start_time, &end_time);
+ zone = gnome_calendar_get_timezone (gcal);
+
+ start_tt = icaltime_from_timet_with_zone (start_time, FALSE, zone);
+ start_tm.tm_year = start_tt.year - 1900;
+ start_tm.tm_mon = start_tt.month - 1;
+ start_tm.tm_mday = start_tt.day;
+ start_tm.tm_hour = start_tt.hour;
+ start_tm.tm_min = start_tt.minute;
+ start_tm.tm_sec = start_tt.second;
+ start_tm.tm_isdst = -1;
+ start_tm.tm_wday = time_day_of_week (start_tt.day, start_tt.month - 1,
+ start_tt.year);
+
+ /* Take one off end_time so we don't get an extra day. */
+ end_tt = icaltime_from_timet_with_zone (end_time - 1, FALSE, zone);
+ end_tm.tm_year = end_tt.year - 1900;
+ end_tm.tm_mon = end_tt.month - 1;
+ end_tm.tm_mday = end_tt.day;
+ end_tm.tm_hour = end_tt.hour;
+ end_tm.tm_min = end_tt.minute;
+ end_tm.tm_sec = end_tt.second;
+ end_tm.tm_isdst = -1;
+ end_tm.tm_wday = time_day_of_week (end_tt.day, end_tt.month - 1,
+ end_tt.year);
+
+ view = gnome_calendar_get_view (gcal);
+
+ switch (view) {
+ case GNOME_CAL_DAY_VIEW:
+ case GNOME_CAL_WORK_WEEK_VIEW:
+ case GNOME_CAL_WEEK_VIEW:
+ if (start_tm.tm_year == end_tm.tm_year
+ && start_tm.tm_mon == end_tm.tm_mon
+ && start_tm.tm_mday == end_tm.tm_mday) {
+ e_utf8_strftime (buffer, sizeof (buffer),
+ _("%A %d %b %Y"), &start_tm);
+ } else if (start_tm.tm_year == end_tm.tm_year) {
+ e_utf8_strftime (buffer, sizeof (buffer),
+ _("%a %d %b"), &start_tm);
+ e_utf8_strftime (end_buffer, sizeof (end_buffer),
+ _("%a %d %b %Y"), &end_tm);
+ strcat (buffer, " - ");
+ strcat (buffer, end_buffer);
+ } else {
+ e_utf8_strftime (buffer, sizeof (buffer),
+ _("%a %d %b %Y"), &start_tm);
+ e_utf8_strftime (end_buffer, sizeof (end_buffer),
+ _("%a %d %b %Y"), &end_tm);
+ strcat (buffer, " - ");
+ strcat (buffer, end_buffer);
+ }
+ break;
+ case GNOME_CAL_MONTH_VIEW:
+ case GNOME_CAL_LIST_VIEW:
+ if (start_tm.tm_year == end_tm.tm_year) {
+ if (start_tm.tm_mon == end_tm.tm_mon) {
+ if (start_tm.tm_mday == end_tm.tm_mday) {
+ buffer [0] = '\0';
+ } else {
+ e_utf8_strftime (buffer, sizeof (buffer),
+ "%d", &start_tm);
+ strcat (buffer, " - ");
+ }
+ e_utf8_strftime (end_buffer, sizeof (end_buffer),
+ _("%d %b %Y"), &end_tm);
+ strcat (buffer, end_buffer);
+ } else {
+ e_utf8_strftime (buffer, sizeof (buffer),
+ _("%d %b"), &start_tm);
+ e_utf8_strftime (end_buffer, sizeof (end_buffer),
+ _("%d %b %Y"), &end_tm);
+ strcat (buffer, " - ");
+ strcat (buffer, end_buffer);
+ }
+ } else {
+ e_utf8_strftime (buffer, sizeof (buffer),
+ _("%d %b %Y"), &start_tm);
+ e_utf8_strftime (end_buffer, sizeof (end_buffer),
+ _("%d %b %Y"), &end_tm);
+ strcat (buffer, " - ");
+ strcat (buffer, end_buffer);
+ }
+ break;
+ default:
+ g_return_val_if_reached (NULL);
+ }
+ return buffer;
+}
+
+static G_CONST_RETURN gchar *
+ea_gnome_calendar_get_name (AtkObject *accessible)
+{
+ if (accessible->name)
+ return accessible->name;
+ return _("Gnome Calendar");
+}
+
+static G_CONST_RETURN gchar *
+ea_gnome_calendar_get_description (AtkObject *accessible)
+{
+ if (accessible->description)
+ return accessible->description;
+ return _("Gnome Calendar");
+}
+
+static gint
+ea_gnome_calendar_get_n_children (AtkObject* obj)
+{
+ g_return_val_if_fail (EA_IS_GNOME_CALENDAR (obj), 0);
+
+ if (!GTK_ACCESSIBLE (obj)->widget)
+ return -1;
+ return 2;
+}
+
+static AtkObject *
+ea_gnome_calendar_ref_child (AtkObject *obj, gint i)
+{
+ AtkObject * child = NULL;
+ GnomeCalendar * calendarWidget;
+ GnomeCalendarViewType view_type;
+ ECalendarView *view;
+ GtkWidget *childWidget;
+
+ g_return_val_if_fail (EA_IS_GNOME_CALENDAR (obj), NULL);
+ /* valid child index range is [0-3] */
+ if (i < 0 || i >3 )
+ return NULL;
+
+ if (!GTK_ACCESSIBLE (obj)->widget)
+ return NULL;
+ calendarWidget = GNOME_CALENDAR (GTK_ACCESSIBLE (obj)->widget);
+
+ switch (i) {
+ case 0:
+ /* for the day/week view */
+ view_type = gnome_calendar_get_view (calendarWidget);
+ view = gnome_calendar_get_calendar_view (calendarWidget, view_type);
+ childWidget = GTK_WIDGET (view);
+ child = gtk_widget_get_accessible (childWidget);
+ atk_object_set_parent (child, obj);
+ break;
+ case 1:
+ /* for calendar */
+ childWidget = gnome_calendar_get_e_calendar_widget (calendarWidget);
+ child = gtk_widget_get_accessible (childWidget);
+ break;
+ default:
+ break;
+ }
+ if (child)
+ g_object_ref(child);
+ return child;
+}
+
+static void
+ea_gcal_dates_change_cb (GnomeCalendar *gcal, gpointer data)
+{
+ const gchar *new_name;
+
+ g_return_if_fail (GNOME_IS_CALENDAR (gcal));
+ g_return_if_fail (data);
+ g_return_if_fail (EA_IS_GNOME_CALENDAR (data));
+
+ new_name = ea_gnome_calendar_get_label_description (gcal);
+ atk_object_set_name (ATK_OBJECT(data), new_name);
+ g_signal_emit_by_name (data, "visible_data_changed");
+
+#ifdef ACC_DEBUG
+ printf ("AccDebug: calendar dates changed, label=%s\n", new_name);
+#endif
+}
diff --git a/calendar/gui/ea-gnome-calendar.h b/calendar/gui/ea-gnome-calendar.h
new file mode 100644
index 0000000000..db9acdb47e
--- /dev/null
+++ b/calendar/gui/ea-gnome-calendar.h
@@ -0,0 +1,59 @@
+/*
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2 of the License, or (at your option) version 3.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with the program; if not, see <http://www.gnu.org/licenses/>
+ *
+ *
+ * Authors:
+ * Bolian Yin <bolian.yin@sun.com>
+ *
+ * Copyright (C) 1999-2008 Novell, Inc. (www.novell.com)
+ *
+ */
+
+#ifndef __EA_GNOME_CALENDAR_H__
+#define __EA_GNOME_CALENDAR_H__
+
+#include <gtk/gtk.h>
+#include "gnome-cal.h"
+
+G_BEGIN_DECLS
+
+#define EA_TYPE_GNOME_CALENDAR (ea_gnome_calendar_get_type ())
+#define EA_GNOME_CALENDAR(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), EA_TYPE_GNOME_CALENDAR, EaGnomeCalendar))
+#define EA_GNOME_CALENDAR_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), EA_TYPE_GNOME_CALENDAR, EaGnomeCalendarClass))
+#define EA_IS_GNOME_CALENDAR(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), EA_TYPE_GNOME_CALENDAR))
+#define EA_IS_GNOME_CALENDAR_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), EA_TYPE_GNOME_CALENDAR))
+#define EA_GNOME_CALENDAR_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), EA_TYPE_GNOME_CALENDAR, EaGnomeCalendarClass))
+
+typedef struct _EaGnomeCalendar EaGnomeCalendar;
+typedef struct _EaGnomeCalendarClass EaGnomeCalendarClass;
+
+struct _EaGnomeCalendar
+{
+ GtkAccessible parent;
+};
+
+GType ea_gnome_calendar_get_type (void);
+
+struct _EaGnomeCalendarClass
+{
+ GtkAccessibleClass parent_class;
+};
+
+AtkObject* ea_gnome_calendar_new (GtkWidget *widget);
+
+const gchar * ea_gnome_calendar_get_label_description (GnomeCalendar *gcal);
+
+G_END_DECLS
+
+#endif /* __EA_GNOME_CALENDAR_H__ */
diff --git a/calendar/gui/ea-jump-button.c b/calendar/gui/ea-jump-button.c
new file mode 100644
index 0000000000..a6775ade55
--- /dev/null
+++ b/calendar/gui/ea-jump-button.c
@@ -0,0 +1,223 @@
+/*
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2 of the License, or (at your option) version 3.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with the program; if not, see <http://www.gnu.org/licenses/>
+ *
+ *
+ * Authors:
+ * Yang Wu <yang.wu@sun.com>
+ *
+ * Copyright (C) 1999-2008 Novell, Inc. (www.novell.com)
+ *
+ */
+
+#include "ea-jump-button.h"
+#include "ea-calendar-helpers.h"
+#include "ea-week-view.h"
+#include "e-week-view.h"
+#include <libgnomecanvas/gnome-canvas.h>
+#include <glib/gi18n.h>
+
+static void ea_jump_button_class_init (EaJumpButtonClass *klass);
+
+static G_CONST_RETURN gchar * ea_jump_button_get_name (AtkObject *accessible);
+static G_CONST_RETURN gchar * ea_jump_button_get_description (AtkObject *accessible);
+
+/* action interface */
+static void atk_action_interface_init (AtkActionIface *iface);
+static gboolean jump_button_do_action (AtkAction *action,
+ gint i);
+static gint jump_button_get_n_actions (AtkAction *action);
+static G_CONST_RETURN gchar * jump_button_get_keybinding (AtkAction *action,
+ gint i);
+
+static gpointer parent_class = NULL;
+
+GType
+ea_jump_button_get_type (void)
+{
+ static GType type = 0;
+ AtkObjectFactory *factory;
+ GTypeQuery query;
+ GType derived_atk_type;
+
+ if (!type) {
+ static GTypeInfo tinfo = {
+ sizeof (EaJumpButtonClass),
+ (GBaseInitFunc) NULL, /* base init */
+ (GBaseFinalizeFunc) NULL, /* base finalize */
+ (GClassInitFunc) ea_jump_button_class_init, /* class init */
+ (GClassFinalizeFunc) NULL, /* class finalize */
+ NULL, /* class data */
+ sizeof (EaJumpButton), /* instance size */
+ 0, /* nb preallocs */
+ (GInstanceInitFunc) NULL, /* instance init */
+ NULL /* value table */
+ };
+
+ static const GInterfaceInfo atk_action_info =
+ {
+ (GInterfaceInitFunc) atk_action_interface_init,
+ (GInterfaceFinalizeFunc) NULL,
+ NULL
+ };
+
+ /*
+ * Figure out the size of the class and instance
+ * we are run-time deriving from (atk object for GNOME_TYPE_CANVAS_ITEM, in this case)
+ */
+
+ factory = atk_registry_get_factory (atk_get_default_registry (),
+ GNOME_TYPE_CANVAS_ITEM);
+ derived_atk_type = atk_object_factory_get_accessible_type (factory);
+ g_type_query (derived_atk_type, &query);
+
+ tinfo.class_size = query.class_size;
+ tinfo.instance_size = query.instance_size;
+
+ /* we inherit the component and other interfaces from GNOME_TYPE_CANVAS_ITEM */
+ type = g_type_register_static (derived_atk_type,
+ "EaJumpButton", &tinfo, 0);
+
+ g_type_add_interface_static (type, ATK_TYPE_ACTION,
+ &atk_action_info);
+ }
+
+ return type;
+}
+
+static void
+ea_jump_button_class_init (EaJumpButtonClass *klass)
+{
+ AtkObjectClass *class = ATK_OBJECT_CLASS (klass);
+
+ parent_class = g_type_class_peek_parent (klass);
+
+ class->get_name = ea_jump_button_get_name;
+ class->get_description = ea_jump_button_get_description;
+}
+
+AtkObject*
+ea_jump_button_new (GObject *obj)
+{
+ AtkObject *atk_obj = NULL;
+ GObject *target_obj;
+
+ g_return_val_if_fail (GNOME_IS_CANVAS_ITEM (obj), NULL);
+
+ target_obj = obj;
+ atk_obj = g_object_get_data (target_obj, "accessible-object");
+
+ if (!atk_obj) {
+ static AtkRole event_role = ATK_ROLE_INVALID;
+ atk_obj = ATK_OBJECT (g_object_new (EA_TYPE_JUMP_BUTTON,
+ NULL));
+ atk_object_initialize (atk_obj, target_obj);
+ if (event_role == ATK_ROLE_INVALID)
+ event_role = atk_role_register ("Jump Button");
+ atk_obj->role = event_role;
+ }
+
+ /* the registered factory for GNOME_TYPE_CANVAS_ITEM is cannot create a EaJumpbutton,
+ * we should save the EaJumpbutton object in it.
+ */
+ g_object_set_data (obj, "accessible-object", atk_obj);
+
+ return atk_obj;
+}
+
+static G_CONST_RETURN gchar *
+ea_jump_button_get_name (AtkObject *accessible)
+{
+ g_return_val_if_fail (EA_IS_JUMP_BUTTON (accessible), NULL);
+
+ if (accessible->name)
+ return accessible->name;
+ return _("Jump button");
+}
+
+static G_CONST_RETURN gchar *
+ea_jump_button_get_description (AtkObject *accessible)
+{
+ if (accessible->description)
+ return accessible->description;
+
+ return _("Click here, you can find more events.");
+}
+
+static void
+atk_action_interface_init (AtkActionIface *iface)
+{
+ g_return_if_fail (iface != NULL);
+
+ iface->do_action = jump_button_do_action;
+ iface->get_n_actions = jump_button_get_n_actions;
+ iface->get_keybinding = jump_button_get_keybinding;
+}
+
+static gboolean
+jump_button_do_action (AtkAction *action,
+ gint i)
+{
+ gboolean return_value = TRUE;
+ AtkGObjectAccessible *atk_gobj;
+ GObject *g_obj;
+ GnomeCanvasItem *item;
+ ECalendarView *cal_view;
+ EWeekView *week_view;
+
+ atk_gobj = ATK_GOBJECT_ACCESSIBLE (action);
+ g_obj = atk_gobject_accessible_get_object (atk_gobj);
+ if (!g_obj)
+ return FALSE;
+
+ item = GNOME_CANVAS_ITEM (g_obj);
+ cal_view = ea_calendar_helpers_get_cal_view_from (GNOME_CANVAS_ITEM (item));
+ week_view = E_WEEK_VIEW (cal_view);
+
+ switch (i)
+ {
+ case 0:
+ e_week_view_jump_to_button_item (week_view, GNOME_CANVAS_ITEM (item));
+ break;
+ default:
+ return_value = FALSE;
+ break;
+ }
+ return return_value;
+}
+
+static gint
+jump_button_get_n_actions (AtkAction *action)
+{
+ return 1;
+}
+
+static G_CONST_RETURN gchar *
+jump_button_get_keybinding (AtkAction *action,
+ gint i)
+{
+ const gchar *return_value = NULL;
+
+ switch (i)
+ {
+ case 0:
+ {
+ return_value = "space or enter";
+ break;
+ }
+ default:
+ break;
+ }
+ return return_value;
+}
diff --git a/calendar/gui/ea-jump-button.h b/calendar/gui/ea-jump-button.h
new file mode 100644
index 0000000000..be0a357a14
--- /dev/null
+++ b/calendar/gui/ea-jump-button.h
@@ -0,0 +1,57 @@
+/*
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2 of the License, or (at your option) version 3.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with the program; if not, see <http://www.gnu.org/licenses/>
+ *
+ *
+ * Authors:
+ * Yang Wu <yang.wu@sun.com>
+ *
+ * Copyright (C) 1999-2008 Novell, Inc. (www.novell.com)
+ *
+ */
+
+#ifndef __EA_JUMP_BUTTON_H__
+#define __EA_JUMP_BUTTON_H__
+
+#include <atk/atkgobjectaccessible.h>
+
+G_BEGIN_DECLS
+
+#define EA_TYPE_JUMP_BUTTON (ea_jump_button_get_type ())
+#define EA_JUMP_BUTTON(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), EA_TYPE_JUMP_BUTTON, EaJumpButton))
+#define EA_JUMP_BUTTON_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), EA_TYPE_JUMP_BUTTON, EaJumpButtonClass))
+#define EA_IS_JUMP_BUTTON(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), EA_TYPE_JUMP_BUTTON))
+#define EA_IS_JUMP_BUTTON_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), EA_TYPE_JUMP_BUTTON))
+#define EA_JUMP_BUTTON_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), EA_TYPE_JUMP_BUTTON, EaJumpButtonClass))
+
+typedef struct _EaJumpButton EaJumpButton;
+typedef struct _EaJumpButtonClass EaJumpButtonClass;
+
+struct _EaJumpButton
+{
+ AtkGObjectAccessible parent;
+};
+
+GType ea_jump_button_get_type (void);
+
+struct _EaJumpButtonClass
+{
+ AtkGObjectAccessibleClass parent_class;
+};
+
+AtkObject *ea_jump_button_new (GObject *obj);
+
+G_END_DECLS
+
+#endif /* __EA_JUMP_BUTTON_H__ */
diff --git a/calendar/gui/ea-week-view-cell.c b/calendar/gui/ea-week-view-cell.c
new file mode 100644
index 0000000000..e4b28e3d59
--- /dev/null
+++ b/calendar/gui/ea-week-view-cell.c
@@ -0,0 +1,477 @@
+/*
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2 of the License, or (at your option) version 3.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with the program; if not, see <http://www.gnu.org/licenses/>
+ *
+ *
+ * Authors:
+ * Bolian Yin <bolian.yin@sun.com>
+ * Yang Wu <Yang.Wu@sun.com>
+ *
+ * Copyright (C) 1999-2008 Novell, Inc. (www.novell.com)
+ *
+ */
+
+#include "ea-week-view-cell.h"
+#include "ea-week-view-main-item.h"
+#include "a11y/ea-factory.h"
+
+/* EWeekViewCell */
+
+static void e_week_view_cell_class_init (EWeekViewCellClass *class);
+
+EA_FACTORY_GOBJECT (EA_TYPE_WEEK_VIEW_CELL, ea_week_view_cell, ea_week_view_cell_new)
+
+GType
+e_week_view_cell_get_type (void)
+{
+ static GType type = 0;
+
+ if (!type) {
+ static GTypeInfo tinfo = {
+ sizeof (EWeekViewCellClass),
+ (GBaseInitFunc) NULL, /* base init */
+ (GBaseFinalizeFunc) NULL, /* base finalize */
+ (GClassInitFunc) e_week_view_cell_class_init, /* class init */
+ (GClassFinalizeFunc) NULL, /* class finalize */
+ NULL, /* class data */
+ sizeof (EWeekViewCell), /* instance size */
+ 0, /* nb preallocs */
+ (GInstanceInitFunc) NULL, /* instance init */
+ NULL /* value table */
+ };
+
+ type = g_type_register_static (G_TYPE_OBJECT,
+ "EWeekViewCell", &tinfo, 0);
+ }
+
+ return type;
+}
+
+static void
+e_week_view_cell_class_init (EWeekViewCellClass *class)
+{
+ EA_SET_FACTORY (e_week_view_cell_get_type (), ea_week_view_cell);
+}
+
+EWeekViewCell *
+e_week_view_cell_new (EWeekView *week_view, gint row, gint column)
+{
+ GObject *object;
+ EWeekViewCell *cell;
+
+ g_return_val_if_fail (E_IS_WEEK_VIEW (week_view), NULL);
+
+ object = g_object_new (E_TYPE_WEEK_VIEW_CELL, NULL);
+ cell = E_WEEK_VIEW_CELL (object);
+ cell->week_view = week_view;
+ cell->row = row;
+ cell->column = column;
+
+#ifdef ACC_DEBUG
+ printf ("EvoAcc: e_week_view_cell created %p\n", (gpointer)cell);
+#endif
+
+ return cell;
+}
+
+/* EaWeekViewCell */
+
+static void ea_week_view_cell_class_init (EaWeekViewCellClass *klass);
+
+static G_CONST_RETURN gchar * ea_week_view_cell_get_name (AtkObject *accessible);
+static G_CONST_RETURN gchar * ea_week_view_cell_get_description (AtkObject *accessible);
+static AtkStateSet* ea_week_view_cell_ref_state_set (AtkObject *obj);
+static AtkObject * ea_week_view_cell_get_parent (AtkObject *accessible);
+static gint ea_week_view_cell_get_index_in_parent (AtkObject *accessible);
+
+/* component interface */
+static void atk_component_interface_init (AtkComponentIface *iface);
+static void component_interface_get_extents (AtkComponent *component,
+ gint *x, gint *y,
+ gint *width, gint *height,
+ AtkCoordType coord_type);
+static gboolean component_interface_grab_focus (AtkComponent *component);
+
+static gpointer parent_class = NULL;
+
+#ifdef ACC_DEBUG
+static gint n_ea_week_view_cell_created = 0, n_ea_week_view_cell_destroyed = 0;
+static void ea_week_view_cell_finalize (GObject *object);
+#endif
+
+GType
+ea_week_view_cell_get_type (void)
+{
+ static GType type = 0;
+
+ if (!type) {
+ static GTypeInfo tinfo = {
+ sizeof (EaWeekViewCellClass),
+ (GBaseInitFunc) NULL, /* base init */
+ (GBaseFinalizeFunc) NULL, /* base finalize */
+ (GClassInitFunc) ea_week_view_cell_class_init, /* class init */
+ (GClassFinalizeFunc) NULL, /* class finalize */
+ NULL, /* class data */
+ sizeof (EaWeekViewCell), /* instance size */
+ 0, /* nb preallocs */
+ (GInstanceInitFunc) NULL, /* instance init */
+ NULL /* value table */
+ };
+
+ static const GInterfaceInfo atk_component_info = {
+ (GInterfaceInitFunc) atk_component_interface_init,
+ (GInterfaceFinalizeFunc) NULL,
+ NULL
+ };
+ type = g_type_register_static (ATK_TYPE_GOBJECT_ACCESSIBLE,
+ "EaWeekViewCell", &tinfo, 0);
+ g_type_add_interface_static (type, ATK_TYPE_COMPONENT,
+ &atk_component_info);
+
+ }
+
+ return type;
+}
+
+static void
+ea_week_view_cell_class_init (EaWeekViewCellClass *klass)
+{
+ AtkObjectClass *class = ATK_OBJECT_CLASS (klass);
+
+#ifdef ACC_DEBUG
+ GObjectClass *gobject_class = G_OBJECT_CLASS (klass);
+ gobject_class->finalize = ea_week_view_cell_finalize;
+#endif
+
+ parent_class = g_type_class_peek_parent (klass);
+
+ class->get_name = ea_week_view_cell_get_name;
+ class->get_description = ea_week_view_cell_get_description;
+ class->ref_state_set = ea_week_view_cell_ref_state_set;
+
+ class->get_parent = ea_week_view_cell_get_parent;
+ class->get_index_in_parent = ea_week_view_cell_get_index_in_parent;
+
+}
+
+AtkObject*
+ea_week_view_cell_new (GObject *obj)
+{
+ gpointer object;
+ AtkObject *atk_object;
+
+ g_return_val_if_fail (E_IS_WEEK_VIEW_CELL (obj), NULL);
+ object = g_object_new (EA_TYPE_WEEK_VIEW_CELL, NULL);
+ atk_object = ATK_OBJECT (object);
+ atk_object_initialize (atk_object, obj);
+ atk_object->role = ATK_ROLE_UNKNOWN;
+
+#ifdef ACC_DEBUG
+ ++n_ea_week_view_cell_created;
+ printf ("ACC_DEBUG: n_ea_week_view_cell_created = %d\n",
+ n_ea_week_view_cell_created);
+#endif
+ return atk_object;
+}
+
+#ifdef ACC_DEBUG
+static void ea_week_view_cell_finalize (GObject *object)
+{
+ G_OBJECT_CLASS (parent_class)->finalize (object);
+
+ ++n_ea_week_view_cell_destroyed;
+ printf ("ACC_DEBUG: n_ea_week_view_cell_destroyed = %d\n",
+ n_ea_week_view_cell_destroyed);
+}
+#endif
+
+static G_CONST_RETURN gchar *
+ea_week_view_cell_get_name (AtkObject *accessible)
+{
+ AtkGObjectAccessible *atk_gobj;
+ GObject *g_obj;
+ EWeekViewCell *cell;
+
+ g_return_val_if_fail (EA_IS_WEEK_VIEW_CELL (accessible), NULL);
+
+ if (!accessible->name) {
+ AtkObject *ea_main_item;
+ GnomeCanvasItem *main_item;
+ gchar *new_name = g_strdup ("");
+ const gchar *row_label, *column_label;
+ gint new_column, new_row;
+ gint start_day;
+
+ atk_gobj = ATK_GOBJECT_ACCESSIBLE (accessible);
+ g_obj = atk_gobject_accessible_get_object (atk_gobj);
+ if (!g_obj)
+ return NULL;
+
+ cell = E_WEEK_VIEW_CELL (g_obj);
+ main_item = cell->week_view->main_canvas_item;
+ ea_main_item = atk_gobject_accessible_for_object (G_OBJECT (main_item));
+
+ start_day = cell->week_view->display_start_day;
+ if (cell->column + start_day >= 7) {
+ new_column = cell->column + start_day - 7;
+ new_row = cell->row + 1;
+ } else {
+ new_column = cell->column + start_day;
+ new_row = cell->row;
+ }
+
+ column_label = atk_table_get_column_description (ATK_TABLE (ea_main_item),
+ new_column);
+ row_label = atk_table_get_row_description (ATK_TABLE (ea_main_item),
+ new_row);
+ new_name = g_strconcat (column_label, " ", row_label, NULL);
+ ATK_OBJECT_CLASS (parent_class)->set_name (accessible, new_name);
+ g_free (new_name);
+ }
+ return accessible->name;
+}
+
+static G_CONST_RETURN gchar *
+ea_week_view_cell_get_description (AtkObject *accessible)
+{
+ return ea_week_view_cell_get_name (accessible);
+}
+
+static AtkStateSet*
+ea_week_view_cell_ref_state_set (AtkObject *obj)
+{
+ AtkStateSet *state_set;
+ GObject *g_obj;
+ AtkObject *parent;
+ gint x, y, width, height;
+ gint parent_x, parent_y, parent_width, parent_height;
+
+ state_set = ATK_OBJECT_CLASS (parent_class)->ref_state_set (obj);
+ g_obj = atk_gobject_accessible_get_object (ATK_GOBJECT_ACCESSIBLE(obj));
+ if (!g_obj)
+ return state_set;
+
+ atk_state_set_add_state (state_set, ATK_STATE_SELECTABLE);
+
+ parent = atk_object_get_parent (obj);
+ atk_component_get_extents (ATK_COMPONENT (obj), &x, &y,
+ &width, &height, ATK_XY_WINDOW);
+ atk_component_get_extents (ATK_COMPONENT (parent), &parent_x, &parent_y,
+ &parent_width, &parent_height, ATK_XY_WINDOW);
+
+ if (x + width < parent_x || x > parent_x + parent_width ||
+ y + height < parent_y || y > parent_y + parent_height)
+ /* the cell is out of the main canvas */
+ ;
+ else
+ atk_state_set_add_state (state_set, ATK_STATE_VISIBLE);
+
+ return state_set;
+}
+
+static AtkObject *
+ea_week_view_cell_get_parent (AtkObject *accessible)
+{
+ AtkGObjectAccessible *atk_gobj;
+ GObject *g_obj;
+ EWeekViewCell *cell;
+
+ g_return_val_if_fail (EA_IS_WEEK_VIEW_CELL (accessible), NULL);
+
+ atk_gobj = ATK_GOBJECT_ACCESSIBLE (accessible);
+ g_obj = atk_gobject_accessible_get_object (atk_gobj);
+ if (!g_obj)
+ return NULL;
+
+ cell = E_WEEK_VIEW_CELL (g_obj);
+ return atk_gobject_accessible_for_object (G_OBJECT (cell->week_view->main_canvas_item));
+}
+
+static gint
+ea_week_view_cell_get_index_in_parent (AtkObject *accessible)
+{
+ AtkGObjectAccessible *atk_gobj;
+ GObject *g_obj;
+ EWeekViewCell *cell;
+ AtkObject *parent;
+
+ g_return_val_if_fail (EA_IS_WEEK_VIEW_CELL (accessible), -1);
+
+ atk_gobj = ATK_GOBJECT_ACCESSIBLE (accessible);
+ g_obj = atk_gobject_accessible_get_object (atk_gobj);
+ if (!g_obj)
+ return -1;
+
+ cell = E_WEEK_VIEW_CELL (g_obj);
+ parent = atk_object_get_parent (accessible);
+ return atk_table_get_index_at (ATK_TABLE (parent),
+ cell->row, cell->column);
+}
+
+/* Atk Component Interface */
+
+static void
+atk_component_interface_init (AtkComponentIface *iface)
+{
+ g_return_if_fail (iface != NULL);
+
+ iface->get_extents = component_interface_get_extents;
+ iface->grab_focus = component_interface_grab_focus;
+}
+
+static void
+component_interface_get_extents (AtkComponent *component,
+ gint *x, gint *y, gint *width, gint *height,
+ AtkCoordType coord_type)
+{
+ GObject *g_obj;
+ AtkObject *atk_obj;
+ EWeekViewCell *cell;
+ EWeekView *week_view;
+ GtkWidget *main_canvas;
+ gint week_view_width, week_view_height;
+ gint scroll_x, scroll_y;
+ gint start_day;
+
+ *x = *y = *width = *height = 0;
+
+ g_return_if_fail (EA_IS_WEEK_VIEW_CELL (component));
+
+ g_obj = atk_gobject_accessible_get_object (ATK_GOBJECT_ACCESSIBLE(component));
+ if (!g_obj)
+ /* defunct object*/
+ return;
+
+ cell = E_WEEK_VIEW_CELL (g_obj);
+ week_view = cell->week_view;
+ main_canvas = cell->week_view->main_canvas;
+
+ atk_obj = atk_gobject_accessible_for_object (G_OBJECT (main_canvas));
+ atk_component_get_extents (ATK_COMPONENT (atk_obj),
+ x, y,
+ &week_view_width, &week_view_height,
+ coord_type);
+ gnome_canvas_get_scroll_offsets (GNOME_CANVAS (week_view->main_canvas),
+ &scroll_x, &scroll_y);
+ start_day = week_view->display_start_day;
+ if (week_view->multi_week_view) {
+ if (week_view->compress_weekend && (cell->column == (5 - start_day))) {
+ *height = week_view->row_heights[cell->row*2];
+ *width = week_view->col_widths[cell->column];
+ *x += week_view->col_offsets[cell->column] - scroll_x;
+ *y += week_view->row_offsets[cell->row*2]- scroll_y;
+ } else if (week_view->compress_weekend && (cell->column == (6 - start_day))) {
+ *height = week_view->row_heights[cell->row*2];
+ *width = week_view->col_widths[cell->column - 1];
+ *x += week_view->col_offsets[cell->column - 1]- scroll_x;
+ *y += week_view->row_offsets[cell->row*2 + 1]- scroll_y;
+ } else if (week_view->compress_weekend && (cell->column > (6 - start_day))) {
+ *height = week_view->row_heights[cell->row*2]*2;
+ *width = week_view->col_widths[cell->column - 1];
+ *x += week_view->col_offsets[cell->column - 1] - scroll_x;
+ *y += week_view->row_offsets[cell->row*2]- scroll_y;
+ } else {
+ *height = week_view->row_heights[cell->row*2]*2;
+ *width = week_view->col_widths[cell->column];
+ *x += week_view->col_offsets[cell->column] - scroll_x;
+ *y += week_view->row_offsets[cell->row*2]- scroll_y;
+ }
+ } else {
+ if (start_day < 3) {
+ if (cell->column < 3) {
+ *height = week_view->row_heights[cell->column*2]*2;
+ *width = week_view->col_widths[0];
+ *x += week_view->col_offsets[0] - scroll_x;
+ *y += week_view->row_offsets[cell->column*2]- scroll_y;
+ } else {
+ if (cell->column == 5 - start_day) {
+ *height = week_view->row_heights[(cell->column - 3)*2];
+ *width = week_view->col_widths[1];
+ *x += week_view->col_offsets[1] - scroll_x;
+ *y += week_view->row_offsets[(cell->column - 3)*2]- scroll_y;
+ } else if (cell->column == 6 - start_day) {
+ *height = week_view->row_heights[(cell->column - 4)*2];
+ *width = week_view->col_widths[1];
+ *x += week_view->col_offsets[1] - scroll_x;
+ *y += week_view->row_offsets[(cell->column - 3)*2 - 1]- scroll_y;
+ } else if (cell->column > 6 - start_day) {
+ *height = week_view->row_heights[(cell->column - 4)*2]*2;
+ *width = week_view->col_widths[1];
+ *x += week_view->col_offsets[1] - scroll_x;
+ *y += week_view->row_offsets[(cell->column - 4)*2]- scroll_y;
+ } else {
+ *height = week_view->row_heights[(cell->column - 3)*2]*2;
+ *width = week_view->col_widths[1];
+ *x += week_view->col_offsets[1] - scroll_x;
+ *y += week_view->row_offsets[(cell->column - 3)*2]- scroll_y;
+ }
+ }
+ } else if (cell->column < 4) {
+ if (cell->column == 5 - start_day) {
+ *height = week_view->row_heights[cell->column*2];
+ *width = week_view->col_widths[0];
+ *x += week_view->col_offsets[0] - scroll_x;
+ *y += week_view->row_offsets[cell->column*2]- scroll_y;
+ } else if (cell->column == 6 - start_day) {
+ *height = week_view->row_heights[(cell->column - 1)*2];
+ *width = week_view->col_widths[0];
+ *x += week_view->col_offsets[0] - scroll_x;
+ *y += week_view->row_offsets[cell->column*2 - 1]- scroll_y;
+ } else if (cell->column > 6 - start_day) {
+ *height = week_view->row_heights[(cell->column - 1)*2]*2;
+ *width = week_view->col_widths[0];
+ *x += week_view->col_offsets[0] - scroll_x;
+ *y += week_view->row_offsets[(cell->column - 1)*2]- scroll_y;
+ } else {
+ *height = week_view->row_heights[(cell->column)*2]*2;
+ *width = week_view->col_widths[0];
+ *x += week_view->col_offsets[0] - scroll_x;
+ *y += week_view->row_offsets[cell->column*2]- scroll_y;
+ }
+ } else {
+ *height = week_view->row_heights[(cell->column - 4)*2]*2;
+ *width = week_view->col_widths[1];
+ *x += week_view->col_offsets[1] - scroll_x;
+ *y += week_view->row_offsets[(cell->column - 4)*2]- scroll_y;
+ }
+ }
+}
+
+static gboolean
+component_interface_grab_focus (AtkComponent *comp)
+{
+ GObject *g_obj;
+ EWeekViewCell *cell;
+ EWeekView *week_view;
+ GtkWidget *toplevel;
+
+ g_return_val_if_fail (EA_IS_WEEK_VIEW_CELL (comp), FALSE);
+
+ g_obj = atk_gobject_accessible_get_object (ATK_GOBJECT_ACCESSIBLE (comp));
+ if (!g_obj)
+ return FALSE;
+
+ cell = E_WEEK_VIEW_CELL (g_obj);
+ week_view = cell->week_view;
+
+ week_view->selection_start_day = cell->row * 7 + cell->column;
+ week_view->selection_end_day = cell->row * 7 + cell->column;
+ gtk_widget_queue_draw (week_view->main_canvas);
+
+ toplevel = gtk_widget_get_toplevel (GTK_WIDGET (week_view));
+ if (GTK_WIDGET_TOPLEVEL (toplevel))
+ gtk_window_present (GTK_WINDOW (toplevel));
+
+ return TRUE;
+}
diff --git a/calendar/gui/ea-week-view-cell.h b/calendar/gui/ea-week-view-cell.h
new file mode 100644
index 0000000000..1524e9d3a8
--- /dev/null
+++ b/calendar/gui/ea-week-view-cell.h
@@ -0,0 +1,85 @@
+/*
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2 of the License, or (at your option) version 3.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with the program; if not, see <http://www.gnu.org/licenses/>
+ *
+ *
+ * Authors:
+ * Bolian Yin <bolian.yin@sun.com>
+ * Yang Wu <yang.wu@sun.com>
+ *
+ * Copyright (C) 1999-2008 Novell, Inc. (www.novell.com)
+ *
+ */
+
+#ifndef __EA_WEEK_VIEW_CELL_H__
+#define __EA_WEEK_VIEW_CELL_H__
+
+#include <atk/atkgobjectaccessible.h>
+#include "e-week-view.h"
+
+G_BEGIN_DECLS
+
+#define E_TYPE_WEEK_VIEW_CELL (e_week_view_cell_get_type ())
+#define E_WEEK_VIEW_CELL(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), E_TYPE_WEEK_VIEW_CELL, EWeekViewCell))
+#define E_WEEK_VIEW_CELL_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), E_TYPE_WEEK_VIEW_CELL, EWeekViewCellClass))
+#define E_IS_WEEK_VIEW_CELL(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), E_TYPE_WEEK_VIEW_CELL))
+#define E_IS_WEEK_VIEW_CELL_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), E_TYPE_WEEK_VIEW_CELL))
+#define E_WEEK_VIEW_CELL_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), E_TYPE_WEEK_VIEW_CELL, EWeekViewCellClass))
+
+typedef struct _EWeekViewCell EWeekViewCell;
+typedef struct _EWeekViewCellClass EWeekViewCellClass;
+
+struct _EWeekViewCell
+{
+ GObject parent;
+ EWeekView *week_view;
+ gint row;
+ gint column;
+};
+
+GType e_week_view_cell_get_type (void);
+
+struct _EWeekViewCellClass
+{
+ GObjectClass parent_class;
+};
+
+EWeekViewCell * e_week_view_cell_new (EWeekView *week_view, gint row, gint column);
+
+#define EA_TYPE_WEEK_VIEW_CELL (ea_week_view_cell_get_type ())
+#define EA_WEEK_VIEW_CELL(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), EA_TYPE_WEEK_VIEW_CELL, EaWeekViewCell))
+#define EA_WEEK_VIEW_CELL_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), EA_TYPE_WEEK_VIEW_CELL, EaWeekViewCellClass))
+#define EA_IS_WEEK_VIEW_CELL(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), EA_TYPE_WEEK_VIEW_CELL))
+#define EA_IS_WEEK_VIEW_CELL_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), EA_TYPE_WEEK_VIEW_CELL))
+#define EA_WEEK_VIEW_CELL_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), EA_TYPE_WEEK_VIEW_CELL, EaWeekViewCellClass))
+
+typedef struct _EaWeekViewCell EaWeekViewCell;
+typedef struct _EaWeekViewCellClass EaWeekViewCellClass;
+
+struct _EaWeekViewCell
+{
+ AtkGObjectAccessible parent;
+};
+
+GType ea_week_view_cell_get_type (void);
+
+struct _EaWeekViewCellClass
+{
+ AtkGObjectAccessibleClass parent_class;
+};
+
+AtkObject* ea_week_view_cell_new (GObject *gobj);
+
+G_END_DECLS
+
+#endif /* __EA_WEEK_VIEW_CELL_H__ */
diff --git a/calendar/gui/ea-week-view-main-item.c b/calendar/gui/ea-week-view-main-item.c
new file mode 100644
index 0000000000..3d0bd9e8e8
--- /dev/null
+++ b/calendar/gui/ea-week-view-main-item.c
@@ -0,0 +1,1246 @@
+/*
+ * Evolution Accessibility: ea-week-view-main-item.c
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2 of the License, or (at your option) version 3.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with the program; if not, see <http://www.gnu.org/licenses/>
+ *
+ *
+ * Authors:
+ *
+ * Copyright (C) 1999-2008 Novell, Inc. (www.novell.com)
+ *
+ */
+
+#include "ea-week-view-main-item.h"
+#include "ea-week-view.h"
+#include "ea-week-view-cell.h"
+#include "ea-cell-table.h"
+#include <glib/gi18n.h>
+
+/* EaWeekViewMainItem */
+static void ea_week_view_main_item_class_init (EaWeekViewMainItemClass *klass);
+
+static void ea_week_view_main_item_finalize (GObject *object);
+static G_CONST_RETURN gchar * ea_week_view_main_item_get_name (AtkObject *accessible);
+static G_CONST_RETURN gchar * ea_week_view_main_item_get_description (AtkObject *accessible);
+
+static gint ea_week_view_main_item_get_n_children (AtkObject *obj);
+static AtkObject* ea_week_view_main_item_ref_child (AtkObject *obj,
+ gint i);
+static AtkObject * ea_week_view_main_item_get_parent (AtkObject *accessible);
+static gint ea_week_view_main_item_get_index_in_parent (AtkObject *accessible);
+
+/* callbacks */
+static void ea_week_view_main_item_dates_change_cb (GnomeCalendar *gcal, gpointer data);
+static void ea_week_view_main_item_time_change_cb (EWeekView *week_view, gpointer data);
+
+/* component interface */
+static void atk_component_interface_init (AtkComponentIface *iface);
+static void component_interface_get_extents (AtkComponent *component,
+ gint *x, gint *y,
+ gint *width, gint *height,
+ AtkCoordType coord_type);
+
+/* atk table interface */
+static void atk_table_interface_init (AtkTableIface *iface);
+static gint table_interface_get_index_at (AtkTable *table,
+ gint row,
+ gint column);
+static gint table_interface_get_column_at_index (AtkTable *table,
+ gint index);
+static gint table_interface_get_row_at_index (AtkTable *table,
+ gint index);
+static AtkObject* table_interface_ref_at (AtkTable *table,
+ gint row,
+ gint column);
+static gint table_interface_get_n_rows (AtkTable *table);
+static gint table_interface_get_n_columns (AtkTable *table);
+static gint table_interface_get_column_extent_at (AtkTable *table,
+ gint row,
+ gint column);
+static gint table_interface_get_row_extent_at (AtkTable *table,
+ gint row,
+ gint column);
+
+static gboolean table_interface_is_row_selected (AtkTable *table,
+ gint row);
+static gboolean table_interface_is_column_selected (AtkTable *table,
+ gint row);
+static gboolean table_interface_is_selected (AtkTable *table,
+ gint row,
+ gint column);
+static gint table_interface_get_selected_rows (AtkTable *table,
+ gint **rows_selected);
+static gint table_interface_get_selected_columns (AtkTable *table,
+ gint **columns_selected);
+static gboolean table_interface_add_row_selection (AtkTable *table, gint row);
+static gboolean table_interface_remove_row_selection (AtkTable *table,
+ gint row);
+static gboolean table_interface_add_column_selection (AtkTable *table,
+ gint column);
+static gboolean table_interface_remove_column_selection (AtkTable *table,
+ gint column);
+static AtkObject* table_interface_get_row_header (AtkTable *table, gint row);
+static AtkObject* table_interface_get_column_header (AtkTable *table,
+ gint in_col);
+static AtkObject* table_interface_get_caption (AtkTable *table);
+
+static G_CONST_RETURN gchar *
+table_interface_get_column_description (AtkTable *table, gint in_col);
+
+static G_CONST_RETURN gchar *
+table_interface_get_row_description (AtkTable *table, gint row);
+
+static AtkObject* table_interface_get_summary (AtkTable *table);
+
+/* atk selection interface */
+static void atk_selection_interface_init (AtkSelectionIface *iface);
+static gboolean selection_interface_add_selection (AtkSelection *selection,
+ gint i);
+static gboolean selection_interface_clear_selection (AtkSelection *selection);
+static AtkObject* selection_interface_ref_selection (AtkSelection *selection,
+ gint i);
+static gint selection_interface_get_selection_count (AtkSelection *selection);
+static gboolean selection_interface_is_child_selected (AtkSelection *selection,
+ gint i);
+
+/* helpers */
+static EaCellTable *
+ea_week_view_main_item_get_cell_data (EaWeekViewMainItem *ea_main_item);
+
+static void
+ea_week_view_main_item_destory_cell_data (EaWeekViewMainItem *ea_main_item);
+
+static gint
+ea_week_view_main_item_get_child_index_at (EaWeekViewMainItem *ea_main_item,
+ gint row, gint column);
+static gint
+ea_week_view_main_item_get_row_at_index (EaWeekViewMainItem *ea_main_item,
+ gint index);
+static gint
+ea_week_view_main_item_get_column_at_index (EaWeekViewMainItem *ea_main_item,
+ gint index);
+static gint
+ea_week_view_main_item_get_row_label (EaWeekViewMainItem *ea_main_item,
+ gint row, gchar *buffer,
+ gint buffer_size);
+
+#ifdef ACC_DEBUG
+static gint n_ea_week_view_main_item_created = 0;
+static gint n_ea_week_view_main_item_destroyed = 0;
+#endif
+
+static gpointer parent_class = NULL;
+
+GType
+ea_week_view_main_item_get_type (void)
+{
+ static GType type = 0;
+ AtkObjectFactory *factory;
+ GTypeQuery query;
+ GType derived_atk_type;
+
+ if (!type) {
+ static GTypeInfo tinfo = {
+ sizeof (EaWeekViewMainItemClass),
+ (GBaseInitFunc) NULL, /* base init */
+ (GBaseFinalizeFunc) NULL, /* base finalize */
+ (GClassInitFunc) ea_week_view_main_item_class_init,
+ (GClassFinalizeFunc) NULL, /* class finalize */
+ NULL, /* class data */
+ sizeof (EaWeekViewMainItem), /* instance size */
+ 0, /* nb preallocs */
+ (GInstanceInitFunc) NULL, /* instance init */
+ NULL /* value table */
+ };
+
+ static const GInterfaceInfo atk_component_info = {
+ (GInterfaceInitFunc) atk_component_interface_init,
+ (GInterfaceFinalizeFunc) NULL,
+ NULL
+ };
+
+ static const GInterfaceInfo atk_table_info = {
+ (GInterfaceInitFunc) atk_table_interface_init,
+ (GInterfaceFinalizeFunc) NULL,
+ NULL
+ };
+ static const GInterfaceInfo atk_selection_info = {
+ (GInterfaceInitFunc) atk_selection_interface_init,
+ (GInterfaceFinalizeFunc) NULL,
+ NULL
+ };
+
+ /*
+ * Figure out the size of the class and instance
+ * we are run-time deriving from (GailCanvasItem, in this case)
+ *
+ */
+
+ factory = atk_registry_get_factory (atk_get_default_registry (),
+ e_week_view_main_item_get_type());
+ derived_atk_type = atk_object_factory_get_accessible_type (factory);
+ g_type_query (derived_atk_type, &query);
+
+ tinfo.class_size = query.class_size;
+ tinfo.instance_size = query.instance_size;
+
+ type = g_type_register_static (derived_atk_type,
+ "EaWeekViewMainItem", &tinfo, 0);
+ g_type_add_interface_static (type, ATK_TYPE_COMPONENT,
+ &atk_component_info);
+ g_type_add_interface_static (type, ATK_TYPE_TABLE,
+ &atk_table_info);
+ g_type_add_interface_static (type, ATK_TYPE_SELECTION,
+ &atk_selection_info);
+ }
+
+ return type;
+}
+
+static void
+ea_week_view_main_item_class_init (EaWeekViewMainItemClass *klass)
+{
+ GObjectClass *gobject_class = G_OBJECT_CLASS (klass);
+ AtkObjectClass *class = ATK_OBJECT_CLASS (klass);
+
+ gobject_class->finalize = ea_week_view_main_item_finalize;
+ parent_class = g_type_class_peek_parent (klass);
+
+ class->get_name = ea_week_view_main_item_get_name;
+ class->get_description = ea_week_view_main_item_get_description;
+
+ class->get_n_children = ea_week_view_main_item_get_n_children;
+ class->ref_child = ea_week_view_main_item_ref_child;
+ class->get_parent = ea_week_view_main_item_get_parent;
+ class->get_index_in_parent = ea_week_view_main_item_get_index_in_parent;
+}
+
+AtkObject*
+ea_week_view_main_item_new (GObject *obj)
+{
+ AtkObject *accessible;
+ GnomeCalendar *gcal;
+ EWeekViewMainItem *main_item;
+
+ g_return_val_if_fail (E_IS_WEEK_VIEW_MAIN_ITEM (obj), NULL);
+
+ accessible = ATK_OBJECT (g_object_new (EA_TYPE_WEEK_VIEW_MAIN_ITEM,
+ NULL));
+
+ atk_object_initialize (accessible, obj);
+ accessible->role = ATK_ROLE_TABLE;
+
+#ifdef ACC_DEBUG
+ ++n_ea_week_view_main_item_created;
+ printf ("ACC_DEBUG: n_ea_week_view_main_item_created = %d\n",
+ n_ea_week_view_main_item_created);
+#endif
+ main_item = E_WEEK_VIEW_MAIN_ITEM (obj);
+ g_signal_connect (main_item->week_view, "selected_time_changed",
+ G_CALLBACK (ea_week_view_main_item_time_change_cb),
+ accessible);
+
+ /* listen for date changes of calendar */
+ gcal = e_calendar_view_get_calendar (E_CALENDAR_VIEW (main_item->week_view));
+ if (gcal)
+ g_signal_connect (gcal, "dates_shown_changed",
+ G_CALLBACK (ea_week_view_main_item_dates_change_cb),
+ accessible);
+
+ return accessible;
+}
+
+static void
+ea_week_view_main_item_finalize (GObject *object)
+{
+ EaWeekViewMainItem *ea_main_item;
+
+ g_return_if_fail (EA_IS_WEEK_VIEW_MAIN_ITEM (object));
+
+ ea_main_item = EA_WEEK_VIEW_MAIN_ITEM (object);
+
+ /* Free the allocated cell data */
+ ea_week_view_main_item_destory_cell_data (ea_main_item);
+
+ G_OBJECT_CLASS (parent_class)->finalize (object);
+#ifdef ACC_DEBUG
+ ++n_ea_week_view_main_item_destroyed;
+ printf ("ACC_DEBUG: n_ea_week_view_main_item_destroyed = %d\n",
+ n_ea_week_view_main_item_destroyed);
+#endif
+}
+
+static G_CONST_RETURN gchar *
+ea_week_view_main_item_get_name (AtkObject *accessible)
+{
+ AtkObject *parent;
+ g_return_val_if_fail (EA_IS_WEEK_VIEW_MAIN_ITEM (accessible), NULL);
+ parent = atk_object_get_parent (accessible);
+ return atk_object_get_name (parent);
+
+}
+
+static G_CONST_RETURN gchar *
+ea_week_view_main_item_get_description (AtkObject *accessible)
+{
+ return _("a table to view and select the current time range");
+}
+
+static gint
+ea_week_view_main_item_get_n_children (AtkObject *accessible)
+{
+ AtkGObjectAccessible *atk_gobj;
+ GObject *g_obj;
+ EWeekViewMainItem *main_item;
+ EWeekView *week_view;
+
+ g_return_val_if_fail (EA_IS_WEEK_VIEW_MAIN_ITEM (accessible), -1);
+
+ atk_gobj = ATK_GOBJECT_ACCESSIBLE (accessible);
+ g_obj = atk_gobject_accessible_get_object (atk_gobj);
+ if (!g_obj)
+ return -1;
+
+ main_item = E_WEEK_VIEW_MAIN_ITEM (g_obj);
+ week_view = main_item->week_view;
+
+ if (week_view->multi_week_view)
+ return 7 * week_view->weeks_shown;
+ else
+ return 7;
+}
+
+static AtkObject *
+ea_week_view_main_item_ref_child (AtkObject *accessible, gint index)
+{
+ AtkGObjectAccessible *atk_gobj;
+ GObject *g_obj;
+ EWeekViewMainItem *main_item;
+ EWeekView *week_view;
+ gint n_children;
+ EWeekViewCell *cell;
+ EaCellTable *cell_data;
+ EaWeekViewMainItem *ea_main_item;
+
+ g_return_val_if_fail (EA_IS_WEEK_VIEW_MAIN_ITEM (accessible), NULL);
+
+ atk_gobj = ATK_GOBJECT_ACCESSIBLE (accessible);
+ g_obj = atk_gobject_accessible_get_object (atk_gobj);
+ if (!g_obj)
+ return NULL;
+
+ main_item = E_WEEK_VIEW_MAIN_ITEM (g_obj);
+ week_view = main_item->week_view;
+
+ n_children = ea_week_view_main_item_get_n_children (accessible);
+ if (index < 0 || index >= n_children)
+ return NULL;
+
+ ea_main_item = EA_WEEK_VIEW_MAIN_ITEM (accessible);
+ cell_data = ea_week_view_main_item_get_cell_data (ea_main_item);
+ if (!cell_data)
+ return NULL;
+ cell = ea_cell_table_get_cell_at_index (cell_data, index);
+ if (!cell) {
+ gint row, column;
+
+ row = ea_week_view_main_item_get_row_at_index (ea_main_item, index);
+ column = ea_week_view_main_item_get_column_at_index (ea_main_item, index);
+ cell = e_week_view_cell_new (week_view, row, column);
+ ea_cell_table_set_cell_at_index (cell_data, index, cell);
+ g_object_unref (cell);
+ }
+
+ return g_object_ref (atk_gobject_accessible_for_object (G_OBJECT(cell)));
+}
+
+static AtkObject *
+ea_week_view_main_item_get_parent (AtkObject *accessible)
+{
+ AtkGObjectAccessible *atk_gobj;
+ GObject *g_obj;
+ EWeekViewMainItem *main_item;
+
+ g_return_val_if_fail (EA_IS_WEEK_VIEW_MAIN_ITEM (accessible), NULL);
+
+ atk_gobj = ATK_GOBJECT_ACCESSIBLE (accessible);
+ g_obj = atk_gobject_accessible_get_object (atk_gobj);
+ if (!g_obj)
+ return NULL;
+
+ main_item = E_WEEK_VIEW_MAIN_ITEM (g_obj);
+ return gtk_widget_get_accessible (GTK_WIDGET (main_item->week_view));
+}
+
+static gint
+ea_week_view_main_item_get_index_in_parent (AtkObject *accessible)
+{
+ AtkGObjectAccessible *atk_gobj;
+ GObject *g_obj;
+
+ g_return_val_if_fail (EA_IS_WEEK_VIEW_MAIN_ITEM (accessible), -1);
+
+ atk_gobj = ATK_GOBJECT_ACCESSIBLE (accessible);
+ g_obj = atk_gobject_accessible_get_object (atk_gobj);
+ if (!g_obj)
+ return -1;
+
+ /* always the first child of ea-week-view */
+ return 0;
+}
+
+/* callbacks */
+
+static void
+ea_week_view_main_item_dates_change_cb (GnomeCalendar *gcal, gpointer data)
+{
+ EaWeekViewMainItem *ea_main_item;
+
+ g_return_if_fail (GNOME_IS_CALENDAR (gcal));
+ g_return_if_fail (data);
+ g_return_if_fail (EA_IS_WEEK_VIEW_MAIN_ITEM (data));
+
+ ea_main_item = EA_WEEK_VIEW_MAIN_ITEM (data);
+
+#ifdef ACC_DEBUG
+ printf ("EvoAcc: ea_week_view_main_item update cb\n");
+#endif
+
+ ea_week_view_main_item_destory_cell_data (ea_main_item);
+}
+
+static void
+ea_week_view_main_item_time_change_cb (EWeekView *week_view, gpointer data)
+{
+ EaWeekViewMainItem *ea_main_item;
+ AtkObject *item_cell = NULL;
+
+ g_return_if_fail (E_IS_WEEK_VIEW (week_view));
+ g_return_if_fail (data);
+ g_return_if_fail (EA_IS_WEEK_VIEW_MAIN_ITEM (data));
+
+ ea_main_item = EA_WEEK_VIEW_MAIN_ITEM (data);
+
+#ifdef ACC_DEBUG
+ printf ("EvoAcc: ea_week_view_main_item time changed cb\n");
+#endif
+ /* only deal with the first selected child, for now */
+ item_cell = atk_selection_ref_selection (ATK_SELECTION (ea_main_item),
+ 0);
+ if (item_cell) {
+ AtkStateSet *state_set;
+ state_set = atk_object_ref_state_set (item_cell);
+ atk_state_set_add_state (state_set, ATK_STATE_FOCUSED);
+ g_object_unref (state_set);
+
+ g_signal_emit_by_name (ea_main_item,
+ "active-descendant-changed",
+ item_cell);
+ g_signal_emit_by_name (data, "selection_changed");
+ atk_focus_tracker_notify (item_cell);
+ g_object_unref (item_cell);
+ }
+}
+
+/* helpers */
+
+static gint
+ea_week_view_main_item_get_child_index_at (EaWeekViewMainItem *ea_main_item,
+ gint row, gint column)
+{
+ AtkGObjectAccessible *atk_gobj;
+ GObject *g_obj;
+ EWeekViewMainItem *main_item;
+ EWeekView *week_view;
+
+ g_return_val_if_fail (ea_main_item, -1);
+
+ atk_gobj = ATK_GOBJECT_ACCESSIBLE (ea_main_item);
+ g_obj = atk_gobject_accessible_get_object (atk_gobj);
+ if (!g_obj)
+ return -1;
+
+ main_item = E_WEEK_VIEW_MAIN_ITEM (g_obj);
+ week_view = main_item->week_view;
+
+ if (row >= 0 && row < week_view->weeks_shown &&
+ column >= 0 && column < 7)
+ return row * 7 + column;
+
+ return -1;
+}
+
+static gint
+ea_week_view_main_item_get_row_at_index (EaWeekViewMainItem *ea_main_item,
+ gint index)
+{
+ AtkGObjectAccessible *atk_gobj;
+ GObject *g_obj;
+ gint n_children;
+
+ g_return_val_if_fail (ea_main_item, -1);
+
+ atk_gobj = ATK_GOBJECT_ACCESSIBLE (ea_main_item);
+ g_obj = atk_gobject_accessible_get_object (atk_gobj);
+ if (!g_obj)
+ return -1;
+
+ n_children = ea_week_view_main_item_get_n_children (ATK_OBJECT (ea_main_item));
+ if (index >= 0 && index < n_children)
+ return index / 7;
+ return -1;
+}
+
+static gint
+ea_week_view_main_item_get_column_at_index (EaWeekViewMainItem *ea_main_item,
+ gint index)
+{
+ AtkGObjectAccessible *atk_gobj;
+ GObject *g_obj;
+ gint n_children;
+
+ g_return_val_if_fail (ea_main_item, -1);
+
+ atk_gobj = ATK_GOBJECT_ACCESSIBLE (ea_main_item);
+ g_obj = atk_gobject_accessible_get_object (atk_gobj);
+ if (!g_obj)
+ return -1;
+
+ n_children = ea_week_view_main_item_get_n_children (ATK_OBJECT (ea_main_item));
+ if (index >= 0 && index < n_children)
+ return index % 7;
+ return -1;
+}
+
+static gint
+ea_week_view_main_item_get_row_label (EaWeekViewMainItem *ea_main_item,
+ gint row, gchar *buffer, gint buffer_size)
+{
+ AtkGObjectAccessible *atk_gobj;
+ GObject *g_obj;
+
+ g_return_val_if_fail (ea_main_item, 0);
+
+ atk_gobj = ATK_GOBJECT_ACCESSIBLE (ea_main_item);
+ g_obj = atk_gobject_accessible_get_object (atk_gobj);
+ if (!g_obj)
+ return 0;
+
+ return g_snprintf (buffer, buffer_size, "the %i week",
+ row + 1);
+
+}
+
+static EaCellTable *
+ea_week_view_main_item_get_cell_data (EaWeekViewMainItem *ea_main_item)
+{
+ AtkGObjectAccessible *atk_gobj;
+ GObject *g_obj;
+ EWeekViewMainItem *main_item;
+ EWeekView *week_view;
+ EaCellTable *cell_data;
+
+ g_return_val_if_fail (ea_main_item, NULL);
+
+ atk_gobj = ATK_GOBJECT_ACCESSIBLE (ea_main_item);
+ g_obj = atk_gobject_accessible_get_object (atk_gobj);
+ if (!g_obj)
+ return NULL;
+
+ main_item = E_WEEK_VIEW_MAIN_ITEM (g_obj);
+ week_view = main_item->week_view;
+
+ cell_data = g_object_get_data (G_OBJECT(ea_main_item),
+ "ea-week-view-cell-table");
+ if (!cell_data) {
+ cell_data = ea_cell_table_create (week_view->weeks_shown, 7, TRUE);
+ g_object_set_data (G_OBJECT(ea_main_item),
+ "ea-week-view-cell-table", cell_data);
+ }
+ return cell_data;
+}
+
+static void
+ea_week_view_main_item_destory_cell_data (EaWeekViewMainItem *ea_main_item)
+{
+ EaCellTable *cell_data;
+
+ g_return_if_fail (ea_main_item);
+
+ cell_data = g_object_get_data (G_OBJECT(ea_main_item),
+ "ea-week-view-cell-table");
+ if (cell_data) {
+ g_object_set_data (G_OBJECT(ea_main_item),
+ "ea-week-view-cell-table", NULL);
+ ea_cell_table_destroy (cell_data);
+ }
+}
+
+/* Atk Component Interface */
+
+static void
+atk_component_interface_init (AtkComponentIface *iface)
+{
+ g_return_if_fail (iface != NULL);
+
+ iface->get_extents = component_interface_get_extents;
+}
+
+static void
+component_interface_get_extents (AtkComponent *component,
+ gint *x, gint *y, gint *width, gint *height,
+ AtkCoordType coord_type)
+{
+ GObject *g_obj;
+ AtkObject *ea_canvas;
+ EWeekViewMainItem *main_item;
+ EWeekView *week_view;
+
+ *x = *y = *width = *height = 0;
+
+ g_return_if_fail (EA_IS_WEEK_VIEW_MAIN_ITEM (component));
+
+ g_obj = atk_gobject_accessible_get_object (ATK_GOBJECT_ACCESSIBLE(component));
+ if (!g_obj)
+ /* defunct object*/
+ return;
+ main_item = E_WEEK_VIEW_MAIN_ITEM (g_obj);
+ week_view = main_item->week_view;
+
+ ea_canvas = gtk_widget_get_accessible (week_view->main_canvas);
+ atk_component_get_extents (ATK_COMPONENT (ea_canvas), x, y,
+ width, height, coord_type);
+}
+
+/* atk table interface */
+
+static void
+atk_table_interface_init (AtkTableIface *iface)
+{
+ g_return_if_fail (iface != NULL);
+
+ iface->ref_at = table_interface_ref_at;
+
+ iface->get_n_rows = table_interface_get_n_rows;
+ iface->get_n_columns = table_interface_get_n_columns;
+ iface->get_index_at = table_interface_get_index_at;
+ iface->get_column_at_index = table_interface_get_column_at_index;
+ iface->get_row_at_index = table_interface_get_row_at_index;
+ iface->get_column_extent_at = table_interface_get_column_extent_at;
+ iface->get_row_extent_at = table_interface_get_row_extent_at;
+
+ iface->is_selected = table_interface_is_selected;
+ iface->get_selected_rows = table_interface_get_selected_rows;
+ iface->get_selected_columns = table_interface_get_selected_columns;
+ iface->is_row_selected = table_interface_is_row_selected;
+ iface->is_column_selected = table_interface_is_column_selected;
+ iface->add_row_selection = table_interface_add_row_selection;
+ iface->remove_row_selection = table_interface_remove_row_selection;
+ iface->add_column_selection = table_interface_add_column_selection;
+ iface->remove_column_selection = table_interface_remove_column_selection;
+
+ iface->get_row_header = table_interface_get_row_header;
+ iface->get_column_header = table_interface_get_column_header;
+ iface->get_caption = table_interface_get_caption;
+ iface->get_summary = table_interface_get_summary;
+ iface->get_row_description = table_interface_get_row_description;
+ iface->get_column_description = table_interface_get_column_description;
+}
+
+static AtkObject*
+table_interface_ref_at (AtkTable *table,
+ gint row,
+ gint column)
+{
+ gint index;
+
+ EaWeekViewMainItem* ea_main_item = EA_WEEK_VIEW_MAIN_ITEM (table);
+ index = ea_week_view_main_item_get_child_index_at (ea_main_item,
+ row, column);
+ return ea_week_view_main_item_ref_child (ATK_OBJECT (ea_main_item), index);
+}
+
+static gint
+table_interface_get_n_rows (AtkTable *table)
+{
+ AtkGObjectAccessible *atk_gobj;
+ GObject *g_obj;
+ EWeekViewMainItem *main_item;
+ EWeekView *week_view;
+ EaWeekViewMainItem* ea_main_item = EA_WEEK_VIEW_MAIN_ITEM (table);
+
+ atk_gobj = ATK_GOBJECT_ACCESSIBLE (ea_main_item);
+ g_obj = atk_gobject_accessible_get_object (atk_gobj);
+ if (!g_obj)
+ return -1;
+
+ main_item = E_WEEK_VIEW_MAIN_ITEM (g_obj);
+ week_view = main_item->week_view;
+
+ return week_view->weeks_shown;
+}
+
+static gint
+table_interface_get_n_columns (AtkTable *table)
+{
+ AtkGObjectAccessible *atk_gobj;
+ GObject *g_obj;
+ EaWeekViewMainItem* ea_main_item = EA_WEEK_VIEW_MAIN_ITEM (table);
+
+ atk_gobj = ATK_GOBJECT_ACCESSIBLE (ea_main_item);
+ g_obj = atk_gobject_accessible_get_object (atk_gobj);
+ if (!g_obj)
+ return -1;
+
+ return 7;
+}
+
+static gint
+table_interface_get_index_at (AtkTable *table,
+ gint row,
+ gint column)
+{
+ EaWeekViewMainItem* ea_main_item = EA_WEEK_VIEW_MAIN_ITEM (table);
+ return ea_week_view_main_item_get_child_index_at (ea_main_item,
+ row, column);
+}
+
+static gint
+table_interface_get_column_at_index (AtkTable *table,
+ gint index)
+{
+ EaWeekViewMainItem* ea_main_item = EA_WEEK_VIEW_MAIN_ITEM (table);
+ return ea_week_view_main_item_get_column_at_index (ea_main_item, index);
+}
+
+static gint
+table_interface_get_row_at_index (AtkTable *table,
+ gint index)
+{
+ EaWeekViewMainItem* ea_main_item = EA_WEEK_VIEW_MAIN_ITEM (table);
+ return ea_week_view_main_item_get_row_at_index (ea_main_item, index);
+}
+
+static gint
+table_interface_get_column_extent_at (AtkTable *table,
+ gint row,
+ gint column)
+{
+ gint index;
+ gint width = 0, height = 0;
+ AtkObject *child;
+ EaWeekViewMainItem* ea_main_item = EA_WEEK_VIEW_MAIN_ITEM (table);
+
+ index = ea_week_view_main_item_get_child_index_at (ea_main_item,
+ row, column);
+ child = atk_object_ref_accessible_child (ATK_OBJECT (ea_main_item),
+ index);
+ if (child)
+ atk_component_get_size (ATK_COMPONENT (child),
+ &width, &height);
+
+ return width;
+}
+
+static gint
+table_interface_get_row_extent_at (AtkTable *table,
+ gint row,
+ gint column)
+{
+ gint index;
+ gint width = 0, height = 0;
+ AtkObject *child;
+ EaWeekViewMainItem* ea_main_item = EA_WEEK_VIEW_MAIN_ITEM (table);
+
+ index = ea_week_view_main_item_get_child_index_at (ea_main_item,
+ row, column);
+ child = atk_object_ref_accessible_child (ATK_OBJECT (ea_main_item),
+ index);
+ if (child)
+ atk_component_get_size (ATK_COMPONENT (child),
+ &width, &height);
+
+ return height;
+}
+
+static gboolean
+table_interface_is_row_selected (AtkTable *table,
+ gint row)
+{
+ AtkGObjectAccessible *atk_gobj;
+ GObject *g_obj;
+ EWeekViewMainItem *main_item;
+ EWeekView *week_view;
+ EaWeekViewMainItem* ea_main_item = EA_WEEK_VIEW_MAIN_ITEM (table);
+
+ atk_gobj = ATK_GOBJECT_ACCESSIBLE (ea_main_item);
+ g_obj = atk_gobject_accessible_get_object (atk_gobj);
+ if (!g_obj)
+ return FALSE;
+
+ main_item = E_WEEK_VIEW_MAIN_ITEM (g_obj);
+ week_view = main_item->week_view;
+
+ if (week_view->selection_start_day == -1)
+ /* no selection */
+ return FALSE;
+ if ((row < 0)&&(row + 1 > week_view->weeks_shown ))
+ return FALSE;
+ if (((week_view->selection_start_day < row*7)&&(week_view->selection_end_day<row*7))
+ ||((week_view->selection_start_day > row*7+6)&&(week_view->selection_end_day > row*7+6)))
+ return FALSE;
+ else
+ return TRUE;
+}
+
+static gboolean
+table_interface_is_selected (AtkTable *table,
+ gint row,
+ gint column)
+{
+ return table_interface_is_row_selected (table, row) && table_interface_is_column_selected(table, column);
+}
+
+static gboolean
+table_interface_is_column_selected (AtkTable *table,
+ gint column)
+{
+ AtkGObjectAccessible *atk_gobj;
+ GObject *g_obj;
+ EWeekViewMainItem *main_item;
+ EWeekView *week_view;
+ EaWeekViewMainItem* ea_main_item = EA_WEEK_VIEW_MAIN_ITEM (table);
+
+ atk_gobj = ATK_GOBJECT_ACCESSIBLE (ea_main_item);
+ g_obj = atk_gobject_accessible_get_object (atk_gobj);
+ if (!g_obj)
+ return FALSE;
+
+ main_item = E_WEEK_VIEW_MAIN_ITEM (g_obj);
+ week_view = main_item->week_view;
+
+ if ((column <0)||(column >6))
+ return FALSE;
+ else {
+ gint i;
+ for (i=0;i<week_view->weeks_shown;i++)
+ if ((column + i*7>= week_view->selection_start_day ) &&
+ (column + i*7<= week_view->selection_end_day))
+ return TRUE;
+ return FALSE;
+ }
+}
+
+static gint
+table_interface_get_selected_rows (AtkTable *table,
+ gint **rows_selected)
+{
+ AtkGObjectAccessible *atk_gobj;
+ GObject *g_obj;
+ EWeekViewMainItem *main_item;
+ EWeekView *week_view;
+ EaWeekViewMainItem* ea_main_item = EA_WEEK_VIEW_MAIN_ITEM (table);
+ gint start_row = -1, n_rows = 0;
+
+ atk_gobj = ATK_GOBJECT_ACCESSIBLE (ea_main_item);
+ g_obj = atk_gobject_accessible_get_object (atk_gobj);
+ if (!g_obj)
+ return -1;
+
+ main_item = E_WEEK_VIEW_MAIN_ITEM (g_obj);
+ week_view = main_item->week_view;
+
+ if (week_view->selection_start_day == -1)
+ return 0;
+
+ start_row = week_view->selection_start_day;
+ n_rows = week_view->selection_end_day - start_row + 1;
+
+ if (n_rows > 0 && start_row != -1 && rows_selected) {
+ gint index;
+
+ *rows_selected = (gint *) g_malloc (n_rows * sizeof (gint));
+ for (index = 0; index < n_rows; ++index)
+ (*rows_selected)[index] = start_row + index;
+ }
+ return n_rows;
+}
+
+static gint
+table_interface_get_selected_columns (AtkTable *table,
+ gint **columns_selected)
+{
+ AtkGObjectAccessible *atk_gobj;
+ GObject *g_obj;
+ EWeekViewMainItem *main_item;
+ EWeekView *week_view;
+ EaWeekViewMainItem* ea_main_item = EA_WEEK_VIEW_MAIN_ITEM (table);
+ gint start_column = -1, n_columns = 0;
+
+ atk_gobj = ATK_GOBJECT_ACCESSIBLE (ea_main_item);
+ g_obj = atk_gobject_accessible_get_object (atk_gobj);
+ if (!g_obj)
+ return -1;
+
+ main_item = E_WEEK_VIEW_MAIN_ITEM (g_obj);
+ week_view = main_item->week_view;
+
+ if (week_view->selection_start_day == -1)
+ return 0;
+ if (week_view->selection_end_day - week_view->selection_start_day >= 6 ) {
+ start_column = 0;
+ n_columns =7;
+ } else {
+ start_column = week_view->selection_start_day % 7;
+ n_columns = (week_view->selection_end_day % 7) - start_column + 1;
+ }
+ if (n_columns > 0 && start_column != -1 && columns_selected) {
+ gint index;
+
+ *columns_selected = (gint *) g_malloc (n_columns * sizeof (gint));
+ for (index = 0; index < n_columns; ++index)
+ (*columns_selected)[index] = start_column + index;
+ }
+ return n_columns;
+}
+
+static gboolean
+table_interface_add_row_selection (AtkTable *table,
+ gint row)
+{
+ AtkGObjectAccessible *atk_gobj;
+ GObject *g_obj;
+ EWeekViewMainItem *main_item;
+ EWeekView *week_view;
+ EaWeekViewMainItem* ea_main_item = EA_WEEK_VIEW_MAIN_ITEM (table);
+
+ atk_gobj = ATK_GOBJECT_ACCESSIBLE (ea_main_item);
+ g_obj = atk_gobject_accessible_get_object (atk_gobj);
+ if (!g_obj)
+ return FALSE;
+
+ main_item = E_WEEK_VIEW_MAIN_ITEM (g_obj);
+ week_view = main_item->week_view;
+
+ /* FIXME: we need multi-selection */
+
+ week_view->selection_start_day = row * 7;
+ week_view->selection_end_day = row *7 + 6;
+
+ gtk_widget_queue_draw (week_view->main_canvas);
+ return TRUE;
+}
+
+static gboolean
+table_interface_remove_row_selection (AtkTable *table,
+ gint row)
+{
+ return FALSE;
+}
+
+static gboolean
+table_interface_add_column_selection (AtkTable *table,
+ gint column)
+{
+ AtkGObjectAccessible *atk_gobj;
+ GObject *g_obj;
+ EWeekViewMainItem *main_item;
+ EWeekView *week_view;
+ EaWeekViewMainItem* ea_main_item = EA_WEEK_VIEW_MAIN_ITEM (table);
+
+ atk_gobj = ATK_GOBJECT_ACCESSIBLE (ea_main_item);
+ g_obj = atk_gobject_accessible_get_object (atk_gobj);
+ if (!g_obj)
+ return FALSE;
+
+ main_item = E_WEEK_VIEW_MAIN_ITEM (g_obj);
+ week_view = main_item->week_view;
+
+ /* FIXME: we need multi-selection */
+
+ week_view->selection_start_day = column;
+ week_view->selection_end_day = (week_view->weeks_shown - 1)*7+column;
+
+ gtk_widget_queue_draw (week_view->main_canvas);
+ return TRUE;
+}
+
+static gboolean
+table_interface_remove_column_selection (AtkTable *table,
+ gint column)
+{
+ /* FIXME: NOT IMPLEMENTED */
+ return FALSE;
+}
+
+static AtkObject*
+table_interface_get_row_header (AtkTable *table,
+ gint row)
+{
+ /* FIXME: NOT IMPLEMENTED */
+ return NULL;
+}
+
+static AtkObject*
+table_interface_get_column_header (AtkTable *table,
+ gint in_col)
+{
+ /* FIXME: NOT IMPLEMENTED */
+ return NULL;
+}
+
+static AtkObject*
+table_interface_get_caption (AtkTable *table)
+{
+ /* FIXME: NOT IMPLEMENTED */
+ return NULL;
+}
+
+static G_CONST_RETURN gchar *
+table_interface_get_column_description (AtkTable *table,
+ gint in_col)
+{
+ AtkGObjectAccessible *atk_gobj;
+ GObject *g_obj;
+ EaWeekViewMainItem* ea_main_item = EA_WEEK_VIEW_MAIN_ITEM (table);
+ const gchar *description;
+ EaCellTable *cell_data;
+
+ atk_gobj = ATK_GOBJECT_ACCESSIBLE (ea_main_item);
+ g_obj = atk_gobject_accessible_get_object (atk_gobj);
+ if (!g_obj)
+ return NULL;
+
+ if (in_col < 0 || in_col > 6)
+ return NULL;
+ cell_data = ea_week_view_main_item_get_cell_data (ea_main_item);
+ if (!cell_data)
+ return NULL;
+
+ description = ea_cell_table_get_column_label (cell_data, in_col);
+ if (!description) {
+ gchar buffer[128];
+
+ switch (in_col) {
+ case 0:
+ g_snprintf(buffer,128,"Monday");
+ break;
+ case 1:
+ g_snprintf(buffer,128,"Tuesday");
+ break;
+ case 2:
+ g_snprintf(buffer,128,"Wednesday");
+ break;
+ case 3:
+ g_snprintf(buffer,128,"Thursday");
+ break;
+ case 4:
+ g_snprintf(buffer,128,"Friday");
+ break;
+ case 5:
+ g_snprintf(buffer,128,"Saturday");
+ break;
+ case 6:
+ g_snprintf(buffer,128,"Sunday");
+ break;
+ default:
+ break;
+ }
+
+ ea_cell_table_set_column_label (cell_data, in_col, buffer);
+ description = ea_cell_table_get_column_label (cell_data, in_col);
+ }
+ return description;
+}
+
+static G_CONST_RETURN gchar *
+table_interface_get_row_description (AtkTable *table,
+ gint row)
+{
+ AtkGObjectAccessible *atk_gobj;
+ GObject *g_obj;
+ EWeekViewMainItem *main_item;
+ EWeekView *week_view;
+ EaWeekViewMainItem* ea_main_item = EA_WEEK_VIEW_MAIN_ITEM (table);
+ const gchar *description;
+ EaCellTable *cell_data;
+
+ atk_gobj = ATK_GOBJECT_ACCESSIBLE (ea_main_item);
+ g_obj = atk_gobject_accessible_get_object (atk_gobj);
+ if (!g_obj)
+ return NULL;
+
+ main_item = E_WEEK_VIEW_MAIN_ITEM (g_obj);
+ week_view = main_item->week_view;
+
+ if (row < 0 || row >= week_view->weeks_shown)
+ return NULL;
+ cell_data = ea_week_view_main_item_get_cell_data (ea_main_item);
+ if (!cell_data)
+ return NULL;
+
+ description = ea_cell_table_get_row_label (cell_data, row);
+ if (!description) {
+ gchar buffer[128];
+ ea_week_view_main_item_get_row_label (ea_main_item, row, buffer, sizeof (buffer));
+ ea_cell_table_set_row_label (cell_data, row, buffer);
+ description = ea_cell_table_get_row_label (cell_data,
+ row);
+ }
+ return description;
+}
+
+static AtkObject*
+table_interface_get_summary (AtkTable *table)
+{
+ /* FIXME: NOT IMPLEMENTED */
+ return NULL;
+}
+
+/* atkselection interface */
+
+static void
+atk_selection_interface_init (AtkSelectionIface *iface)
+{
+ g_return_if_fail (iface != NULL);
+
+ iface->add_selection = selection_interface_add_selection;
+ iface->clear_selection = selection_interface_clear_selection;
+ iface->ref_selection = selection_interface_ref_selection;
+ iface->get_selection_count = selection_interface_get_selection_count;
+ iface->is_child_selected = selection_interface_is_child_selected;
+}
+
+static gboolean
+selection_interface_add_selection (AtkSelection *selection, gint i)
+{
+ AtkGObjectAccessible *atk_gobj;
+ GObject *g_obj;
+ EWeekViewMainItem *main_item;
+ EWeekView *week_view;
+ EaWeekViewMainItem* ea_main_item = EA_WEEK_VIEW_MAIN_ITEM (selection);
+
+ atk_gobj = ATK_GOBJECT_ACCESSIBLE (ea_main_item);
+ g_obj = atk_gobject_accessible_get_object (atk_gobj);
+ if (!g_obj)
+ return FALSE;
+
+ main_item = E_WEEK_VIEW_MAIN_ITEM (g_obj);
+ week_view = main_item->week_view;
+
+ if (i < 0 || i > week_view->weeks_shown * 7 -1)
+ return FALSE;
+
+ /*FIXME: multi-selection is needed */
+ week_view->selection_start_day = i;
+ week_view->selection_end_day = i;
+
+ gtk_widget_queue_draw (week_view->main_canvas);
+ return TRUE;
+}
+
+static gboolean
+selection_interface_clear_selection (AtkSelection *selection)
+{
+ AtkGObjectAccessible *atk_gobj;
+ GObject *g_obj;
+ EWeekViewMainItem *main_item;
+ EWeekView *week_view;
+ EaWeekViewMainItem* ea_main_item = EA_WEEK_VIEW_MAIN_ITEM (selection);
+
+ atk_gobj = ATK_GOBJECT_ACCESSIBLE (ea_main_item);
+ g_obj = atk_gobject_accessible_get_object (atk_gobj);
+ if (!g_obj)
+ return FALSE;
+
+ main_item = E_WEEK_VIEW_MAIN_ITEM (g_obj);
+ week_view = main_item->week_view;
+
+ week_view->selection_start_day = -1;
+ week_view->selection_end_day = -1;
+
+ gtk_widget_queue_draw (week_view->main_canvas);
+
+ return TRUE;
+}
+
+static AtkObject*
+selection_interface_ref_selection (AtkSelection *selection, gint i)
+{
+ gint count;
+ GObject *g_obj;
+ EWeekView *week_view;
+ EaWeekViewMainItem* ea_main_item = EA_WEEK_VIEW_MAIN_ITEM (selection);
+ gint start_index;
+
+ count = selection_interface_get_selection_count (selection);
+ if (i < 0 || i >=count)
+ return NULL;
+
+ g_obj = atk_gobject_accessible_get_object (ATK_GOBJECT_ACCESSIBLE (ea_main_item));
+ week_view = E_WEEK_VIEW_MAIN_ITEM (g_obj)->week_view;
+ start_index = ea_week_view_main_item_get_child_index_at (ea_main_item,
+ week_view->selection_start_day / 7,
+ week_view->selection_start_day % 7);
+
+ return ea_week_view_main_item_ref_child (ATK_OBJECT (selection), start_index + i);
+}
+
+static gint
+selection_interface_get_selection_count (AtkSelection *selection)
+{
+ AtkGObjectAccessible *atk_gobj;
+ GObject *g_obj;
+ EWeekViewMainItem *main_item;
+ EWeekView *week_view;
+ EaWeekViewMainItem* ea_main_item = EA_WEEK_VIEW_MAIN_ITEM (selection);
+
+ atk_gobj = ATK_GOBJECT_ACCESSIBLE (ea_main_item);
+ g_obj = atk_gobject_accessible_get_object (atk_gobj);
+ if (!g_obj)
+ return 0;
+
+ main_item = E_WEEK_VIEW_MAIN_ITEM (g_obj);
+ week_view = main_item->week_view;
+
+ if (week_view->selection_start_day == -1 ||
+ week_view->selection_end_day == -1)
+ return 0;
+
+ return week_view->selection_end_day - week_view->selection_start_day + 1;
+}
+
+static gboolean
+selection_interface_is_child_selected (AtkSelection *selection, gint i)
+{
+ AtkGObjectAccessible *atk_gobj;
+ GObject *g_obj;
+ EWeekViewMainItem *main_item;
+ EWeekView *week_view;
+ EaWeekViewMainItem* ea_main_item = EA_WEEK_VIEW_MAIN_ITEM (selection);
+
+ atk_gobj = ATK_GOBJECT_ACCESSIBLE (ea_main_item);
+ g_obj = atk_gobject_accessible_get_object (atk_gobj);
+ if (!g_obj)
+ return FALSE;
+
+ main_item = E_WEEK_VIEW_MAIN_ITEM (g_obj);
+ week_view = main_item->week_view;
+
+ if ((week_view->selection_start_day <= i)&&(week_view->selection_end_day >= i))
+ return TRUE;
+ else
+ return FALSE;
+}
+
diff --git a/calendar/gui/ea-week-view-main-item.h b/calendar/gui/ea-week-view-main-item.h
new file mode 100644
index 0000000000..d9110160c4
--- /dev/null
+++ b/calendar/gui/ea-week-view-main-item.h
@@ -0,0 +1,59 @@
+/*
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2 of the License, or (at your option) version 3.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with the program; if not, see <http://www.gnu.org/licenses/>
+ *
+ *
+ * Authors:
+ * Bolian Yin <bolian.yin@sun.com>
+ * Yang Wu <Yang.Wu@sun.com>
+ *
+ * Copyright (C) 1999-2008 Novell, Inc. (www.novell.com)
+ *
+ */
+
+#ifndef __EA_WEEK_VIEW_MAIN_ITEM_H__
+#define __EA_WEEK_VIEW_MAIN_ITEM_H__
+
+#include <atk/atkgobjectaccessible.h>
+#include "e-week-view-main-item.h"
+
+G_BEGIN_DECLS
+
+#define EA_TYPE_WEEK_VIEW_MAIN_ITEM (ea_week_view_main_item_get_type ())
+#define EA_WEEK_VIEW_MAIN_ITEM(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), EA_TYPE_WEEK_VIEW_MAIN_ITEM, EaWeekViewMainItem))
+#define EA_WEEK_VIEW_MAIN_ITEM_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), EA_TYPE_WEEK_VIEW_MAIN_ITEM, EaWeekViewMainItemClass))
+#define EA_IS_WEEK_VIEW_MAIN_ITEM(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), EA_TYPE_WEEK_VIEW_MAIN_ITEM))
+#define EA_IS_WEEK_VIEW_MAIN_ITEM_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), EA_TYPE_WEEK_VIEW_MAIN_ITEM))
+#define EA_WEEK_VIEW_MAIN_ITEM_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), EA_TYPE_WEEK_VIEW_MAIN_ITEM, EaWeekViewMainItemClass))
+
+typedef struct _EaWeekViewMainItem EaWeekViewMainItem;
+typedef struct _EaWeekViewMainItemClass EaWeekViewMainItemClass;
+
+struct _EaWeekViewMainItem
+{
+ AtkGObjectAccessible parent;
+};
+
+GType ea_week_view_main_item_get_type (void);
+
+struct _EaWeekViewMainItemClass
+{
+ AtkGObjectAccessibleClass parent_class;
+};
+
+AtkObject* ea_week_view_main_item_new (GObject *obj);
+
+G_END_DECLS
+
+#endif /* __EA_WEEK_VIEW_MAIN_ITEM_H__ */
diff --git a/calendar/gui/ea-week-view.c b/calendar/gui/ea-week-view.c
new file mode 100644
index 0000000000..6e9751eb27
--- /dev/null
+++ b/calendar/gui/ea-week-view.c
@@ -0,0 +1,320 @@
+/*
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2 of the License, or (at your option) version 3.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with the program; if not, see <http://www.gnu.org/licenses/>
+ *
+ *
+ * Authors:
+ * Bolian Yin <bolian.yin@sun.com>
+ *
+ * Copyright (C) 1999-2008 Novell, Inc. (www.novell.com)
+ *
+ */
+
+#include "ea-week-view.h"
+#include "ea-cal-view-event.h"
+#include "ea-calendar-helpers.h"
+#include "ea-gnome-calendar.h"
+#include <text/e-text.h>
+#include <glib/gi18n.h>
+
+static void ea_week_view_class_init (EaWeekViewClass *klass);
+
+static G_CONST_RETURN gchar * ea_week_view_get_name (AtkObject *accessible);
+static G_CONST_RETURN gchar * ea_week_view_get_description (AtkObject *accessible);
+static gint ea_week_view_get_n_children (AtkObject *obj);
+static AtkObject* ea_week_view_ref_child (AtkObject *obj,
+ gint i);
+
+static gpointer parent_class = NULL;
+
+GType
+ea_week_view_get_type (void)
+{
+ static GType type = 0;
+ AtkObjectFactory *factory;
+ GTypeQuery query;
+ GType derived_atk_type;
+
+ if (!type) {
+ static GTypeInfo tinfo = {
+ sizeof (EaWeekViewClass),
+ (GBaseInitFunc) NULL, /* base init */
+ (GBaseFinalizeFunc) NULL, /* base finalize */
+ (GClassInitFunc) ea_week_view_class_init, /* class init */
+ (GClassFinalizeFunc) NULL, /* class finalize */
+ NULL, /* class data */
+ sizeof (EaWeekView), /* instance size */
+ 0, /* nb preallocs */
+ (GInstanceInitFunc) NULL, /* instance init */
+ NULL /* value table */
+ };
+
+ /*
+ * Figure out the size of the class and instance
+ * we are run-time deriving from (EaCalView, in this case)
+ *
+ * Note: we must still use run-time deriving here, because
+ * our parent class EaCalView is run-time deriving.
+ */
+
+ factory = atk_registry_get_factory (atk_get_default_registry (),
+ e_calendar_view_get_type());
+ derived_atk_type = atk_object_factory_get_accessible_type (factory);
+ g_type_query (derived_atk_type, &query);
+
+ tinfo.class_size = query.class_size;
+ tinfo.instance_size = query.instance_size;
+
+ type = g_type_register_static (derived_atk_type,
+ "EaWeekView", &tinfo, 0);
+
+ }
+
+ return type;
+}
+
+static void
+ea_week_view_class_init (EaWeekViewClass *klass)
+{
+ AtkObjectClass *class = ATK_OBJECT_CLASS (klass);
+
+ parent_class = g_type_class_peek_parent (klass);
+
+ class->get_name = ea_week_view_get_name;
+ class->get_description = ea_week_view_get_description;
+
+ class->get_n_children = ea_week_view_get_n_children;
+ class->ref_child = ea_week_view_ref_child;
+}
+
+AtkObject*
+ea_week_view_new (GtkWidget *widget)
+{
+ GObject *object;
+ AtkObject *accessible;
+
+ g_return_val_if_fail (GTK_IS_WIDGET (widget), NULL);
+
+ object = g_object_new (EA_TYPE_WEEK_VIEW, NULL);
+
+ accessible = ATK_OBJECT (object);
+ atk_object_initialize (accessible, widget);
+
+#ifdef ACC_DEBUG
+ printf ("EvoAcc: ea_week_view created %p\n", (gpointer)accessible);
+#endif
+
+ return accessible;
+}
+
+static G_CONST_RETURN gchar *
+ea_week_view_get_name (AtkObject *accessible)
+{
+ EWeekView *week_view;
+ GnomeCalendar *gcal;
+ const gchar *label_text;
+ GnomeCalendarViewType view_type;
+ gint n_events;
+ gchar *event_str, *name_str;
+
+ g_return_val_if_fail (EA_IS_WEEK_VIEW (accessible), NULL);
+
+ if (!GTK_ACCESSIBLE (accessible)->widget)
+ return NULL;
+
+ week_view = E_WEEK_VIEW (GTK_ACCESSIBLE (accessible)->widget);
+ gcal = e_calendar_view_get_calendar (E_CALENDAR_VIEW (week_view));
+ if (!GTK_WIDGET_VISIBLE (GTK_WIDGET (gcal)))
+ return NULL;
+
+ label_text = ea_gnome_calendar_get_label_description (gcal);
+
+ n_events = atk_object_get_n_accessible_children (accessible);
+ /* the child main item is always there */
+ --n_events;
+ if (n_events >= 1)
+ event_str = g_strdup_printf (ngettext ("It has %d event.", "It has %d events.", n_events), n_events);
+ else
+ event_str = g_strdup (_("It has no events."));
+
+ view_type = gnome_calendar_get_view (gcal);
+
+ if (view_type == GNOME_CAL_MONTH_VIEW)
+ name_str = g_strdup_printf (_("Month View: %s. %s"),
+ label_text, event_str);
+
+ else
+ name_str = g_strdup_printf (_("Week View: %s. %s"),
+ label_text, event_str);
+
+ ATK_OBJECT_CLASS (parent_class)->set_name (accessible, name_str);
+ g_free (name_str);
+ g_free (event_str);
+
+ return accessible->name;
+}
+
+static G_CONST_RETURN gchar *
+ea_week_view_get_description (AtkObject *accessible)
+{
+ EWeekView *week_view;
+
+ g_return_val_if_fail (EA_IS_WEEK_VIEW (accessible), NULL);
+
+ if (!GTK_ACCESSIBLE (accessible)->widget)
+ return NULL;
+ week_view = E_WEEK_VIEW (GTK_ACCESSIBLE (accessible)->widget);
+
+ if (accessible->description)
+ return accessible->description;
+ else {
+ GnomeCalendar *gcal;
+ GnomeCalendarViewType view_type;
+
+ gcal = e_calendar_view_get_calendar (E_CALENDAR_VIEW (week_view));
+ view_type = gnome_calendar_get_view (gcal);
+
+ if (view_type == GNOME_CAL_MONTH_VIEW)
+ return _("calendar view for a month");
+ else
+ return _("calendar view for one or more weeks");
+ }
+}
+
+static gint
+ea_week_view_get_n_children (AtkObject *accessible)
+{
+ EWeekView *week_view;
+ gint i, count = 0;
+ gint event_index;
+
+ g_return_val_if_fail (EA_IS_WEEK_VIEW (accessible), -1);
+
+ if (!GTK_ACCESSIBLE (accessible)->widget)
+ return -1;
+ week_view = E_WEEK_VIEW (GTK_ACCESSIBLE (accessible)->widget);
+
+ for (event_index = 0; event_index < week_view->events->len;
+ ++event_index) {
+ EWeekViewEvent *event;
+ EWeekViewEventSpan *span;
+
+ /* If week_view->spans == NULL, there is no visible events. */
+ if (!week_view->spans)
+ break;
+
+ event = &g_array_index (week_view->events,
+ EWeekViewEvent, event_index);
+ if (!event)
+ continue;
+ span = &g_array_index (week_view->spans, EWeekViewEventSpan,
+ event->spans_index + 0);
+
+ if (!span)
+ continue;
+
+ /* at least one of the event spans is visible, count it */
+ if (span->text_item)
+ ++count;
+ }
+
+ /* add the number of visible jump buttons */
+ for (i = 0; i < E_WEEK_VIEW_MAX_WEEKS * 7; i++) {
+ if (week_view->jump_buttons[i]->object.flags & GNOME_CANVAS_ITEM_VISIBLE)
+ ++count;
+ }
+
+ /* "+1" for the main item */
+ count++;
+
+#ifdef ACC_DEBUG
+ printf("AccDebug: week view %p has %d children\n", (gpointer)week_view, count);
+#endif
+ return count;
+}
+
+static AtkObject *
+ea_week_view_ref_child (AtkObject *accessible, gint index)
+{
+ EWeekView *week_view;
+ gint child_num, max_count;
+ AtkObject *atk_object = NULL;
+ gint event_index;
+ gint jump_button = -1;
+ gint span_num = 0;
+ gint count = 0;
+
+ g_return_val_if_fail (EA_IS_WEEK_VIEW (accessible), NULL);
+
+ child_num = atk_object_get_n_accessible_children (accessible);
+ if (child_num <= 0 || index < 0 || index >= child_num)
+ return NULL;
+
+ if (!GTK_ACCESSIBLE (accessible)->widget)
+ return NULL;
+ week_view = E_WEEK_VIEW (GTK_ACCESSIBLE (accessible)->widget);
+ max_count = week_view->events->len;
+
+ if (index == 0) {
+ /* index == 0 is the main item */
+ atk_object = atk_gobject_accessible_for_object (G_OBJECT (week_view->main_canvas_item));
+ g_object_ref (atk_object);
+ } else
+ for (event_index = 0; event_index < max_count; ++event_index) {
+ EWeekViewEvent *event;
+ EWeekViewEventSpan *span;
+ gint current_day;
+
+ event = &g_array_index (week_view->events,
+ EWeekViewEvent, event_index);
+ if (!event)
+ continue;
+
+ span = &g_array_index (week_view->spans, EWeekViewEventSpan,
+ event->spans_index + span_num);
+
+ if (!span)
+ continue;
+
+ current_day = span->start_day;
+ if (span->text_item)
+ ++count;
+ else if (current_day != jump_button) {
+ /* we should go to the jump button */
+ jump_button = current_day;
+ ++count;
+ }
+ else
+ continue;
+
+ if (count == index) {
+ if (span->text_item) {
+ /* Not use atk_gobject_accessible_for_object for event
+ * text_item we need to do special thing here
+ */
+ atk_object = ea_calendar_helpers_get_accessible_for (span->text_item);
+ }
+ else {
+ atk_object = ea_calendar_helpers_get_accessible_for (week_view->jump_buttons[current_day == -1 ? 0 : current_day]);
+ }
+ g_object_ref (atk_object);
+ break;
+ }
+ }
+
+#ifdef ACC_DEBUG
+ printf ("EvoAcc: ea_week_view_ref_child [%d]=%p\n",
+ index, (gpointer)atk_object);
+#endif
+ return atk_object;
+}
diff --git a/calendar/gui/ea-week-view.h b/calendar/gui/ea-week-view.h
new file mode 100644
index 0000000000..09409ec4cf
--- /dev/null
+++ b/calendar/gui/ea-week-view.h
@@ -0,0 +1,58 @@
+/*
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2 of the License, or (at your option) version 3.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with the program; if not, see <http://www.gnu.org/licenses/>
+ *
+ *
+ * Authors:
+ * Bolian Yin <bolian.yin@sun.com>
+ *
+ * Copyright (C) 1999-2008 Novell, Inc. (www.novell.com)
+ *
+ */
+
+#ifndef __EA_WEEK_VIEW_H__
+#define __EA_WEEK_VIEW_H__
+
+#include "ea-cal-view.h"
+#include "e-week-view.h"
+
+G_BEGIN_DECLS
+
+#define EA_TYPE_WEEK_VIEW (ea_week_view_get_type ())
+#define EA_WEEK_VIEW(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), EA_TYPE_WEEK_VIEW, EaWeekView))
+#define EA_WEEK_VIEW_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), EA_TYPE_WEEK_VIEW, EaWeekViewClass))
+#define EA_IS_WEEK_VIEW(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), EA_TYPE_WEEK_VIEW))
+#define EA_IS_WEEK_VIEW_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), EA_TYPE_WEEK_VIEW))
+#define EA_WEEK_VIEW_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), EA_TYPE_WEEK_VIEW, EaWeekViewClass))
+
+typedef struct _EaWeekView EaWeekView;
+typedef struct _EaWeekViewClass EaWeekViewClass;
+
+struct _EaWeekView
+{
+ EaCalView parent;
+};
+
+GType ea_week_view_get_type (void);
+
+struct _EaWeekViewClass
+{
+ EaCalViewClass parent_class;
+};
+
+AtkObject* ea_week_view_new (GtkWidget *widget);
+
+G_END_DECLS
+
+#endif /* __EA_WEEK_VIEW_H__ */
diff --git a/calendar/gui/gnome-cal.c b/calendar/gui/gnome-cal.c
index adfcdac09f..d249100b71 100644
--- a/calendar/gui/gnome-cal.c
+++ b/calendar/gui/gnome-cal.c
@@ -41,19 +41,16 @@
#include <libedataserver/e-url.h>
#include <libedataserverui/e-passwords.h>
-#include "shell/e-user-creatable-items-handler.h"
#include <libecal/e-cal-time-util.h>
#include <widgets/menus/gal-view-factory-etable.h>
#include <widgets/menus/gal-view-etable.h>
#include <widgets/menus/gal-define-views-dialog.h>
-#include "widgets/menus/gal-view-menus.h"
#include "e-util/e-util.h"
#include "e-util/e-error.h"
#include "e-util/e-util-private.h"
#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,28 +62,16 @@
#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"
#include "calendar-view.h"
#include "calendar-view-factory.h"
#include "tag-calendar.h"
#include "misc.h"
-#include "ea-calendar.h"
+/*#include "a11y/ea-calendar.h" KILL-BONOBO */
#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
-#define G_MAXINT32 ((gint32) 0x7fffffff)
-#endif
#define d(x)
@@ -97,9 +82,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
@@ -110,19 +95,12 @@ struct _GnomeCalendarPrivate {
/* Widgets */
- GtkWidget *search_bar;
-
GtkWidget *hpane;
GtkWidget *notebook;
GtkWidget *vpane;
ECalendar *date_navigator;
EMiniCalendarConfig *date_navigator_config;
- GtkWidget *todo;
- ECalendarTableConfig *todo_config;
-
- GtkWidget *memo;
- EMemoTableConfig *memo_config;
GtkWidget *day_view;
GtkWidget *work_week_view;
@@ -130,13 +108,8 @@ struct _GnomeCalendarPrivate {
GtkWidget *month_view;
GtkWidget *list_view;
- /* Activity */
- EActivityHandler *activity_handler;
-
/* plugin menu managers */
ECalMenu *calendar_menu;
- ECalMenu *taskpad_menu;
- ECalMenu *memopad_menu;
/* Calendar query for the date navigator */
GList *dn_queries; /* list of CalQueries */
@@ -161,16 +134,10 @@ struct _GnomeCalendarPrivate {
will work OK after theme changes. */
gint hpane_pos;
gint hpane_pos_month_view;
- gint vpane_pos;
- gint vpane_pos_month_view;
/* 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 +168,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 +175,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];
@@ -231,15 +185,12 @@ static void gnome_calendar_goto_date (GnomeCalendar *gcal,
static void gnome_calendar_change_view (GnomeCalendar *gcal,
GnomeCalendarViewType view_type);
-static void gnome_calendar_set_pane_positions (GnomeCalendar *gcal);
static void update_view_times (GnomeCalendar *gcal, time_t start_time);
static void gnome_calendar_update_date_navigator (GnomeCalendar *gcal);
static void gnome_calendar_hpane_realized (GtkWidget *w, GnomeCalendar *gcal);
static void gnome_calendar_date_navigator_scrolled (GtkWidget *widget, GdkEventScroll *event, gpointer user_data);
static gboolean gnome_calendar_hpane_resized (GtkWidget *w, GdkEventButton *e, GnomeCalendar *gcal);
-static void gnome_calendar_vpane_realized (GtkWidget *w, GnomeCalendar *gcal);
-static gboolean gnome_calendar_vpane_resized (GtkWidget *w, GdkEventButton *e, GnomeCalendar *gcal);
static void gnome_calendar_on_date_navigator_date_range_changed (ECalendarItem *calitem,
GnomeCalendar *gcal);
@@ -316,54 +267,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),
@@ -412,11 +315,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;
@@ -614,15 +512,15 @@ dn_e_cal_view_done_cb (ECalView *query, ECalendarStatus status, gpointer data)
g_warning (G_STRLOC ": Query did not successfully complete");
}
-/* Returns the current view widget, an EDayView, EWeekView or ECalListView. */
-GtkWidget*
-gnome_calendar_get_current_view_widget (GnomeCalendar *gcal)
+ECalendarView *
+gnome_calendar_get_calendar_view (GnomeCalendar *gcal,
+ GnomeCalendarViewType view_type)
{
- GnomeCalendarPrivate *priv;
-
- priv = gcal->priv;
+ g_return_val_if_fail (GNOME_IS_CALENDAR (gcal), NULL);
+ g_return_val_if_fail (view_type >= 0, NULL);
+ g_return_val_if_fail (view_type < GNOME_CAL_LAST_VIEW, NULL);
- return GTK_WIDGET (priv->views[priv->current_view_type]);
+ return gcal->priv->views[view_type];
}
static void
@@ -732,69 +630,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)
@@ -898,7 +733,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;
@@ -962,14 +797,17 @@ update_query (GnomeCalendar *gcal)
message_push ((Message *) msg);
}
-static void
-set_search_query (GnomeCalendar *gcal, const gchar *sexp)
+void
+gnome_calendar_set_search_query (GnomeCalendar *gcal,
+ const gchar *sexp,
+ gboolean range_search,
+ time_t start_range,
+ time_t end_range)
{
GnomeCalendarPrivate *priv;
gint i;
time_t start, end;
- g_return_if_fail (gcal != NULL);
g_return_if_fail (GNOME_IS_CALENDAR (gcal));
g_return_if_fail (sexp != NULL);
@@ -977,11 +815,13 @@ set_search_query (GnomeCalendar *gcal, const gchar *sexp)
/* Set the query on the date navigator */
- if (priv->sexp)
- g_free (priv->sexp);
-
+ g_free (priv->sexp);
priv->sexp = g_strdup (sexp);
+ priv->lview_select_daten_range = range_search;
+ start = start_range;
+ end = end_range;
+
d(g_print ("Changing the queries %s \n", sexp));
update_query (gcal);
@@ -991,7 +831,6 @@ set_search_query (GnomeCalendar *gcal, const gchar *sexp)
/* Set the query on the views */
if (i == GNOME_CAL_LIST_VIEW) {
if (!priv->lview_select_daten_range) {
- cal_search_bar_get_time_range ((CalSearchBar *)priv->search_bar, &start, &end);
e_cal_model_set_search_query_with_time_range (e_calendar_view_get_model (priv->views [i]), sexp, start, end);
} else {
start = priv->base_view_time;
@@ -1029,201 +868,12 @@ get_current_time (ECalendarItem *calitem, gpointer data)
return tmp_tm;
}
-/* Callback used when the sexp changes in the calendar search bar */
-static void
-search_bar_sexp_changed_cb (CalSearchBar *cal_search, const gchar *sexp, gpointer data)
-{
- GnomeCalendar *gcal;
- const gchar *d_sexp = "occur-in-time-range?";
-
- gcal = GNOME_CALENDAR (data);
-
- /* Choose List view if the search made in the search bar is based on date */
- if (sexp != NULL && strstr (sexp, d_sexp ) != NULL) {
- gcal->priv->lview_select_daten_range = FALSE;
- gtk_widget_hide (GTK_WIDGET (gcal->priv->date_navigator));
- gnome_calendar_set_view (gcal, GNOME_CAL_LIST_VIEW);
- } else {
- gcal->priv->lview_select_daten_range = TRUE;
- gtk_widget_show (GTK_WIDGET (gcal->priv->date_navigator));
- }
-
- set_search_query (gcal, sexp);
-}
-
-/* Callback used when the selected category in the search bar changes */
-static void
-search_bar_category_changed_cb (CalSearchBar *cal_search, const gchar *category, gpointer data)
-{
- GnomeCalendar *gcal;
- GnomeCalendarPrivate *priv;
- ECalModel *model;
- gint i;
-
- gcal = GNOME_CALENDAR (data);
- priv = gcal->priv;
-
- for (i = 0; i < GNOME_CAL_LAST_VIEW; i++) {
- e_calendar_view_set_default_category (E_CALENDAR_VIEW (priv->views[i]),
- category);
- }
-
- model = e_calendar_table_get_model (E_CALENDAR_TABLE (priv->todo));
- e_cal_model_set_default_category (model, category);
-}
-
static void
view_selection_changed_cb (GtkWidget *view, GnomeCalendar *gcal)
{
g_signal_emit (gcal, gnome_calendar_signals[CALENDAR_SELECTION_CHANGED], 0);
}
-/**
- * gnome_calendar_emit_user_created_signal
- * Emits "user_created" signal on a gcal and use calendar as a store where was event created.
- *
- * @param instance Instance on which emit signal.
- * @param gcal GnomeCalendar, it will store info about used calendar here.
- * @param calendar Used calendar, where was event created.
- **/
-void
-gnome_calendar_emit_user_created_signal (gpointer instance, GnomeCalendar *gcal, ECal *calendar)
-{
- GnomeCalendarPrivate *priv;
-
- g_return_if_fail (gcal != NULL);
-
- priv = gcal->priv;
- priv->user_created_cal = calendar;
- g_signal_emit_by_name (instance, "user_created");
- priv->user_created_cal = NULL;
-}
-
-static void
-user_created_cb (GtkWidget *view, GnomeCalendar *gcal)
-{
- GnomeCalendarPrivate *priv;
- ECal *ecal;
-
- priv = gcal->priv;
- ecal = priv->user_created_cal;
-
- if (!ecal) {
- ECalModel *model;
-
- model = e_calendar_view_get_model (priv->views[priv->current_view_type]);
- ecal = e_cal_model_get_default_client (model);
- }
-
- gnome_calendar_add_source (gcal, E_CAL_SOURCE_TYPE_EVENT, e_cal_get_source (ecal));
-}
-
-/* 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)
{
@@ -1276,27 +926,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])
@@ -1316,6 +957,7 @@ struct _mupdate_todo_msg {
GnomeCalendar *gcal;
};
+#if 0 /* KILL-BONOBO */
static void
update_todo_view_async (struct _mupdate_todo_msg *msg)
{
@@ -1354,10 +996,12 @@ update_todo_view_async (struct _mupdate_todo_msg *msg)
g_object_unref (msg->gcal);
g_slice_free (struct _mupdate_todo_msg, msg);
}
+#endif
static void
update_todo_view (GnomeCalendar *gcal)
{
+#if 0 /* KILL-BONOBO */
struct _mupdate_todo_msg *msg;
msg = g_slice_new0 (struct _mupdate_todo_msg);
@@ -1365,11 +1009,13 @@ update_todo_view (GnomeCalendar *gcal)
msg->gcal = g_object_ref (gcal);
message_push ((Message *) msg);
+#endif
}
static void
update_memo_view (GnomeCalendar *gcal)
{
+#if 0 /* KILL-BONOBO */
GnomeCalendarPrivate *priv;
ECalModel *model, *view_model;
time_t start, end;
@@ -1401,11 +1047,13 @@ update_memo_view (GnomeCalendar *gcal)
g_free (iso_start);
g_free (iso_end);
}
+#endif
}
static void
process_completed_tasks (GnomeCalendar *gcal, gboolean config_changed)
{
+#if 0 /* KILL-BONOBO */
GnomeCalendarPrivate *priv;
g_return_if_fail (gcal != NULL);
@@ -1414,8 +1062,10 @@ process_completed_tasks (GnomeCalendar *gcal, gboolean config_changed)
priv = gcal->priv;
e_calendar_table_process_completed_tasks (E_CALENDAR_TABLE (priv->todo), priv->clients_list[E_CAL_SOURCE_TYPE_TODO], config_changed);
+#endif
}
+#if 0 /* KILL-BONOBO */
static gboolean
update_todo_view_cb (GnomeCalendar *gcal)
{
@@ -1428,26 +1078,29 @@ update_todo_view_cb (GnomeCalendar *gcal)
return TRUE;
}
+#endif
static gboolean
update_marcus_bains_line_cb (GnomeCalendar *gcal)
{
GnomeCalendarPrivate *priv;
+ GnomeCalendarViewType view_type;
+ ECalendarView *view;
time_t now, day_begin;
priv = gcal->priv;
- if ((priv->current_view_type == GNOME_CAL_DAY_VIEW) ||
- (priv->current_view_type == GNOME_CAL_WORK_WEEK_VIEW)) {
- e_day_view_update_marcus_bains (E_DAY_VIEW (gnome_calendar_get_current_view_widget (gcal)));
- }
+ view_type = gnome_calendar_get_view (gcal);
+ view = gnome_calendar_get_calendar_view (gcal, view_type);
+
+ if (E_IS_DAY_VIEW (view))
+ e_day_view_update_marcus_bains (E_DAY_VIEW (view));
time (&now);
day_begin = time_day_begin (now);
/* check in the first two minutes */
if (now >= day_begin && now <= day_begin + 120) {
- ECalendarView *view = priv->views[priv->current_view_type];
time_t start_time = 0, end_time = 0;
g_return_val_if_fail (view != NULL, TRUE);
@@ -1506,9 +1159,7 @@ setup_config (GnomeCalendar *calendar)
/* Pane positions */
priv->hpane_pos = calendar_config_get_hpane_pos ();
- priv->vpane_pos = calendar_config_get_vpane_pos ();
priv->hpane_pos_month_view = calendar_config_get_month_hpane_pos ();
- priv->vpane_pos_month_view = calendar_config_get_month_vpane_pos ();
}
static void
@@ -1564,51 +1215,21 @@ month_view_adjustment_changed_cb (GtkAdjustment *adjustment, GnomeCalendar *gcal
}
static void
-categories_changed_cb (gpointer object, gpointer user_data)
-{
- GList *cat_list;
- GPtrArray *cat_array;
- GnomeCalendarPrivate *priv;
- GnomeCalendar *gcal = user_data;
-
- priv = gcal->priv;
-
- cat_array = g_ptr_array_new ();
- cat_list = e_categories_get_list ();
- while (cat_list != NULL) {
- if (e_categories_is_searchable ((const gchar *) cat_list->data))
- g_ptr_array_add (cat_array, cat_list->data);
- cat_list = g_list_remove (cat_list, cat_list->data);
- }
-
- cal_search_bar_set_categories ((CalSearchBar *)priv->search_bar, cat_array);
-
- g_ptr_array_free (cat_array, TRUE);
-}
-
-static void
view_progress_cb (ECalModel *model, const gchar *message, gint percent, ECalSourceType type, GnomeCalendar *gcal)
{
- if (type == E_CAL_SOURCE_TYPE_EVENT) {
+#if 0 /* KILL-BONOBO */
+ 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);
- }
+#endif
}
static void
view_done_cb (ECalModel *model, ECalendarStatus status, ECalSourceType type, GnomeCalendar *gcal)
{
- if (type == E_CAL_SOURCE_TYPE_EVENT) {
+#if 0 /* KILL-BONOBO */
+ 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);
- }
-
+#endif
}
GtkWidget *
@@ -1648,16 +1269,6 @@ setup_widgets (GnomeCalendar *gcal)
priv = gcal->priv;
- priv->search_bar = cal_search_bar_new (CAL_SEARCH_CALENDAR_DEFAULT);
- g_signal_connect (priv->search_bar, "sexp_changed",
- G_CALLBACK (search_bar_sexp_changed_cb), gcal);
- g_signal_connect (priv->search_bar, "category_changed",
- G_CALLBACK (search_bar_category_changed_cb), gcal);
- categories_changed_cb (NULL, gcal);
-
- gtk_widget_show (priv->search_bar);
- gtk_box_pack_start (GTK_BOX (gcal), priv->search_bar, FALSE, FALSE, 6);
-
/* The main HPaned, with the notebook of calendar views on the left
and the ECalendar and ToDo list on the right. */
priv->hpane = gtk_hpaned_new ();
@@ -1668,13 +1279,6 @@ setup_widgets (GnomeCalendar *gcal)
gtk_widget_show (priv->hpane);
gtk_box_pack_start (GTK_BOX (gcal), priv->hpane, TRUE, TRUE, 6);
- /* The Notebook containing the 4 calendar views. */
- priv->notebook = gtk_notebook_new ();
- gtk_notebook_set_show_border (GTK_NOTEBOOK (priv->notebook), FALSE);
- gtk_notebook_set_show_tabs (GTK_NOTEBOOK (priv->notebook), FALSE);
- gtk_widget_show (priv->notebook);
- gtk_paned_pack1 (GTK_PANED (priv->hpane), priv->notebook, FALSE, TRUE);
-
/* The ECalendar. */
w = e_calendar_new ();
priv->date_navigator = E_CALENDAR (w);
@@ -1693,15 +1297,6 @@ setup_widgets (GnomeCalendar *gcal)
g_signal_connect (w, "scroll-event",
G_CALLBACK (gnome_calendar_date_navigator_scrolled), gcal);
- /* The VPaned widget, to contain the ToDo list & Memo list */
- priv->vpane = gtk_vpaned_new ();
- g_signal_connect_after (priv->vpane, "realize",
- G_CALLBACK(gnome_calendar_vpane_realized), gcal);
- g_signal_connect (priv->vpane, "button_release_event",
- G_CALLBACK (gnome_calendar_vpane_resized), gcal);
- gtk_widget_show (priv->vpane);
- gtk_paned_pack2 (GTK_PANED (priv->hpane), priv->vpane, TRUE, TRUE);
-
/* The ToDo list. */
vbox = gtk_vbox_new (FALSE, 0);
sep = gtk_hseparator_new ();
@@ -1713,39 +1308,16 @@ 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 */
+#if 0 /* KILL-BONOBO */
priv->update_timeout = g_timeout_add_full (G_PRIORITY_LOW, 60000, (GSourceFunc) update_todo_view_cb, gcal, NULL);
+#endif
/* Create the model for the views */
cal_model = (ECalModel *) e_cal_model_calendar_new ();
@@ -1757,7 +1329,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);
@@ -1766,7 +1337,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);
@@ -1778,8 +1348,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),
@@ -1799,8 +1367,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),
@@ -1814,8 +1380,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);
@@ -1827,16 +1391,6 @@ setup_widgets (GnomeCalendar *gcal)
priv->views[GNOME_CAL_LIST_VIEW] = E_CALENDAR_VIEW (priv->list_view);
priv->configs[GNOME_CAL_LIST_VIEW] = G_OBJECT (e_cal_list_view_config_new (E_CAL_LIST_VIEW (priv->views[GNOME_CAL_LIST_VIEW])));
- for (i = 0; i < GNOME_CAL_LAST_VIEW; i++) {
- gtk_notebook_append_page (GTK_NOTEBOOK (priv->notebook),
- GTK_WIDGET (priv->views[i]), gtk_label_new (""));
-
- g_signal_connect (priv->views[i], "user_created",
- G_CALLBACK (user_created_cb), gcal);
-
- gtk_widget_show (GTK_WIDGET (priv->views[i]));
- }
-
/* Memo view */
vbox = gtk_vbox_new (FALSE, 0);
label = gtk_label_new (NULL);
@@ -1844,38 +1398,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);
-
+#if 0 /* KILL-BONOBO */
e_cal_model_set_default_time_func (e_memo_table_get_model (E_MEMO_TABLE (priv->memo)), gc_get_default_time, gcal);
+#endif
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 */
@@ -1883,18 +1413,17 @@ 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);
- e_categories_register_change_listener (G_CALLBACK (categories_changed_cb), gcal);
+ 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);
priv->todo_update_lock = g_mutex_new ();
@@ -1906,17 +1435,12 @@ 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 */
priv->todo_sexp = g_strdup ("#t");
priv->memo_sexp = g_strdup ("#t");
- priv->view_instance = NULL;
- priv->view_menus = NULL;
-
priv->visible_start = -1;
priv->visible_end = -1;
priv->updating = FALSE;
@@ -1940,40 +1464,25 @@ gnome_calendar_destroy (GtkObject *object)
GList *l;
gint i;
- 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;
+ 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);
+ }
- if (priv->default_client[i]) {
- ESource *source = e_cal_get_source (priv->default_client[i]);
+ g_hash_table_destroy (priv->clients);
+ g_list_free (priv->clients_list);
- g_signal_handlers_disconnect_matched (priv->default_client[i],
- G_SIGNAL_MATCH_DATA,
- 0, 0, NULL, NULL, gcal);
+ priv->clients = NULL;
+ priv->clients_list = NULL;
- if (source)
- g_signal_handlers_disconnect_matched (source, G_SIGNAL_MATCH_DATA, 0, 0, NULL, NULL, gcal);
-
- 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])
@@ -1981,26 +1490,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,
@@ -2022,50 +1517,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,
@@ -2073,18 +1539,6 @@ 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_free (priv);
@@ -2288,7 +1742,13 @@ gnome_calendar_dayjump (GnomeCalendar *gcal, time_t time)
static void
focus_current_view (GnomeCalendar *gcal)
{
- gtk_widget_grab_focus (gnome_calendar_get_current_view_widget (gcal));
+ GnomeCalendarViewType view_type;
+ ECalendarView *view;
+
+ view_type = gnome_calendar_get_view (gcal);
+ view = gnome_calendar_get_calendar_view (gcal, view_type);
+
+ gtk_widget_grab_focus (GTK_WIDGET (view));
}
void
@@ -2312,13 +1772,9 @@ gnome_calendar_goto_today (GnomeCalendar *gcal)
GnomeCalendarViewType
gnome_calendar_get_view (GnomeCalendar *gcal)
{
- GnomeCalendarPrivate *priv;
-
- g_return_val_if_fail (gcal != NULL, GNOME_CAL_DAY_VIEW);
g_return_val_if_fail (GNOME_IS_CALENDAR (gcal), GNOME_CAL_DAY_VIEW);
- priv = gcal->priv;
- return priv->current_view_type;
+ return gcal->priv->current_view_type;
}
static void
@@ -2360,7 +1816,6 @@ set_view (GnomeCalendar *gcal, GnomeCalendarViewType view_type, gboolean range_s
priv->range_selected = range_selected;
priv->current_view_type = view_type;
- gal_view_instance_set_current_view_id (priv->view_instance, view_id);
focus_current_view (gcal);
}
@@ -2450,8 +1905,6 @@ display_view (GnomeCalendar *gcal, GnomeCalendarViewType view_type, gboolean gra
if (grab_focus)
focus_current_view (gcal);
- gnome_calendar_set_pane_positions (gcal);
-
/* For the week & month views we want the selection in the date
navigator to be rounded to the nearest week when the arrow buttons
are pressed to move to the previous/next month. */
@@ -2469,6 +1922,7 @@ static void gnome_calendar_change_view (GnomeCalendar *gcal, GnomeCalendarViewTy
}
/* Callback used when the view collection asks us to display a particular view */
+#if 0 /* KILL-BONOBO */
static void
display_view_cb (GalViewInstance *view_instance, GalView *view, gpointer data)
{
@@ -2507,274 +1961,7 @@ display_view_cb (GalViewInstance *view_instance, GalView *view, gpointer data)
gnome_calendar_notify_dates_shown_changed (gcal);
}
-
-/**
- * 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)
-{
- 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);
-
- }
-
- 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 },
-};
-
-static void
-gc_popup_free (EPopup *ep, GSList *list, gpointer data)
-{
- 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;
- }
-}
-
-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;
- }
-}
-
-void
-gnome_calendar_view_popup_factory (GnomeCalendar *gcal, EPopup *ep, const gchar *prefix)
-{
- 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);
-
- 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);
- }
-
- e_popup_add_items(ep, menus, NULL, gc_popup_free_static, gcal);
-}
-
-static void
-gnome_calendar_set_pane_positions (GnomeCalendar *gcal)
-{
- 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);
- }
-}
+#endif
struct _mclient_msg {
Message header;
@@ -2815,7 +2002,6 @@ static void
client_cal_opened_cb (ECal *ecal, ECalendarStatus status, GnomeCalendar *gcal)
{
GnomeCalendarPrivate *priv;
- ECalSourceType source_type;
ESource *source;
ECalModel *model;
ECalLoadState state;
@@ -2825,23 +2011,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);
@@ -2862,7 +2034,7 @@ client_cal_opened_cb (ECal *ecal, ECalendarStatus status, GnomeCalendar *gcal)
}
w = e_error_new(NULL, "calendar:server-version", NULL);
- e_calendar_utils_show_error_silent (w);
+ /*e_calendar_utils_show_error_silent (w); KILL-BONOBO */
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);
@@ -2873,32 +2045,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); KILL-BONOBO */
+ 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));
@@ -2908,74 +2075,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); KILL-BONOBO */
+ 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); KILL-BONOBO */
}
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;
@@ -2996,15 +2124,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));
@@ -3014,22 +2142,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 *);
@@ -3047,20 +2163,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); KILL-BONOBO */
g_free (msg);
@@ -3091,7 +2194,7 @@ backend_error_cb (ECal *client, const gchar *message, gpointer data)
}
dialog = (GtkDialog *)e_error_new(GTK_WINDOW (gtk_widget_get_toplevel (GTK_WIDGET (gcal))), "calendar:error-on-loading-the-calendar", uristr, message, NULL);
- e_calendar_utils_show_error_silent(GTK_WIDGET (dialog));
+ /* e_calendar_utils_show_error_silent(GTK_WIDGET (dialog)); KILL-BONOBO */
g_hash_table_insert (non_intrusive_error_table, id, g_object_ref(dialog));
g_signal_connect(GTK_WIDGET (dialog), "destroy", G_CALLBACK(non_intrusive_error_remove), id);
@@ -3105,7 +2208,6 @@ backend_died_cb (ECal *ecal, gpointer data)
{
GnomeCalendar *gcal;
GnomeCalendarPrivate *priv;
- ECalSourceType source_type;
ESource *source;
const gchar *id;
GtkWidget *w = NULL;
@@ -3116,39 +2218,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");
+ priv->clients_list = g_list_remove (priv->clients_list, ecal);
+ g_hash_table_remove (priv->clients, e_source_peek_uid (source));
- e_calendar_view_set_status_message (E_CALENDAR_VIEW (priv->week_view), 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_TODO:
- id = g_strdup ("calendar:calendar-crashed");
-
- e_calendar_table_set_status_message (E_CALENDAR_TABLE (priv->todo), NULL, -1);
-
- g_signal_emit (gcal, gnome_calendar_signals[SOURCE_REMOVED], 0, source_type, source);
- break;
+ /* e_calendar_view_set_status_message (E_CALENDAR_VIEW (priv->week_view), NULL, -1); KILL-BONOBO */
- case E_CAL_SOURCE_TYPE_JOURNAL:
- id = g_strdup ("calendar:calendar-crashed");
-
- e_memo_table_set_status_message (E_MEMO_TABLE (priv->memo), NULL);
-
- 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);
@@ -3159,7 +2238,7 @@ backend_died_cb (ECal *ecal, gpointer data)
}
w = e_error_new(GTK_WINDOW (gtk_widget_get_toplevel (GTK_WIDGET (gcal))), "calendar:backend_died", NULL);
- e_calendar_utils_show_error_silent (w);
+ /* e_calendar_utils_show_error_silent (w); KILL-BONOBO */
g_hash_table_insert (non_intrusive_error_table, (gpointer) id, g_object_ref(w));
g_signal_connect((GtkObject *)w, "destroy", G_CALLBACK(non_intrusive_error_remove), (gpointer) id);
}
@@ -3193,35 +2272,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.
@@ -3269,7 +2319,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;
@@ -3280,7 +2330,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 */
@@ -3288,18 +2338,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;
}
@@ -3309,10 +2359,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);
@@ -3330,7 +2380,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;
@@ -3338,15 +2388,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;
@@ -3359,51 +2409,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;
}
@@ -3421,7 +2454,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;
@@ -3432,20 +2465,20 @@ 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;
}
@@ -3493,6 +2526,7 @@ gnome_calendar_get_selected_time_range (GnomeCalendar *gcal,
*
* Opens a task editor dialog for a new task. dtstart or dtend can be NULL.
**/
+#if 0 /* KILL-BONOBO */
void
gnome_calendar_new_task (GnomeCalendar *gcal, time_t *dtstart, time_t *dtend)
{
@@ -3523,9 +2557,6 @@ gnome_calendar_new_task (GnomeCalendar *gcal, time_t *dtstart, time_t *dtend)
comp = e_cal_component_new ();
e_cal_component_set_icalcomponent (comp, icalcomp);
- category = cal_search_bar_get_category (CAL_SEARCH_BAR (priv->search_bar));
- e_cal_component_set_categories (comp, category);
-
dt.value = &itt;
dt.tzid = icaltimezone_get_tzid (e_cal_model_get_timezone (model));
@@ -3547,6 +2578,7 @@ gnome_calendar_new_task (GnomeCalendar *gcal, time_t *dtstart, time_t *dtend)
gtk_window_present (GTK_WINDOW (editor));
}
+#endif
/* Returns the selected time range for the current view. Note that this may be
different from the fields in the GnomeCalendar, since the view may clip
@@ -3556,8 +2588,13 @@ gnome_calendar_get_current_time_range (GnomeCalendar *gcal,
time_t *start_time,
time_t *end_time)
{
- e_calendar_view_get_selected_time_range (E_CALENDAR_VIEW (gnome_calendar_get_current_view_widget (gcal)),
- start_time, end_time);
+ GnomeCalendarViewType view_type;
+ ECalendarView *view;
+
+ view_type = gnome_calendar_get_view (gcal);
+ view = gnome_calendar_get_calendar_view (gcal, view_type);
+
+ e_calendar_view_get_selected_time_range (view, start_time, end_time);
}
/* Gets the visible time range for the current view. Returns FALSE if no
@@ -3567,14 +2604,16 @@ gnome_calendar_get_visible_time_range (GnomeCalendar *gcal,
time_t *start_time,
time_t *end_time)
{
- gboolean retval = FALSE;
+ GnomeCalendarViewType view_type;
+ ECalendarView *view;
g_return_val_if_fail (GNOME_IS_CALENDAR (gcal), FALSE);
- retval = e_calendar_view_get_visible_time_range (E_CALENDAR_VIEW (gnome_calendar_get_current_view_widget (gcal)),
- start_time, end_time);
+ view_type = gnome_calendar_get_view (gcal);
+ view = gnome_calendar_get_calendar_view (gcal, view_type);
- return retval;
+ return e_calendar_view_get_visible_time_range (
+ view, start_time, end_time);
}
/* This updates the month shown and the days selected in the calendar, if
@@ -3770,90 +2809,46 @@ gnome_calendar_hpane_resized (GtkWidget *w, GdkEventButton *e, GnomeCalendar *gc
return FALSE;
}
-static void
-gnome_calendar_vpane_realized (GtkWidget *w, GnomeCalendar *gcal)
-{
- GnomeCalendarPrivate *priv;
-
- priv = gcal->priv;
-
- if (priv->current_view_type == GNOME_CAL_MONTH_VIEW && !priv->range_selected) {
- gtk_paned_set_position (GTK_PANED (priv->vpane), priv->vpane_pos_month_view);
- } else {
- gtk_paned_set_position (GTK_PANED (priv->vpane), priv->vpane_pos);
- }
-}
-
-static gboolean
-gnome_calendar_vpane_resized (GtkWidget *w, GdkEventButton *e, GnomeCalendar *gcal)
-{
- GnomeCalendarPrivate *priv;
-
- priv = gcal->priv;
-
- if (priv->current_view_type == GNOME_CAL_MONTH_VIEW && !priv->range_selected) {
- priv->vpane_pos_month_view = gtk_paned_get_position (GTK_PANED (priv->vpane));
- calendar_config_set_month_vpane_pos (priv->vpane_pos_month_view);
- } else {
- priv->vpane_pos = gtk_paned_get_position (GTK_PANED (priv->vpane));
- calendar_config_set_vpane_pos (priv->vpane_pos);
- }
-
- return FALSE;
-}
-
void
gnome_calendar_cut_clipboard (GnomeCalendar *gcal)
{
- GnomeCalendarPrivate *priv;
- FocusLocation location;
+ GnomeCalendarViewType view_type;
+ ECalendarView *view;
- priv = gcal->priv;
+ g_return_if_fail (GNOME_IS_CALENDAR (gcal));
- location = get_focus_location (gcal);
+ view_type = gnome_calendar_get_view (gcal);
+ view = gnome_calendar_get_calendar_view (gcal, view_type);
- 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));
+ e_calendar_view_cut_clipboard (view);
}
void
gnome_calendar_copy_clipboard (GnomeCalendar *gcal)
{
- GnomeCalendarPrivate *priv;
- FocusLocation location;
+ GnomeCalendarViewType view_type;
+ ECalendarView *view;
- priv = gcal->priv;
+ g_return_if_fail (GNOME_IS_CALENDAR (gcal));
- location = get_focus_location (gcal);
+ view_type = gnome_calendar_get_view (gcal);
+ view = gnome_calendar_get_calendar_view (gcal, view_type);
- 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));
+ e_calendar_view_copy_clipboard (view);
}
void
gnome_calendar_paste_clipboard (GnomeCalendar *gcal)
{
- GnomeCalendarPrivate *priv;
- FocusLocation location;
+ GnomeCalendarViewType view_type;
+ ECalendarView *view;
- priv = gcal->priv;
+ g_return_if_fail (GNOME_IS_CALENDAR (gcal));
- location = get_focus_location (gcal);
+ view_type = gnome_calendar_get_view (gcal);
+ view = gnome_calendar_get_calendar_view (gcal, view_type);
- 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));
+ e_calendar_view_paste_clipboard (view);
}
/* Get the current timezone. */
@@ -3898,12 +2893,15 @@ gnome_calendar_notify_dates_shown_changed (GnomeCalendar *gcal)
gint
gnome_calendar_get_num_events_selected (GnomeCalendar *gcal)
{
- GtkWidget *view;
+ GnomeCalendarViewType view_type;
+ ECalendarView *view;
gint retval = 0;
g_return_val_if_fail (GNOME_IS_CALENDAR (gcal), 0);
- view = gnome_calendar_get_current_view_widget (gcal);
+ view_type = gnome_calendar_get_view (gcal);
+ view = gnome_calendar_get_calendar_view (gcal, view_type);
+
if (E_IS_DAY_VIEW (view))
retval = e_day_view_get_num_events_selected (E_DAY_VIEW (view));
else
@@ -3912,68 +2910,32 @@ 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;
+ GnomeCalendarViewType view_type;
+ ECalendarView *view;
g_return_if_fail (GNOME_IS_CALENDAR (gcal));
- priv = gcal->priv;
-
- location = get_focus_location (gcal);
+ view_type = gnome_calendar_get_view (gcal);
+ view = gnome_calendar_get_calendar_view (gcal, view_type);
- 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));
+ e_calendar_view_delete_selected_events (view);
}
void
gnome_calendar_delete_selected_occurrence (GnomeCalendar *gcal)
{
- FocusLocation location;
- GtkWidget *view;
+ GnomeCalendarViewType view_type;
+ ECalendarView *view;
g_return_if_fail (GNOME_IS_CALENDAR (gcal));
- location = get_focus_location (gcal);
+ view_type = gnome_calendar_get_view (gcal);
+ view = gnome_calendar_get_calendar_view (gcal, view_type);
- if (location == FOCUS_CALENDAR) {
-
- view = gnome_calendar_get_current_view_widget (gcal);
- e_calendar_view_delete_selected_occurrence (E_CALENDAR_VIEW (view));
- }
+ e_calendar_view_delete_selected_occurrence (view);
}
static gboolean
@@ -4006,10 +2968,10 @@ gnome_calendar_purge (GnomeCalendar *gcal, time_t older_than)
" (make-time \"%s\"))",
start, end);
- e_calendar_view_set_status_message (E_CALENDAR_VIEW (priv->week_view), _("Purging"), -1);
+ /*e_calendar_view_set_status_message (E_CALENDAR_VIEW (priv->week_view), _("Purging"), -1); KILL-BONOBO */
/* FIXME Confirm expunge */
- 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) {
ECal *client = l->data;
GList *objects, *m;
gboolean read_only;
@@ -4064,7 +3026,7 @@ gnome_calendar_purge (GnomeCalendar *gcal, time_t older_than)
g_list_free (objects);
}
- e_calendar_view_set_status_message (E_CALENDAR_VIEW (priv->week_view), NULL, -1);
+ /* e_calendar_view_set_status_message (E_CALENDAR_VIEW (priv->week_view), NULL, -1); KILL-BONOBO */
g_free (sexp);
g_free (start);
@@ -4072,14 +3034,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)
{
@@ -4088,29 +3042,6 @@ gnome_calendar_get_e_calendar_widget (GnomeCalendar *gcal)
return GTK_WIDGET(gcal->priv->date_navigator);
}
-GtkWidget *
-gnome_calendar_get_search_bar_widget (GnomeCalendar *gcal)
-{
- g_return_val_if_fail (GNOME_IS_CALENDAR (gcal), NULL);
-
- return GTK_WIDGET(gcal->priv->search_bar);
-}
-
-GtkWidget *
-gnome_calendar_get_view_notebook_widget (GnomeCalendar *gcal)
-{
- g_return_val_if_fail (GNOME_IS_CALENDAR (gcal), NULL);
-
- 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);
@@ -4118,13 +3049,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,
@@ -4139,7 +3063,7 @@ gnome_calendar_edit_appointment (GnomeCalendar *gcal,
if (!src_uid || !comp_uid)
return;
- for (l = gcal->priv->clients_list[E_CAL_SOURCE_TYPE_EVENT]; l != NULL; l = l->next) {
+ for (l = gcal->priv->clients_list; l != NULL; l = l->next) {
ESource *client_src;
client = l->data;
diff --git a/calendar/gui/gnome-cal.h b/calendar/gui/gnome-cal.h
index 2a5e2f847d..2560a04215 100644
--- a/calendar/gui/gnome-cal.h
+++ b/calendar/gui/gnome-cal.h
@@ -37,10 +37,6 @@
#include "e-cal-menu.h"
#include "e-calendar-table.h"
-G_BEGIN_DECLS
-
-
-
#define GNOME_TYPE_CALENDAR (gnome_calendar_get_type ())
#define GNOME_CALENDAR(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), GNOME_TYPE_CALENDAR, GnomeCalendar))
#define GNOME_CALENDAR_CLASS(klass) (G_TYPE_CHECK_INSTANCE_CAST_CLASS ((klass), GNOME_TYPE_CALENDAR, \
@@ -48,6 +44,11 @@ G_BEGIN_DECLS
#define GNOME_IS_CALENDAR(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), GNOME_TYPE_CALENDAR))
#define GNOME_IS_CALENDAR_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), GNOME_TYPE_CALENDAR))
+G_BEGIN_DECLS
+
+/* Avoid circular inclusion. */
+struct _ECalendarView;
+
typedef struct _GnomeCalendar GnomeCalendar;
typedef struct _GnomeCalendarClass GnomeCalendarClass;
typedef struct _GnomeCalendarPrivate GnomeCalendarPrivate;
@@ -87,17 +88,13 @@ struct _GnomeCalendarClass {
void (* dates_shown_changed) (GnomeCalendar *gcal);
void (* calendar_selection_changed) (GnomeCalendar *gcal);
- void (* taskpad_selection_changed) (GnomeCalendar *gcal);
- void (* memopad_selection_changed) (GnomeCalendar *gcal);
void (* calendar_focus_change) (GnomeCalendar *gcal, gboolean in);
- void (* taskpad_focus_change) (GnomeCalendar *gcal, gboolean in);
- void (* memopad_focus_change) (GnomeCalendar *gcal, gboolean in);
void (* change_view) (GnomeCalendar *gcal,
GnomeCalendarViewType view_type);
- void (* source_added) (GnomeCalendar *gcal, ECalSourceType source_type, ESource *source);
- void (* source_removed) (GnomeCalendar *gcal, ECalSourceType source_type, ESource *source);
+ void (* source_added) (GnomeCalendar *gcal, ESource *source);
+ void (* source_removed) (GnomeCalendar *gcal, ESource *source);
/* Action signals */
void (* goto_date) (GnomeCalendar *gcal, GnomeCalendarGotoDateType date);
@@ -108,16 +105,18 @@ GtkWidget *gnome_calendar_construct (GnomeCalendar *gcal);
GtkWidget *gnome_calendar_new (void);
-void gnome_calendar_set_activity_handler (GnomeCalendar *cal, EActivityHandler *activity_handler);
-void gnome_calendar_set_ui_component (GnomeCalendar *cal, BonoboUIComponent *ui_component);
-
ECalModel *gnome_calendar_get_calendar_model (GnomeCalendar *gcal);
ECal *gnome_calendar_get_default_client (GnomeCalendar *gcal);
-gboolean gnome_calendar_add_source (GnomeCalendar *gcal, ECalSourceType source_type, ESource *source);
-gboolean gnome_calendar_remove_source (GnomeCalendar *gcal, ECalSourceType source_type, ESource *source);
-gboolean gnome_calendar_remove_source_by_uid (GnomeCalendar *gcal, ECalSourceType source_type, const gchar *uid);
-gboolean gnome_calendar_set_default_source (GnomeCalendar *gcal, ECalSourceType source_type, ESource *source);
+gboolean gnome_calendar_add_source (GnomeCalendar *gcal, ESource *source);
+gboolean gnome_calendar_remove_source (GnomeCalendar *gcal, ESource *source);
+gboolean gnome_calendar_remove_source_by_uid (GnomeCalendar *gcal, const gchar *uid);
+gboolean gnome_calendar_set_default_source (GnomeCalendar *gcal, ESource *source);
+void gnome_calendar_set_search_query (GnomeCalendar *gcal,
+ const gchar *sexp,
+ gboolean range_search,
+ time_t start_range,
+ time_t end_range);
void gnome_calendar_next (GnomeCalendar *gcal);
void gnome_calendar_previous (GnomeCalendar *gcal);
@@ -131,22 +130,13 @@ void gnome_calendar_goto_today (GnomeCalendar *gcal);
GnomeCalendarViewType gnome_calendar_get_view (GnomeCalendar *gcal);
void gnome_calendar_set_view (GnomeCalendar *gcal, GnomeCalendarViewType view_type);
-GtkWidget *gnome_calendar_get_current_view_widget (GnomeCalendar *gcal);
+struct _ECalendarView *gnome_calendar_get_calendar_view (GnomeCalendar *gcal,
+ GnomeCalendarViewType view_type);
-ECalendarTable *gnome_calendar_get_task_pad (GnomeCalendar *gcal);
GtkWidget *gnome_calendar_get_e_calendar_widget (GnomeCalendar *gcal);
-GtkWidget *gnome_calendar_get_search_bar_widget (GnomeCalendar *gcal);
-GtkWidget *gnome_calendar_get_view_notebook_widget (GnomeCalendar *gcal);
GtkWidget *gnome_calendar_get_tag (GnomeCalendar *gcal);
-ECalMenu *gnome_calendar_get_taskpad_menu (GnomeCalendar *gcal);
ECalMenu *gnome_calendar_get_calendar_menu (GnomeCalendar *gcal);
-ECalMenu *gnome_calendar_get_memopad_menu (GnomeCalendar *gcal);
-
-void gnome_calendar_setup_view_menus (GnomeCalendar *gcal, BonoboUIComponent *uic);
-void gnome_calendar_discard_view_menus (GnomeCalendar *gcal);
-
-void gnome_calendar_view_popup_factory (GnomeCalendar *gcal, EPopup *ep, const gchar *prefix);
void gnome_calendar_set_selected_time_range (GnomeCalendar *gcal,
time_t start_time,
@@ -173,9 +163,6 @@ gboolean gnome_calendar_get_visible_time_range (GnomeCalendar *gcal,
/* Returns the number of selected events (0 or 1 at present). */
gint gnome_calendar_get_num_events_selected (GnomeCalendar *gcal);
-/* Returns the number of selected tasks */
-gint gnome_calendar_get_num_tasks_selected (GnomeCalendar *gcal);
-
/* Get the current timezone. */
icaltimezone *gnome_calendar_get_timezone (GnomeCalendar *gcal);
@@ -197,8 +184,6 @@ void gnome_calendar_edit_appointment (GnomeCalendar *gcal,
const gchar * comp_uid,
const gchar * comp_rid);
-void gnome_calendar_emit_user_created_signal (gpointer instance, GnomeCalendar *gcal, ECal *calendar);
-
G_END_DECLS
#endif
diff --git a/calendar/gui/goto.c b/calendar/gui/goto.c
index 06986efdd6..dcbe643901 100644
--- a/calendar/gui/goto.c
+++ b/calendar/gui/goto.c
@@ -28,7 +28,6 @@
#include <gtk/gtk.h>
#include <glade/glade.h>
#include "e-util/e-util-private.h"
-#include "calendar-commands.h"
#include "calendar-config.h"
#include "tag-calendar.h"
#include "goto.h"
@@ -76,12 +75,14 @@ month_changed (GtkToggleButton *toggle, gpointer data)
static void
ecal_date_range_changed (ECalendarItem *calitem, gpointer user_data)
{
+#if 0 /* KILL-BONOBO */
GoToDialog *dlg = user_data;
ECal *client;
client = gnome_calendar_get_default_client (dlg->gcal);
if (client)
tag_calendar_by_client (dlg->ecal, client);
+#endif
}
/* Event handler for day groups in the month item. A button press makes the calendar jump to the
@@ -90,6 +91,7 @@ ecal_date_range_changed (ECalendarItem *calitem, gpointer user_data)
static void
ecal_event (ECalendarItem *calitem, gpointer user_data)
{
+#if 0 /* KILL-BONOBO */
GoToDialog *dlg = user_data;
GDate start_date, end_date;
struct icaltimetype tt = icaltime_null_time ();
@@ -106,6 +108,7 @@ ecal_event (ECalendarItem *calitem, gpointer user_data)
gnome_calendar_goto (dlg->gcal, et);
gtk_dialog_response (GTK_DIALOG (dlg->dialog), GTK_RESPONSE_NONE);
+#endif
}
/* Returns the current time, for the ECalendarItem. */
@@ -160,7 +163,9 @@ create_ecal (GoToDialog *dlg)
static void
goto_today (GoToDialog *dlg)
{
+#if 0 /* KILL-BONOBO */
gnome_calendar_goto_today (dlg->gcal);
+#endif
}
/* Gets the widgets from the XML file and returns if they are all available. */
@@ -201,6 +206,7 @@ goto_dialog_init_widgets (GoToDialog *dlg)
void
goto_dialog (GnomeCalendar *gcal)
{
+#if 0 /* KILL-BONOBO */
time_t start_time;
struct icaltimetype tt;
gint b;
@@ -269,4 +275,5 @@ goto_dialog (GnomeCalendar *gcal)
g_object_unref (dlg->xml);
g_free (dlg);
dlg = NULL;
+#endif
}
diff --git a/calendar/gui/itip-bonobo-control.c b/calendar/gui/itip-bonobo-control.c
deleted file mode 100644
index 10599f2a17..0000000000
--- a/calendar/gui/itip-bonobo-control.c
+++ /dev/null
@@ -1,264 +0,0 @@
-/*
- * Evolution calendar - Control for displaying iTIP mail messages
- *
- * This program is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 2 of the License, or (at your option) version 3.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with the program; if not, see <http://www.gnu.org/licenses/>
- *
- *
- * Authors:
- * Jesse Pavel <jpavel@ximian.com>
- *
- * Copyright (C) 1999-2008 Novell, Inc. (www.novell.com)
- *
- */
-
-#include <config.h>
-#include <string.h>
-#include <gtk/gtk.h>
-#include <bonobo/bonobo-generic-factory.h>
-#include <bonobo/bonobo-control.h>
-#include <bonobo/bonobo-property-bag.h>
-#include <bonobo/bonobo-persist-stream.h>
-#include <bonobo/bonobo-stream-client.h>
-#include <bonobo/bonobo-context.h>
-#include <bonobo/bonobo-exception.h>
-#include <libical/ical.h>
-
-#include "e-itip-control.h"
-#include "itip-bonobo-control.h"
-
-extern gchar *evolution_dir;
-
-enum E_ITIP_BONOBO_ARGS {
- FROM_ADDRESS_ARG_ID,
- VIEW_ONLY_ARG_ID
-};
-
-/*
- * Bonobo::PersistStream
- *
- * These two functions implement the Bonobo::PersistStream load and
- * save methods which allow data to be loaded into and out of the
- * BonoboObject.
- */
-
-static gchar *
-stream_read (Bonobo_Stream stream)
-{
- Bonobo_Stream_iobuf *buffer;
- CORBA_Environment ev;
- gchar *data = NULL;
- gint length = 0;
-
- CORBA_exception_init (&ev);
- do {
-#define READ_CHUNK_SIZE 65536
- Bonobo_Stream_read (stream, READ_CHUNK_SIZE,
- &buffer, &ev);
-
- if (BONOBO_EX (&ev)) {
- CORBA_exception_free (&ev);
- return NULL;
- }
-
- if (buffer->_length <= 0)
- break;
-
- data = g_realloc (data, length + buffer->_length + 1);
- memcpy (data + length, buffer->_buffer, buffer->_length);
- length += buffer->_length;
- data[length] = '\0';
-
- CORBA_free (buffer);
-#undef READ_CHUNK_SIZE
- } while (1);
-
- CORBA_free (buffer);
- CORBA_exception_free (&ev);
-
- if (data == NULL)
- data = g_strdup("");
-
- return data;
-} /* stream_read */
-
-/*
- * This function implements the Bonobo::PersistStream:load method.
- */
-typedef struct {
- EItipControl *itip;
- gchar *text;
-} idle_data;
-
-static gboolean
-set_data_idle_cb (gpointer data)
-{
- idle_data *id = data;
-
- e_itip_control_set_data (id->itip, id->text);
- g_object_unref (id->itip);
- g_free (id->text);
- g_free (id);
-
- return FALSE;
-}
-
-static void
-pstream_load (BonoboPersistStream *ps, const Bonobo_Stream stream,
- Bonobo_Persist_ContentType type, gpointer data,
- CORBA_Environment *ev)
-{
- EItipControl *itip = data;
- idle_data *id;
-
- if (type && g_ascii_strcasecmp (type, "text/calendar") != 0 &&
- g_ascii_strcasecmp (type, "text/x-calendar") != 0) {
- bonobo_exception_set (ev, ex_Bonobo_Persist_WrongDataType);
- return;
- }
-
- id = g_new0 (idle_data, 1);
- if ((id->text = stream_read (stream)) == NULL) {
- bonobo_exception_set (ev, ex_Bonobo_Persist_FileNotFound);
- g_free (id);
- return;
- }
- g_object_ref (itip);
- id->itip = itip;
-
- g_idle_add (set_data_idle_cb, id);
-}
-/*
- * This function implements the Bonobo::PersistStream:save method.
- */
-static void
-pstream_save (BonoboPersistStream *ps, const Bonobo_Stream stream,
- Bonobo_Persist_ContentType type, gpointer data,
- CORBA_Environment *ev)
-{
- EItipControl *itip = data;
- gchar *text;
- gint len;
-
- if (type && g_ascii_strcasecmp (type, "text/calendar") != 0 &&
- g_ascii_strcasecmp (type, "text/x-calendar") != 0) {
- bonobo_exception_set (ev, ex_Bonobo_Persist_WrongDataType);
- return;
- }
-
- text = e_itip_control_get_data (itip);
- len = e_itip_control_get_data_size (itip);
-
- bonobo_stream_client_write (stream, text, len, ev);
- g_free (text);
-} /* pstream_save */
-
-/* static CORBA_long */
-/* pstream_get_max_size (BonoboPersistStream *ps, gpointer data, */
-/* CORBA_Environment *ev) */
-/* { */
-/* EItipControl *itip = data; */
-/* gint len; */
-
-/* len = e_itip_control_get_data_size (itip); */
-
-/* if (len > 0) */
-/* return len; */
-
-/* return 0L; */
-/* } */
-
-static Bonobo_Persist_ContentTypeList *
-pstream_get_content_types (BonoboPersistStream *ps, gpointer closure,
- CORBA_Environment *ev)
-{
- return bonobo_persist_generate_content_types (2, "text/calendar", "text/x-calendar");
-}
-
-static void
-get_prop (BonoboPropertyBag *bag,
- BonoboArg *arg,
- guint arg_id,
- CORBA_Environment *ev,
- gpointer user_data)
-{
- EItipControl *itip = user_data;
-
- switch (arg_id) {
- case FROM_ADDRESS_ARG_ID:
- BONOBO_ARG_SET_STRING (arg, e_itip_control_get_from_address (itip));
- break;
- case VIEW_ONLY_ARG_ID:
- BONOBO_ARG_SET_INT (arg, e_itip_control_get_view_only (itip));
- break;
- }
-}
-
-static void
-set_prop ( BonoboPropertyBag *bag,
- const BonoboArg *arg,
- guint arg_id,
- CORBA_Environment *ev,
- gpointer user_data)
-{
- EItipControl *itip = user_data;
-
- switch (arg_id) {
- case FROM_ADDRESS_ARG_ID:
- e_itip_control_set_from_address (itip, BONOBO_ARG_GET_STRING (arg));
- break;
- case VIEW_ONLY_ARG_ID:
- e_itip_control_set_view_only (itip, BONOBO_ARG_GET_INT (arg));
- break;
- }
-}
-
-BonoboControl *
-itip_bonobo_control_new (void)
-{
- BonoboControl *control;
- BonoboPropertyBag *prop_bag;
- BonoboPersistStream *stream;
- GtkWidget *itip;
-
- itip = e_itip_control_new ();
- gtk_widget_show (itip);
- control = bonobo_control_new (itip);
-
- /* create a property bag */
- prop_bag = bonobo_property_bag_new (get_prop, set_prop, itip);
- bonobo_property_bag_add (prop_bag, "from_address", FROM_ADDRESS_ARG_ID, BONOBO_ARG_STRING, NULL,
- "from_address", 0 );
- bonobo_property_bag_add (prop_bag, "view_only", VIEW_ONLY_ARG_ID, BONOBO_ARG_INT, NULL,
- "view_only", 0 );
-
- bonobo_control_set_properties (control, bonobo_object_corba_objref (BONOBO_OBJECT (prop_bag)), NULL);
- bonobo_object_unref (BONOBO_OBJECT (prop_bag));
-
- bonobo_control_set_automerge (control, TRUE);
-
- stream = bonobo_persist_stream_new (pstream_load, pstream_save,
- pstream_get_content_types,
- "OAFIID:GNOME_Evolution_Calendar_iTip_Control:" BASE_VERSION,
- itip);
-
- if (stream == NULL) {
- bonobo_object_unref (BONOBO_OBJECT (control));
- return NULL;
- }
-
- bonobo_object_add_interface (BONOBO_OBJECT (control),
- BONOBO_OBJECT (stream));
-
- return control;
-}
diff --git a/calendar/gui/itip-utils.c b/calendar/gui/itip-utils.c
index 79df2ddad4..5acabdbc25 100644
--- a/calendar/gui/itip-utils.c
+++ b/calendar/gui/itip-utils.c
@@ -37,7 +37,6 @@
#include <time.h>
#include <composer/e-msg-composer.h>
-#include <mail/em-composer-utils.h>
#include <camel/camel-mime-filter-tohtml.h>
static const gchar *itip_methods[] = {
@@ -1248,7 +1247,6 @@ itip_send_comp (ECalComponentItipMethod method, ECalComponent *send_comp,
composer = e_msg_composer_new ();
table = e_msg_composer_get_header_table (composer);
- em_composer_utils_setup_default_callbacks (composer);
e_composer_header_table_set_subject (table, subject);
e_composer_header_table_set_account_name (table, from);
@@ -1356,7 +1354,6 @@ reply_to_calendar_comp (ECalComponentItipMethod method,
composer = e_msg_composer_new ();
table = e_msg_composer_get_header_table (composer);
- em_composer_utils_setup_default_callbacks (composer);
e_composer_header_table_set_subject (table, subject);
e_composer_header_table_set_account_name (table, from);
diff --git a/calendar/gui/main.c b/calendar/gui/main.c
deleted file mode 100644
index 9d078edbd9..0000000000
--- a/calendar/gui/main.c
+++ /dev/null
@@ -1,193 +0,0 @@
-/*
- * This program is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 2 of the License, or (at your option) version 3.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with the program; if not, see <http://www.gnu.org/licenses/>
- *
- *
- * Authors:
- * Ettore Perazzoli <ettore@ximian.com>
- *
- * Copyright (C) 1999-2008 Novell, Inc. (www.novell.com)
- *
- */
-
-#ifdef HAVE_CONFIG_H
-#include <config.h>
-#endif
-
-#include <glib.h>
-#include <glib/gi18n.h>
-#include <libgnome/gnome-init.h>
-#include <glade/glade.h>
-
-#include <bonobo/bonobo-main.h>
-#include <bonobo/bonobo-shlib-factory.h>
-#include <bonobo/bonobo-exception.h>
-
-#include "dialogs/cal-prefs-dialog.h"
-#include "calendar-commands.h"
-#include "calendar-config.h"
-#include "calendar-component.h"
-#include "e-comp-editor-registry.h"
-#include "comp-editor-factory.h"
-#include "control-factory.h"
-#include "itip-bonobo-control.h"
-#include "tasks-control.h"
-#include "tasks-component.h"
-#include "memos-component.h"
-
-#include <e-util/e-plugin.h>
-#include <e-util/e-import.h>
-#include "e-cal-config.h"
-#include "e-cal-popup.h"
-#include "e-cal-menu.h"
-#include "e-cal-event.h"
-#include "calendar/importers/evolution-calendar-importer.h"
-
-#define FACTORY_ID "OAFIID:GNOME_Evolution_Calendar_Factory:" BASE_VERSION
-
-#define CALENDAR_COMPONENT_ID "OAFIID:GNOME_Evolution_Calendar_Component:" BASE_VERSION
-#define TASKS_COMPONENT_ID "OAFIID:GNOME_Evolution_Tasks_Component:" BASE_VERSION
-#define MEMOS_COMPONENT_ID "OAFIID:GNOME_Evolution_Memos_Component:" BASE_VERSION
-#define ITIP_CONTROL_ID "OAFIID:GNOME_Evolution_Calendar_iTip_Control:" BASE_VERSION
-#define CONFIG_CONTROL_ID "OAFIID:GNOME_Evolution_Calendar_ConfigControl:" BASE_VERSION
-#define COMP_EDITOR_FACTORY_ID "OAFIID:GNOME_Evolution_Calendar_CompEditorFactory:" BASE_VERSION
-
-ECompEditorRegistry *comp_editor_registry = NULL;
-
-/* The component editor factory */
-static CompEditorFactory *comp_editor_factory = NULL;
-
-/* Factory function for the calendar component factory; just creates and
- * references a singleton service object.
- */
-static BonoboObject *
-comp_editor_factory_fn (void)
-{
- if (!comp_editor_factory) {
- comp_editor_factory = comp_editor_factory_new ();
- if (!comp_editor_factory)
- return NULL;
- }
-
- bonobo_object_ref (BONOBO_OBJECT (comp_editor_factory));
- return BONOBO_OBJECT (comp_editor_factory);
-}
-
-/* Does a simple activation and unreffing of the alarm notification service so
- * that the daemon will be launched if it is not running yet.
- */
-static gboolean
-launch_alarm_daemon_cb (gpointer data)
-{
- CORBA_Environment ev;
- CORBA_Object an;
-
- /* activate the alarm daemon */
- CORBA_exception_init (&ev);
- an = bonobo_activation_activate_from_id (
- (Bonobo_ActivationID) "OAFIID:GNOME_Evolution_Calendar_AlarmNotify:" BASE_VERSION, 0, NULL, &ev);
-
- if (BONOBO_EX (&ev)) {
- g_message ("launch_alarm_daemon_cb(): %s", bonobo_exception_get_text (&ev));
- CORBA_exception_free (&ev);
- return FALSE;
- }
- CORBA_exception_free (&ev);
-
- /* Just get rid of it; what we are interested in is that it gets launched */
-
- CORBA_exception_init (&ev);
- bonobo_object_release_unref (an, &ev);
- if (BONOBO_EX (&ev))
- g_message ("add_alarms(): Could not unref the alarm notification service");
-
- CORBA_exception_free (&ev);
-
- return FALSE;
-}
-
-static void
-launch_alarm_daemon (void)
-{
- g_idle_add ((GSourceFunc) launch_alarm_daemon_cb, NULL);
-}
-
-static void
-initialize (void)
-{
- EImportClass *klass;
-
- comp_editor_registry = E_COMP_EDITOR_REGISTRY (e_comp_editor_registry_new ());
-
-#if 0
- itip_control_factory_init ();
- component_editor_factory_init ();
-#endif
-
- launch_alarm_daemon ();
-
- /* Initialize plugin system */
- e_plugin_hook_register_type (e_cal_popup_hook_get_type());
- e_plugin_hook_register_type (e_cal_menu_hook_get_type());
- e_plugin_hook_register_type (e_cal_config_hook_get_type ());
- e_plugin_hook_register_type (e_cal_event_hook_get_type ());
-
- klass = g_type_class_ref(e_import_get_type());
- e_import_class_add_importer(klass, gnome_calendar_importer_peek(), NULL, NULL);
- e_import_class_add_importer(klass, ical_importer_peek(), NULL, NULL);
- e_import_class_add_importer(klass, vcal_importer_peek(), NULL, NULL);
-}
-
-static BonoboObject *
-factory (BonoboGenericFactory *factory,
- const gchar *component_id,
- gpointer closure)
-{
- static gboolean initialized = FALSE;
-
- if (! initialized) {
- initialize ();
- initialized = TRUE;
- }
-
- if (strcmp (component_id, CALENDAR_COMPONENT_ID) == 0) {
- BonoboObject *object = BONOBO_OBJECT (calendar_component_peek ());
- bonobo_object_ref (object);
- return object;
- } else if (strcmp (component_id, TASKS_COMPONENT_ID) == 0) {
- BonoboObject *object = BONOBO_OBJECT (tasks_component_peek ());
- bonobo_object_ref (object);
- return object;
- } else if (strcmp (component_id, MEMOS_COMPONENT_ID) == 0) {
- BonoboObject *object = BONOBO_OBJECT (memos_component_peek ());
- bonobo_object_ref (object);
- return object;
- } else if (strcmp (component_id, ITIP_CONTROL_ID) == 0)
- return BONOBO_OBJECT (itip_bonobo_control_new ());
- else if (strcmp (component_id, CONFIG_CONTROL_ID) == 0) {
- GtkWidget *prefs;
- EvolutionConfigControl *control;
-
- prefs = calendar_prefs_dialog_new ();
- gtk_widget_show (prefs);
- control = evolution_config_control_new (prefs);
-
- return BONOBO_OBJECT (control);
- } else if (strcmp (component_id, COMP_EDITOR_FACTORY_ID) == 0)
- return BONOBO_OBJECT (comp_editor_factory_fn ());
-
- g_warning (FACTORY_ID ": Don't know what to do with %s", component_id);
- return NULL;
-}
-
-BONOBO_ACTIVATION_SHLIB_FACTORY (FACTORY_ID, "Evolution Calendar component factory", factory, NULL)
diff --git a/calendar/gui/memos-component.c b/calendar/gui/memos-component.c
index f4e3200e8c..2e45ad4ec9 100644
--- a/calendar/gui/memos-component.c
+++ b/calendar/gui/memos-component.c
@@ -58,27 +58,13 @@
#define CREATE_SHARED_MEMO_ID "shared-memo"
#define CREATE_MEMO_LIST_ID "memo-list"
-enum DndTargetType {
- DND_TARGET_TYPE_CALENDAR_LIST
-};
-#define CALENDAR_TYPE "text/calendar"
-#define XCALENDAR_TYPE "text/x-calendar"
#define WEB_BASE_URI "webcal://"
#define PERSONAL_RELATIVE_URI "system"
-static GtkTargetEntry drag_types[] = {
- { (gchar *) CALENDAR_TYPE, 0, DND_TARGET_TYPE_CALENDAR_LIST },
- { (gchar *) XCALENDAR_TYPE, 0, DND_TARGET_TYPE_CALENDAR_LIST }
-};
-static gint num_drag_types = sizeof(drag_types) / sizeof(drag_types[0]);
-
#define PARENT_TYPE bonobo_object_get_type ()
static BonoboObjectClass *parent_class = NULL;
-/* Memos should have their own registry */
-extern ECompEditorRegistry *comp_editor_registry;
-
typedef struct _MemosComponentView
{
ESourceList *source_list;
@@ -89,29 +75,17 @@ typedef struct _MemosComponentView
ETable *table;
ETableModel *model;
- EInfoLabel *info_label;
GtkWidget *source_selector;
- BonoboControl *view_control;
- BonoboControl *sidebar_control;
- BonoboControl *statusbar_control;
-
GList *notifications;
- EUserCreatableItemsHandler *creatable_items_handler;
-
- EActivityHandler *activity_handler;
} MemosComponentView;
struct _MemosComponentPrivate {
- gchar *base_directory;
- gchar *config_directory;
ESourceList *source_list;
GSList *source_selection;
- GList *views;
-
ECal *create_ecal;
GList *notifications;
@@ -119,109 +93,6 @@ struct _MemosComponentPrivate {
#define d(x)
-static void
-ensure_sources (MemosComponent *component)
-{
- ESourceList *source_list;
- ESourceGroup *on_this_computer;
- ESource *personal_source;
- gchar *base_uri, *base_uri_proto, base_uri_proto_seventh;
- const gchar *base_dir;
-
- personal_source = NULL;
-
- if (!e_cal_get_sources (&source_list, E_CAL_SOURCE_TYPE_JOURNAL, NULL)) {
- g_warning ("Could not get memo source list from GConf!");
- return;
- }
-
- base_dir = memos_component_peek_base_directory (component);
- base_uri = g_build_filename (base_dir, "local", NULL);
-
- base_uri_proto = g_filename_to_uri (base_uri, NULL, NULL);
- if (strlen (base_uri_proto) > 7) {
- /* compare only file:// part. If user home dir name changes we do not want to create
- one more group */
- base_uri_proto_seventh = base_uri_proto[7];
- base_uri_proto[7] = 0;
- } else {
- base_uri_proto_seventh = -1;
- }
-
- on_this_computer = e_source_list_ensure_group (source_list, _("On This Computer"), base_uri_proto, TRUE);
- e_source_list_ensure_group (source_list, _("On The Web"), WEB_BASE_URI, FALSE);
-
- if (base_uri_proto_seventh != -1) {
- base_uri_proto[7] = base_uri_proto_seventh;
- }
-
- if (on_this_computer) {
- /* make sure "Personal" shows up as a source under
- this group */
- GSList *sources = e_source_group_peek_sources (on_this_computer);
- GSList *s;
- for (s = sources; s; s = s->next) {
- ESource *source = E_SOURCE (s->data);
- const gchar *relative_uri;
-
- relative_uri = e_source_peek_relative_uri (source);
- if (relative_uri == NULL)
- continue;
- if (!strcmp (PERSONAL_RELATIVE_URI, relative_uri)) {
- personal_source = source;
- break;
- }
- }
- /* Make sure we have the correct base uri. This can change when user's
- homedir name changes */
- if (strcmp (base_uri_proto, e_source_group_peek_base_uri (on_this_computer))) {
- e_source_group_set_base_uri (on_this_computer, base_uri_proto);
-
- /* *sigh* . We shouldn't need this sync call here as set_base_uri
- call results in synching to gconf, but that happens in idle loop
- and too late to prevent user seeing "Can not Open ... because of invalid uri" error.*/
- e_source_list_sync (source_list,NULL);
- }
- }
-
- if (personal_source) {
- /* ensure the source name is in current locale, not read from configuration */
- e_source_set_name (personal_source, _("Personal"));
- } else {
- GSList *memos_selected;
- /* Create the default Person addressbook */
- ESource *source = e_source_new (_("Personal"), PERSONAL_RELATIVE_URI);
- e_source_group_add_source (on_this_computer, source, -1);
- g_object_unref (source);
-
- memos_selected = calendar_config_get_memos_selected ();
-
- if (!calendar_config_get_primary_memos () && !memos_selected) {
- GSList selected;
-
- calendar_config_set_primary_memos (e_source_peek_uid (source));
-
- selected.data = (gpointer)e_source_peek_uid (source);
- selected.next = NULL;
- calendar_config_set_memos_selected (&selected);
- }
-
- if (memos_selected) {
- g_slist_foreach (memos_selected, (GFunc) g_free, NULL);
- g_slist_free (memos_selected);
- }
-
- e_source_set_color_spec (source, "#BECEDD");
- personal_source = source;
- }
-
- component->priv->source_list = source_list;
-
- g_object_unref (on_this_computer);
- g_free (base_uri_proto);
- g_free (base_uri);
-}
-
/* Utility functions. */
/* FIXME Some of these are duplicated from calendar-component.c */
static gboolean
@@ -255,7 +126,7 @@ is_in_uids (GSList *uids, ESource *source)
}
static void
-update_uris_for_selection (MemosComponentView *component_view)
+source_selection_changed_cb (ESourceSelector *selector, MemosComponentView *component_view)
{
GSList *selection, *l, *uids_selected = NULL;
@@ -283,338 +154,8 @@ update_uris_for_selection (MemosComponentView *component_view)
g_slist_free (uids_selected);
}
-static void
-update_uri_for_primary_selection (MemosComponentView *component_view)
-{
- ESource *source;
- EMemoTable *cal_table;
- ETable *etable;
-
- source = e_source_selector_peek_primary_selection (E_SOURCE_SELECTOR (component_view->source_selector));
- if (!source)
- return;
-
- /* Set the default */
- e_memos_set_default_source (component_view->memos, source);
-
- cal_table = e_memos_get_calendar_table (component_view->memos);
- etable = e_memo_table_get_table (cal_table);
-
- memos_control_sensitize_commands (component_view->view_control, component_view->memos, e_table_selected_count (etable));
-
- /* Save the selection for next time we start up */
- calendar_config_set_primary_memos (e_source_peek_uid (source));
-}
-
-static void
-update_selection (MemosComponentView *component_view)
-{
- GSList *selection, *uids_selected, *l;
-
- d(g_message("memos-component.c: update_selection called");)
-
- /* Get the selection in gconf */
- uids_selected = calendar_config_get_memos_selected ();
-
- /* Remove any that aren't there any more */
- selection = e_source_selector_get_selection (E_SOURCE_SELECTOR (component_view->source_selector));
-
- for (l = selection; l; l = l->next) {
- ESource *source = l->data;
-
- if (!is_in_uids (uids_selected, source))
- e_source_selector_unselect_source (E_SOURCE_SELECTOR (component_view->source_selector), source);
- }
-
- e_source_selector_free_selection (selection);
-
- /* Make sure the whole selection is there */
- for (l = uids_selected; l; l = l->next) {
- gchar *uid = l->data;
- ESource *source;
-
- source = e_source_list_peek_source_by_uid (component_view->source_list, uid);
- if (source)
- e_source_selector_select_source (E_SOURCE_SELECTOR (component_view->source_selector), source);
-
- g_free (uid);
- }
- g_slist_free (uids_selected);
-}
-
-static void
-update_primary_selection (MemosComponentView *component_view)
-{
- ESource *source = NULL;
- gchar *uid;
-
- uid = calendar_config_get_primary_memos ();
- if (uid) {
- source = e_source_list_peek_source_by_uid (component_view->source_list, uid);
- g_free (uid);
- }
-
- if (source) {
- e_source_selector_set_primary_selection (E_SOURCE_SELECTOR (component_view->source_selector), source);
- } else {
- /* Try to create a default if there isn't one */
- source = e_source_list_peek_source_any (component_view->source_list);
- if (source)
- e_source_selector_set_primary_selection (E_SOURCE_SELECTOR (component_view->source_selector), source);
- }
-
-}
-
-/* Callbacks. */
-/* TODO: doesn't work! */
-static void
-copy_memo_list_cb (EPopup *ep, EPopupItem *pitem, gpointer data)
-{
- MemosComponentView *component_view = data;
- ESource *selected_source;
-
- selected_source = e_source_selector_peek_primary_selection (E_SOURCE_SELECTOR (component_view->source_selector));
- if (!selected_source)
- return;
-
- copy_source_dialog (GTK_WINDOW (gtk_widget_get_toplevel(ep->target->widget)), selected_source, E_CAL_SOURCE_TYPE_JOURNAL);
-}
-
-static void
-delete_memo_list_cb (EPopup *ep, EPopupItem *pitem, gpointer data)
-{
- MemosComponentView *component_view = data;
- ESource *selected_source;
- ECal *cal;
- gchar *uri;
-
- selected_source = e_source_selector_peek_primary_selection (E_SOURCE_SELECTOR (component_view->source_selector));
- if (!selected_source)
- return;
-
- if (e_error_run((GtkWindow *)gtk_widget_get_toplevel(ep->target->widget),
- "calendar:prompt-delete-memo-list", e_source_peek_name(selected_source), NULL) != GTK_RESPONSE_YES)
- return;
-
- /* first, ask the backend to remove the memo list */
- uri = e_source_get_uri (selected_source);
- cal = e_cal_model_get_client_for_uri (
- e_memo_table_get_model (E_MEMO_TABLE (e_memos_get_calendar_table (component_view->memos))),
- uri);
- if (!cal)
- cal = e_cal_new_from_uri (uri, E_CAL_SOURCE_TYPE_JOURNAL);
- g_free (uri);
- if (cal) {
- if (e_cal_remove (cal, NULL)) {
- if (e_source_selector_source_is_selected (E_SOURCE_SELECTOR (component_view->source_selector),
- selected_source)) {
- e_memos_remove_memo_source (component_view->memos, selected_source);
- e_source_selector_unselect_source (E_SOURCE_SELECTOR (component_view->source_selector),
- selected_source);
- }
-
- e_source_group_remove_source (e_source_peek_group (selected_source), selected_source);
- e_source_list_sync (component_view->source_list, NULL);
- }
- }
-}
-
-static void
-new_memo_list_cb (EPopup *ep, EPopupItem *pitem, gpointer data)
-{
- calendar_setup_new_memo_list (GTK_WINDOW (gtk_widget_get_toplevel(ep->target->widget)));
-}
-
-static void
-rename_memo_list_cb (EPopup *ep, EPopupItem *pitem, gpointer data)
-{
- MemosComponentView *component_view = data;
- ESourceSelector *selector;
-
- selector = E_SOURCE_SELECTOR (component_view->source_selector);
- e_source_selector_edit_primary_selection (selector);
-}
-
-static void
-edit_memo_list_cb (EPopup *ep, EPopupItem *pitem, gpointer data)
-{
- MemosComponentView *component_view = data;
- ESource *selected_source;
-
- selected_source = e_source_selector_peek_primary_selection (E_SOURCE_SELECTOR (component_view->source_selector));
- if (!selected_source)
- return;
-
- calendar_setup_edit_memo_list (GTK_WINDOW (gtk_widget_get_toplevel(ep->target->widget)), selected_source);
-}
-
-static void
-set_offline_availability (EPopup *ep, EPopupItem *pitem, gpointer data, const gchar *value)
-{
- MemosComponentView *component_view = data;
- ESource *selected_source;
-
- selected_source = e_source_selector_peek_primary_selection (E_SOURCE_SELECTOR (component_view->source_selector));
- if (!selected_source)
- return;
-
- e_source_set_property (selected_source, "offline_sync", value);
-}
-
-static void
-mark_no_offline_cb (EPopup *ep, EPopupItem *pitem, gpointer data)
-{
- set_offline_availability (ep, pitem, data, "0");
-}
-
-static void
-mark_offline_cb (EPopup *ep, EPopupItem *pitem, gpointer data)
-{
- set_offline_availability (ep, pitem, data, "1");
-}
-
-static EPopupItem emc_source_popups[] = {
- { E_POPUP_ITEM, (gchar *) "10.new", (gchar *) N_("_New Memo List"), new_memo_list_cb, NULL, (gchar *) "stock_notes", 0, 0 },
- { E_POPUP_ITEM, (gchar *) "15.copy", (gchar *) N_("_Copy..."), copy_memo_list_cb, NULL, (gchar *) "edit-copy", 0, E_CAL_POPUP_SOURCE_PRIMARY },
- { E_POPUP_ITEM, (gchar *) "18.rename", (gchar *) N_("_Rename..."), rename_memo_list_cb, NULL, NULL, 0, E_CAL_POPUP_SOURCE_PRIMARY },
-
- { E_POPUP_BAR, (gchar *) "20.bar" },
- { E_POPUP_ITEM, (gchar *) "20.delete", (gchar *) N_("_Delete"), delete_memo_list_cb, NULL, (gchar *) "edit-delete", 0, E_CAL_POPUP_SOURCE_USER|E_CAL_POPUP_SOURCE_PRIMARY },
- { E_POPUP_ITEM, (gchar *) "30.mark_memos_offline", (gchar *) N_("_Make available for offline use"), mark_offline_cb, NULL, (gchar *) "stock_disconnect", E_CAL_POPUP_SOURCE_OFFLINE, E_CAL_POPUP_SOURCE_USER|E_CAL_POPUP_SOURCE_PRIMARY|E_CAL_POPUP_SOURCE_OFFLINE },
- { E_POPUP_ITEM, (gchar *) "40.mark_memos_no_offline", (gchar *) N_("_Do not make available for offline use"), mark_no_offline_cb, NULL, (gchar *) "stock_connect", E_CAL_POPUP_SOURCE_NO_OFFLINE, E_CAL_POPUP_SOURCE_USER|E_CAL_POPUP_SOURCE_PRIMARY|E_CAL_POPUP_SOURCE_NO_OFFLINE },
-
- { E_POPUP_BAR, (gchar *) "99.bar" },
- { E_POPUP_ITEM, (gchar *) "99.properties", (gchar *) N_("_Properties"), edit_memo_list_cb, NULL, (gchar *) "document-properties", 0, E_CAL_POPUP_SOURCE_PRIMARY },
-};
-
-static void
-emc_source_popup_free(EPopup *ep, GSList *list, gpointer data)
-{
- g_slist_free(list);
-}
-
-static gboolean
-popup_event_cb(ESourceSelector *selector, ESource *insource, GdkEventButton *event, MemosComponentView *component_view)
-{
- ECalPopup *ep;
- ECalPopupTargetSource *t;
- GSList *menus = NULL;
- gint i;
- GtkMenu *menu;
-
- /** @HookPoint-ECalPopup: Memos Source Selector Context Menu
- * @Id: org.gnome.evolution.memos.source.popup
- * @Class: org.gnome.evolution.calendar.popup:1.0
- * @Target: ECalPopupTargetSource
- *
- * The context menu on the source selector in the memos window.
- */
- ep = e_cal_popup_new("org.gnome.evolution.memos.source.popup");
- t = e_cal_popup_target_new_source(ep, selector);
- t->target.widget = (GtkWidget *)component_view->memos;
-
- for (i=0;i<sizeof(emc_source_popups)/sizeof(emc_source_popups[0]);i++)
- menus = g_slist_prepend(menus, &emc_source_popups[i]);
-
- e_popup_add_items((EPopup *)ep, menus, NULL,emc_source_popup_free, component_view);
-
- menu = e_popup_create_menu_once((EPopup *)ep, (EPopupTarget *)t, 0);
- gtk_menu_popup(menu, NULL, NULL, NULL, NULL, event?event->button:0, event?event->time:gtk_get_current_event_time());
-
- return TRUE;
-}
-
-static void
-source_selection_changed_cb (ESourceSelector *selector, MemosComponentView *component_view)
-{
- update_uris_for_selection (component_view);
-}
-
-static void
-primary_source_selection_changed_cb (ESourceSelector *selector, MemosComponentView *component_view)
-{
- update_uri_for_primary_selection (component_view);
-}
-
-static void
-source_added_cb (EMemos *memos, ESource *source, MemosComponentView *component_view)
-{
- e_source_selector_select_source (E_SOURCE_SELECTOR (component_view->source_selector), source);
-}
-
-static void
-source_removed_cb (EMemos *memos, ESource *source, MemosComponentView *component_view)
-{
- e_source_selector_unselect_source (E_SOURCE_SELECTOR (component_view->source_selector), source);
-}
-
-static void
-set_info (MemosComponentView *component_view)
-{
- GString *message = g_string_new (NULL);
- gint rows, selected_rows;
-
- rows = e_table_model_row_count (component_view->model);
- selected_rows = e_table_selected_count (component_view->table);
-
- g_string_append_printf(message, ngettext("%d memo", "%d memos", rows), rows);
- if (selected_rows > 0)
- g_string_append_printf(message, ngettext(", %d selected", ", %d selected", selected_rows), selected_rows);
-
- e_info_label_set_info (component_view->info_label, _("Memos"), message->str);
-
- g_string_free (message, TRUE);
-}
-
-static void
-table_selection_change_cb (ETableModel *etm, MemosComponentView *component_view)
-{
- set_info (component_view);
-}
-
-static void
-model_changed_cb (ETableModel *etm, MemosComponentView *component_view)
-{
- set_info (component_view);
-}
-
-static void
-model_rows_inserted_cb (ETableModel *etm, gint row, gint count, MemosComponentView *component_view)
-{
- set_info (component_view);
-}
-
-static void
-model_rows_deleted_cb (ETableModel *etm, gint row, gint count, MemosComponentView *component_view)
-{
- set_info (component_view);
-}
-
/* Evolution::Component CORBA methods */
-static void
-impl_upgradeFromVersion (PortableServer_Servant servant,
- CORBA_short major,
- CORBA_short minor,
- CORBA_short revision,
- CORBA_Environment *ev)
-{
- GError *err = NULL;
- MemosComponent *component = MEMOS_COMPONENT (bonobo_object_from_servant (servant));
-
- if (!migrate_memos(component, major, minor, revision, &err)) {
- GNOME_Evolution_Component_UpgradeFailed *failedex;
-
- failedex = GNOME_Evolution_Component_UpgradeFailed__alloc();
- failedex->what = CORBA_string_dup(_("Failed upgrading memos."));
- failedex->why = CORBA_string_dup(err->message);
- CORBA_exception_set(ev, CORBA_USER_EXCEPTION, ex_GNOME_Evolution_Component_UpgradeFailed, failedex);
- }
-
- if (err)
- g_error_free(err);
-}
-
static gboolean
selector_tree_data_dropped (ESourceSelector *selector,
GtkSelectionData *data,
@@ -666,19 +207,6 @@ selector_tree_data_dropped (ESourceSelector *selector,
}
static void
-control_activate_cb (BonoboControl *control, gboolean activate, gpointer data)
-{
- MemosComponentView *component_view = data;
-
- if (activate) {
- BonoboUIComponent *uic;
- uic = bonobo_control_get_ui_component (component_view->view_control);
-
- e_user_creatable_items_handler_activate (component_view->creatable_items_handler, uic);
- }
-}
-
-static void
config_create_ecal_changed_cb (GConfClient *client, guint id, GConfEntry *entry, gpointer data)
{
MemosComponent *component = data;
@@ -810,140 +338,32 @@ create_new_memo (MemosComponent *memo_component, gboolean is_assigned, MemosComp
return TRUE;
}
-static void
-create_local_item_cb (EUserCreatableItemsHandler *handler, const gchar *item_type_name, gpointer data)
-{
- MemosComponent *memos_component = data;
- MemosComponentPrivate *priv;
- MemosComponentView *component_view = NULL;
- GList *l;
-
- priv = memos_component->priv;
-
- for (l = priv->views; l; l = l->next) {
- component_view = l->data;
-
- if (component_view->creatable_items_handler == handler)
- break;
-
- component_view = NULL;
- }
-
- if (strcmp (item_type_name, CREATE_MEMO_ID) == 0) {
- create_new_memo (memos_component, FALSE, component_view);
- } else if (strcmp (item_type_name, CREATE_SHARED_MEMO_ID) == 0) {
- create_new_memo (memos_component, TRUE, component_view);
- } else if (strcmp (item_type_name, CREATE_MEMO_LIST_ID) == 0) {
- calendar_setup_new_memo_list (GTK_WINDOW (gtk_widget_get_toplevel (GTK_WIDGET (component_view->memos))));
- }
-}
-
static MemosComponentView *
create_component_view (MemosComponent *memos_component)
{
MemosComponentPrivate *priv;
MemosComponentView *component_view;
- GtkWidget *selector_scrolled_window, *vbox;
GtkWidget *statusbar_widget;
- AtkObject *a11y;
priv = memos_component->priv;
/* Create the calendar component view */
component_view = g_new0 (MemosComponentView, 1);
- /* Add the source lists */
- component_view->source_list = g_object_ref (priv->source_list);
-
/* Create sidebar selector */
- component_view->source_selector = e_source_selector_new (memos_component->priv->source_list);
- e_source_selector_set_select_new ((ESourceSelector *)component_view->source_selector, TRUE);
- a11y = gtk_widget_get_accessible (GTK_WIDGET (component_view->source_selector));
- atk_object_set_name (a11y, _("Memo Source Selector"));
-
- g_signal_connect (
- component_view->source_selector, "data-dropped",
- G_CALLBACK (selector_tree_data_dropped), memos_component);
-
- gtk_drag_dest_set(component_view->source_selector, GTK_DEST_DEFAULT_ALL, drag_types,
- num_drag_types, GDK_ACTION_COPY | GDK_ACTION_MOVE);
-
- gtk_widget_show (component_view->source_selector);
-
- selector_scrolled_window = gtk_scrolled_window_new (NULL, NULL);
- gtk_container_add (GTK_CONTAINER (selector_scrolled_window), component_view->source_selector);
- gtk_scrolled_window_set_policy (GTK_SCROLLED_WINDOW (selector_scrolled_window),
- GTK_POLICY_AUTOMATIC, GTK_POLICY_AUTOMATIC);
- gtk_scrolled_window_set_shadow_type (GTK_SCROLLED_WINDOW (selector_scrolled_window),
- GTK_SHADOW_IN);
- gtk_widget_show (selector_scrolled_window);
-
- component_view->info_label = (EInfoLabel *)e_info_label_new("evolution-memos");
- e_info_label_set_info(component_view->info_label, _("Memos"), "");
- gtk_widget_show (GTK_WIDGET (component_view->info_label));
-
- vbox = gtk_vbox_new(FALSE, 0);
- gtk_box_pack_start(GTK_BOX (vbox), GTK_WIDGET (component_view->info_label), FALSE, TRUE, 0);
- gtk_box_pack_start(GTK_BOX (vbox), selector_scrolled_window, TRUE, TRUE, 0);
- gtk_widget_show (vbox);
-
- component_view->sidebar_control = bonobo_control_new (vbox);
-
- /* Create main view */
- component_view->view_control = memos_control_new ();
- if (!component_view->view_control) {
- /* FIXME free memory */
-
- return NULL;
- }
+ g_signal_connect (component_view->source_selector, "drag-data-received",
+ G_CALLBACK (selector_tree_drag_data_received), memos_component);
component_view->memos = (EMemos *) bonobo_control_get_widget (component_view->view_control);
component_view->table = e_memo_table_get_table (e_memos_get_calendar_table (component_view->memos));
component_view->model = E_TABLE_MODEL (e_memo_table_get_model (e_memos_get_calendar_table (component_view->memos)));
- /* This signal is thrown if backends die - we update the selector */
- g_signal_connect (component_view->memos, "source_added",
- G_CALLBACK (source_added_cb), component_view);
- g_signal_connect (component_view->memos, "source_removed",
- G_CALLBACK (source_removed_cb), component_view);
-
- /* Create status bar */
- statusbar_widget = e_task_bar_new ();
- component_view->activity_handler = e_activity_handler_new ();
- e_activity_handler_attach_task_bar (component_view->activity_handler, E_TASK_BAR (statusbar_widget));
- gtk_widget_show (statusbar_widget);
-
- component_view->statusbar_control = bonobo_control_new (statusbar_widget);
-
- e_memo_table_set_activity_handler (e_memos_get_calendar_table (component_view->memos), component_view->activity_handler);
-
/* connect after setting the initial selections, or we'll get unwanted calls
to calendar_control_sensitize_calendar_commands */
g_signal_connect (component_view->source_selector, "selection_changed",
G_CALLBACK (source_selection_changed_cb), component_view);
g_signal_connect (component_view->source_selector, "primary_selection_changed",
G_CALLBACK (primary_source_selection_changed_cb), component_view);
- g_signal_connect (component_view->source_selector, "popup_event",
- G_CALLBACK (popup_event_cb), component_view);
-
- /* Set up the "new" item handler */
- component_view->creatable_items_handler = e_user_creatable_items_handler_new ("memos", create_local_item_cb, memos_component);
- g_signal_connect (component_view->view_control, "activate", G_CALLBACK (control_activate_cb), component_view);
-
- /* We use this to update the component information */
- set_info (component_view);
- g_signal_connect (component_view->table, "selection_change",
- G_CALLBACK (table_selection_change_cb), component_view);
- g_signal_connect (component_view->model, "model_changed",
- G_CALLBACK (model_changed_cb), component_view);
- g_signal_connect (component_view->model, "model_rows_inserted",
- G_CALLBACK (model_rows_inserted_cb), component_view);
- g_signal_connect (component_view->model, "model_rows_deleted",
- G_CALLBACK (model_rows_deleted_cb), component_view);
-
- /* Load the selection from the last run */
- update_selection (component_view);
- update_primary_selection (component_view);
return component_view;
}
@@ -963,130 +383,9 @@ destroy_component_view (MemosComponentView *component_view)
calendar_config_remove_notification (GPOINTER_TO_UINT (l->data));
g_list_free (component_view->notifications);
- if (component_view->creatable_items_handler)
- g_object_unref (component_view->creatable_items_handler);
-
- if (component_view->activity_handler)
- g_object_unref (component_view->activity_handler);
-
g_free (component_view);
}
-static void
-view_destroyed_cb (gpointer data, GObject *where_the_object_was)
-{
- MemosComponent *memos_component = data;
- MemosComponentPrivate *priv;
- GList *l;
-
- priv = memos_component->priv;
-
- for (l = priv->views; l; l = l->next) {
- MemosComponentView *component_view = l->data;
-
- if (G_OBJECT (component_view->view_control) == where_the_object_was) {
- priv->views = g_list_remove (priv->views, component_view);
- destroy_component_view (component_view);
-
- break;
- }
- }
-}
-
-static GNOME_Evolution_ComponentView
-impl_createView (PortableServer_Servant servant,
- GNOME_Evolution_ShellView parent,
- CORBA_boolean select_item,
- CORBA_Environment *ev)
-{
- MemosComponent *component = MEMOS_COMPONENT (bonobo_object_from_servant (servant));
- MemosComponentPrivate *priv;
- MemosComponentView *component_view;
- EComponentView *ecv;
-
- priv = component->priv;
-
- /* Create the calendar component view */
- component_view = create_component_view (component);
- if (!component_view) {
- /* FIXME Should we describe the problem in a control? */
- bonobo_exception_set (ev, ex_GNOME_Evolution_Component_Failed);
-
- return CORBA_OBJECT_NIL;
- }
-
- g_object_weak_ref (G_OBJECT (component_view->view_control), view_destroyed_cb, component);
- priv->views = g_list_append (priv->views, component_view);
-
- /* TODO: Make CalendarComponentView just subclass EComponentView */
- ecv = e_component_view_new_controls (parent, "memos", component_view->sidebar_control,
- component_view->view_control, component_view->statusbar_control);
-
- return BONOBO_OBJREF(ecv);
-}
-
-static GNOME_Evolution_CreatableItemTypeList *
-impl__get_userCreatableItems (PortableServer_Servant servant,
- CORBA_Environment *ev)
-{
- GNOME_Evolution_CreatableItemTypeList *list = GNOME_Evolution_CreatableItemTypeList__alloc ();
-
- list->_length = 3;
- list->_maximum = list->_length;
- list->_buffer = GNOME_Evolution_CreatableItemTypeList_allocbuf (list->_length);
-
- CORBA_sequence_set_release (list, FALSE);
-
- list->_buffer[0].id = (gchar *) CREATE_MEMO_ID;
- list->_buffer[0].description = (gchar *) _("New memo");
- list->_buffer[0].menuDescription = (gchar *) C_("New", "Mem_o");
- list->_buffer[0].tooltip = (gchar *) _("Create a new memo");
- list->_buffer[0].menuShortcut = 'o';
- list->_buffer[0].iconName = (gchar *) "stock_insert-note";
- list->_buffer[0].type = GNOME_Evolution_CREATABLE_OBJECT;
-
- list->_buffer[1].id = (gchar *) CREATE_SHARED_MEMO_ID;
- list->_buffer[1].description = (gchar *) _("New shared memo");
- list->_buffer[1].menuDescription = (gchar *) C_("New", "_Shared memo");
- list->_buffer[1].tooltip = (gchar *) _("Create a shared new memo");
- list->_buffer[1].menuShortcut = 'h';
- list->_buffer[1].iconName = (gchar *) "stock_insert-note";
- list->_buffer[1].type = GNOME_Evolution_CREATABLE_OBJECT;
-
- list->_buffer[2].id = (gchar *) CREATE_MEMO_LIST_ID;
- list->_buffer[2].description = (gchar *) _("New memo list");
- list->_buffer[2].menuDescription = (gchar *) C_("New", "Memo li_st");
- list->_buffer[2].tooltip = (gchar *) _("Create a new memo list");
- list->_buffer[2].menuShortcut = '\0';
- list->_buffer[2].iconName = (gchar *) "stock_notes";
- list->_buffer[2].type = GNOME_Evolution_CREATABLE_FOLDER;
-
- return list;
-}
-
-static void
-impl_requestCreateItem (PortableServer_Servant servant,
- const CORBA_char *item_type_name,
- CORBA_Environment *ev)
-{
- MemosComponent *memos_component = MEMOS_COMPONENT (bonobo_object_from_servant (servant));
-
- if (strcmp (item_type_name, CREATE_MEMO_ID) == 0) {
- if (!create_new_memo (memos_component, FALSE, NULL))
- bonobo_exception_set (ev, ex_GNOME_Evolution_Component_Failed);
- }
- else if (strcmp (item_type_name, CREATE_MEMO_LIST_ID) == 0) {
- /* FIXME Should we use the last opened window? */
- calendar_setup_new_memo_list (NULL);
- } else if (strcmp (item_type_name, CREATE_SHARED_MEMO_ID) == 0) {
- if (!create_new_memo (memos_component, TRUE, NULL))
- bonobo_exception_set (ev, ex_GNOME_Evolution_Component_Failed);
- }
- else {
- bonobo_exception_set (ev, ex_GNOME_Evolution_Component_UnknownType);
- }
-}
-
/* GObject methods. */
static void
@@ -1110,14 +409,6 @@ impl_dispose (GObject *object)
priv->create_ecal = NULL;
}
- for (l = priv->views; l; l = l->next) {
- MemosComponentView *component_view = l->data;
-
- g_object_weak_unref (G_OBJECT (component_view->view_control), view_destroyed_cb, memos_component);
- }
- g_list_free (priv->views);
- priv->views = NULL;
-
for (l = priv->notifications; l; l = l->next)
calendar_config_remove_notification (GPOINTER_TO_UINT (l->data));
g_list_free (priv->notifications);
@@ -1125,98 +416,3 @@ impl_dispose (GObject *object)
(* G_OBJECT_CLASS (parent_class)->dispose) (object);
}
-
-static void
-impl_finalize (GObject *object)
-{
- MemosComponentPrivate *priv = MEMOS_COMPONENT (object)->priv;
- GList *l;
-
- for (l = priv->views; l; l = l->next) {
- MemosComponentView *component_view = l->data;
-
- destroy_component_view (component_view);
- }
- g_list_free (priv->views);
-
- g_free (priv->base_directory);
- g_free (priv->config_directory);
- g_free (priv);
-
- (* G_OBJECT_CLASS (parent_class)->finalize) (object);
-}
-
-static void
-memos_component_class_init (MemosComponentClass *klass)
-{
- POA_GNOME_Evolution_Component__epv *epv = &klass->epv;
- GObjectClass *object_class = G_OBJECT_CLASS (klass);
-
- bindtextdomain (GETTEXT_PACKAGE, EVOLUTION_LOCALEDIR);
- bind_textdomain_codeset (GETTEXT_PACKAGE, "UTF-8");
-
- parent_class = g_type_class_peek_parent (klass);
-
- epv->upgradeFromVersion = impl_upgradeFromVersion;
- epv->createView = impl_createView;
- epv->_get_userCreatableItems = impl__get_userCreatableItems;
- epv->requestCreateItem = impl_requestCreateItem;
-
- object_class->dispose = impl_dispose;
- object_class->finalize = impl_finalize;
-}
-
-static void
-memos_component_init (MemosComponent *component, MemosComponentClass *klass)
-{
- MemosComponentPrivate *priv;
-
- priv = g_new0 (MemosComponentPrivate, 1);
-
- priv->base_directory = g_build_filename (e_get_user_data_dir (), "memos", NULL);
- priv->config_directory = g_build_filename (priv->base_directory, "config", NULL);
-
- component->priv = priv;
- ensure_sources (component);
-}
-
-/* Public API */
-
-MemosComponent *
-memos_component_peek (void)
-{
- static MemosComponent *component = NULL;
-
- if (component == NULL) {
- component = g_object_new (memos_component_get_type (), NULL);
-
- if (g_mkdir_with_parents (component->priv->config_directory, 0777) != 0) {
- g_warning (G_STRLOC ": Cannot create directory %s: %s",
- component->priv->config_directory, g_strerror (errno));
- g_object_unref (component);
- component = NULL;
- }
- }
-
- return component;
-}
-
-const gchar *
-memos_component_peek_base_directory (MemosComponent *component)
-{
- return component->priv->base_directory;
-}
-
-const gchar *
-memos_component_peek_config_directory (MemosComponent *component)
-{
- return component->priv->config_directory;
-}
-
-ESourceList *
-memos_component_peek_source_list (MemosComponent *component)
-{
- return component->priv->source_list;
-}
-
-BONOBO_TYPE_FUNC_FULL (MemosComponent, GNOME_Evolution_Component, PARENT_TYPE, memos_component)
diff --git a/calendar/gui/memos-component.h b/calendar/gui/memos-component.h
index 54f522ba9c..b46095c629 100644
--- a/calendar/gui/memos-component.h
+++ b/calendar/gui/memos-component.h
@@ -54,8 +54,4 @@ struct _MemosComponentClass {
GType memos_component_get_type (void);
MemosComponent *memos_component_peek (void);
-const gchar *memos_component_peek_base_directory (MemosComponent *component);
-const gchar *memos_component_peek_config_directory (MemosComponent *component);
-ESourceList *memos_component_peek_source_list (MemosComponent *component);
-
#endif /* _MEMOS_COMPONENT_H_ */
diff --git a/calendar/gui/memos-control.c b/calendar/gui/memos-control.c
deleted file mode 100644
index a7983779a7..0000000000
--- a/calendar/gui/memos-control.c
+++ /dev/null
@@ -1,404 +0,0 @@
-/*
- *
- * This program is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 2 of the License, or (at your option) version 3.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with the program; if not, see <http://www.gnu.org/licenses/>
- *
- *
- * Authors:
- * Damon Chaplin <damon@ximian.com>
- * Ettore Perazzoli
- * Nathan Owens <pianocomp81@yahoo.com>
- *
- * Copyright (C) 1999-2008 Novell, Inc. (www.novell.com)
- *
- */
-
-#ifdef HAVE_CONFIG_H
-#include <config.h>
-#endif
-
-#include <gtk/gtk.h>
-#include <glib/gi18n.h>
-#include <bonobo/bonobo-control.h>
-#include <bonobo/bonobo-ui-util.h>
-#include <e-util/e-dialog-utils.h>
-#include <e-util/e-icon-factory.h>
-#include <e-util/e-print.h>
-#include <e-util/e-util-private.h>
-#include <gtkhtml/gtkhtml.h>
-
-#include "calendar-config.h"
-#include "e-memos.h"
-#include "e-memo-table.h"
-#include "print.h"
-#include "memos-control.h"
-#include "e-cal-component-memo-preview.h"
-#include "evolution-shell-component-utils.h"
-
-#define FIXED_MARGIN .05
-
-static void memos_control_activate_cb (BonoboControl *control,
- gboolean activate,
- gpointer user_data);
-static void memos_control_open_memo_cmd (BonoboUIComponent *uic,
- gpointer data,
- const gchar *path);
-static void memos_control_new_memo_cmd (BonoboUIComponent *uic,
- gpointer data,
- const gchar *path);
-static void memos_control_cut_cmd (BonoboUIComponent *uic,
- gpointer data,
- const gchar *path);
-static void memos_control_copy_cmd (BonoboUIComponent *uic,
- gpointer data,
- const gchar *path);
-static void memos_control_paste_cmd (BonoboUIComponent *uic,
- gpointer data,
- const gchar *path);
-static void memos_control_delete_cmd (BonoboUIComponent *uic,
- gpointer data,
- const gchar *path);
-static void memos_control_print_cmd (BonoboUIComponent *uic,
- gpointer data,
- const gchar *path);
-static void memos_control_print_preview_cmd (BonoboUIComponent *uic,
- gpointer data,
- const gchar *path);
-
-struct focus_changed_data {
- BonoboControl *control;
- EMemos *memos;
-};
-
-static gboolean memos_control_focus_changed (GtkWidget *widget, GdkEventFocus *event, struct focus_changed_data *fc_data);
-
-BonoboControl *
-memos_control_new (void)
-{
- BonoboControl *control;
- GtkWidget *memos, *preview;
- struct focus_changed_data *fc_data;
-
- memos = e_memos_new ();
- if (!memos)
- return NULL;
- gtk_widget_show (memos);
-
- control = bonobo_control_new (memos);
- if (!control) {
- gtk_widget_destroy (memos);
- g_message ("control_factory_fn(): could not create the control!");
- return NULL;
- }
-
- g_signal_connect (control, "activate", G_CALLBACK (memos_control_activate_cb), memos);
-
- fc_data = g_new0 (struct focus_changed_data, 1);
- fc_data->control = control;
- fc_data->memos = E_MEMOS (memos);
-
- preview = e_cal_component_memo_preview_get_html (E_CAL_COMPONENT_MEMO_PREVIEW (e_memos_get_preview (fc_data->memos)));
- g_object_set_data_full (G_OBJECT (preview), "memos-ctrl-fc-data", fc_data, g_free);
- g_signal_connect (preview, "focus-in-event", G_CALLBACK (memos_control_focus_changed), fc_data);
- g_signal_connect (preview, "focus-out-event", G_CALLBACK (memos_control_focus_changed), fc_data);
-
- return control;
-}
-
-static void
-memos_control_activate_cb (BonoboControl *control,
- gboolean activate,
- gpointer user_data)
-{
- EMemos *memos;
-
- memos = E_MEMOS (user_data);
-
- if (activate)
- memos_control_activate (control, memos);
- else
- memos_control_deactivate (control, memos);
-}
-
-/* Sensitizes the UI Component menu/toolbar commands based on the number of
- * selected memos.
- */
-void
-memos_control_sensitize_commands (BonoboControl *control, EMemos *memos, gint n_selected)
-{
- BonoboUIComponent *uic;
- gboolean read_only = TRUE, preview_active;
- ECal *ecal;
- ECalModel *model;
- GtkWidget *preview;
-
- uic = bonobo_control_get_ui_component (control);
- g_return_if_fail (uic != NULL);
-
- if (bonobo_ui_component_get_container (uic) == CORBA_OBJECT_NIL)
- return;
-
- preview = e_cal_component_memo_preview_get_html (E_CAL_COMPONENT_MEMO_PREVIEW (e_memos_get_preview (memos)));
- preview_active = preview && GTK_WIDGET_VISIBLE (preview) && GTK_WIDGET_HAS_FOCUS (preview);
-
- model = e_memo_table_get_model (e_memos_get_calendar_table (memos));
- ecal = e_cal_model_get_default_client (model);
- if (ecal)
- e_cal_is_read_only (ecal, &read_only, NULL);
-
- bonobo_ui_component_set_prop (uic, "/commands/MemosOpenMemo", "sensitive",
- n_selected != 1 ? "0" : "1",
- NULL);
- bonobo_ui_component_set_prop (uic, "/commands/MemosCut", "sensitive",
- n_selected == 0 || read_only || preview_active ? "0" : "1",
- NULL);
- bonobo_ui_component_set_prop (uic, "/commands/MemosCopy", "sensitive",
- n_selected == 0 ? "0" : "1",
- NULL);
- bonobo_ui_component_set_prop (uic, "/commands/MemosPaste", "sensitive",
- read_only || preview_active ? "0" : "1",
- NULL);
- bonobo_ui_component_set_prop (uic, "/commands/MemosDelete", "sensitive",
- n_selected == 0 || read_only ? "0" : "1",
- NULL);
-}
-
-/* Callback used when the selection in the table changes */
-static void
-selection_changed_cb (EMemos *memos, gint n_selected, gpointer data)
-{
- BonoboControl *control;
-
- control = BONOBO_CONTROL (data);
-
- memos_control_sensitize_commands (control, memos, n_selected);
-}
-
-static gboolean
-memos_control_focus_changed (GtkWidget *widget, GdkEventFocus *event, struct focus_changed_data *fc_data)
-{
- g_return_val_if_fail (fc_data != NULL, FALSE);
-
- memos_control_sensitize_commands (fc_data->control, fc_data->memos, e_table_selected_count (e_memo_table_get_table (e_memos_get_calendar_table (fc_data->memos))));
-
- return FALSE;
-}
-
-static BonoboUIVerb verbs [] = {
- BONOBO_UI_VERB ("MemosOpenMemo", memos_control_open_memo_cmd),
- BONOBO_UI_VERB ("MemosNewMemo", memos_control_new_memo_cmd),
- BONOBO_UI_VERB ("MemosCut", memos_control_cut_cmd),
- BONOBO_UI_VERB ("MemosCopy", memos_control_copy_cmd),
- BONOBO_UI_VERB ("MemosPaste", memos_control_paste_cmd),
- BONOBO_UI_VERB ("MemosDelete", memos_control_delete_cmd),
- BONOBO_UI_VERB ("MemosPrint", memos_control_print_cmd),
- BONOBO_UI_VERB ("MemosPrintPreview", memos_control_print_preview_cmd),
-
- BONOBO_UI_VERB_END
-};
-
-static EPixmap pixmaps [] = {
- E_PIXMAP ("/commands/MemosCopy", "edit-copy", GTK_ICON_SIZE_MENU),
- E_PIXMAP ("/commands/MemosCut", "edit-cut", GTK_ICON_SIZE_MENU),
- E_PIXMAP ("/commands/MemosDelete", "edit-delete", GTK_ICON_SIZE_MENU),
- E_PIXMAP ("/commands/MemosPaste", "edit-paste", GTK_ICON_SIZE_MENU),
- E_PIXMAP ("/commands/MemosPrint", "document-print", GTK_ICON_SIZE_MENU),
- E_PIXMAP ("/commands/MemosPrintPreview", "document-print-preview", GTK_ICON_SIZE_MENU),
-
- E_PIXMAP ("/Toolbar/Cut", "edit-cut", GTK_ICON_SIZE_LARGE_TOOLBAR),
- E_PIXMAP ("/Toolbar/Copy", "edit-copy", GTK_ICON_SIZE_LARGE_TOOLBAR),
- E_PIXMAP ("/Toolbar/Paste", "edit-paste", GTK_ICON_SIZE_LARGE_TOOLBAR),
- E_PIXMAP ("/Toolbar/Print", "document-print", GTK_ICON_SIZE_LARGE_TOOLBAR),
- E_PIXMAP ("/Toolbar/Delete", "edit-delete", GTK_ICON_SIZE_LARGE_TOOLBAR),
-
- E_PIXMAP_END
-};
-
-void
-memos_control_activate (BonoboControl *control, EMemos *memos)
-{
- Bonobo_UIContainer remote_uih;
- BonoboUIComponent *uic;
- gint n_selected;
- EMemoTable *cal_table;
- ETable *etable;
- gchar *xmlfile;
-
- uic = bonobo_control_get_ui_component (control);
- g_return_if_fail (uic != NULL);
-
- remote_uih = bonobo_control_get_remote_ui_container (control, NULL);
- bonobo_ui_component_set_container (uic, remote_uih, NULL);
- bonobo_object_release_unref (remote_uih, NULL);
-
- e_memos_set_ui_component (memos, uic);
-
- bonobo_ui_component_add_verb_list_with_data (uic, verbs, memos);
-
- bonobo_ui_component_freeze (uic, NULL);
-
- xmlfile = g_build_filename (EVOLUTION_UIDIR,
- "evolution-memos.xml",
- NULL);
- bonobo_ui_util_set_ui (uic, PREFIX,
- xmlfile,
- "evolution-memos",
- NULL);
- g_free (xmlfile);
-
- e_pixmaps_update (uic, pixmaps);
-
- e_memos_setup_view_menus (memos, uic);
-
- /* Signals from the memos widget; also sensitize the menu items as appropriate */
-
- g_signal_connect (memos, "selection_changed", G_CALLBACK (selection_changed_cb), control);
-
- cal_table = e_memos_get_calendar_table (memos);
- etable = e_memo_table_get_table (cal_table);
- n_selected = e_table_selected_count (etable);
-
- memos_control_sensitize_commands (control, memos, n_selected);
-
- bonobo_ui_component_thaw (uic, NULL);
-}
-
-void
-memos_control_deactivate (BonoboControl *control, EMemos *memos)
-{
- BonoboUIComponent *uic = bonobo_control_get_ui_component (control);
-
- g_return_if_fail (uic != NULL);
-
- e_memos_set_ui_component (memos, NULL);
-
- e_memos_discard_view_menus (memos);
-
- /* Stop monitoring the "selection_changed" signal */
- g_signal_handlers_disconnect_matched (memos, G_SIGNAL_MATCH_DATA, 0, 0, NULL, NULL, control);
-
- bonobo_ui_component_rm (uic, "/", NULL);
- bonobo_ui_component_unset_container (uic, NULL);
-}
-
-static void memos_control_open_memo_cmd (BonoboUIComponent *uic,
- gpointer data,
- const gchar *path)
-{
- EMemos *memos;
-
- memos = E_MEMOS (data);
- e_memos_open_memo (memos);
-}
-
-static void
-memos_control_new_memo_cmd (BonoboUIComponent *uic,
- gpointer data,
- const gchar *path)
-{
- EMemos *memos;
-
- memos = E_MEMOS (data);
- e_memos_new_memo (memos);
-}
-
-static void
-memos_control_cut_cmd (BonoboUIComponent *uic,
- gpointer data,
- const gchar *path)
-{
- EMemos *memos;
- EMemoTable *cal_table;
-
- memos = E_MEMOS (data);
- cal_table = e_memos_get_calendar_table (memos);
- e_memo_table_cut_clipboard (cal_table);
-}
-
-static void
-memos_control_copy_cmd (BonoboUIComponent *uic,
- gpointer data,
- const gchar *path)
-{
- EMemos *memos;
- EMemoTable *cal_table;
- GtkWidget *preview;
-
- memos = E_MEMOS (data);
-
- preview = e_cal_component_memo_preview_get_html (E_CAL_COMPONENT_MEMO_PREVIEW (e_memos_get_preview (memos)));
- if (preview && GTK_WIDGET_VISIBLE (preview) && GTK_WIDGET_HAS_FOCUS (preview)) {
- /* copy selected text in a preview when that's shown and focused */
- gtk_html_copy (GTK_HTML (preview));
- } else {
- cal_table = e_memos_get_calendar_table (memos);
- e_memo_table_copy_clipboard (cal_table);
- }
-}
-
-static void
-memos_control_paste_cmd (BonoboUIComponent *uic,
- gpointer data,
- const gchar *path)
-{
- EMemos *memos;
- EMemoTable *cal_table;
-
- memos = E_MEMOS (data);
- cal_table = e_memos_get_calendar_table (memos);
- e_memo_table_paste_clipboard (cal_table);
-}
-
-static void
-memos_control_delete_cmd (BonoboUIComponent *uic,
- gpointer data,
- const gchar *path)
-{
- EMemos *memos;
-
- memos = E_MEMOS (data);
- e_memos_delete_selected (memos);
-}
-
-/* File/Print callback */
-static void
-memos_control_print_cmd (BonoboUIComponent *uic,
- gpointer data,
- const gchar *path)
-{
- EMemos *memos = E_MEMOS (data);
- ETable *table;
-
- table = e_memo_table_get_table (
- E_MEMO_TABLE (e_memos_get_calendar_table (memos)));
-
- print_table (
- table, _("Print Memos"), _("Memos"),
- GTK_PRINT_OPERATION_ACTION_PRINT_DIALOG);
-}
-
-static void
-memos_control_print_preview_cmd (BonoboUIComponent *uic,
- gpointer data,
- const gchar *path)
-{
- EMemos *memos = E_MEMOS (data);
- ETable *table;
-
- table = e_memo_table_get_table (
- E_MEMO_TABLE (e_memos_get_calendar_table (memos)));
-
- print_table (
- table, _("Print Memos"), _("Memos"),
- GTK_PRINT_OPERATION_ACTION_PREVIEW);
-}
diff --git a/calendar/gui/memos-control.h b/calendar/gui/memos-control.h
deleted file mode 100644
index 854f5f9d9b..0000000000
--- a/calendar/gui/memos-control.h
+++ /dev/null
@@ -1,36 +0,0 @@
-/*
- *
- * This program is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 2 of the License, or (at your option) version 3.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with the program; if not, see <http://www.gnu.org/licenses/>
- *
- *
- * Authors:
- * Federico Mena Quintero <federico@ximian.com>
- * Damon Chaplin <damon@ximian.com>
- * Nathan Owens <pianocomp81@yahoo.com>
- *
- * Copyright (C) 1999-2008 Novell, Inc. (www.novell.com)
- *
- */
-
-#ifndef _MEMOS_CONTROL_H_
-#define _MEMOS_CONTROL_H_
-
-#include "e-memos.h"
-
-BonoboControl *memos_control_new (void);
-void memos_control_activate (BonoboControl *control, EMemos *memos);
-void memos_control_deactivate (BonoboControl *control, EMemos *memos);
-void memos_control_sensitize_commands (BonoboControl *control, EMemos *memos, gint n_selected);
-
-#endif /* _MEMOS_CONTROL_H_ */
diff --git a/calendar/gui/migration.c b/calendar/gui/migration.c
deleted file mode 100644
index 1597b96ebc..0000000000
--- a/calendar/gui/migration.c
+++ /dev/null
@@ -1,1243 +0,0 @@
-/*
- * This program is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 2 of the License, or (at your option) version 3.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with the program; if not, see <http://www.gnu.org/licenses/>
- *
- *
- * Authors:
- * Rodrigo Moya <rodrigo@ximian.com>
- *
- * Copyright (C) 1999-2008 Novell, Inc. (www.novell.com)
- *
- */
-
-#include <config.h>
-
-#include <string.h>
-#include <sys/types.h>
-#include <sys/stat.h>
-#include <unistd.h>
-#include <fcntl.h>
-#include <errno.h>
-
-#include <gtk/gtk.h>
-#include <glib/gi18n.h>
-#include <glib/gstdio.h>
-
-#include <libecal/e-cal.h>
-
-#include <libebackend/e-dbhash.h>
-#include <libedataserver/e-xml-hash-utils.h>
-#include <libedataserver/e-xml-utils.h>
-#include <libedataserver/e-account-list.h>
-#include <camel/camel-url.h>
-
-#include "e-util/e-bconf-map.h"
-#include "e-util/e-folder-map.h"
-#include "e-util/e-util-private.h"
-
-#include "calendar-config-keys.h"
-#include "calendar-config.h"
-#include "e-cal-event.h"
-#include "migration.h"
-
-#ifndef G_OS_WIN32
-
-/* No previous versions have been available on Win32, so don't
- * bother with upgrade support from 1.x on Win32.
- */
-
-static e_gconf_map_t calendar_display_map[] = {
- /* /Calendar/Display */
- { "Timezone", "calendar/display/timezone", E_GCONF_MAP_STRING },
- { "Use24HourFormat", "calendar/display/use_24hour_format", E_GCONF_MAP_BOOL },
- { "WeekStartDay", "calendar/display/week_start_day", E_GCONF_MAP_INT },
- { "DayStartHour", "calendar/display/day_start_hour", E_GCONF_MAP_INT },
- { "DayStartMinute", "calendar/display/day_start_minute", E_GCONF_MAP_INT },
- { "DayEndHour", "calendar/display/day_end_hour", E_GCONF_MAP_INT },
- { "DayEndMinute", "calendar/display/day_end_minute", E_GCONF_MAP_INT },
- { "TimeDivisions", "calendar/display/time_divisions", E_GCONF_MAP_INT },
- { "View", "calendar/display/default_view", E_GCONF_MAP_INT },
- { "HPanePosition", "calendar/display/hpane_position", E_GCONF_MAP_FLOAT },
- { "VPanePosition", "calendar/display/vpane_position", E_GCONF_MAP_FLOAT },
- { "MonthHPanePosition", "calendar/display/month_hpane_position", E_GCONF_MAP_FLOAT },
- { "MonthVPanePosition", "calendar/display/month_vpane_position", E_GCONF_MAP_FLOAT },
- { "CompressWeekend", "calendar/display/compress_weekend", E_GCONF_MAP_BOOL },
- { "ShowEventEndTime", "calendar/display/show_event_end", E_GCONF_MAP_BOOL },
- { "WorkingDays", "calendar/display/working_days", E_GCONF_MAP_INT },
- { NULL },
-};
-
-static e_gconf_map_t calendar_tasks_map[] = {
- /* /Calendar/Tasks */
- { "HideCompletedTasks", "calendar/tasks/hide_completed", E_GCONF_MAP_BOOL },
- { "HideCompletedTasksUnits", "calendar/tasks/hide_completed_units", E_GCONF_MAP_STRING },
- { "HideCompletedTasksValue", "calendar/tasks/hide_completed_value", E_GCONF_MAP_INT },
- { NULL },
-};
-
-static e_gconf_map_t calendar_tasks_colours_map[] = {
- /* /Calendar/Tasks/Colors */
- { "TasksDueToday", "calendar/tasks/colors/due_today", E_GCONF_MAP_STRING },
- { "TasksOverDue", "calendar/tasks/colors/overdue", E_GCONF_MAP_STRING },
- { "TasksDueToday", "calendar/tasks/colors/due_today", E_GCONF_MAP_STRING },
- { NULL },
-};
-
-static e_gconf_map_t calendar_other_map[] = {
- /* /Calendar/Other */
- { "ConfirmDelete", "calendar/prompts/confirm_delete", E_GCONF_MAP_BOOL },
- { "ConfirmExpunge", "calendar/prompts/confirm_purge", E_GCONF_MAP_BOOL },
- { "UseDefaultReminder", "calendar/other/use_default_reminder", E_GCONF_MAP_BOOL },
- { "DefaultReminderInterval", "calendar/other/default_reminder_interval", E_GCONF_MAP_INT },
- { "DefaultReminderUnits", "calendar/other/default_reminder_units", E_GCONF_MAP_STRING },
- { NULL },
-};
-
-static e_gconf_map_t calendar_datenavigator_map[] = {
- /* /Calendar/DateNavigator */
- { "ShowWeekNumbers", "calendar/date_navigator/show_week_numbers", E_GCONF_MAP_BOOL },
- { NULL },
-};
-
-static e_gconf_map_t calendar_alarmnotify_map[] = {
- /* /Calendar/AlarmNotify */
- { "LastNotificationTime", "calendar/notify/last_notification_time", E_GCONF_MAP_INT },
- { "CalendarToLoad%i", "calendar/notify/calendars", E_GCONF_MAP_STRING|E_GCONF_MAP_LIST },
- { "BlessedProgram%i", "calendar/notify/programs", E_GCONF_MAP_STRING|E_GCONF_MAP_LIST },
- { NULL },
-};
-
-static e_gconf_map_list_t calendar_remap_list[] = {
-
- { "/Calendar/Display", calendar_display_map },
- { "/Calendar/Other/Map", calendar_other_map },
- { "/Calendar/DateNavigator", calendar_datenavigator_map },
- { "/Calendar/AlarmNotify", calendar_alarmnotify_map },
-
- { NULL },
-};
-
-static e_gconf_map_list_t task_remap_list[] = {
-
- { "/Calendar/Tasks", calendar_tasks_map },
- { "/Calendar/Tasks/Colors", calendar_tasks_colours_map },
-
- { NULL },
-};
-
-static GtkWidget *window;
-static GtkLabel *label;
-static GtkProgressBar *progress;
-
-static void
-setup_progress_dialog (gboolean tasks)
-{
- GtkWidget *vbox, *hbox, *w;
-
- window = gtk_window_new (GTK_WINDOW_TOPLEVEL);
- gtk_window_set_title ((GtkWindow *) window, _("Migrating..."));
- gtk_window_set_modal ((GtkWindow *) window, TRUE);
- gtk_container_set_border_width ((GtkContainer *) window, 6);
-
- vbox = gtk_vbox_new (FALSE, 6);
- gtk_widget_show (vbox);
- gtk_container_add ((GtkContainer *) window, vbox);
-
- if (tasks)
- w = gtk_label_new (_("The location and hierarchy of the Evolution task "
- "folders has changed since Evolution 1.x.\n\nPlease be "
- "patient while Evolution migrates your folders..."));
- else
- w = gtk_label_new (_("The location and hierarchy of the Evolution calendar "
- "folders has changed since Evolution 1.x.\n\nPlease be "
- "patient while Evolution migrates your folders..."));
-
- gtk_label_set_line_wrap ((GtkLabel *) w, TRUE);
- gtk_widget_show (w);
- gtk_box_pack_start ((GtkBox *) vbox, w, TRUE, TRUE, 0);
-
- hbox = gtk_hbox_new (FALSE, 6);
- gtk_widget_show (hbox);
- gtk_box_pack_start ((GtkBox *) vbox, hbox, TRUE, TRUE, 0);
-
- label = (GtkLabel *) gtk_label_new ("");
- gtk_widget_show ((GtkWidget *) label);
- gtk_box_pack_start ((GtkBox *) hbox, (GtkWidget *) label, TRUE, TRUE, 0);
-
- progress = (GtkProgressBar *) gtk_progress_bar_new ();
- gtk_widget_show ((GtkWidget *) progress);
- gtk_box_pack_start ((GtkBox *) hbox, (GtkWidget *) progress, TRUE, TRUE, 0);
-
- gtk_widget_show (window);
-}
-
-static void
-dialog_close (void)
-{
- gtk_widget_destroy ((GtkWidget *) window);
-}
-
-static void
-dialog_set_folder_name (const gchar *folder_name)
-{
- gchar *text;
-
- text = g_strdup_printf (_("Migrating '%s':"), folder_name);
- gtk_label_set_text (label, text);
- g_free (text);
-
- gtk_progress_bar_set_fraction (progress, 0.0);
-
- while (gtk_events_pending ())
- gtk_main_iteration ();
-}
-
-static void
-dialog_set_progress (double percent)
-{
- gchar text[5];
-
- snprintf (text, sizeof (text), "%d%%", (gint) (percent * 100.0f));
-
- gtk_progress_bar_set_fraction (progress, percent);
- gtk_progress_bar_set_text (progress, text);
-
- while (gtk_events_pending ())
- gtk_main_iteration ();
-}
-
-static gboolean
-check_for_conflict (ESourceGroup *group, gchar *name)
-{
- GSList *sources;
- GSList *s;
-
- sources = e_source_group_peek_sources (group);
-
- for (s = sources; s; s = s->next) {
- ESource *source = E_SOURCE (s->data);
-
- if (!strcmp (e_source_peek_name (source), name))
- return TRUE;
- }
-
- return FALSE;
-}
-
-static gchar *
-get_source_name (ESourceGroup *group, const gchar *path)
-{
- gchar **p = g_strsplit (path, "/", 0);
- gint i, j, starting_index;
- gint num_elements;
- gboolean conflict;
- GString *s = g_string_new (NULL);
-
- for (i = 0; p[i]; i ++);
-
- num_elements = i;
- i--;
-
- /* p[i] is now the last path element */
-
- /* check if it conflicts */
- starting_index = i;
- do {
- for (j = starting_index; j < num_elements; j += 2) {
- if (j != starting_index)
- g_string_append_c (s, '_');
- g_string_append (s, p[j]);
- }
-
- conflict = check_for_conflict (group, s->str);
-
- /* if there was a conflict back up 2 levels (skipping the /subfolder/ element) */
- if (conflict)
- starting_index -= 2;
-
- /* we always break out if we can't go any further,
- regardless of whether or not we conflict. */
- if (starting_index < 0)
- break;
-
- } while (conflict);
- g_strfreev (p);
-
- return g_string_free (s, FALSE);
-}
-
-static gboolean
-migrate_ical (ECal *old_ecal, ECal *new_ecal)
-{
- GList *l, *objects;
- gint num_added = 0;
- gint num_objects;
- gboolean retval = TRUE;
-
- /* both ecals are loaded, start the actual migration */
- if (!e_cal_get_object_list (old_ecal, "#t", &objects, NULL))
- return FALSE;
-
- num_objects = g_list_length (objects);
- for (l = objects; l; l = l->next) {
- icalcomponent *ical_comp = l->data;
- GError *error = NULL;
-
- if (!e_cal_create_object (new_ecal, ical_comp, NULL, &error)) {
- g_warning ("Migration of object failed: %s", error->message);
- retval = FALSE;
- }
-
- g_clear_error (&error);
-
- num_added ++;
- dialog_set_progress ((double)num_added / num_objects);
- }
-
- g_list_foreach (objects, (GFunc) icalcomponent_free, NULL);
- g_list_free (objects);
-
- return retval;
-}
-
-static gboolean
-migrate_ical_folder_to_source (gchar *old_path, ESource *new_source, ECalSourceType type)
-{
- ECal *old_ecal = NULL, *new_ecal = NULL;
- ESource *old_source;
- ESourceGroup *group;
- gchar *old_uri = g_filename_to_uri (old_path, NULL, NULL);
- GError *error = NULL;
- gboolean retval = FALSE;
-
- group = e_source_group_new ("", old_uri);
- old_source = e_source_new ("", "");
- e_source_group_add_source (group, old_source, -1);
-
- dialog_set_folder_name (e_source_peek_name (new_source));
-
- if (!(old_ecal = e_cal_new (old_source, type))) {
- g_warning ("could not find a backend for '%s'", e_source_get_uri (old_source));
- goto finish;
- }
- if (!e_cal_open (old_ecal, FALSE, &error)) {
- g_warning ("failed to load source ecal for migration: '%s' (%s)", error->message,
- e_source_get_uri (old_source));
- goto finish;
- }
-
- if (!(new_ecal = e_cal_new (new_source, type))) {
- g_warning ("could not find a backend for '%s'", e_source_get_uri (new_source));
- goto finish;
- }
- if (!e_cal_open (new_ecal, FALSE, &error)) {
- g_warning ("failed to load destination ecal for migration: '%s' (%s)", error->message,
- e_source_get_uri (new_source));
- goto finish;
- }
-
- retval = migrate_ical (old_ecal, new_ecal);
-
-finish:
- g_clear_error (&error);
- if (old_ecal)
- g_object_unref (old_ecal);
- g_object_unref (group);
- if (new_ecal)
- g_object_unref (new_ecal);
- g_free (old_uri);
-
- return retval;
-}
-
-static gboolean
-migrate_ical_folder (gchar *old_path, ESourceGroup *dest_group, gchar *source_name, ECalSourceType type)
-{
- ESource *new_source;
- gboolean retval;
-
- new_source = e_source_new (source_name, source_name);
- e_source_set_relative_uri (new_source, e_source_peek_uid (new_source));
- e_source_group_add_source (dest_group, new_source, -1);
-
- retval = migrate_ical_folder_to_source (old_path, new_source, type);
-
- g_object_unref (new_source);
-
- return retval;
-}
-
-#endif /* !G_OS_WIN32 */
-
-#define WEBCAL_BASE_URI "webcal://"
-#define CONTACTS_BASE_URI "contacts://"
-#define BAD_CONTACTS_BASE_URI "contact://"
-#define PERSONAL_RELATIVE_URI "system"
-#define GROUPWISE_BASE_URI "groupwise://"
-
-static ESourceGroup *
-create_calendar_contact_source (ESourceList *source_list)
-{
- ESourceGroup *group;
- ESource *source;
-
- /* Create the contacts group */
- group = e_source_group_new (_("Contacts"), CONTACTS_BASE_URI);
- e_source_list_add_group (source_list, group, -1);
-
- source = e_source_new (_("Birthdays & Anniversaries"), "/");
- e_source_group_add_source (group, source, -1);
- g_object_unref (source);
-
- e_source_set_color_spec (source, "#FED4D3");
- e_source_group_set_readonly (group, TRUE);
-
- return group;
-}
-
-static void
-create_calendar_sources (CalendarComponent *component,
- ESourceList *source_list,
- ESourceGroup **on_this_computer,
- ESource **personal_source,
- ESourceGroup **on_the_web,
- ESourceGroup **contacts)
-{
- GSList *groups;
- ESourceGroup *group;
- gchar *base_uri, *base_uri_proto;
- const gchar *base_dir;
-
- *on_this_computer = NULL;
- *on_the_web = NULL;
- *contacts = NULL;
- *personal_source = NULL;
-
- base_dir = calendar_component_peek_base_directory (component);
- base_uri = g_build_filename (base_dir, "local", NULL);
-
- base_uri_proto = g_filename_to_uri (base_uri, NULL, NULL);
-
- groups = e_source_list_peek_groups (source_list);
- if (groups) {
- /* groups are already there, we need to search for things... */
- GSList *g;
-
- for (g = groups; g; g = g->next) {
-
- group = E_SOURCE_GROUP (g->data);
-
- if (!strcmp (BAD_CONTACTS_BASE_URI, e_source_group_peek_base_uri (group)))
- e_source_group_set_base_uri (group, CONTACTS_BASE_URI);
-
- if (!strcmp (base_uri, e_source_group_peek_base_uri (group)))
- e_source_group_set_base_uri (group, base_uri_proto);
-
- if (!*on_this_computer && !strcmp (base_uri_proto, e_source_group_peek_base_uri (group)))
- *on_this_computer = g_object_ref (group);
- else if (!*on_the_web && !strcmp (WEBCAL_BASE_URI, e_source_group_peek_base_uri (group)))
- *on_the_web = g_object_ref (group);
- else if (!*contacts && !strcmp (CONTACTS_BASE_URI, e_source_group_peek_base_uri (group)))
- *contacts = g_object_ref (group);
- }
- }
-
- if (*on_this_computer) {
- /* make sure "Personal" shows up as a source under
- this group */
- GSList *sources = e_source_group_peek_sources (*on_this_computer);
- GSList *s;
- for (s = sources; s; s = s->next) {
- ESource *source = E_SOURCE (s->data);
- const gchar *relative_uri;
-
- relative_uri = e_source_peek_relative_uri (source);
- if (relative_uri == NULL)
- continue;
- if (!strcmp (PERSONAL_RELATIVE_URI, relative_uri)) {
- *personal_source = g_object_ref (source);
- break;
- }
- }
- } else {
- /* create the local source group */
- group = e_source_group_new (_("On This Computer"), base_uri_proto);
- e_source_list_add_group (source_list, group, -1);
-
- *on_this_computer = group;
- }
-
- if (!*personal_source) {
- gchar *primary_calendar = calendar_config_get_primary_calendar ();
-
- /* Create the default Person calendar */
- ESource *source = e_source_new (_("Personal"), PERSONAL_RELATIVE_URI);
- e_source_group_add_source (*on_this_computer, source, -1);
-
- if (!primary_calendar && !calendar_config_get_calendars_selected ()) {
- GSList selected;
-
- calendar_config_set_primary_calendar (e_source_peek_uid (source));
-
- selected.data = (gpointer)e_source_peek_uid (source);
- selected.next = NULL;
- calendar_config_set_calendars_selected (&selected);
- }
-
- g_free (primary_calendar);
- e_source_set_color_spec (source, "#BECEDD");
- *personal_source = source;
- }
-
- if (!*on_the_web) {
- /* Create the Webcal source group */
- group = e_source_group_new (_("On The Web"), WEBCAL_BASE_URI);
- e_source_list_add_group (source_list, group, -1);
-
- *on_the_web = group;
- }
-
- if (!*contacts) {
- group = create_calendar_contact_source (source_list);
-
- *contacts = group;
- }
-
- g_free (base_uri_proto);
- g_free (base_uri);
-}
-
-static void
-create_task_sources (TasksComponent *component,
- ESourceList *source_list,
- ESourceGroup **on_this_computer,
- ESourceGroup **on_the_web,
- ESource **personal_source)
-{
- GSList *groups;
- ESourceGroup *group;
- gchar *base_uri, *base_uri_proto;
- const gchar *base_dir;
-
- *on_this_computer = NULL;
- *on_the_web = NULL;
- *personal_source = NULL;
-
- base_dir = tasks_component_peek_base_directory (component);
- base_uri = g_build_filename (base_dir, "local", NULL);
-
- base_uri_proto = g_filename_to_uri (base_uri, NULL, NULL);
-
- groups = e_source_list_peek_groups (source_list);
- if (groups) {
- /* groups are already there, we need to search for things... */
- GSList *g;
-
- for (g = groups; g; g = g->next) {
-
- group = E_SOURCE_GROUP (g->data);
-
- if (!*on_this_computer && !strcmp (base_uri_proto, e_source_group_peek_base_uri (group)))
- *on_this_computer = g_object_ref (group);
- else if (!*on_the_web && !strcmp (WEBCAL_BASE_URI, e_source_group_peek_base_uri (group)))
- *on_the_web = g_object_ref (group);
- }
- }
-
- if (*on_this_computer) {
- /* make sure "Personal" shows up as a source under
- this group */
- GSList *sources = e_source_group_peek_sources (*on_this_computer);
- GSList *s;
- for (s = sources; s; s = s->next) {
- ESource *source = E_SOURCE (s->data);
- const gchar *relative_uri;
-
- relative_uri = e_source_peek_relative_uri (source);
- if (relative_uri == NULL)
- continue;
- if (!strcmp (PERSONAL_RELATIVE_URI, relative_uri)) {
- *personal_source = g_object_ref (source);
- break;
- }
- }
- } else {
- /* create the local source group */
- group = e_source_group_new (_("On This Computer"), base_uri_proto);
- e_source_list_add_group (source_list, group, -1);
-
- *on_this_computer = group;
- }
-
- if (!*personal_source) {
- /* Create the default Person task list */
- ESource *source = e_source_new (_("Personal"), PERSONAL_RELATIVE_URI);
- e_source_group_add_source (*on_this_computer, source, -1);
-
- if (!calendar_config_get_primary_tasks () && !calendar_config_get_tasks_selected ()) {
- GSList selected;
-
- calendar_config_set_primary_tasks (e_source_peek_uid (source));
-
- selected.data = (gpointer)e_source_peek_uid (source);
- selected.next = NULL;
- calendar_config_set_tasks_selected (&selected);
- }
-
- e_source_set_color_spec (source, "#BECEDD");
- *personal_source = source;
- }
-
- if (!*on_the_web) {
- /* Create the Webcal source group */
- group = e_source_group_new (_("On The Web"), WEBCAL_BASE_URI);
- e_source_list_add_group (source_list, group, -1);
-
- *on_the_web = group;
- }
-
- g_free (base_uri_proto);
- g_free (base_uri);
-}
-
-#ifndef G_OS_WIN32
-
-static void
-migrate_pilot_db_key (const gchar *key, gpointer user_data)
-{
- EXmlHash *xmlhash = user_data;
-
- e_xmlhash_add (xmlhash, key, "");
-}
-
-static void
-migrate_pilot_data (const gchar *component, const gchar *conduit, const gchar *old_path, const gchar *new_path)
-{
- gchar *changelog, *map;
- const gchar *dent;
- const gchar *ext;
- gchar *filename;
- GDir *dir;
-
- if (!(dir = g_dir_open (old_path, 0, NULL)))
- return;
-
- map = g_alloca (12 + strlen (conduit));
- sprintf (map, "pilot-map-%s-", conduit);
-
- changelog = g_alloca (24 + strlen (conduit));
- sprintf (changelog, "pilot-sync-evolution-%s-", conduit);
-
- while ((dent = g_dir_read_name (dir))) {
- if (!strncmp (dent, map, strlen (map)) &&
- ((ext = strrchr (dent, '.')) && !strcmp (ext, ".xml"))) {
- /* pilot map file - src and dest file formats are identical */
- guchar inbuf[4096];
- gsize nread, nwritten;
- gint fd0, fd1;
- gssize n;
-
- filename = g_build_filename (old_path, dent, NULL);
- if ((fd0 = g_open (filename, O_RDONLY|O_BINARY, 0)) == -1) {
- g_free (filename);
- continue;
- }
-
- g_free (filename);
- filename = g_build_filename (new_path, dent, NULL);
- if ((fd1 = g_open (filename, O_WRONLY | O_CREAT | O_TRUNC | O_BINARY, 0666)) == -1) {
- g_free (filename);
- close (fd0);
- continue;
- }
-
- do {
- do {
- n = read (fd0, inbuf, sizeof (inbuf));
- } while (n == -1 && errno == EINTR);
-
- if (n < 1)
- break;
-
- nread = n;
- nwritten = 0;
- do {
- do {
- n = write (fd1, inbuf + nwritten, nread - nwritten);
- } while (n == -1 && errno == EINTR);
-
- if (n > 0)
- nwritten += n;
- } while (nwritten < nread && n != -1);
-
- if (n == -1)
- break;
- } while (1);
-
- if (n != -1)
- n = fsync (fd1);
-
- if (n == -1) {
- g_warning ("Failed to migrate %s: %s", dent, g_strerror (errno));
- g_unlink (filename);
- }
-
- close (fd0);
- close (fd1);
- g_free (filename);
- } else if (!strncmp (dent, changelog, strlen (changelog)) &&
- ((ext = strrchr (dent, '.')) && !strcmp (ext, ".db"))) {
- /* src and dest formats differ, src format is db3 while dest format is xml */
- EXmlHash *xmlhash;
- EDbHash *dbhash;
- struct stat st;
-
- filename = g_build_filename (old_path, dent, NULL);
- if (g_stat (filename, &st) == -1) {
- g_free (filename);
- continue;
- }
-
- dbhash = e_dbhash_new (filename);
- g_free (filename);
-
- filename = g_strdup_printf ("%s/%s.ics-%s", new_path, component, dent);
- if (g_stat (filename, &st) != -1)
- g_unlink (filename);
- xmlhash = e_xmlhash_new (filename);
- g_free (filename);
-
- e_dbhash_foreach_key (dbhash, migrate_pilot_db_key, xmlhash);
-
- e_dbhash_destroy (dbhash);
-
- e_xmlhash_write (xmlhash);
- e_xmlhash_destroy (xmlhash);
- }
- }
-
- g_dir_close (dir);
-}
-
-#endif
-
-gboolean
-migrate_calendars (CalendarComponent *component, gint major, gint minor, gint revision, GError **err)
-{
- ESourceGroup *on_this_computer = NULL, *on_the_web = NULL, *contacts = NULL;
- ESource *personal_source = NULL;
- ECalEvent *ece;
- ECalEventTargetComponent *target;
- gboolean retval = FALSE;
-
- /* we call this unconditionally now - create_groups either
- creates the groups/sources or it finds the necessary
- groups/sources. */
- create_calendar_sources (component, calendar_component_peek_source_list (component), &on_this_computer, &personal_source, &on_the_web, &contacts);
-
-#ifndef G_OS_WIN32
- if (major == 1) {
- xmlDocPtr config_doc = NULL;
- gchar *conf_file;
- struct stat st;
-
- conf_file = g_build_filename (g_get_home_dir (), "evolution", "config.xmldb", NULL);
- if (lstat (conf_file, &st) == 0 && S_ISREG (st.st_mode))
- config_doc = xmlParseFile (conf_file);
- g_free (conf_file);
-
- if (config_doc && minor <= 2) {
- GConfClient *gconf;
- gint res = 0;
-
- /* move bonobo config to gconf */
- gconf = gconf_client_get_default ();
-
- res = e_bconf_import (gconf, config_doc, calendar_remap_list);
-
- g_object_unref (gconf);
-
- xmlFreeDoc(config_doc);
-
- if (res != 0) {
- /* FIXME: set proper domain/code */
- g_set_error(err, 0, 0, _("Unable to migrate old settings from evolution/config.xmldb"));
- goto fail;
- }
- }
-
- if (minor <= 4) {
- GSList *migration_dirs, *l;
- gchar *path, *local_cal_folder;
-
- setup_progress_dialog (FALSE);
-
- path = g_build_filename (g_get_home_dir (), "evolution", "local", NULL);
- migration_dirs = e_folder_map_local_folders (path, "calendar");
- local_cal_folder = g_build_filename (path, "Calendar", NULL);
- g_free (path);
-
- if (personal_source)
- migrate_ical_folder_to_source (local_cal_folder, personal_source, E_CAL_SOURCE_TYPE_EVENT);
-
- for (l = migration_dirs; l; l = l->next) {
- gchar *source_name;
-
- if (personal_source && !strcmp ((gchar *)l->data, local_cal_folder))
- continue;
-
- source_name = get_source_name (on_this_computer, (gchar *)l->data);
-
- if (!migrate_ical_folder (l->data, on_this_computer, source_name, E_CAL_SOURCE_TYPE_EVENT)) {
- /* FIXME: domain/code */
- g_set_error(err, 0, 0, _("Unable to migrate calendar `%s'"), source_name);
- g_free(source_name);
- goto fail;
- }
-
- g_free (source_name);
- }
-
- g_free (local_cal_folder);
-
- dialog_close ();
- }
-
- if (minor <= 4 || (minor == 5 && revision < 5)) {
- GConfClient *gconf;
- GConfValue *gconf_val;
- gint i;
- const gchar *keys[] = {
- CALENDAR_CONFIG_HPANE_POS,
- CALENDAR_CONFIG_VPANE_POS,
- CALENDAR_CONFIG_MONTH_HPANE_POS,
- CALENDAR_CONFIG_MONTH_VPANE_POS,
- NULL
- };
-
- gconf = gconf_client_get_default ();
-
- for (i = 0; keys[i]; i++) {
- gconf_val = gconf_client_get (gconf, keys[i], NULL);
- if (gconf_val) {
- if (gconf_val->type != GCONF_VALUE_INT)
- gconf_client_unset (gconf, keys[i], NULL);
- gconf_value_free (gconf_val);
- }
- }
-
- g_object_unref (gconf);
- }
-
- if (minor < 5 || (minor == 5 && revision <= 10)) {
- gchar *old_path, *new_path;
-
- old_path = g_build_filename (g_get_home_dir (), "evolution", "local", "Calendar", NULL);
- new_path = g_build_filename (calendar_component_peek_base_directory (component),
- "local", "system", NULL);
- migrate_pilot_data ("calendar", "calendar", old_path, new_path);
- g_free (new_path);
- g_free (old_path);
- }
-
- /* we only need to do this next step if people ran
- older versions of 1.5. We need to clear out the
- absolute URI's that were assigned to ESources
- during one phase of development, as they take
- precedent over relative uris (but aren't updated
- when editing an ESource). */
- if (minor == 5 && revision <= 11) {
- GSList *g;
- for (g = e_source_list_peek_groups (calendar_component_peek_source_list (component)); g; g = g->next) {
- ESourceGroup *group = g->data;
- GSList *s;
-
- for (s = e_source_group_peek_sources (group); s; s = s->next) {
- ESource *source = s->data;
- e_source_set_absolute_uri (source, NULL);
- }
- }
- }
-
- }
-#endif /* !G_OS_WIN32 */
-
- e_source_list_sync (calendar_component_peek_source_list (component), NULL);
-
- /** @Event: component.migration
- * @Title: Migration step in component initialization
- * @Target: ECalEventTargetComponent
- *
- * component.migration is emitted during the calendar component
- * initialization process. This allows new calendar backend types
- * to be distributed as an e-d-s backend and a plugin without
- * reaching their grubby little fingers into migration.c
- */
- /* Fire off migration event */
- ece = e_cal_event_peek ();
- target = e_cal_event_target_new_component (ece, calendar_component_peek (), 0);
- e_event_emit ((EEvent *) ece, "component.migration", (EEventTarget *) target);
-
- retval = TRUE;
-fail:
- if (on_this_computer)
- g_object_unref (on_this_computer);
- if (on_the_web)
- g_object_unref (on_the_web);
- if (contacts)
- g_object_unref (contacts);
- if (personal_source)
- g_object_unref (personal_source);
-
- return retval;
-}
-
-gboolean
-migrate_tasks (TasksComponent *component, gint major, gint minor, gint revision, GError **err)
-{
- ESourceGroup *on_this_computer = NULL;
- ESourceGroup *on_the_web = NULL;
- ESource *personal_source = NULL;
- gboolean retval = FALSE;
-
- /* we call this unconditionally now - create_groups either
- creates the groups/sources or it finds the necessary
- groups/sources. */
- create_task_sources (component, tasks_component_peek_source_list (component), &on_this_computer, &on_the_web, &personal_source);
-
-#ifndef G_OS_WIN32
- if (major == 1) {
- xmlDocPtr config_doc = NULL;
- gchar *conf_file;
-
- conf_file = g_build_filename (g_get_home_dir (), "evolution", "config.xmldb", NULL);
- if (g_file_test (conf_file, G_FILE_TEST_IS_REGULAR))
- config_doc = e_xml_parse_file (conf_file);
- g_free (conf_file);
-
- if (config_doc && minor <= 2) {
- GConfClient *gconf;
- gint res = 0;
-
- /* move bonobo config to gconf */
- gconf = gconf_client_get_default ();
-
- res = e_bconf_import (gconf, config_doc, task_remap_list);
-
- g_object_unref (gconf);
-
- xmlFreeDoc(config_doc);
-
- if (res != 0) {
- g_set_error(err, 0, 0, _("Unable to migrate old settings from evolution/config.xmldb"));
- goto fail;
- }
- }
-
- if (minor <= 4) {
- GSList *migration_dirs, *l;
- gchar *path, *local_task_folder;
-
- setup_progress_dialog (TRUE);
-
- path = g_build_filename (g_get_home_dir (), "evolution", "local", NULL);
- migration_dirs = e_folder_map_local_folders (path, "tasks");
- local_task_folder = g_build_filename (path, "Tasks", NULL);
- g_free (path);
-
- if (personal_source)
- migrate_ical_folder_to_source (local_task_folder, personal_source, E_CAL_SOURCE_TYPE_TODO);
-
- for (l = migration_dirs; l; l = l->next) {
- gchar *source_name;
-
- if (personal_source && !strcmp ((gchar *)l->data, local_task_folder))
- continue;
-
- source_name = get_source_name (on_this_computer, (gchar *)l->data);
-
- if (!migrate_ical_folder (l->data, on_this_computer, source_name, E_CAL_SOURCE_TYPE_TODO)) {
- /* FIXME: domain/code */
- g_set_error(err, 0, 0, _("Unable to migrate tasks `%s'"), source_name);
- g_free(source_name);
- goto fail;
- }
-
- g_free (source_name);
- }
-
- g_free (local_task_folder);
-
- dialog_close ();
- }
-
- if (minor < 5 || (minor == 5 && revision <= 10)) {
- gchar *old_path, *new_path;
-
- old_path = g_build_filename (g_get_home_dir (), "evolution", "local", "Tasks", NULL);
- new_path = g_build_filename (tasks_component_peek_base_directory (component),
- "local", "system", NULL);
- migrate_pilot_data ("tasks", "todo", old_path, new_path);
- g_free (new_path);
- g_free (old_path);
- }
-
- /* we only need to do this next step if people ran
- older versions of 1.5. We need to clear out the
- absolute URI's that were assigned to ESources
- during one phase of development, as they take
- precedent over relative uris (but aren't updated
- when editing an ESource). */
- if (minor == 5 && revision <= 11) {
- GSList *g;
- for (g = e_source_list_peek_groups (tasks_component_peek_source_list (component)); g; g = g->next) {
- ESourceGroup *group = g->data;
- GSList *s;
-
- for (s = e_source_group_peek_sources (group); s; s = s->next) {
- ESource *source = s->data;
- e_source_set_absolute_uri (source, NULL);
- }
- }
- }
- }
-#endif /* !G_OS_WIN32 */
- e_source_list_sync (tasks_component_peek_source_list (component), NULL);
- retval = TRUE;
-fail:
- if (on_this_computer)
- g_object_unref (on_this_computer);
- if (on_the_web)
- g_object_unref (on_the_web);
- if (personal_source)
- g_object_unref (personal_source);
-
- return retval;
-}
-
-/********************************************************************************************************
- *
- * MEMOS
- *
- ********************************************************************************************************/
-
-static void
-create_memo_sources (MemosComponent *component,
- ESourceList *source_list,
- ESourceGroup **on_this_computer,
- ESourceGroup **on_the_web,
- ESource **personal_source)
-{
- GSList *groups;
- ESourceGroup *group;
- gchar *base_uri, *base_uri_proto;
- const gchar *base_dir;
-
- *on_this_computer = NULL;
- *on_the_web = NULL;
- *personal_source = NULL;
-
- base_dir = memos_component_peek_base_directory (component);
- base_uri = g_build_filename (base_dir, "local", NULL);
-
- base_uri_proto = g_filename_to_uri (base_uri, NULL, NULL);
-
- groups = e_source_list_peek_groups (source_list);
- if (groups) {
- /* groups are already there, we need to search for things... */
- GSList *g;
-
- for (g = groups; g; g = g->next) {
-
- group = E_SOURCE_GROUP (g->data);
-
- if (!*on_this_computer && !strcmp (base_uri_proto, e_source_group_peek_base_uri (group)))
- *on_this_computer = g_object_ref (group);
- else if (!*on_the_web && !strcmp (WEBCAL_BASE_URI, e_source_group_peek_base_uri (group)))
- *on_the_web = g_object_ref (group);
- }
- }
-
- if (*on_this_computer) {
- /* make sure "Personal" shows up as a source under
- this group */
- GSList *sources = e_source_group_peek_sources (*on_this_computer);
- GSList *s;
- for (s = sources; s; s = s->next) {
- ESource *source = E_SOURCE (s->data);
- const gchar *relative_uri;
-
- relative_uri = e_source_peek_relative_uri (source);
- if (relative_uri == NULL)
- continue;
- if (!strcmp (PERSONAL_RELATIVE_URI, relative_uri)) {
- *personal_source = g_object_ref (source);
- break;
- }
- }
- } else {
- /* create the local source group */
- group = e_source_group_new (_("On This Computer"), base_uri_proto);
- e_source_list_add_group (source_list, group, -1);
-
- *on_this_computer = group;
- }
-
- if (!*personal_source) {
- /* Create the default Person task list */
- ESource *source = e_source_new (_("Personal"), PERSONAL_RELATIVE_URI);
- e_source_group_add_source (*on_this_computer, source, -1);
-
- if (!calendar_config_get_primary_memos () && !calendar_config_get_memos_selected ()) {
- GSList selected;
-
- calendar_config_set_primary_memos (e_source_peek_uid (source));
-
- selected.data = (gpointer)e_source_peek_uid (source);
- selected.next = NULL;
- calendar_config_set_memos_selected (&selected);
- }
-
- e_source_set_color_spec (source, "#BECEDD");
- *personal_source = source;
- }
-
- if (!*on_the_web) {
- /* Create the Webcal source group */
- group = e_source_group_new (_("On The Web"), WEBCAL_BASE_URI);
- e_source_list_add_group (source_list, group, -1);
-
- *on_the_web = group;
- }
-
- g_free (base_uri_proto);
- g_free (base_uri);
-}
-
-static gboolean
-is_groupwise_account (EAccount *account)
-{
- if (account->source->url != NULL) {
- return g_str_has_prefix (account->source->url, GROUPWISE_BASE_URI);
- } else {
- return FALSE;
- }
-}
-
-static void
-add_gw_esource (ESourceList *source_list, const gchar *group_name, const gchar *source_name, CamelURL *url, GConfClient *client)
-{
- ESourceGroup *group;
- ESource *source;
- GSList *ids, *temp;
- GError *error = NULL;
- gchar *relative_uri;
- const gchar *soap_port;
- const gchar * use_ssl;
- const gchar *poa_address;
- const gchar *offline_sync;
-
- poa_address = url->host;
- if (!poa_address || strlen (poa_address) ==0)
- return;
- soap_port = camel_url_get_param (url, "soap_port");
-
- if (!soap_port || strlen (soap_port) == 0)
- soap_port = "7191";
-
- use_ssl = camel_url_get_param (url, "use_ssl");
- offline_sync = camel_url_get_param (url, "offline_sync");
-
- group = e_source_group_new (group_name, GROUPWISE_BASE_URI);
- if (!e_source_list_add_group (source_list, group, -1))
- return;
- relative_uri = g_strdup_printf ("%s@%s/", url->user, poa_address);
-
- source = e_source_new (source_name, relative_uri);
- e_source_set_property (source, "auth", "1");
- e_source_set_property (source, "username", url->user);
- e_source_set_property (source, "port", camel_url_get_param (url, "soap_port"));
- e_source_set_property (source, "auth-domain", "Groupwise");
- e_source_set_property (source, "use_ssl", use_ssl);
- e_source_set_property (source, "offline_sync", offline_sync ? "1" : "0" );
-
- e_source_set_color_spec (source, "#EEBC60");
- e_source_group_add_source (group, source, -1);
-
- ids = gconf_client_get_list (client, CALENDAR_CONFIG_MEMOS_SELECTED_MEMOS, GCONF_VALUE_STRING, &error);
- if ( error != NULL ) {
- g_warning("%s (%s) %s\n", G_STRLOC, G_STRFUNC, error->message);
- g_error_free(error);
- }
- ids = g_slist_append (ids, g_strdup (e_source_peek_uid (source)));
- gconf_client_set_list (client, CALENDAR_CONFIG_MEMOS_SELECTED_MEMOS, GCONF_VALUE_STRING, ids, NULL);
- temp = ids;
- for (; temp != NULL; temp = g_slist_next (temp))
- g_free (temp->data);
-
- g_slist_free (ids);
- g_object_unref (source);
- g_object_unref (group);
- g_free (relative_uri);
-}
-
-gboolean
-migrate_memos (MemosComponent *component, gint major, gint minor, gint revision, struct _GError **err)
-{
- ESourceGroup *on_this_computer = NULL;
- ESourceGroup *on_the_web = NULL;
- ESource *personal_source = NULL;
- ESourceList *source_list = NULL;
- gboolean retval = FALSE;
-
- source_list = memos_component_peek_source_list (component);
-
- /* we call this unconditionally now - create_groups either
- creates the groups/sources or it finds the necessary
- groups/sources. */
- create_memo_sources (component, source_list, &on_this_computer, &on_the_web, &personal_source);
-
- /* Migration for Gw accounts between versions < 2.8 */
- if (major == 2 && minor < 8) {
- EAccountList *al;
- EAccount *a;
- CamelURL *url;
- EIterator *it;
- GConfClient *gconf_client = gconf_client_get_default ();
- al = e_account_list_new (gconf_client);
- for (it = e_list_get_iterator((EList *)al);
- e_iterator_is_valid(it);
- e_iterator_next(it)) {
- a = (EAccount *) e_iterator_get(it);
- if (!a->enabled || !is_groupwise_account (a))
- continue;
- url = camel_url_new (a->source->url, NULL);
- add_gw_esource (source_list, a->name, _("Notes"), url, gconf_client);
- camel_url_free (url);
- }
- g_object_unref (al);
- g_object_unref (gconf_client);
- }
-
- e_source_list_sync (source_list, NULL);
- retval = TRUE;
-
- if (on_this_computer)
- g_object_unref (on_this_computer);
- if (on_the_web)
- g_object_unref (on_the_web);
- if (personal_source)
- g_object_unref (personal_source);
-
- return retval;
-}
diff --git a/calendar/gui/migration.h b/calendar/gui/migration.h
deleted file mode 100644
index 78bc501599..0000000000
--- a/calendar/gui/migration.h
+++ /dev/null
@@ -1,35 +0,0 @@
-/*
- *
- * This program is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 2 of the License, or (at your option) version 3.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with the program; if not, see <http://www.gnu.org/licenses/>
- *
- *
- * Authors:
- * Rodrigo Moya <rodrigo@ximian.com>
- *
- * Copyright (C) 1999-2008 Novell, Inc. (www.novell.com)
- *
- */
-
-#ifndef MIGRATION_H
-#define MIGRATION_H
-
-#include <libedataserver/e-source-group.h>
-#include "calendar-component.h"
-#include "tasks-component.h"
-#include "memos-component.h"
-
-gboolean migrate_calendars (CalendarComponent *component, gint major, gint minor, gint revision, GError **err);
-gboolean migrate_tasks (TasksComponent *component, gint major, gint minor, gint revision, GError **err);
-gboolean migrate_memos (MemosComponent *component, gint major, gint minor, gint revision, GError **err);
-#endif
diff --git a/calendar/gui/print.c b/calendar/gui/print.c
index 48be727e40..1a8e5a1d76 100644
--- a/calendar/gui/print.c
+++ b/calendar/gui/print.c
@@ -43,7 +43,6 @@
#include <e-util/e-print.h>
#include <libecal/e-cal-time-util.h>
#include <libecal/e-cal-component.h>
-#include "calendar-commands.h"
#include "calendar-config.h"
#include "e-cal-model.h"
#include "e-day-view.h"
@@ -1947,6 +1946,7 @@ print_todo_details (GtkPrintContext *context, GnomeCalendar *gcal,
time_t start, time_t end,
double left, double right, double top, double bottom)
{
+#if 0 /* KILL-BONOBO */
PangoFontDescription *font_summary;
double y, yend, x, xend;
struct icaltimetype *tt;
@@ -2035,6 +2035,7 @@ print_todo_details (GtkPrintContext *context, GnomeCalendar *gcal,
}
pango_font_description_free (font_summary);
+#endif
}
static void
diff --git a/calendar/gui/print.h b/calendar/gui/print.h
index 39482b33f2..39d5608222 100644
--- a/calendar/gui/print.h
+++ b/calendar/gui/print.h
@@ -25,9 +25,7 @@
#ifndef PRINT_H
#define PRINT_H
-#include "gnome-cal.h"
-
-
+#include "calendar/gui/gnome-cal.h"
typedef enum {
PRINT_VIEW_DAY,
diff --git a/calendar/gui/tasks-component.c b/calendar/gui/tasks-component.c
index f7934742d2..02783496f6 100644
--- a/calendar/gui/tasks-component.c
+++ b/calendar/gui/tasks-component.c
@@ -57,27 +57,13 @@
#define CREATE_TASK_ASSIGNED_ID "task-assigned"
#define CREATE_TASK_LIST_ID "task-list"
-enum DndTargetType {
- DND_TARGET_TYPE_CALENDAR_LIST
-};
-#define CALENDAR_TYPE "text/calendar"
-#define XCALENDAR_TYPE "text/x-calendar"
#define WEB_BASE_URI "webcal://"
#define PERSONAL_RELATIVE_URI "system"
-static GtkTargetEntry drag_types[] = {
- { (gchar *) CALENDAR_TYPE, 0, DND_TARGET_TYPE_CALENDAR_LIST },
- { (gchar *) XCALENDAR_TYPE, 0, DND_TARGET_TYPE_CALENDAR_LIST }
-};
-static gint num_drag_types = sizeof(drag_types) / sizeof(drag_types[0]);
-
#define PARENT_TYPE bonobo_object_get_type ()
static BonoboObjectClass *parent_class = NULL;
-/* Tasks should have their own registry */
-extern ECompEditorRegistry *comp_editor_registry;
-
typedef struct
{
ESourceList *source_list;
@@ -88,23 +74,15 @@ typedef struct
ETable *table;
ETableModel *model;
- EInfoLabel *info_label;
GtkWidget *source_selector;
BonoboControl *view_control;
- BonoboControl *sidebar_control;
- BonoboControl *statusbar_control;
GList *notifications;
- EUserCreatableItemsHandler *creatable_items_handler;
-
- EActivityHandler *activity_handler;
} TasksComponentView;
struct _TasksComponentPrivate {
- gchar *base_directory;
- gchar *config_directory;
ESourceList *source_list;
GSList *source_selection;
@@ -116,109 +94,6 @@ struct _TasksComponentPrivate {
GList *notifications;
};
-static void
-ensure_sources (TasksComponent *component)
-{
- ESourceList *source_list;
- ESourceGroup *on_this_computer;
- ESource *personal_source;
- gchar *base_uri, *base_uri_proto, base_uri_proto_seventh;
- const gchar *base_dir;
-
- personal_source = NULL;
-
- if (!e_cal_get_sources (&source_list, E_CAL_SOURCE_TYPE_TODO, NULL)) {
- g_warning ("Could not get task source list from GConf!");
- return;
- }
-
- base_dir = tasks_component_peek_base_directory (component);
- base_uri = g_build_filename (base_dir, "local", NULL);
-
- base_uri_proto = g_filename_to_uri (base_uri, NULL, NULL);
- if (strlen (base_uri_proto) > 7) {
- /* compare only file:// part. If user home dir name changes we do not want to create
- one more group */
- base_uri_proto_seventh = base_uri_proto[7];
- base_uri_proto[7] = 0;
- } else {
- base_uri_proto_seventh = -1;
- }
-
- on_this_computer = e_source_list_ensure_group (source_list, _("On This Computer"), base_uri_proto, TRUE);
- e_source_list_ensure_group (source_list, _("On The Web"), WEB_BASE_URI, FALSE);
-
- if (base_uri_proto_seventh != -1) {
- base_uri_proto[7] = base_uri_proto_seventh;
- }
-
- if (on_this_computer) {
- /* make sure "Personal" shows up as a source under
- this group */
- GSList *sources = e_source_group_peek_sources (on_this_computer);
- GSList *s;
- for (s = sources; s; s = s->next) {
- ESource *source = E_SOURCE (s->data);
- const gchar *relative_uri;
-
- relative_uri = e_source_peek_relative_uri (source);
- if (relative_uri == NULL)
- continue;
- if (!strcmp (PERSONAL_RELATIVE_URI, relative_uri)) {
- personal_source = source;
- break;
- }
- }
- /* Make sure we have the correct base uri. This can change when user's
- homedir name changes */
- if (strcmp (base_uri_proto, e_source_group_peek_base_uri (on_this_computer))) {
- e_source_group_set_base_uri (on_this_computer, base_uri_proto);
-
- /* *sigh* . We shouldn't need this sync call here as set_base_uri
- call results in synching to gconf, but that happens in idle loop
- and too late to prevent user seeing "Can not Open ... because of invalid uri" error.*/
- e_source_list_sync (source_list,NULL);
- }
- }
-
- if (personal_source) {
- /* ensure the source name is in current locale, not read from configuration */
- e_source_set_name (personal_source, _("Personal"));
- } else {
- GSList *tasks_selected;
- /* Create the default Person addressbook */
- ESource *source = e_source_new (_("Personal"), PERSONAL_RELATIVE_URI);
- e_source_group_add_source (on_this_computer, source, -1);
- g_object_unref (source);
-
- tasks_selected = calendar_config_get_tasks_selected ();
-
- if (!calendar_config_get_primary_tasks () && !tasks_selected) {
- GSList selected;
-
- calendar_config_set_primary_tasks (e_source_peek_uid (source));
-
- selected.data = (gpointer)e_source_peek_uid (source);
- selected.next = NULL;
- calendar_config_set_tasks_selected (&selected);
- }
-
- if (tasks_selected) {
- g_slist_foreach (tasks_selected, (GFunc) g_free, NULL);
- g_slist_free (tasks_selected);
- }
-
- e_source_set_color_spec (source, "#BECEDD");
- personal_source = source;
- }
-
- component->priv->source_list = source_list;
-
- g_object_unref (on_this_computer);
- g_free (base_uri_proto);
- g_free (base_uri);
-}
-
/* Utility functions. */
/* FIXME Some of these are duplicated from calendar-component.c */
static gboolean
@@ -303,62 +178,6 @@ update_uri_for_primary_selection (TasksComponentView *component_view)
calendar_config_set_primary_tasks (e_source_peek_uid (source));
}
-static void
-update_selection (TasksComponentView *component_view)
-{
- GSList *selection, *uids_selected, *l;
-
- /* Get the selection in gconf */
- uids_selected = calendar_config_get_tasks_selected ();
-
- /* Remove any that aren't there any more */
- selection = e_source_selector_get_selection (E_SOURCE_SELECTOR (component_view->source_selector));
-
- for (l = selection; l; l = l->next) {
- ESource *source = l->data;
-
- if (!is_in_uids (uids_selected, source))
- e_source_selector_unselect_source (E_SOURCE_SELECTOR (component_view->source_selector), source);
- }
-
- e_source_selector_free_selection (selection);
-
- /* Make sure the whole selection is there */
- for (l = uids_selected; l; l = l->next) {
- gchar *uid = l->data;
- ESource *source;
-
- source = e_source_list_peek_source_by_uid (component_view->source_list, uid);
- if (source)
- e_source_selector_select_source (E_SOURCE_SELECTOR (component_view->source_selector), source);
-
- g_free (uid);
- }
- g_slist_free (uids_selected);
-}
-
-static void
-update_primary_selection (TasksComponentView *component_view)
-{
- ESource *source = NULL;
- gchar *uid;
-
- uid = calendar_config_get_primary_tasks ();
- if (uid) {
- source = e_source_list_peek_source_by_uid (component_view->source_list, uid);
- g_free (uid);
- }
-
- if (source) {
- e_source_selector_set_primary_selection (E_SOURCE_SELECTOR (component_view->source_selector), source);
- } else {
- /* Try to create a default if there isn't one */
- source = e_source_list_peek_source_any (component_view->source_list);
- if (source)
- e_source_selector_set_primary_selection (E_SOURCE_SELECTOR (component_view->source_selector), source);
- }
-}
-
/* Callbacks. */
static void
copy_task_list_cb (EPopup *ep, EPopupItem *pitem, gpointer data)
@@ -530,84 +349,11 @@ primary_source_selection_changed_cb (ESourceSelector *selector, TasksComponentVi
}
static void
-source_added_cb (ETasks *tasks, ESource *source, TasksComponentView *component_view)
-{
- e_source_selector_select_source (E_SOURCE_SELECTOR (component_view->source_selector), source);
-}
-
-static void
source_removed_cb (ETasks *tasks, ESource *source, TasksComponentView *component_view)
{
e_source_selector_unselect_source (E_SOURCE_SELECTOR (component_view->source_selector), source);
}
-static void
-set_info (TasksComponentView *component_view)
-{
- GString *message = g_string_new (NULL);
- gint rows, selected_rows;
-
- rows = e_table_model_row_count (component_view->model);
- selected_rows = e_table_selected_count (component_view->table);
-
- g_string_append_printf(message, ngettext("%d task", "%d tasks", rows), rows);
- if (selected_rows > 0)
- g_string_append_printf(message, ngettext(", %d selected", ", %d selected", selected_rows), selected_rows);
-
- e_info_label_set_info (component_view->info_label, _("Tasks"), message->str);
-
- g_string_free (message, TRUE);
-}
-
-static void
-table_selection_change_cb (ETableModel *etm, TasksComponentView *component_view)
-{
- set_info (component_view);
-}
-
-static void
-model_changed_cb (ETableModel *etm, TasksComponentView *component_view)
-{
- set_info (component_view);
-}
-
-static void
-model_rows_inserted_cb (ETableModel *etm, gint row, gint count, TasksComponentView *component_view)
-{
- set_info (component_view);
-}
-
-static void
-model_rows_deleted_cb (ETableModel *etm, gint row, gint count, TasksComponentView *component_view)
-{
- set_info (component_view);
-}
-
-/* Evolution::Component CORBA methods */
-
-static void
-impl_upgradeFromVersion (PortableServer_Servant servant,
- CORBA_short major,
- CORBA_short minor,
- CORBA_short revision,
- CORBA_Environment *ev)
-{
- GError *err = NULL;
- TasksComponent *component = TASKS_COMPONENT (bonobo_object_from_servant (servant));
-
- if (!migrate_tasks(component, major, minor, revision, &err)) {
- GNOME_Evolution_Component_UpgradeFailed *failedex;
-
- failedex = GNOME_Evolution_Component_UpgradeFailed__alloc();
- failedex->what = CORBA_string_dup(_("Failed upgrading tasks."));
- failedex->why = CORBA_string_dup(err->message);
- CORBA_exception_set(ev, CORBA_USER_EXCEPTION, ex_GNOME_Evolution_Component_UpgradeFailed, failedex);
- }
-
- if (err)
- g_error_free(err);
-}
-
static gboolean
selector_tree_data_dropped (ESourceSelector *selector,
GtkSelectionData *data,
@@ -658,19 +404,6 @@ selector_tree_data_dropped (ESourceSelector *selector,
}
static void
-control_activate_cb (BonoboControl *control, gboolean activate, gpointer data)
-{
- TasksComponentView *component_view = data;
-
- if (activate) {
- BonoboUIComponent *uic;
- uic = bonobo_control_get_ui_component (component_view->view_control);
-
- e_user_creatable_items_handler_activate (component_view->creatable_items_handler, uic);
- }
-}
-
-static void
config_create_ecal_changed_cb (GConfClient *client, guint id, GConfEntry *entry, gpointer data)
{
TasksComponent *component = data;
@@ -807,42 +540,11 @@ create_new_todo (TasksComponent *task_component, gboolean is_assigned, TasksComp
return TRUE;
}
-static void
-create_local_item_cb (EUserCreatableItemsHandler *handler, const gchar *item_type_name, gpointer data)
-{
- TasksComponent *tasks_component = data;
- TasksComponentPrivate *priv;
- TasksComponentView *component_view = NULL;
- GList *l;
-
- priv = tasks_component->priv;
-
- for (l = priv->views; l; l = l->next) {
- component_view = l->data;
-
- if (component_view->creatable_items_handler == handler)
- break;
-
- component_view = NULL;
- }
-
- if (strcmp (item_type_name, CREATE_TASK_ID) == 0) {
- create_new_todo (tasks_component, FALSE, component_view);
- } else if (strcmp (item_type_name, CREATE_TASK_ASSIGNED_ID) == 0) {
- create_new_todo (tasks_component, TRUE, component_view);
- } else if (strcmp (item_type_name, CREATE_TASK_LIST_ID) == 0) {
- calendar_setup_new_task_list (GTK_WINDOW (gtk_widget_get_toplevel (GTK_WIDGET (component_view->tasks))));
- }
-}
-
static TasksComponentView *
create_component_view (TasksComponent *tasks_component)
{
TasksComponentPrivate *priv;
TasksComponentView *component_view;
- GtkWidget *selector_scrolled_window, *vbox;
- GtkWidget *statusbar_widget;
- AtkObject *a11y;
priv = tasks_component->priv;
@@ -854,66 +556,18 @@ create_component_view (TasksComponent *tasks_component)
/* Create sidebar selector */
component_view->source_selector = e_source_selector_new (tasks_component->priv->source_list);
- e_source_selector_set_select_new ((ESourceSelector *)component_view->source_selector, TRUE);
- a11y = gtk_widget_get_accessible (GTK_WIDGET (component_view->source_selector));
- atk_object_set_name (a11y, _("Task Source Selector"));
-
- g_signal_connect (
- component_view->source_selector, "data-dropped",
- G_CALLBACK (selector_tree_data_dropped), tasks_component);
-
- gtk_drag_dest_set(component_view->source_selector, GTK_DEST_DEFAULT_ALL, drag_types,
- num_drag_types, GDK_ACTION_COPY | GDK_ACTION_MOVE);
-
- gtk_widget_show (component_view->source_selector);
-
- selector_scrolled_window = gtk_scrolled_window_new (NULL, NULL);
- gtk_container_add (GTK_CONTAINER (selector_scrolled_window), component_view->source_selector);
- gtk_scrolled_window_set_policy (GTK_SCROLLED_WINDOW (selector_scrolled_window),
- GTK_POLICY_AUTOMATIC, GTK_POLICY_AUTOMATIC);
- gtk_scrolled_window_set_shadow_type (GTK_SCROLLED_WINDOW (selector_scrolled_window),
- GTK_SHADOW_IN);
- gtk_widget_show (selector_scrolled_window);
-
- component_view->info_label = (EInfoLabel *)e_info_label_new("evolution-tasks");
- e_info_label_set_info(component_view->info_label, _("Tasks"), "");
- gtk_widget_show (GTK_WIDGET (component_view->info_label));
- vbox = gtk_vbox_new(FALSE, 0);
- gtk_box_pack_start(GTK_BOX (vbox), GTK_WIDGET (component_view->info_label), FALSE, TRUE, 0);
- gtk_box_pack_start(GTK_BOX (vbox), selector_scrolled_window, TRUE, TRUE, 0);
- gtk_widget_show (vbox);
-
- component_view->sidebar_control = bonobo_control_new (vbox);
-
- /* Create main view */
- component_view->view_control = tasks_control_new ();
- if (!component_view->view_control) {
- /* FIXME free memory */
-
- return NULL;
- }
+ g_signal_connect (component_view->source_selector, "drag-data-received",
+ G_CALLBACK (selector_tree_drag_data_received), tasks_component);
component_view->tasks = (ETasks *) bonobo_control_get_widget (component_view->view_control);
component_view->table = e_calendar_table_get_table (e_tasks_get_calendar_table (component_view->tasks));
component_view->model = E_TABLE_MODEL (e_calendar_table_get_model (e_tasks_get_calendar_table (component_view->tasks)));
/* This signal is thrown if backends die - we update the selector */
- g_signal_connect (component_view->tasks, "source_added",
- G_CALLBACK (source_added_cb), component_view);
g_signal_connect (component_view->tasks, "source_removed",
G_CALLBACK (source_removed_cb), component_view);
- /* Create status bar */
- statusbar_widget = e_task_bar_new ();
- component_view->activity_handler = e_activity_handler_new ();
- e_activity_handler_attach_task_bar (component_view->activity_handler, E_TASK_BAR (statusbar_widget));
- gtk_widget_show (statusbar_widget);
-
- component_view->statusbar_control = bonobo_control_new (statusbar_widget);
-
- e_calendar_table_set_activity_handler (e_tasks_get_calendar_table (component_view->tasks), component_view->activity_handler);
-
/* connect after setting the initial selections, or we'll get unwanted calls
to calendar_control_sensitize_calendar_commands */
g_signal_connect (component_view->source_selector, "selection_changed",
@@ -923,25 +577,6 @@ create_component_view (TasksComponent *tasks_component)
g_signal_connect (component_view->source_selector, "popup_event",
G_CALLBACK (popup_event_cb), component_view);
- /* Set up the "new" item handler */
- component_view->creatable_items_handler = e_user_creatable_items_handler_new ("tasks", create_local_item_cb, tasks_component);
- g_signal_connect (component_view->view_control, "activate", G_CALLBACK (control_activate_cb), component_view);
-
- /* We use this to update the component information */
- set_info (component_view);
- g_signal_connect (component_view->table, "selection_change",
- G_CALLBACK (table_selection_change_cb), component_view);
- g_signal_connect (component_view->model, "model_changed",
- G_CALLBACK (model_changed_cb), component_view);
- g_signal_connect (component_view->model, "model_rows_inserted",
- G_CALLBACK (model_rows_inserted_cb), component_view);
- g_signal_connect (component_view->model, "model_rows_deleted",
- G_CALLBACK (model_rows_deleted_cb), component_view);
-
- /* Load the selection from the last run */
- update_selection (component_view);
- update_primary_selection (component_view);
-
return component_view;
}
@@ -962,12 +597,6 @@ destroy_component_view (TasksComponentView *component_view)
calendar_config_remove_notification (GPOINTER_TO_UINT (l->data));
g_list_free (component_view->notifications);
- if (component_view->creatable_items_handler)
- g_object_unref (component_view->creatable_items_handler);
-
- if (component_view->activity_handler)
- g_object_unref (component_view->activity_handler);
-
g_free (component_view);
}
@@ -992,38 +621,6 @@ view_destroyed_cb (gpointer data, GObject *where_the_object_was)
}
}
-static GNOME_Evolution_ComponentView
-impl_createView (PortableServer_Servant servant,
- GNOME_Evolution_ShellView parent,
- CORBA_boolean select_item,
- CORBA_Environment *ev)
-{
- TasksComponent *component = TASKS_COMPONENT (bonobo_object_from_servant (servant));
- TasksComponentPrivate *priv;
- TasksComponentView *component_view;
- EComponentView *ecv;
-
- priv = component->priv;
-
- /* Create the calendar component view */
- component_view = create_component_view (component);
- if (!component_view) {
- /* FIXME Should we describe the problem in a control? */
- bonobo_exception_set (ev, ex_GNOME_Evolution_Component_Failed);
-
- return CORBA_OBJECT_NIL;
- }
-
- g_object_weak_ref (G_OBJECT (component_view->view_control), view_destroyed_cb, component);
- priv->views = g_list_append (priv->views, component_view);
-
- /* TODO: Make TasksComponentView just subclass EComponentView */
- ecv = e_component_view_new_controls (parent, "tasks", component_view->sidebar_control,
- component_view->view_control, component_view->statusbar_control);
-
- return BONOBO_OBJREF(ecv);
-}
-
static void
impl_handleURI (PortableServer_Servant servant, const gchar *uri, CORBA_Environment *ev)
{
@@ -1097,45 +694,6 @@ impl_handleURI (PortableServer_Servant servant, const gchar *uri, CORBA_Environm
return;
}
-static GNOME_Evolution_CreatableItemTypeList *
-impl__get_userCreatableItems (PortableServer_Servant servant,
- CORBA_Environment *ev)
-{
- GNOME_Evolution_CreatableItemTypeList *list = GNOME_Evolution_CreatableItemTypeList__alloc ();
-
- list->_length = 3;
- list->_maximum = list->_length;
- list->_buffer = GNOME_Evolution_CreatableItemTypeList_allocbuf (list->_length);
-
- CORBA_sequence_set_release (list, FALSE);
-
- list->_buffer[0].id = (gchar *) CREATE_TASK_ID;
- list->_buffer[0].description = (gchar *) _("New task");
- list->_buffer[0].menuDescription = (gchar *) C_("New", "_Task");
- list->_buffer[0].tooltip = (gchar *) _("Create a new task");
- list->_buffer[0].menuShortcut = 't';
- list->_buffer[0].iconName = (gchar *) "stock_task";
- list->_buffer[0].type = GNOME_Evolution_CREATABLE_OBJECT;
-
- list->_buffer[1].id = (gchar *) CREATE_TASK_ASSIGNED_ID;
- list->_buffer[1].description = (gchar *) _("New assigned task");
- list->_buffer[1].menuDescription = (gchar *) C_("New", "Assigne_d Task");
- list->_buffer[1].tooltip = (gchar *) _("Create a new assigned task");
- list->_buffer[1].menuShortcut = '\0';
- list->_buffer[1].iconName = (gchar *) "stock_task";
- list->_buffer[1].type = GNOME_Evolution_CREATABLE_OBJECT;
-
- list->_buffer[2].id = (gchar *) CREATE_TASK_LIST_ID;
- list->_buffer[2].description = (gchar *) _("New task list");
- list->_buffer[2].menuDescription = (gchar *) C_("New", "Tas_k list");
- list->_buffer[2].tooltip = (gchar *) _("Create a new task list");
- list->_buffer[2].menuShortcut = '\0';
- list->_buffer[2].iconName = (gchar *) "stock_todo";
- list->_buffer[2].type = GNOME_Evolution_CREATABLE_FOLDER;
-
- return list;
-}
-
static void
impl_requestCreateItem (PortableServer_Servant servant,
const CORBA_char *item_type_name,
@@ -1209,8 +767,6 @@ impl_finalize (GObject *object)
}
g_list_free (priv->views);
- g_free (priv->base_directory);
- g_free (priv->config_directory);
g_free (priv);
(* G_OBJECT_CLASS (parent_class)->finalize) (object);
@@ -1227,9 +783,6 @@ tasks_component_class_init (TasksComponentClass *klass)
parent_class = g_type_class_peek_parent (klass);
- epv->upgradeFromVersion = impl_upgradeFromVersion;
- epv->createView = impl_createView;
- epv->_get_userCreatableItems = impl__get_userCreatableItems;
epv->requestCreateItem = impl_requestCreateItem;
epv->handleURI = impl_handleURI;
@@ -1244,50 +797,5 @@ tasks_component_init (TasksComponent *component, TasksComponentClass *klass)
priv = g_new0 (TasksComponentPrivate, 1);
- priv->base_directory = g_build_filename (e_get_user_data_dir (), "tasks", NULL);
- priv->config_directory = g_build_filename (priv->base_directory, "config", NULL);
-
component->priv = priv;
- ensure_sources (component);
-}
-
-/* Public API */
-
-TasksComponent *
-tasks_component_peek (void)
-{
- static TasksComponent *component = NULL;
-
- if (component == NULL) {
- component = g_object_new (tasks_component_get_type (), NULL);
-
- if (g_mkdir_with_parents (component->priv->config_directory, 0777) != 0) {
- g_warning (G_STRLOC ": Cannot create directory %s: %s",
- component->priv->config_directory, g_strerror (errno));
- g_object_unref (component);
- component = NULL;
- }
- }
-
- return component;
-}
-
-const gchar *
-tasks_component_peek_base_directory (TasksComponent *component)
-{
- return component->priv->base_directory;
-}
-
-const gchar *
-tasks_component_peek_config_directory (TasksComponent *component)
-{
- return component->priv->config_directory;
-}
-
-ESourceList *
-tasks_component_peek_source_list (TasksComponent *component)
-{
- return component->priv->source_list;
}
-
-BONOBO_TYPE_FUNC_FULL (TasksComponent, GNOME_Evolution_Component, PARENT_TYPE, tasks_component)
diff --git a/calendar/gui/tasks-component.h b/calendar/gui/tasks-component.h
index 9824797640..851d3d0381 100644
--- a/calendar/gui/tasks-component.h
+++ b/calendar/gui/tasks-component.h
@@ -51,10 +51,5 @@ struct _TasksComponentClass {
};
GType tasks_component_get_type (void);
-TasksComponent *tasks_component_peek (void);
-
-const gchar *tasks_component_peek_base_directory (TasksComponent *component);
-const gchar *tasks_component_peek_config_directory (TasksComponent *component);
-ESourceList *tasks_component_peek_source_list (TasksComponent *component);
#endif /* _TASKS_COMPONENT_H_ */
diff --git a/calendar/gui/tasks-control.c b/calendar/gui/tasks-control.c
index a7134e9421..61f7eb4848 100644
--- a/calendar/gui/tasks-control.c
+++ b/calendar/gui/tasks-control.c
@@ -52,36 +52,15 @@
static void tasks_control_activate_cb (BonoboControl *control,
gboolean activate,
gpointer user_data);
-static void tasks_control_open_task_cmd (BonoboUIComponent *uic,
- gpointer data,
- const gchar *path);
static void tasks_control_new_task_cmd (BonoboUIComponent *uic,
gpointer data,
const gchar *path);
-static void tasks_control_cut_cmd (BonoboUIComponent *uic,
- gpointer data,
- const gchar *path);
-static void tasks_control_copy_cmd (BonoboUIComponent *uic,
- gpointer data,
- const gchar *path);
-static void tasks_control_paste_cmd (BonoboUIComponent *uic,
- gpointer data,
- const gchar *path);
-static void tasks_control_delete_cmd (BonoboUIComponent *uic,
- gpointer data,
- const gchar *path);
static void tasks_control_complete_cmd (BonoboUIComponent *uic,
gpointer data,
const gchar *path);
static void tasks_control_purge_cmd (BonoboUIComponent *uic,
gpointer data,
const gchar *path);
-static void tasks_control_print_cmd (BonoboUIComponent *uic,
- gpointer data,
- const gchar *path);
-static void tasks_control_print_preview_cmd (BonoboUIComponent *uic,
- gpointer data,
- const gchar *path);
static void tasks_control_assign_cmd (BonoboUIComponent *uic,
gpointer data,
const gchar *path);
@@ -90,67 +69,6 @@ static void tasks_control_forward_cmd (BonoboUIComponent *uic,
gpointer data,
const gchar *path);
-static void tasks_control_view_preview (BonoboUIComponent *uic,
- const gchar *path,
- Bonobo_UIComponent_EventType type,
- const gchar *state,
- gpointer data);
-
-struct focus_changed_data {
- BonoboControl *control;
- ETasks *tasks;
-};
-
-static gboolean tasks_control_focus_changed (GtkWidget *widget, GdkEventFocus *event, struct focus_changed_data *fc_data);
-
-BonoboControl *
-tasks_control_new (void)
-{
- BonoboControl *control;
- GtkWidget *tasks, *preview;
- struct focus_changed_data *fc_data;
-
- tasks = e_tasks_new ();
- if (!tasks)
- return NULL;
- gtk_widget_show (tasks);
-
- control = bonobo_control_new (tasks);
- if (!control) {
- gtk_widget_destroy (tasks);
- g_message ("control_factory_fn(): could not create the control!");
- return NULL;
- }
-
- g_signal_connect (control, "activate", G_CALLBACK (tasks_control_activate_cb), tasks);
-
- fc_data = g_new0 (struct focus_changed_data, 1);
- fc_data->control = control;
- fc_data->tasks = E_TASKS (tasks);
-
- preview = e_cal_component_preview_get_html (E_CAL_COMPONENT_PREVIEW (e_tasks_get_preview (fc_data->tasks)));
- g_object_set_data_full (G_OBJECT (preview), "tasks-ctrl-fc-data", fc_data, g_free);
- g_signal_connect (preview, "focus-in-event", G_CALLBACK (tasks_control_focus_changed), fc_data);
- g_signal_connect (preview, "focus-out-event", G_CALLBACK (tasks_control_focus_changed), fc_data);
-
- return control;
-}
-
-static void
-tasks_control_activate_cb (BonoboControl *control,
- gboolean activate,
- gpointer user_data)
-{
- ETasks *tasks;
-
- tasks = E_TASKS (user_data);
-
- if (activate)
- tasks_control_activate (control, tasks);
- else
- tasks_control_deactivate (control, tasks);
-}
-
struct _tasks_sensitize_item {
const gchar *command;
guint32 enable;
@@ -265,38 +183,14 @@ tasks_control_focus_changed (GtkWidget *widget, GdkEventFocus *event, struct foc
}
static BonoboUIVerb verbs [] = {
- BONOBO_UI_VERB ("TasksOpenTask", tasks_control_open_task_cmd),
BONOBO_UI_VERB ("TasksNewTask", tasks_control_new_task_cmd),
- BONOBO_UI_VERB ("TasksCut", tasks_control_cut_cmd),
- BONOBO_UI_VERB ("TasksCopy", tasks_control_copy_cmd),
- BONOBO_UI_VERB ("TasksPaste", tasks_control_paste_cmd),
- BONOBO_UI_VERB ("TasksDelete", tasks_control_delete_cmd),
BONOBO_UI_VERB ("TasksMarkComplete", tasks_control_complete_cmd),
BONOBO_UI_VERB ("TasksPurge", tasks_control_purge_cmd),
- BONOBO_UI_VERB ("TasksPrint", tasks_control_print_cmd),
- BONOBO_UI_VERB ("TasksPrintPreview", tasks_control_print_preview_cmd),
BONOBO_UI_VERB ("TasksAssign", tasks_control_assign_cmd),
BONOBO_UI_VERB ("TasksForward", tasks_control_forward_cmd),
BONOBO_UI_VERB_END
};
-static EPixmap pixmaps [] = {
- E_PIXMAP ("/commands/TasksCopy", "edit-copy", GTK_ICON_SIZE_MENU),
- E_PIXMAP ("/commands/TasksCut", "edit-cut", GTK_ICON_SIZE_MENU),
- E_PIXMAP ("/commands/TasksDelete", "edit-delete", GTK_ICON_SIZE_MENU),
- E_PIXMAP ("/commands/TasksForward", "mail-forward", GTK_ICON_SIZE_MENU),
- E_PIXMAP ("/commands/TasksPaste", "edit-paste", GTK_ICON_SIZE_MENU),
- E_PIXMAP ("/commands/TasksPrint", "document-print", GTK_ICON_SIZE_MENU),
- E_PIXMAP ("/commands/TasksPrintPreview", "document-print-preview", GTK_ICON_SIZE_MENU),
-
- E_PIXMAP ("/Toolbar/Cut", "edit-cut", GTK_ICON_SIZE_LARGE_TOOLBAR),
- E_PIXMAP ("/Toolbar/Copy", "edit-copy", GTK_ICON_SIZE_LARGE_TOOLBAR),
- E_PIXMAP ("/Toolbar/Paste", "edit-paste", GTK_ICON_SIZE_LARGE_TOOLBAR),
- E_PIXMAP ("/Toolbar/Print", "document-print", GTK_ICON_SIZE_LARGE_TOOLBAR),
- E_PIXMAP ("/Toolbar/Delete", "edit-delete", GTK_ICON_SIZE_LARGE_TOOLBAR),
-
- E_PIXMAP_END
-};
void
tasks_control_activate (BonoboControl *control, ETasks *tasks)
{
@@ -330,8 +224,6 @@ tasks_control_activate (BonoboControl *control, ETasks *tasks)
NULL);
g_free (xmlfile);
- e_pixmaps_update (uic, pixmaps);
-
e_tasks_setup_view_menus (tasks, uic);
/* Signals from the tasks widget; also sensitize the menu items as appropriate */
@@ -372,16 +264,6 @@ tasks_control_deactivate (BonoboControl *control, ETasks *tasks)
bonobo_ui_component_unset_container (uic, NULL);
}
-static void tasks_control_open_task_cmd (BonoboUIComponent *uic,
- gpointer data,
- const gchar *path)
-{
- ETasks *tasks;
-
- tasks = E_TASKS (data);
- e_tasks_open_task (tasks);
-}
-
static void
tasks_control_new_task_cmd (BonoboUIComponent *uic,
gpointer data,
@@ -394,64 +276,6 @@ tasks_control_new_task_cmd (BonoboUIComponent *uic,
}
static void
-tasks_control_cut_cmd (BonoboUIComponent *uic,
- gpointer data,
- const gchar *path)
-{
- ETasks *tasks;
- ECalendarTable *cal_table;
-
- tasks = E_TASKS (data);
- cal_table = e_tasks_get_calendar_table (tasks);
- e_calendar_table_cut_clipboard (cal_table);
-}
-
-static void
-tasks_control_copy_cmd (BonoboUIComponent *uic,
- gpointer data,
- const gchar *path)
-{
- ETasks *tasks;
- ECalendarTable *cal_table;
- GtkWidget *preview;
-
- tasks = E_TASKS (data);
-
- preview = e_cal_component_preview_get_html (E_CAL_COMPONENT_PREVIEW (e_tasks_get_preview (tasks)));
- if (preview && GTK_WIDGET_VISIBLE (preview) && GTK_WIDGET_HAS_FOCUS (preview)) {
- /* copy selected text in a preview when that's shown and focused */
- gtk_html_copy (GTK_HTML (preview));
- } else {
- cal_table = e_tasks_get_calendar_table (tasks);
- e_calendar_table_copy_clipboard (cal_table);
- }
-}
-
-static void
-tasks_control_paste_cmd (BonoboUIComponent *uic,
- gpointer data,
- const gchar *path)
-{
- ETasks *tasks;
- ECalendarTable *cal_table;
-
- tasks = E_TASKS (data);
- cal_table = e_tasks_get_calendar_table (tasks);
- e_calendar_table_paste_clipboard (cal_table);
-}
-
-static void
-tasks_control_delete_cmd (BonoboUIComponent *uic,
- gpointer data,
- const gchar *path)
-{
- ETasks *tasks;
-
- tasks = E_TASKS (data);
- e_tasks_delete_selected (tasks);
-}
-
-static void
tasks_control_complete_cmd (BonoboUIComponent *uic,
gpointer data,
const gchar *path)
@@ -507,87 +331,3 @@ tasks_control_purge_cmd (BonoboUIComponent *uic,
if (confirm_purge (tasks))
e_tasks_delete_completed (tasks);
}
-
-/* File/Print callback */
-static void
-tasks_control_print_cmd (BonoboUIComponent *uic,
- gpointer data,
- const gchar *path)
-{
- ETasks *tasks = E_TASKS (data);
- ETable *table;
-
- table = e_calendar_table_get_table (
- E_CALENDAR_TABLE (e_tasks_get_calendar_table (tasks)));
-
- print_table (
- table, _("Print Tasks"), _("Tasks"),
- GTK_PRINT_OPERATION_ACTION_PRINT_DIALOG);
-}
-
-static void
-tasks_control_print_preview_cmd (BonoboUIComponent *uic,
- gpointer data,
- const gchar *path)
-{
- ETasks *tasks = E_TASKS (data);
- ETable *table;
-
- table = e_calendar_table_get_table (
- E_CALENDAR_TABLE (e_tasks_get_calendar_table (tasks)));
-
- print_table (
- table, _("Print Tasks"), _("Tasks"),
- GTK_PRINT_OPERATION_ACTION_PREVIEW);
-}
-
-static void
-tasks_control_assign_cmd (BonoboUIComponent *uic,
- gpointer data,
- const gchar *path)
-{
- ETasks *tasks;
- ECalendarTable *cal_table;
- ECalModelComponent *comp_data;
-
- tasks = E_TASKS (data);
- cal_table = e_tasks_get_calendar_table (tasks);
- comp_data = e_calendar_table_get_selected_comp (cal_table);
- if (comp_data)
- e_calendar_table_open_task (cal_table, comp_data->client, comp_data->icalcomp, TRUE);
-}
-
-static void
-tasks_control_forward_cmd (BonoboUIComponent *uic,
- gpointer data,
- const gchar *path)
-{
- ETasks *tasks;
- ECalendarTable *cal_table;
- ECalModelComponent *comp_data;
-
- tasks = E_TASKS (data);
- cal_table = e_tasks_get_calendar_table (tasks);
- comp_data = e_calendar_table_get_selected_comp (cal_table);
- if (comp_data) {
- ECalComponent *comp;
- comp = e_cal_component_new ();
- e_cal_component_set_icalcomponent (comp, icalcomponent_new_clone (comp_data->icalcomp));
- itip_send_comp (E_CAL_COMPONENT_METHOD_PUBLISH, comp, comp_data->client, NULL, NULL, NULL, TRUE);
- g_object_unref (comp);
- }
-}
-
-static void
-tasks_control_view_preview (BonoboUIComponent *uic, const gchar *path, Bonobo_UIComponent_EventType type, const gchar *state, gpointer data)
-{
- ETasks *tasks;
-
- if (type != Bonobo_UIComponent_STATE_CHANGED)
- return;
-
- tasks = E_TASKS (data);
-
- calendar_config_set_preview_state (state[0] != '0');
- e_tasks_show_preview (tasks, state[0] != '0');
-}