aboutsummaryrefslogtreecommitdiffstats
path: root/calendar/gui
diff options
context:
space:
mode:
Diffstat (limited to 'calendar/gui')
-rw-r--r--calendar/gui/Makefile.am226
-rw-r--r--calendar/gui/alarm-notify/Makefile.am6
-rw-r--r--calendar/gui/alarm-notify/alarm-queue.c19
-rw-r--r--calendar/gui/alarm-notify/notify-main.c6
-rw-r--r--calendar/gui/apps_evolution_calendar.schemas.in107
-rw-r--r--calendar/gui/cal-editor-utils.c21
-rw-r--r--calendar/gui/cal-editor-utils.h13
-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.c334
-rw-r--r--calendar/gui/calendar-component.c970
-rw-r--r--calendar/gui/calendar-component.h8
-rw-r--r--calendar/gui/calendar-config-keys.h8
-rw-r--r--calendar/gui/calendar-config.c810
-rw-r--r--calendar/gui/calendar-config.h106
-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.c405
-rw-r--r--calendar/gui/dialogs/cal-prefs-dialog.h37
-rw-r--r--calendar/gui/dialogs/comp-editor-util.c30
-rw-r--r--calendar/gui/dialogs/comp-editor-util.h7
-rw-r--r--calendar/gui/dialogs/comp-editor.c207
-rw-r--r--calendar/gui/dialogs/comp-editor.h6
-rw-r--r--calendar/gui/dialogs/event-editor.c56
-rw-r--r--calendar/gui/dialogs/event-editor.h1
-rw-r--r--calendar/gui/dialogs/event-page.c220
-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.c17
-rw-r--r--calendar/gui/dialogs/memo-page.glade1
-rw-r--r--calendar/gui/dialogs/recurrence-page.c51
-rw-r--r--calendar/gui/dialogs/schedule-page.c19
-rw-r--r--calendar/gui/dialogs/task-details-page.c14
-rw-r--r--calendar/gui/dialogs/task-details-page.glade190
-rw-r--r--calendar/gui/dialogs/task-editor.c60
-rw-r--r--calendar/gui/dialogs/task-editor.h1
-rw-r--r--calendar/gui/dialogs/task-page.c200
-rw-r--r--calendar/gui/e-attachment-handler-calendar.c511
-rw-r--r--calendar/gui/e-attachment-handler-calendar.h65
-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-config.c47
-rw-r--r--calendar/gui/e-cal-config.h15
-rw-r--r--calendar/gui/e-cal-event.c75
-rw-r--r--calendar/gui/e-cal-event.h33
-rw-r--r--calendar/gui/e-cal-list-view-config.c201
-rw-r--r--calendar/gui/e-cal-list-view-config.h56
-rw-r--r--calendar/gui/e-cal-list-view.c69
-rw-r--r--calendar/gui/e-cal-list-view.h37
-rw-r--r--calendar/gui/e-cal-menu.c293
-rw-r--r--calendar/gui/e-cal-menu.h121
-rw-r--r--calendar/gui/e-cal-model-calendar.c10
-rw-r--r--calendar/gui/e-cal-model-calendar.h43
-rw-r--r--calendar/gui/e-cal-model-memos.c10
-rw-r--r--calendar/gui/e-cal-model-memos.h43
-rw-r--r--calendar/gui/e-cal-model-tasks.c254
-rw-r--r--calendar/gui/e-cal-model-tasks.h65
-rw-r--r--calendar/gui/e-cal-model.c555
-rw-r--r--calendar/gui/e-cal-model.h249
-rw-r--r--calendar/gui/e-cal-popup.c501
-rw-r--r--calendar/gui/e-cal-popup.h214
-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.c244
-rw-r--r--calendar/gui/e-calendar-table-config.h56
-rw-r--r--calendar/gui/e-calendar-table.c1332
-rw-r--r--calendar/gui/e-calendar-table.h121
-rw-r--r--calendar/gui/e-calendar-view.c1244
-rw-r--r--calendar/gui/e-calendar-view.h70
-rw-r--r--calendar/gui/e-cell-date-edit-config.c321
-rw-r--r--calendar/gui/e-cell-date-edit-config.h57
-rw-r--r--calendar/gui/e-cell-date-edit-text.c220
-rw-r--r--calendar/gui/e-cell-date-edit-text.h66
-rw-r--r--calendar/gui/e-date-edit-config.c257
-rw-r--r--calendar/gui/e-date-edit-config.h56
-rw-r--r--calendar/gui/e-day-view-config.c462
-rw-r--r--calendar/gui/e-day-view-config.h56
-rw-r--r--calendar/gui/e-day-view-main-item.c8
-rw-r--r--calendar/gui/e-day-view-time-item.c9
-rw-r--r--calendar/gui/e-day-view-top-item.c7
-rw-r--r--calendar/gui/e-day-view.c683
-rw-r--r--calendar/gui/e-day-view.h89
-rw-r--r--calendar/gui/e-itip-control.c17
-rw-r--r--calendar/gui/e-meeting-list-view.c5
-rw-r--r--calendar/gui/e-meeting-store.c252
-rw-r--r--calendar/gui/e-meeting-store.h134
-rw-r--r--calendar/gui/e-meeting-time-sel.c378
-rw-r--r--calendar/gui/e-meeting-time-sel.h72
-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-config.c245
-rw-r--r--calendar/gui/e-memo-table-config.h56
-rw-r--r--calendar/gui/e-memo-table.c1294
-rw-r--r--calendar/gui/e-memo-table.h109
-rw-r--r--calendar/gui/e-memos.c1229
-rw-r--r--calendar/gui/e-memos.h85
-rw-r--r--calendar/gui/e-mini-calendar-config.c235
-rw-r--r--calendar/gui/e-mini-calendar-config.h55
-rw-r--r--calendar/gui/e-month-view.c213
-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.c1569
-rw-r--r--calendar/gui/e-tasks.h91
-rw-r--r--calendar/gui/e-timezone-entry.c450
-rw-r--r--calendar/gui/e-timezone-entry.h63
-rw-r--r--calendar/gui/e-week-view-config.c286
-rw-r--r--calendar/gui/e-week-view-config.h55
-rw-r--r--calendar/gui/e-week-view-event-item.c5
-rw-r--r--calendar/gui/e-week-view.c927
-rw-r--r--calendar/gui/e-week-view.h198
-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.c427
-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.c324
-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.c3061
-rw-r--r--calendar/gui/gnome-cal.h195
-rw-r--r--calendar/gui/goto.c19
-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.c1222
-rw-r--r--calendar/gui/memos-component.h61
-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.c40
-rw-r--r--calendar/gui/print.h4
-rw-r--r--calendar/gui/tasks-component.c1293
-rw-r--r--calendar/gui/tasks-component.h60
-rw-r--r--calendar/gui/tasks-control.c593
-rw-r--r--calendar/gui/tasks-control.h35
158 files changed, 14793 insertions, 25259 deletions
diff --git a/calendar/gui/Makefile.am b/calendar/gui/Makefile.am
index 853cfce649..ede213e1ff 100644
--- a/calendar/gui/Makefile.am
+++ b/calendar/gui/Makefile.am
@@ -1,53 +1,27 @@
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
-privsolib_LTLIBRARIES = libevolution-cal-shared.la
-component_LTLIBRARIES = libevolution-calendar.la
+privsolib_LTLIBRARIES = libevolution-calendar.la
ecalendarincludedir = $(privincludedir)/calendar/gui
ecalendarinclude_HEADERS = \
cal-editor-utils.h \
- cal-search-bar.h \
calendar-config.h \
calendar-config-keys.h \
comp-util.h \
e-alarm-list.h \
- e-attachment-handler-calendar.h \
e-cal-config.h \
e-cal-event.h \
e-cal-model-calendar.h \
e-cal-model.h \
- e-cal-popup.h \
e-calendar-view.h \
e-cell-date-edit-text.h \
e-comp-editor-registry.h \
- e-date-edit-config.h \
e-date-time-list.h \
- e-day-view-config.h \
e-day-view-layout.h \
e-day-view-main-item.h \
e-day-view-time-item.h \
@@ -60,10 +34,8 @@ ecalendarinclude_HEADERS = \
e-meeting-time-sel-item.h \
e-meeting-types.h \
e-meeting-utils.h \
- e-mini-calendar-config.h \
e-select-names-editable.h \
e-select-names-renderer.h \
- e-week-view-config.h \
e-week-view-event-item.h \
e-week-view-layout.h \
e-week-view-main-item.h \
@@ -89,7 +61,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)"\" \
@@ -110,20 +81,22 @@ etspec_DATA = \
e-cal-list-view.etspec \
e-memo-table.etspec
-libevolution_cal_shared_la_SOURCES = \
+libevolution_calendar_la_SOURCES = \
cal-editor-utils.c \
cal-editor-utils.h \
- cal-search-bar.c \
- cal-search-bar.h \
calendar-config.c \
calendar-config.h \
calendar-config-keys.h \
+ calendar-view.c \
+ calendar-view.h \
+ calendar-view-factory.c \
+ calendar-view-factory.h \
comp-util.c \
comp-util.h \
e-alarm-list.c \
e-alarm-list.h \
- e-attachment-handler-calendar.c \
- e-attachment-handler-calendar.h \
+ e-cal-component-preview.c \
+ e-cal-component-preview.h \
e-cal-config.c \
e-cal-config.h \
e-cal-event.c \
@@ -132,20 +105,24 @@ libevolution_cal_shared_la_SOURCES = \
e-cal-model-calendar.h \
e-cal-model.c \
e-cal-model.h \
- e-cal-popup.h \
- e-cal-popup.c \
+ e-cal-list-view.c \
+ e-cal-list-view.h \
+ e-cal-model-memos.c \
+ e-cal-model-memos.h \
+ e-cal-model-tasks.c \
+ e-cal-model-tasks.h \
+ e-calendar-selector.c \
+ e-calendar-selector.h \
+ e-calendar-table.c \
+ e-calendar-table.h \
e-calendar-view.c \
e-calendar-view.h \
e-cell-date-edit-text.h \
e-cell-date-edit-text.c \
e-comp-editor-registry.c \
e-comp-editor-registry.h \
- e-date-edit-config.c \
- e-date-edit-config.h \
- e-date-time-list.c \
- e-date-time-list.h \
- e-day-view-config.c \
- e-day-view-config.h \
+ e-date-time-list.c \
+ e-date-time-list.h \
e-day-view-layout.c \
e-day-view-layout.h \
e-day-view-main-item.c \
@@ -156,6 +133,8 @@ libevolution_cal_shared_la_SOURCES = \
e-day-view-top-item.h \
e-day-view.c \
e-day-view.h \
+ e-itip-control.c \
+ e-itip-control.h \
e-meeting-attendee.c \
e-meeting-attendee.h \
e-meeting-list-view.c \
@@ -169,14 +148,18 @@ libevolution_cal_shared_la_SOURCES = \
e-meeting-types.h \
e-meeting-utils.c \
e-meeting-utils.h \
- e-mini-calendar-config.c \
- e-mini-calendar-config.h \
+ e-memo-list-selector.c \
+ e-memo-list-selector.h \
+ e-memo-table.c \
+ e-memo-table.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-week-view-config.c \
- e-week-view-config.h \
+ e-task-list-selector.c \
+ e-task-list-selector.h \
e-week-view-event-item.c \
e-week-view-event-item.h \
e-week-view-layout.c \
@@ -191,140 +174,63 @@ libevolution_cal_shared_la_SOURCES = \
e-timezone-entry.h \
goto.c \
goto.h \
+ gnome-cal.c \
+ gnome-cal.h \
itip-utils.c \
itip-utils.h \
misc.c \
misc.h \
+ print.c \
+ print.h \
tag-calendar.c \
tag-calendar.h \
weekday-picker.c \
- weekday-picker.h
-
-libevolution_calendar_la_SOURCES = \
- $(IDL_GENERATED) \
- 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 \
- control-factory.c \
- control-factory.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-menu.c \
- e-cal-menu.h \
- e-cal-model-tasks.c \
- e-cal-model-tasks.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-cell-date-edit-config.c \
- e-cell-date-edit-config.h \
- e-itip-control.h \
- e-itip-control.c \
- 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-tasks.c \
- e-tasks.h \
- gnome-cal.c \
- gnome-cal.h \
- itip-bonobo-control.c \
- itip-bonobo-control.h \
- main.c \
- memos-component.c \
- memos-component.h \
- memos-control.c \
- memos-control.h \
- migration.c \
- migration.h \
- print.c \
- print.h \
- tasks-component.c \
- tasks-component.h \
- tasks-control.c \
- tasks-control.h
-
-libevolution_cal_shared_la_LIBADD = \
- $(WIN32_BOOTSTRAP_LIBS) \
- $(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)/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_cal_shared_la_LDFLAGS = $(NO_UNDEFINED)
-
+ 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 = \
- $(top_builddir)/calendar/gui/libevolution-cal-shared.la \
- $(WIN32_BOOTSTRAP_LIBS) \
+ $(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)
-
-libevolution_calendar_la_DEPENDENCIES = libevolution-cal-shared.la
-
-# --- BIG NASTY AUTOMAKE HACK ---
-#
-# Automake apparently sorts Makefile.am rules alphabetically. And
-# since component_LTLIBRARIES < privsolib_LTLIBRARIES, it tries to
-# install libevolution-calendar.la before libevolution-cal-shared.la,
-# which fails when libtool tries to relink libevolution-calendar.la
-# against the not-yet-installed libevolution-cal-shared.la.
-install-data-am: \
- install-privsolibLTLIBRARIES \
- install-componentLTLIBRARIES \
- install-data-local \
- install-etspecDATA \
- install-gladeDATA \
- install-schemaDATA \
- install-ruleDATA \
- install-ecalendarincludeHEADERS \
- install-serverDATA
+libevolution_calendar_la_LDFLAGS = $(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
@@ -339,10 +245,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/Makefile.am b/calendar/gui/alarm-notify/Makefile.am
index 680c5e95e5..ea1c36e0d9 100644
--- a/calendar/gui/alarm-notify/Makefile.am
+++ b/calendar/gui/alarm-notify/Makefile.am
@@ -25,7 +25,8 @@ AM_CPPFLAGS = \
-DEVOLUTION_GLADEDIR=\""$(gladedir)"\" \
-DEVOLUTION_LOCALEDIR=\""$(localedir)"\" \
-DEVOLUTION_LIBEXECDIR=\""$(privlibexecdir)"\" \
- $(EVOLUTION_CALENDAR_CFLAGS)
+ $(EVOLUTION_CALENDAR_CFLAGS) \
+ $(CANBERRA_CFLAGS)
glade_DATA = \
alarm-notify.glade
@@ -51,7 +52,8 @@ evolution_alarm_notify_LDADD = \
$(top_builddir)/widgets/misc/libemiscwidgets.la \
$(top_builddir)/calendar/common/libevolution-calendarprivate.la \
$(CAMEL_LIBS) \
- $(EVOLUTION_CALENDAR_LIBS)
+ $(EVOLUTION_CALENDAR_LIBS) \
+ $(CANBERRA_LIBS)
if OS_WIN32
evolution_alarm_notify_LDFLAGS = -mwindows
diff --git a/calendar/gui/alarm-notify/alarm-queue.c b/calendar/gui/alarm-notify/alarm-queue.c
index 99e9a4f8e5..ef6e77d386 100644
--- a/calendar/gui/alarm-notify/alarm-queue.c
+++ b/calendar/gui/alarm-notify/alarm-queue.c
@@ -34,7 +34,7 @@
#include <bonobo/bonobo-main.h>
#include <gtk/gtk.h>
#include <glib/gi18n.h>
-#include <libgnome/gnome-sound.h>
+#include <canberra-gtk.h>
#include <libecal/e-cal-time-util.h>
#include <libecal/e-cal-component.h>
@@ -50,7 +50,6 @@
#include "alarm-notify.h"
#include "config-data.h"
#include "util.h"
-#include "e-util/e-popup.h"
#include "e-util/e-error.h"
#define d(x)
@@ -896,6 +895,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;
@@ -939,6 +939,7 @@ edit_component (ECal *client, ECalComponent *comp)
/* Get rid of the factory */
bonobo_object_release_unref (factory, NULL);
+#endif
}
typedef struct {
@@ -1640,13 +1641,23 @@ audio_notification (time_t trigger, CompQueuedAlarms *cqa,
if (attach && icalattach_get_is_url (attach)) {
const gchar *url;
+ gchar *filename;
+ GError *error = NULL;
url = icalattach_get_url (attach);
+ filename = g_filename_from_uri (url, NULL, &error);
- if (url && *url && g_file_test (url, G_FILE_TEST_EXISTS)) {
+ if (error != NULL) {
+ g_warning ("%s", error->message);
+ g_error_free (error);
+ } else if (g_file_test (filename, G_FILE_TEST_EXISTS)) {
flag = 1;
- gnome_sound_play (url); /* this sucks */
+ ca_context_play (
+ ca_gtk_context_get(), 0,
+ CA_PROP_MEDIA_FILENAME, filename, NULL);
}
+
+ g_free (filename);
}
if (!flag)
diff --git a/calendar/gui/alarm-notify/notify-main.c b/calendar/gui/alarm-notify/notify-main.c
index 887adaa1d5..b3ff0db6a5 100644
--- a/calendar/gui/alarm-notify/notify-main.c
+++ b/calendar/gui/alarm-notify/notify-main.c
@@ -31,7 +31,6 @@
#include <gtk/gtk.h>
#include <glib/gi18n.h>
#include <libgnome/gnome-init.h>
-#include <libgnome/gnome-sound.h>
#include <libgnomeui/gnome-client.h>
#include <libgnomeui/gnome-ui-init.h>
#include <glade/glade.h>
@@ -48,8 +47,6 @@
#include "config-data.h"
#include <camel/camel-object.h>
-
-
static BonoboGenericFactory *factory;
static AlarmNotify *alarm_notify_service = NULL;
@@ -142,8 +139,6 @@ main (gint argc, gchar **argv)
glade_init ();
- gnome_sound_init ("localhost");
-
e_icon_factory_init ();
init_alarm_service (NULL);
@@ -173,7 +168,6 @@ main (gint argc, gchar **argv)
alarm_done ();
e_passwords_shutdown ();
- gnome_sound_shutdown ();
return 0;
}
diff --git a/calendar/gui/apps_evolution_calendar.schemas.in b/calendar/gui/apps_evolution_calendar.schemas.in
index 210a6fc159..b232c60cce 100644
--- a/calendar/gui/apps_evolution_calendar.schemas.in
+++ b/calendar/gui/apps_evolution_calendar.schemas.in
@@ -279,16 +279,91 @@
</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>
</locale>
</schema>
+
+ <schema>
+ <key>/schemas/apps/evolution/calendar/display/memo_layout</key>
+ <applyto>/apps/evolution/calendar/display/memo_layout</applyto>
+ <type>int</type>
+ <default>0</default>
+ <locale name="C">
+ <short>Memo layout style</short>
+ <long>
+ The layout style determines where to place the preview pane
+ in relation to the memo list. "0" (Classic View) places the
+ preview pane below the memo list. "1" (Vertical View) places
+ the preview pane next to the memo list.
+ </long>
+ </locale>
+ </schema>
+
+ <schema>
+ <key>/schemas/apps/evolution/calendar/display/show_memo_preview</key>
+ <applyto>/apps/evolution/calendar/display/show_memo_preview</applyto>
+ <owner>evolution-calendar</owner>
+ <type>bool</type>
+ <default>true</default>
+ <locale name="C">
+ <short>Show the memo preview pane</short>
+ <long>
+ If "true", show the memo preview pane in the main window.
+ </long>
+ </locale>
+ </schema>
+
+ <schema>
+ <key>/schemas/apps/evolution/calendar/display/memo_hpane_position</key>
+ <applyto>/apps/evolution/calendar/display/memo_hpane_position</applyto>
+ <owner>evolution-calendar</owner>
+ <type>int</type>
+ <default>200</default>
+ <locale name="C">
+ <short>Memo preview pane position (horizontal)</short>
+ <long>
+ Position of the task preview pane when oriented horizontally.
+ </long>
+ </locale>
+ </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>Memo preview pane position (vertical)</short>
+ <long>
+ Position of the memo preview pane when oriented vertically.
+ </long>
+ </locale>
+ </schema>
+
+ <schema>
+ <key>/schemas/apps/evolution/calendar/display/task_layout</key>
+ <applyto>/apps/evolution/calendar/display/task_layout</applyto>
+ <type>int</type>
+ <default>0</default>
+ <locale name="C">
+ <short>Task layout style</short>
+ <long>
+ The layout style determines where to place the preview pane
+ in relation to the task list. "0" (Classic View) places the
+ preview pane below the task list. "1" (Vertical View) places
+ the preview pane next to the task list.
+ </long>
+ </locale>
+ </schema>
+
<schema>
<key>/schemas/apps/evolution/calendar/display/show_task_preview</key>
<applyto>/apps/evolution/calendar/display/show_task_preview</applyto>
@@ -296,22 +371,38 @@
<type>bool</type>
<default>true</default>
<locale name="C">
- <short>Show the "Preview" pane</short>
+ <short>Show the task preview pane</short>
<long>
- Show the "Preview" pane.
+ If "true", show the task preview pane in the main window.
</long>
</locale>
</schema>
<schema>
+ <key>/schemas/apps/evolution/calendar/display/task_hpane_position</key>
+ <applyto>/apps/evolution/calendar/display/task_hpane_position</applyto>
+ <owner>evolution-calendar</owner>
+ <type>int</type>
+ <default>200</default>
+ <locale name="C">
+ <short>Task preview pane position (horizontal)</short>
+ <long>
+ Position of the task preview pane when oriented horizontally.
+ </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>
- <long>Position of the vertical pane, between the task list and the task preview pane, in pixels.</long>
+ <short>Task preview pane position (vertical)</short>
+ <long>
+ Position of the task preview pane when oriented vertically.
+ </long>
</locale>
</schema>
diff --git a/calendar/gui/cal-editor-utils.c b/calendar/gui/cal-editor-utils.c
index ece9abe532..0da7ca2af9 100644
--- a/calendar/gui/cal-editor-utils.c
+++ b/calendar/gui/cal-editor-utils.c
@@ -47,14 +47,19 @@ extern ECompEditorRegistry *comp_editor_registry;
* It blocks until finished and should be called in the main thread.
**/
void
-open_component_editor (ECal *client, ECalComponent *comp, gboolean is_new, GError **error)
+open_component_editor (EShell *shell,
+ ECal *client,
+ ECalComponent *comp,
+ gboolean is_new,
+ GError **error)
{
ECalComponentId *id;
CompEditorFlags flags = 0;
CompEditor *editor = NULL;
- g_return_if_fail (client != NULL);
- g_return_if_fail (comp != NULL);
+ g_return_if_fail (E_IS_SHELL (shell));
+ g_return_if_fail (E_IS_CAL (client));
+ g_return_if_fail (E_IS_CAL_COMPONENT (comp));
id = e_cal_component_get_id (comp);
g_return_if_fail (id != NULL);
@@ -63,7 +68,7 @@ open_component_editor (ECal *client, ECalComponent *comp, gboolean is_new, GErro
if (is_new) {
flags |= COMP_EDITOR_NEW_ITEM;
} else {
- editor = e_comp_editor_registry_find (comp_editor_registry, id->uid);
+ editor = comp_editor_find_instance (id->uid);
}
if (!editor) {
@@ -75,7 +80,7 @@ open_component_editor (ECal *client, ECalComponent *comp, gboolean is_new, GErro
if (e_cal_component_has_attendees (comp))
flags |= COMP_EDITOR_MEETING;
- editor = event_editor_new (client, flags);
+ editor = event_editor_new (client, shell, flags);
if (flags & COMP_EDITOR_MEETING)
event_editor_show_meeting (EVENT_EDITOR (editor));
@@ -84,7 +89,7 @@ open_component_editor (ECal *client, ECalComponent *comp, gboolean is_new, GErro
if (e_cal_component_has_attendees (comp))
flags |= COMP_EDITOR_IS_ASSIGNED;
- editor = task_editor_new (client, flags);
+ editor = task_editor_new (client, shell, flags);
if (flags & COMP_EDITOR_IS_ASSIGNED)
task_editor_show_assignment (TASK_EDITOR (editor));
@@ -93,7 +98,7 @@ open_component_editor (ECal *client, ECalComponent *comp, gboolean is_new, GErro
if (e_cal_component_has_organizer (comp))
flags |= COMP_EDITOR_IS_SHARED;
- editor = memo_editor_new (client, flags);
+ editor = memo_editor_new (client, shell, flags);
break;
default:
if (error)
@@ -106,8 +111,6 @@ open_component_editor (ECal *client, ECalComponent *comp, gboolean is_new, GErro
/* request save for new events */
comp_editor_set_changed (editor, is_new);
-
- e_comp_editor_registry_add (comp_editor_registry, editor, TRUE);
}
}
diff --git a/calendar/gui/cal-editor-utils.h b/calendar/gui/cal-editor-utils.h
index de37367756..211684eb20 100644
--- a/calendar/gui/cal-editor-utils.h
+++ b/calendar/gui/cal-editor-utils.h
@@ -17,17 +17,22 @@
*
*/
-#ifndef CAL_EDITOR_UTILS_HEADER
-#define CAL_EDITOR_UTILS_HEADER
+#ifndef CAL_EDITOR_UTILS_H
+#define CAL_EDITOR_UTILS_H
#include <glib.h>
#include <libecal/e-cal.h>
#include <libecal/e-cal-component.h>
+#include <shell/e-shell.h>
G_BEGIN_DECLS
-void open_component_editor (ECal *client, ECalComponent *comp, gboolean is_new, GError **error);
+void open_component_editor (EShell *shell,
+ ECal *client,
+ ECalComponent *comp,
+ gboolean is_new,
+ GError **error);
G_END_DECLS
-#endif
+#endif /* CAL_EDITOR_UTILS_H */
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 f91442a109..6368857ead 100644
--- a/calendar/gui/calendar-commands.c
+++ b/calendar/gui/calendar-commands.c
@@ -66,71 +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);
-
- if (gnome_calendar_get_view (gcal) == GNOME_CAL_MONTH_VIEW) {
- EWeekView *week_view = E_WEEK_VIEW (gnome_calendar_get_current_view_widget (gcal));
-
- if (week_view && week_view->multi_week_view && week_view->weeks_shown >= 4 && g_date_valid (&week_view->first_day_shown)) {
- GDate date = week_view->first_day_shown;
- struct icaltimetype start_tt = icaltime_null_time ();
-
- g_date_add_days (&date, 7);
-
- start_tt.is_date = TRUE;
- start_tt.year = g_date_get_year (&date);
- start_tt.month = g_date_get_month (&date);
- start_tt.day = g_date_get_day (&date);
-
- start = icaltime_as_timet (start_tt);
- }
- }
-
- 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)
@@ -152,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;
@@ -253,113 +136,6 @@ show_list_view_clicked (BonoboUIComponent *uic, gpointer data, const gchar *path
gnome_calendar_set_view (gcal, GNOME_CAL_LIST_VIEW);
}
-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;
- GtkWidget *dialog, *parent, *box, *label, *spin;
- gint response;
-
- gcal = GNOME_CALENDAR (data);
-
- /* create the dialog */
- parent = gtk_widget_get_toplevel (GTK_WIDGET (gcal));
- dialog = gtk_message_dialog_new (
- (GtkWindow *)parent,
- GTK_DIALOG_DESTROY_WITH_PARENT,
- GTK_MESSAGE_WARNING,
- GTK_BUTTONS_OK_CANCEL,
- _("This operation will permanently erase all events older than the selected amount of time. If you continue, you will not be able to recover these events."));
- gtk_dialog_set_default_response (GTK_DIALOG (dialog), GTK_RESPONSE_CANCEL);
-
- box = gtk_hbox_new (FALSE, 6);
- gtk_box_pack_start (GTK_BOX (GTK_DIALOG (dialog)->vbox), box, TRUE, FALSE, 6);
-
- label = gtk_label_new (_("Purge events older than"));
- gtk_box_pack_start (GTK_BOX (box), label, TRUE, FALSE, 6);
- spin = gtk_spin_button_new_with_range (0.0, 1000.0, 1.0);
- gtk_spin_button_set_value (GTK_SPIN_BUTTON (spin), 60.0);
- gtk_box_pack_start (GTK_BOX (box), spin, FALSE, FALSE, 6);
- label = gtk_label_new (_("days"));
- gtk_box_pack_start (GTK_BOX (box), label, TRUE, FALSE, 6);
-
- gtk_widget_show_all (box);
-
- /* run the dialog */
- response = gtk_dialog_run (GTK_DIALOG (dialog));
- if (response == GTK_RESPONSE_OK) {
- gint days;
- time_t tt;
-
- days = gtk_spin_button_get_value_as_int (GTK_SPIN_BUTTON (spin));
- tt = time (NULL);
- tt -= (days * (24 * 3600));
-
- gnome_calendar_purge (gcal, tt);
- }
-
- gtk_widget_destroy (dialog);
-}
-
struct _sensitize_item {
const gchar *command;
guint32 enable;
@@ -384,69 +160,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 | E_CAL_MENU_SELECT_ANY },
- { "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 = ~((~t->target.mask) & E_CAL_MENU_SELECT_EDITABLE);
-
- 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 | E_CAL_MENU_SELECT_ANY },
{ "Copy", E_CAL_MENU_SELECT_ANY },
@@ -574,21 +287,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),
@@ -596,40 +294,10 @@ static BonoboUIVerb verbs [] = {
BONOBO_UI_VERB ("ShowMonthView", show_month_view_clicked),
BONOBO_UI_VERB ("ShowListView", show_list_view_clicked),
- BONOBO_UI_VERB ("CalendarPurge", purge_cmd),
BONOBO_UI_VERB ("HelpDebug", help_debug),
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)
@@ -661,8 +329,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..e9629c70ee 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)
{
@@ -930,8 +337,7 @@ impl_handleURI (PortableServer_Servant servant, const gchar *uri, CORBA_Environm
if (start != -1) {
if (end == -1)
- end = start;
- gnome_calendar_set_selected_time_range (view->calendar, start, end);
+ gnome_calendar_set_selected_time_range (view->calendar, start);
}
if (src_uid && uid)
gnome_calendar_edit_appointment (view->calendar, src_uid, uid, rid);
@@ -945,84 +351,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 +448,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 +471,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 +542,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 +594,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 +628,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 +642,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 +674,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 +684,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 +695,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 +705,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 7210e83834..9afa8dc7e4 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 9262836d32..3208fb5f5b 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"
@@ -155,85 +156,33 @@ 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)
+static gchar *
+calendar_config_get_timezone_stored (void)
{
calendar_config_init ();
- return gconf_client_get_bool (config, CALENDAR_CONFIG_USE_SYSTEM_TIMEZONE, NULL);
+ return gconf_client_get_string (config, CALENDAR_CONFIG_TIMEZONE, NULL);
}
-void
-calendar_config_set_use_system_timezone (gboolean use)
+static gchar *
+calendar_config_get_timezone (void)
{
- 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);
+ EShell *shell;
+ EShellSettings *shell_settings;
+ gboolean use_system_timezone;
- /* FIXME: notify CALENDAR_CONFIG_TIMEZONE change on system timezone change
- itself too, when using system timezone. How to receive such change? */
- }
-}
+ shell = e_shell_get_default ();
+ shell_settings = e_shell_get_shell_settings (shell);
-guint
-calendar_config_add_notification_use_system_timezone (GConfClientNotifyFunc func, gpointer data)
-{
- calendar_config_init ();
+ use_system_timezone = e_shell_settings_get_boolean (
+ shell_settings, "cal-use-system-timezone");
- 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 ())
+ if (use_system_timezone)
return e_cal_util_get_system_timezone_location ();
return calendar_config_get_timezone_stored ();
}
-gchar *
-calendar_config_get_timezone_stored (void)
-{
- calendar_config_init ();
-
- return gconf_client_get_string (config, CALENDAR_CONFIG_TIMEZONE, NULL);
-}
-
icaltimezone *
calendar_config_get_icaltimezone (void)
{
@@ -251,31 +200,6 @@ calendar_config_get_icaltimezone (void)
return zone;
}
-/* Sets the timezone. If set to NULL it defaults to UTC.
- FIXME: Should check it is being set to a valid timezone. */
-void
-calendar_config_set_timezone (const gchar *timezone)
-{
- calendar_config_init ();
-
- if (timezone && timezone[0])
- gconf_client_set_string (config, CALENDAR_CONFIG_TIMEZONE, timezone, NULL);
- else
- gconf_client_set_string (config, CALENDAR_CONFIG_TIMEZONE, "UTC", NULL);
-}
-
-guint
-calendar_config_add_notification_timezone (GConfClientNotifyFunc func, gpointer data)
-{
- guint id;
-
- calendar_config_init ();
-
- id = gconf_client_notify_add (config, CALENDAR_CONFIG_TIMEZONE, func, data, NULL, NULL);
-
- return id;
-}
-
/* Whether we use 24-hour format or 12-hour format (AM/PM). */
gboolean
calendar_config_get_24_hour_format (void)
@@ -292,126 +216,6 @@ calendar_config_get_24_hour_format (void)
return TRUE;
}
-void
-calendar_config_set_24_hour_format (gboolean use_24_hour)
-{
- calendar_config_init ();
-
- gconf_client_set_bool (config, CALENDAR_CONFIG_24HOUR, use_24_hour, NULL);
-}
-
-guint
-calendar_config_add_notification_24_hour_format (GConfClientNotifyFunc func, gpointer data)
-{
- guint id;
-
- calendar_config_init ();
-
- id = gconf_client_notify_add (config, CALENDAR_CONFIG_24HOUR, func, data, NULL, NULL);
-
- 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)
@@ -421,26 +225,6 @@ calendar_config_get_week_start_day (void)
return gconf_client_get_int (config, CALENDAR_CONFIG_WEEK_START, NULL);
}
-void
-calendar_config_set_week_start_day (gint week_start_day)
-{
- calendar_config_init ();
-
- gconf_client_set_int (config, CALENDAR_CONFIG_WEEK_START, week_start_day, NULL);
-}
-
-guint
-calendar_config_add_notification_week_start_day (GConfClientNotifyFunc func, gpointer data)
-{
- guint id;
-
- calendar_config_init ();
-
- id = gconf_client_notify_add (config, CALENDAR_CONFIG_WEEK_START, func, data, NULL, NULL);
-
- return id;
-}
-
/* The start and end times of the work-day. */
gint
calendar_config_get_day_start_hour (void)
@@ -458,18 +242,6 @@ calendar_config_set_day_start_hour (gint day_start_hour)
gconf_client_set_int (config, CALENDAR_CONFIG_DAY_START_HOUR, day_start_hour, NULL);
}
-guint
-calendar_config_add_notification_day_start_hour (GConfClientNotifyFunc func, gpointer data)
-{
- guint id;
-
- calendar_config_init ();
-
- id = gconf_client_notify_add (config, CALENDAR_CONFIG_DAY_START_HOUR, func, data, NULL, NULL);
-
- return id;
-}
-
gint
calendar_config_get_day_start_minute (void)
{
@@ -486,18 +258,6 @@ calendar_config_set_day_start_minute (gint day_start_min)
gconf_client_set_int (config, CALENDAR_CONFIG_DAY_START_MINUTE, day_start_min, NULL);
}
-guint
-calendar_config_add_notification_day_start_minute (GConfClientNotifyFunc func, gpointer data)
-{
- guint id;
-
- calendar_config_init ();
-
- id = gconf_client_notify_add (config, CALENDAR_CONFIG_DAY_START_MINUTE, func, data, NULL, NULL);
-
- return id;
-}
-
gint
calendar_config_get_day_end_hour (void)
{
@@ -514,18 +274,6 @@ calendar_config_set_day_end_hour (gint day_end_hour)
gconf_client_set_int (config, CALENDAR_CONFIG_DAY_END_HOUR, day_end_hour, NULL);
}
-guint
-calendar_config_add_notification_day_end_hour (GConfClientNotifyFunc func, gpointer data)
-{
- guint id;
-
- calendar_config_init ();
-
- id = gconf_client_notify_add (config, CALENDAR_CONFIG_DAY_END_HOUR, func, data, NULL, NULL);
-
- return id;
-}
-
gint
calendar_config_get_day_end_minute (void)
{
@@ -542,18 +290,6 @@ calendar_config_set_day_end_minute (gint day_end_min)
gconf_client_set_int (config, CALENDAR_CONFIG_DAY_END_MINUTE, day_end_min, NULL);
}
-guint
-calendar_config_add_notification_day_end_minute (GConfClientNotifyFunc func, gpointer data)
-{
- guint id;
-
- calendar_config_init ();
-
- id = gconf_client_notify_add (config, CALENDAR_CONFIG_DAY_END_MINUTE, func, data, NULL, NULL);
-
- return id;
-}
-
/* The time divisions in the Day/Work-Week view in minutes (5/10/15/30/60). */
gint
calendar_config_get_time_divisions (void)
@@ -612,66 +348,6 @@ calendar_config_add_notification_month_scroll_by_week (GConfClientNotifyFunc fun
return id;
}
-/* Whether we show the Marcus Bains Line (current time), and in what colors. */
-void
-calendar_config_get_marcus_bains (gboolean *show_line, const gchar **dayview_color, const gchar **timebar_color)
-{
- static gchar *dcolor = NULL, *tcolor = NULL;
-
- calendar_config_init ();
-
- if (dcolor)
- g_free (dcolor);
- if (tcolor)
- g_free (tcolor);
-
- dcolor = gconf_client_get_string (config, CALENDAR_CONFIG_MARCUS_BAINS_COLOR_DAYVIEW, NULL);
- tcolor = gconf_client_get_string (config, CALENDAR_CONFIG_MARCUS_BAINS_COLOR_TIMEBAR, NULL);
-
- *show_line = gconf_client_get_bool (config, CALENDAR_CONFIG_MARCUS_BAINS_LINE, NULL);
- *dayview_color = dcolor;
- *timebar_color = tcolor;
-}
-
-void
-calendar_config_add_notification_marcus_bains (GConfClientNotifyFunc func, gpointer data, gint *not_show, gint *not_dcolor, gint *not_tcolor)
-{
- calendar_config_init ();
-
- *not_show = gconf_client_notify_add (config, CALENDAR_CONFIG_MARCUS_BAINS_LINE, func, data, NULL, NULL);
- *not_dcolor = gconf_client_notify_add (config, CALENDAR_CONFIG_MARCUS_BAINS_COLOR_DAYVIEW, func, data, NULL, NULL);
- *not_tcolor = gconf_client_notify_add (config, CALENDAR_CONFIG_MARCUS_BAINS_COLOR_TIMEBAR, func, data, NULL, NULL);
-}
-
-/* Whether we show week number in the Day View. */
-gboolean
-calendar_config_get_dview_show_week_no (void)
-{
- calendar_config_init ();
-
- return gconf_client_get_bool (config, CALENDAR_CONFIG_DV_WEEK_NUMBER, NULL);
-}
-
-void
-calendar_config_set_dview_show_week_no (gboolean show_week_no)
-{
- calendar_config_init ();
-
- gconf_client_set_bool (config, CALENDAR_CONFIG_DV_WEEK_NUMBER, show_week_no, NULL);
-}
-
-guint
-calendar_config_add_notification_dview_show_week_no (GConfClientNotifyFunc func, gpointer data)
-{
- guint id;
-
- calendar_config_init ();
-
- id = gconf_client_notify_add (config, CALENDAR_CONFIG_DV_WEEK_NUMBER, func, data, NULL, NULL);
-
- return id;
-}
-
/* Whether we show week numbers in the Date Navigator. */
gboolean
calendar_config_get_dnav_show_week_no (void)
@@ -681,14 +357,6 @@ calendar_config_get_dnav_show_week_no (void)
return gconf_client_get_bool (config, CALENDAR_CONFIG_DN_SHOW_WEEK_NUMBERS, NULL);
}
-void
-calendar_config_set_dnav_show_week_no (gboolean show_week_no)
-{
- calendar_config_init ();
-
- gconf_client_set_bool (config, CALENDAR_CONFIG_DN_SHOW_WEEK_NUMBERS, show_week_no, NULL);
-}
-
guint
calendar_config_add_notification_dnav_show_week_no (GConfClientNotifyFunc func, gpointer data)
{
@@ -702,14 +370,6 @@ calendar_config_add_notification_dnav_show_week_no (GConfClientNotifyFunc func,
}
/* The positions of the panes in the normal and month views. */
-gint
-calendar_config_get_hpane_pos (void)
-{
- calendar_config_init ();
-
- return gconf_client_get_int (config, CALENDAR_CONFIG_HPANE_POS, NULL);
-}
-
void
calendar_config_set_hpane_pos (gint hpane_pos)
{
@@ -718,58 +378,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)
-{
- calendar_config_init ();
-
- return gconf_client_get_bool (config, CALENDAR_CONFIG_TASK_PREVIEW, NULL);
-}
-
-void
-calendar_config_set_preview_state (gboolean state)
-{
- calendar_config_init ();
-
- gconf_client_set_bool (config, CALENDAR_CONFIG_TASK_PREVIEW, state, NULL);
-}
-
-guint
-calendar_config_add_notification_preview_state (GConfClientNotifyFunc func, gpointer data)
-{
- guint id;
-
- calendar_config_init ();
-
- id = gconf_client_notify_add (config, CALENDAR_CONFIG_TASK_PREVIEW, func, data, NULL, NULL);
-
- return id;
-}
-
-gint
-calendar_config_get_month_hpane_pos (void)
-{
- calendar_config_init ();
-
- return gconf_client_get_int (config, CALENDAR_CONFIG_MONTH_HPANE_POS, NULL);
-}
-
void
calendar_config_set_month_hpane_pos (gint hpane_pos)
{
@@ -778,38 +386,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)
-{
- calendar_config_init ();
-
- return gconf_client_get_float (config, CALENDAR_CONFIG_TAG_VPANE_POS, NULL);
-}
-
-void
-calendar_config_set_tag_vpane_pos (gfloat vpane_pos)
-{
- calendar_config_init ();
-
- gconf_client_set_float (config, CALENDAR_CONFIG_TAG_VPANE_POS, vpane_pos, NULL);
-}
-
/* The current list of task lists selected */
GSList *
calendar_config_get_tasks_selected (void)
@@ -839,51 +415,6 @@ calendar_config_add_notification_tasks_selected (GConfClientNotifyFunc func, gpo
return id;
}
-/* The primary task list */
-gchar *
-calendar_config_get_primary_tasks (void)
-{
- calendar_config_init ();
-
- return gconf_client_get_string (config, CALENDAR_CONFIG_PRIMARY_TASKS, NULL);
-}
-
-void
-calendar_config_set_primary_tasks (const gchar *primary_uid)
-{
- calendar_config_init ();
-
- gconf_client_set_string (config, CALENDAR_CONFIG_PRIMARY_TASKS, primary_uid, NULL);
-}
-
-guint
-calendar_config_add_notification_primary_tasks (GConfClientNotifyFunc func, gpointer data)
-{
- guint id;
-
- calendar_config_init ();
-
- id = gconf_client_notify_add (config, CALENDAR_CONFIG_PRIMARY_TASKS, func, data, NULL, NULL);
-
- return id;
-}
-
-gint
-calendar_config_get_task_vpane_pos (void)
-{
- calendar_config_init ();
-
- return gconf_client_get_int (config, CALENDAR_CONFIG_TASK_VPANE_POS, NULL);
-}
-
-void
-calendar_config_set_task_vpane_pos (gint vpane_pos)
-{
- calendar_config_init ();
-
- gconf_client_set_int (config, CALENDAR_CONFIG_TASK_VPANE_POS, vpane_pos, NULL);
-}
-
/***************************************/
/* The current list of memo lists selected */
@@ -915,34 +446,6 @@ calendar_config_add_notification_memos_selected (GConfClientNotifyFunc func, gpo
return id;
}
-/* The primary memo list */
-gchar *
-calendar_config_get_primary_memos (void)
-{
- calendar_config_init ();
-
- return gconf_client_get_string (config, CALENDAR_CONFIG_PRIMARY_MEMOS, NULL);
-}
-
-void
-calendar_config_set_primary_memos (const gchar *primary_uid)
-{
- calendar_config_init ();
-
- gconf_client_set_string (config, CALENDAR_CONFIG_PRIMARY_MEMOS, primary_uid, NULL);
-}
-
-guint
-calendar_config_add_notification_primary_memos (GConfClientNotifyFunc func, gpointer data)
-{
- guint id;
-
- calendar_config_init ();
-
- id = gconf_client_notify_add (config, CALENDAR_CONFIG_PRIMARY_MEMOS, func, data, NULL, NULL);
-
- return id;
-}
/***************************************/
/* Whether we compress the weekend in the week/month views. */
@@ -954,55 +457,6 @@ calendar_config_get_compress_weekend (void)
return gconf_client_get_bool (config, CALENDAR_CONFIG_COMPRESS_WEEKEND, NULL);
}
-void
-calendar_config_set_compress_weekend (gboolean compress)
-{
- calendar_config_init ();
-
- gconf_client_set_bool (config, CALENDAR_CONFIG_COMPRESS_WEEKEND, compress, NULL);
-}
-
-guint
-calendar_config_add_notification_compress_weekend (GConfClientNotifyFunc func, gpointer data)
-{
- guint id;
-
- calendar_config_init ();
-
- id = gconf_client_notify_add (config, CALENDAR_CONFIG_COMPRESS_WEEKEND, func, data, NULL, NULL);
-
- return id;
-}
-
-/* Whether we show event end times. */
-gboolean
-calendar_config_get_show_event_end (void)
-{
- calendar_config_init ();
-
- return gconf_client_get_bool (config, CALENDAR_CONFIG_SHOW_EVENT_END, NULL);
-}
-
-void
-calendar_config_set_show_event_end (gboolean show_end)
-{
- calendar_config_init ();
-
- gconf_client_set_bool (config, CALENDAR_CONFIG_SHOW_EVENT_END, show_end, NULL);
-}
-
-guint
-calendar_config_add_notification_show_event_end (GConfClientNotifyFunc func, gpointer data)
-{
- guint id;
-
- calendar_config_init ();
-
- id = gconf_client_notify_add (config, CALENDAR_CONFIG_SHOW_EVENT_END, func, data, NULL, NULL);
-
- return id;
-}
-
/* The working days of the week, a bit-wise combination of flags. */
CalWeekdays
calendar_config_get_working_days (void)
@@ -1012,14 +466,6 @@ calendar_config_get_working_days (void)
return gconf_client_get_int (config, CALENDAR_CONFIG_WORKING_DAYS, NULL);
}
-void
-calendar_config_set_working_days (CalWeekdays days)
-{
- calendar_config_init ();
-
- gconf_client_set_int (config, CALENDAR_CONFIG_WORKING_DAYS, days, NULL);
-}
-
guint
calendar_config_add_notification_working_days (GConfClientNotifyFunc func, gpointer data)
{
@@ -1049,18 +495,6 @@ calendar_config_set_hide_completed_tasks (gboolean hide)
gconf_client_set_bool (config, CALENDAR_CONFIG_TASKS_HIDE_COMPLETED, hide, NULL);
}
-guint
-calendar_config_add_notification_hide_completed_tasks (GConfClientNotifyFunc func, gpointer data)
-{
- guint id;
-
- calendar_config_init ();
-
- id = gconf_client_notify_add (config, CALENDAR_CONFIG_TASKS_HIDE_COMPLETED , func, data, NULL, NULL);
-
- return id;
-}
-
CalUnits
calendar_config_get_hide_completed_tasks_units (void)
{
@@ -1106,18 +540,6 @@ calendar_config_set_hide_completed_tasks_units (CalUnits cu)
g_free (units);
}
-guint
-calendar_config_add_notification_hide_completed_tasks_units (GConfClientNotifyFunc func, gpointer data)
-{
- guint id;
-
- calendar_config_init ();
-
- id = gconf_client_notify_add (config, CALENDAR_CONFIG_TASKS_HIDE_COMPLETED_UNITS , func, data, NULL, NULL);
-
- return id;
-}
-
gint
calendar_config_get_hide_completed_tasks_value (void)
{
@@ -1134,18 +556,6 @@ calendar_config_set_hide_completed_tasks_value (gint value)
gconf_client_set_int (config, CALENDAR_CONFIG_TASKS_HIDE_COMPLETED_VALUE, value, NULL);
}
-guint
-calendar_config_add_notification_hide_completed_tasks_value (GConfClientNotifyFunc func, gpointer data)
-{
- guint id;
-
- calendar_config_init ();
-
- id = gconf_client_notify_add (config, CALENDAR_CONFIG_TASKS_HIDE_COMPLETED_VALUE , func, data, NULL, NULL);
-
- return id;
-}
-
/**
* calendar_config_get_confirm_delete:
*
@@ -1163,162 +573,6 @@ calendar_config_get_confirm_delete (void)
}
/**
- * calendar_config_set_confirm_delete:
- * @confirm: Whether confirmation is required when deleting items.
- *
- * Sets the configuration value for whether a confirmation dialog is presented
- * when deleting calendar/tasks items.
- **/
-void
-calendar_config_set_confirm_delete (gboolean confirm)
-{
- calendar_config_init ();
-
- gconf_client_set_bool (config, CALENDAR_CONFIG_PROMPT_DELETE, confirm, NULL);
-}
-
-/**
- * calendar_config_get_confirm_purge:
- *
- * Queries the configuration value for whether a confirmation dialog is
- * presented when purging calendar/tasks items.
- *
- * Return value: Whether confirmation is required when purging items.
- **/
-gboolean
-calendar_config_get_confirm_purge (void)
-{
- calendar_config_init ();
-
- return gconf_client_get_bool (config, CALENDAR_CONFIG_PROMPT_PURGE, NULL);
-}
-
-/**
- * calendar_config_set_confirm_purge:
- * @confirm: Whether confirmation is required when purging items.
- *
- * Sets the configuration value for whether a confirmation dialog is presented
- * when purging calendar/tasks items.
- **/
-void
-calendar_config_set_confirm_purge (gboolean confirm)
-{
- calendar_config_init ();
-
- gconf_client_set_bool (config, CALENDAR_CONFIG_PROMPT_PURGE, confirm, NULL);
-}
-
-/**
- * calendar_config_get_tasks_due_today_color:
- * @color: the location to store the color
- *
- * Queries the color to be used to display tasks that are due today.
- **/
-void
-calendar_config_get_tasks_due_today_color (GdkColor *color)
-{
- const gchar *key = CALENDAR_CONFIG_TASKS_DUE_TODAY_COLOR;
- GError *error = NULL;
- gchar *color_spec;
-
- g_return_if_fail (color != NULL);
-
- calendar_config_init ();
-
- color_spec = gconf_client_get_string (config, key, &error);
-
- if (color_spec != NULL && !gdk_color_parse (color_spec, color))
- g_warning ("Unknown color \"%s\"", color_spec);
- else if (error != NULL) {
- g_warning ("%s", error->message);
- g_error_free (error);
- }
-
- g_free (color_spec);
-}
-
-/**
- * calendar_config_set_tasks_due_today_color:
- * @color: a #GdkColor
- *
- * Sets the color to be used to display tasks that are due today.
- **/
-void
-calendar_config_set_tasks_due_today_color (GdkColor *color)
-{
- const gchar *key = CALENDAR_CONFIG_TASKS_DUE_TODAY_COLOR;
- GError *error = NULL;
- gchar color_spec[16];
-
- g_return_if_fail (color != NULL);
-
- g_snprintf (color_spec, sizeof (color_spec), "#%04x%04x%04x",
- color->red, color->green, color->blue);
-
- calendar_config_init ();
-
- if (!gconf_client_set_string (config, key, color_spec, &error)) {
- g_warning ("%s", error->message);
- g_error_free (error);
- }
-}
-
-/**
- * calendar_config_get_tasks_overdue_color:
- * @color: the location to store the color
- *
- * Queries the color to be used to display overdue tasks.
- **/
-void
-calendar_config_get_tasks_overdue_color (GdkColor *color)
-{
- const gchar *key = CALENDAR_CONFIG_TASKS_OVERDUE_COLOR;
- GError *error = NULL;
- gchar *color_spec;
-
- g_return_if_fail (color != NULL);
-
- calendar_config_init ();
-
- color_spec = gconf_client_get_string (config, key, &error);
-
- if (color_spec != NULL && !gdk_color_parse (color_spec, color))
- g_warning ("Unknown color \"%s\"", color_spec);
- else if (error != NULL) {
- g_warning ("%s", error->message);
- g_error_free (error);
- }
-
- g_free (color_spec);
-}
-
-/**
- * calendar_config_set_tasks_overdue_color:
- * @color: a #GdkColor
- *
- * Sets the color to be used to display overdue tasks.
- **/
-void
-calendar_config_set_tasks_overdue_color (GdkColor *color)
-{
- const gchar *key = CALENDAR_CONFIG_TASKS_OVERDUE_COLOR;
- GError *error = NULL;
- gchar color_spec[16];
-
- g_return_if_fail (color != NULL);
-
- g_snprintf (color_spec, sizeof (color_spec), "#%04x%04x%04x",
- color->red, color->green, color->blue);
-
- calendar_config_init ();
-
- if (!gconf_client_set_string (config, key, color_spec, &error)) {
- g_warning ("%s", error->message);
- g_error_free (error);
- }
-}
-
-/**
* calendar_config_get_use_default_reminder:
*
* Queries whether new appointments should be created with a default reminder.
@@ -1540,36 +794,6 @@ calendar_config_get_hide_completed_tasks_sexp (gboolean get_completed)
return sexp;
}
-gchar *
-calendar_config_get_free_busy_template (void)
-{
- calendar_config_init ();
-
- return gconf_client_get_string (config, CALENDAR_CONFIG_TEMPLATE, NULL);
-}
-
-void
-calendar_config_set_free_busy_template (const gchar *template)
-{
- calendar_config_init ();
-
- gconf_client_set_string (config, CALENDAR_CONFIG_TEMPLATE, template, NULL);
-}
-
-guint
-calendar_config_add_notification_free_busy_template (GConfClientNotifyFunc func,
- gpointer data)
-{
- guint id;
-
- calendar_config_init ();
-
- id = gconf_client_notify_add (config, CALENDAR_CONFIG_TEMPLATE, func, data,
- NULL, NULL);
-
- return id;
-}
-
void
calendar_config_set_dir_path (const gchar *path)
{
diff --git a/calendar/gui/calendar-config.h b/calendar/gui/calendar-config.h
index 53d636faf5..ff018abeca 100644
--- a/calendar/gui/calendar-config.h
+++ b/calendar/gui/calendar-config.h
@@ -66,174 +66,73 @@ 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);
icaltimezone *calendar_config_get_icaltimezone (void);
-void calendar_config_set_timezone (const gchar *timezone);
-guint calendar_config_add_notification_timezone (GConfClientNotifyFunc func, gpointer data);
/* The working days of the week, a bit-wise combination of flags. */
CalWeekdays calendar_config_get_working_days (void);
-void calendar_config_set_working_days (CalWeekdays days);
guint calendar_config_add_notification_working_days (GConfClientNotifyFunc func, gpointer data);
/* The start day of the week (0 = Sun to 6 = Sat). */
gint calendar_config_get_week_start_day (void);
-void calendar_config_set_week_start_day (gint week_start_day);
-guint calendar_config_add_notification_week_start_day (GConfClientNotifyFunc func, gpointer data);
/* The start and end times of the work-day. */
gint calendar_config_get_day_start_hour (void);
void calendar_config_set_day_start_hour (gint day_start_hour);
-guint calendar_config_add_notification_day_start_hour (GConfClientNotifyFunc func, gpointer data);
gint calendar_config_get_day_start_minute (void);
void calendar_config_set_day_start_minute (gint day_start_min);
-guint calendar_config_add_notification_day_start_minute (GConfClientNotifyFunc func, gpointer data);
gint calendar_config_get_day_end_hour (void);
void calendar_config_set_day_end_hour (gint day_end_hour);
-guint calendar_config_add_notification_day_end_hour (GConfClientNotifyFunc func, gpointer data);
gint calendar_config_get_day_end_minute (void);
void calendar_config_set_day_end_minute (gint day_end_min);
-guint calendar_config_add_notification_day_end_minute (GConfClientNotifyFunc func, gpointer data);
/* Whether we use 24-hour format or 12-hour format (AM/PM). */
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);
guint calendar_config_add_notification_time_divisions (GConfClientNotifyFunc func, gpointer data);
-/* Whether we show the Marcus Bains Line, and in what colors. */
-void calendar_config_get_marcus_bains (gboolean *show_line, const gchar **dayview_color, const gchar **timebar_color);
-void calendar_config_add_notification_marcus_bains (GConfClientNotifyFunc func, gpointer data, gint *not_show, gint *not_dcolor, gint *not_tcolor);
-
-/* Whether we show event end times. */
-gboolean calendar_config_get_show_event_end (void);
-void calendar_config_set_show_event_end (gboolean show_end);
-guint calendar_config_add_notification_show_event_end (GConfClientNotifyFunc func, gpointer data);
-
/* Whether we compress the weekend in the week/month views. */
gboolean calendar_config_get_compress_weekend (void);
-void calendar_config_set_compress_weekend (gboolean compress);
-guint calendar_config_add_notification_compress_weekend (GConfClientNotifyFunc func, gpointer data);
/* Whether we show week numbers in the Date Navigator. */
gboolean calendar_config_get_dnav_show_week_no (void);
-void calendar_config_set_dnav_show_week_no (gboolean show_week_no);
guint calendar_config_add_notification_dnav_show_week_no (GConfClientNotifyFunc func, gpointer data);
-/* Whether we show week number in the day view. */
-gboolean calendar_config_get_dview_show_week_no (void);
-void calendar_config_set_dview_show_week_no (gboolean show_week_no);
-guint calendar_config_add_notification_dview_show_week_no (GConfClientNotifyFunc func, gpointer data);
-
/* The positions of the panes in the normal and month views. */
-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);
-
-gint calendar_config_get_month_hpane_pos (void);
void calendar_config_set_month_hpane_pos (gint hpane_pos);
-gint calendar_config_get_month_vpane_pos (void);
-void calendar_config_set_month_vpane_pos (gint vpane_pos);
-
-gfloat calendar_config_get_tag_vpane_pos (void);
-void calendar_config_set_tag_vpane_pos (gfloat vpane_pos);
-
/* The current list of task lists selected */
GSList *calendar_config_get_tasks_selected (void);
void calendar_config_set_tasks_selected (GSList *selected);
guint calendar_config_add_notification_tasks_selected (GConfClientNotifyFunc func, gpointer data);
-/* The primary calendar */
-gchar *calendar_config_get_primary_tasks (void);
-void calendar_config_set_primary_tasks (const gchar *primary_uid);
-guint calendar_config_add_notification_primary_tasks (GConfClientNotifyFunc func, gpointer data);
-
-/* The pane position */
-gint calendar_config_get_task_vpane_pos (void);
-void calendar_config_set_task_vpane_pos (gint vpane_pos);
-
/* The current list of memo lists selected */
GSList *calendar_config_get_memos_selected (void);
void calendar_config_set_memos_selected (GSList *selected);
guint calendar_config_add_notification_memos_selected (GConfClientNotifyFunc func, gpointer data);
-/* The primary calendar */
-gchar *calendar_config_get_primary_memos (void);
-void calendar_config_set_primary_memos (const gchar *primary_uid);
-guint calendar_config_add_notification_primary_memos (GConfClientNotifyFunc func, gpointer data);
-
-/* Colors for the task list */
-void calendar_config_get_tasks_due_today_color (GdkColor *color);
-void calendar_config_set_tasks_due_today_color (GdkColor *color);
-
-void calendar_config_get_tasks_overdue_color (GdkColor *color);
-void calendar_config_set_tasks_overdue_color (GdkColor *color);
-
/* Settings to hide completed tasks. */
gboolean calendar_config_get_hide_completed_tasks (void);
void calendar_config_set_hide_completed_tasks (gboolean hide);
-guint calendar_config_add_notification_hide_completed_tasks (GConfClientNotifyFunc func, gpointer data);
CalUnits calendar_config_get_hide_completed_tasks_units(void);
void calendar_config_set_hide_completed_tasks_units(CalUnits units);
-guint calendar_config_add_notification_hide_completed_tasks_units (GConfClientNotifyFunc func, gpointer data);
gint calendar_config_get_hide_completed_tasks_value(void);
void calendar_config_set_hide_completed_tasks_value(gint value);
-guint calendar_config_add_notification_hide_completed_tasks_value (GConfClientNotifyFunc func, gpointer data);
gchar * calendar_config_get_hide_completed_tasks_sexp (gboolean get_completed);
/* Confirmation options */
gboolean calendar_config_get_confirm_delete (void);
-void calendar_config_set_confirm_delete (gboolean confirm);
-
-gboolean calendar_config_get_confirm_purge (void);
-void calendar_config_set_confirm_purge (gboolean confirm);
/* Default reminder options */
gboolean calendar_config_get_use_default_reminder (void);
@@ -249,11 +148,6 @@ void calendar_config_set_default_reminder_units (CalUnits units);
GSList * calendar_config_get_free_busy (void);
void calendar_config_set_free_busy (GSList * url_list);
-gchar *calendar_config_get_free_busy_template (void);
-void calendar_config_set_free_busy_template (const gchar *template);
-guint calendar_config_add_notification_free_busy_template (GConfClientNotifyFunc func,
- gpointer data);
-
/* Returns TRUE if the locale has 'am' and 'pm' strings defined, i.e. it
supports 12-hour time format. */
gboolean calendar_config_locale_supports_12_hour_format(void);
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 2fc17202cc..6fccf0cea1 100644
--- a/calendar/gui/dialogs/cal-prefs-dialog.c
+++ b/calendar/gui/dialogs/cal-prefs-dialog.c
@@ -31,16 +31,13 @@
#include "../calendar-config.h"
#include "cal-prefs-dialog.h"
#include <widgets/misc/e-dateedit.h>
-#include "e-util/e-datetime-format.h"
+#include <e-util/e-binding.h>
+#include <e-util/e-datetime-format.h>
#include <e-util/e-dialog-widgets.h>
#include <e-util/e-util-private.h>
#include <glib/gi18n.h>
#include <string.h>
-static const gint week_start_day_map[] = {
- 1, 2, 3, 4, 5, 6, 0, -1
-};
-
static const gint time_division_map[] = {
60, 30, 15, 10, 5, -1
};
@@ -99,32 +96,6 @@ eccp_widget_glade (EConfig *ec, EConfigItem *item, GtkWidget *parent, GtkWidget
}
static void
-working_days_changed (GtkWidget *widget, CalendarPrefsDialog *prefs)
-{
- CalWeekdays working_days = 0;
- guint32 mask = 1;
- gint day;
-
- for (day = 0; day < 7; day++) {
- if (e_dialog_toggle_get (prefs->working_days[day]))
- working_days |= mask;
- mask <<= 1;
- }
-
- calendar_config_set_working_days (working_days);
-}
-
-static void
-timezone_changed (GtkWidget *widget, CalendarPrefsDialog *prefs)
-{
- icaltimezone *zone;
-
- zone = e_timezone_entry_get_timezone (E_TIMEZONE_ENTRY (prefs->timezone));
-
- calendar_config_set_timezone (icaltimezone_get_location (zone));
-}
-
-static void
update_day_second_zone_caption (CalendarPrefsDialog *prefs)
{
gchar *location;
@@ -268,27 +239,6 @@ end_of_day_changed (GtkWidget *widget, CalendarPrefsDialog *prefs)
calendar_config_set_day_end_hour (end_hour);
calendar_config_set_day_end_minute (end_minute);
}
-static void
-week_start_day_changed (GtkWidget *widget, CalendarPrefsDialog *prefs)
-{
- gint week_start_day;
-
- week_start_day = e_dialog_combo_box_get (prefs->week_start_day, week_start_day_map);
- calendar_config_set_week_start_day (week_start_day);
-}
-
-static void
-use_24_hour_toggled (GtkToggleButton *toggle, CalendarPrefsDialog *prefs)
-{
- gboolean use_24_hour;
-
- use_24_hour = gtk_toggle_button_get_active (toggle);
-
- e_date_edit_set_use_24_hour_format (E_DATE_EDIT (prefs->start_of_day), use_24_hour);
- e_date_edit_set_use_24_hour_format (E_DATE_EDIT (prefs->end_of_day), use_24_hour);
-
- calendar_config_set_24_hour_format (use_24_hour);
-}
static void
time_divisions_changed (GtkWidget *widget, CalendarPrefsDialog *prefs)
@@ -300,30 +250,6 @@ time_divisions_changed (GtkWidget *widget, CalendarPrefsDialog *prefs)
}
static void
-show_end_times_toggled (GtkToggleButton *toggle, CalendarPrefsDialog *prefs)
-{
- calendar_config_set_show_event_end (gtk_toggle_button_get_active (toggle));
-}
-
-static void
-compress_weekend_toggled (GtkToggleButton *toggle, CalendarPrefsDialog *prefs)
-{
- calendar_config_set_compress_weekend (gtk_toggle_button_get_active (toggle));
-}
-
-static void
-dnav_show_week_no_toggled (GtkToggleButton *toggle, CalendarPrefsDialog *prefs)
-{
- calendar_config_set_dnav_show_week_no (gtk_toggle_button_get_active (toggle));
-}
-
-static void
-dview_show_week_no_toggled (GtkToggleButton *toggle, CalendarPrefsDialog *prefs)
-{
- calendar_config_set_dview_show_week_no (gtk_toggle_button_get_active (toggle));
-}
-
-static void
month_scroll_by_week_toggled (GtkToggleButton *toggle, CalendarPrefsDialog *prefs)
{
calendar_config_set_month_scroll_by_week (gtk_toggle_button_get_active (toggle));
@@ -356,30 +282,6 @@ hide_completed_tasks_units_changed (GtkWidget *widget, CalendarPrefsDialog *pref
}
static void
-tasks_due_today_set_color (GtkColorButton *color_button, CalendarPrefsDialog *prefs)
-{
- GdkColor color;
-
- gtk_color_button_get_color (color_button, &color);
- calendar_config_set_tasks_due_today_color (&color);
-}
-
-static void
-tasks_overdue_set_color (GtkColorButton *color_button, CalendarPrefsDialog *prefs)
-{
- GdkColor color;
-
- gtk_color_button_get_color (color_button, &color);
- calendar_config_set_tasks_overdue_color (&color);
-}
-
-static void
-confirm_delete_toggled (GtkToggleButton *toggle, CalendarPrefsDialog *prefs)
-{
- calendar_config_set_confirm_delete (gtk_toggle_button_get_active (toggle));
-}
-
-static void
default_reminder_toggled (GtkToggleButton *toggle, CalendarPrefsDialog *prefs)
{
calendar_config_set_use_default_reminder (gtk_toggle_button_get_active (toggle));
@@ -491,13 +393,9 @@ alarms_selection_changed (ESourceSelector *selector, CalendarPrefsDialog *prefs)
}
static void
-template_url_changed (GtkEntry *entry, CalendarPrefsDialog *prefs)
-{
- calendar_config_set_free_busy_template (gtk_entry_get_text (entry));
-}
-
-static void
-update_system_tz_widgets (CalendarPrefsDialog *prefs)
+update_system_tz_widgets (EShellSettings *shell_settings,
+ GParamSpec *pspec,
+ CalendarPrefsDialog *prefs)
{
icaltimezone *zone;
@@ -509,42 +407,18 @@ 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
setup_changes (CalendarPrefsDialog *prefs)
{
- gint i;
-
- 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);
g_signal_connect (G_OBJECT (prefs->start_of_day), "changed", G_CALLBACK (start_of_day_changed), prefs);
g_signal_connect (G_OBJECT (prefs->end_of_day), "changed", G_CALLBACK (end_of_day_changed), prefs);
- g_signal_connect (G_OBJECT (prefs->week_start_day), "changed", G_CALLBACK (week_start_day_changed), prefs);
-
- g_signal_connect (G_OBJECT (prefs->use_24_hour), "toggled", G_CALLBACK (use_24_hour_toggled), prefs);
-
g_signal_connect (G_OBJECT (prefs->time_divisions), "changed", G_CALLBACK (time_divisions_changed), prefs);
- g_signal_connect (G_OBJECT (prefs->show_end_times), "toggled", G_CALLBACK (show_end_times_toggled), prefs);
- g_signal_connect (G_OBJECT (prefs->compress_weekend), "toggled", G_CALLBACK (compress_weekend_toggled), prefs);
- g_signal_connect (G_OBJECT (prefs->dnav_show_week_no), "toggled", G_CALLBACK (dnav_show_week_no_toggled), prefs);
- g_signal_connect (G_OBJECT (prefs->dview_show_week_no), "toggled", G_CALLBACK (dview_show_week_no_toggled), prefs);
g_signal_connect (G_OBJECT (prefs->month_scroll_by_week), "toggled", G_CALLBACK (month_scroll_by_week_toggled), prefs);
g_signal_connect (G_OBJECT (prefs->tasks_hide_completed), "toggled",
@@ -552,12 +426,7 @@ setup_changes (CalendarPrefsDialog *prefs)
g_signal_connect (G_OBJECT (prefs->tasks_hide_completed_interval), "value-changed",
G_CALLBACK (hide_completed_tasks_changed), prefs);
g_signal_connect (G_OBJECT (prefs->tasks_hide_completed_units), "changed", G_CALLBACK (hide_completed_tasks_units_changed), prefs);
- g_signal_connect (G_OBJECT (prefs->tasks_due_today_color), "color-set",
- G_CALLBACK (tasks_due_today_set_color), prefs);
- g_signal_connect (G_OBJECT (prefs->tasks_overdue_color), "color-set",
- G_CALLBACK (tasks_overdue_set_color), prefs);
- g_signal_connect (G_OBJECT (prefs->confirm_delete), "toggled", G_CALLBACK (confirm_delete_toggled), prefs);
g_signal_connect (G_OBJECT (prefs->default_reminder), "toggled", G_CALLBACK (default_reminder_toggled), prefs);
g_signal_connect (G_OBJECT (prefs->default_reminder_interval), "changed",
G_CALLBACK (default_reminder_interval_changed), prefs);
@@ -570,39 +439,15 @@ setup_changes (CalendarPrefsDialog *prefs)
g_signal_connect (G_OBJECT (prefs->notify_with_tray), "toggled", G_CALLBACK (notify_with_tray_toggled), prefs);
g_signal_connect (G_OBJECT (prefs->alarm_list_widget), "selection_changed", G_CALLBACK (alarms_selection_changed), prefs);
-
- g_signal_connect (G_OBJECT (prefs->template_url), "changed", G_CALLBACK (template_url_changed), prefs);
-}
-
-/* Shows the current Free/Busy settings in the dialog */
-static void
-show_fb_config (CalendarPrefsDialog *prefs)
-{
- gchar *template_url;
-
- template_url = calendar_config_get_free_busy_template ();
- gtk_entry_set_text (GTK_ENTRY (prefs->template_url), (template_url ? template_url : ""));
-
- g_free (template_url);
}
/* Shows the current task list settings in the dialog */
static void
show_task_list_config (CalendarPrefsDialog *prefs)
{
- GtkColorButton *color_button;
- GdkColor color;
CalUnits units;
gboolean hide_completed_tasks;
- color_button = GTK_COLOR_BUTTON (prefs->tasks_due_today_color);
- calendar_config_get_tasks_due_today_color (&color);
- gtk_color_button_set_color (color_button, &color);
-
- color_button = GTK_COLOR_BUTTON (prefs->tasks_overdue_color);
- calendar_config_get_tasks_overdue_color (&color);
- gtk_color_button_set_color (color_button, &color);
-
/* Hide Completed Tasks. */
hide_completed_tasks = calendar_config_get_hide_completed_tasks ();
e_dialog_toggle_set (prefs->tasks_hide_completed, hide_completed_tasks);
@@ -660,39 +505,16 @@ show_alarms_config (CalendarPrefsDialog *prefs)
static void
show_config (CalendarPrefsDialog *prefs)
{
- CalWeekdays working_days;
- gint mask, day, week_start_day, time_divisions;
- icaltimezone *zone;
- gboolean sensitive, set = FALSE;
- gchar *location;
+ gint time_divisions;
+ gboolean set = FALSE;
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);
- e_timezone_entry_set_timezone (E_TIMEZONE_ENTRY (prefs->timezone), zone);
- g_free (location);
-
/* Day's second zone */
update_day_second_zone_caption (prefs);
- /* Working Days. */
- working_days = calendar_config_get_working_days ();
- mask = 1 << 0;
- for (day = 0; day < 7; day++) {
- e_dialog_toggle_set (prefs->working_days[day], (working_days & mask) ? TRUE : FALSE);
- mask <<= 1;
- }
-
- /* Week Start Day. */
- week_start_day = calendar_config_get_week_start_day ();
- e_dialog_combo_box_set (prefs->week_start_day, week_start_day, week_start_day_map);
+ /* Day's second zone */
+ update_day_second_zone_caption (prefs);
/* Start of Day. */
e_date_edit_set_time_of_day (E_DATE_EDIT (prefs->start_of_day), calendar_config_get_day_start_hour (), calendar_config_get_day_start_minute ());
@@ -700,32 +522,10 @@ show_config (CalendarPrefsDialog *prefs)
/* End of Day. */
e_date_edit_set_time_of_day (E_DATE_EDIT (prefs->end_of_day), calendar_config_get_day_end_hour (), calendar_config_get_day_end_minute ());
- /* 12/24 Hour Format. */
- if (calendar_config_get_24_hour_format ())
- e_dialog_toggle_set (prefs->use_24_hour, TRUE);
- else
- e_dialog_toggle_set (prefs->use_12_hour, TRUE);
-
- sensitive = calendar_config_locale_supports_12_hour_format ();
- gtk_widget_set_sensitive (prefs->use_12_hour, sensitive);
- gtk_widget_set_sensitive (prefs->use_24_hour, sensitive);
-
/* Time Divisions. */
time_divisions = calendar_config_get_time_divisions ();
e_dialog_combo_box_set (prefs->time_divisions, time_divisions, time_division_map);
- /* Show Appointment End Times. */
- e_dialog_toggle_set (prefs->show_end_times, calendar_config_get_show_event_end ());
-
- /* Compress Weekend. */
- e_dialog_toggle_set (prefs->compress_weekend, calendar_config_get_compress_weekend ());
-
- /* Date Navigator - Show Week Numbers. */
- e_dialog_toggle_set (prefs->dnav_show_week_no, calendar_config_get_dnav_show_week_no ());
-
- /* Day/Work Week view - Show Week Number. */
- e_dialog_toggle_set (prefs->dview_show_week_no, calendar_config_get_dview_show_week_no ());
-
/* Month View - Scroll by a week */
e_dialog_toggle_set (prefs->month_scroll_by_week, calendar_config_get_month_scroll_by_week ());
@@ -735,11 +535,7 @@ show_config (CalendarPrefsDialog *prefs)
/* Alarms list*/
show_alarms_config (prefs);
- /* Free/Busy */
- show_fb_config (prefs);
-
/* Other page */
- e_dialog_toggle_set (prefs->confirm_delete, calendar_config_get_confirm_delete ());
e_dialog_toggle_set (prefs->default_reminder, calendar_config_get_use_default_reminder ());
e_dialog_spin_set (prefs->default_reminder_interval, calendar_config_get_default_reminder_interval ());
e_dialog_combo_box_set (prefs->default_reminder_units, calendar_config_get_default_reminder_units (), default_reminder_units_map);
@@ -774,25 +570,26 @@ 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;
+ gboolean locale_supports_12_hour_format;
gint i;
- GtkWidget *toplevel, *table;
+ GtkWidget *toplevel;
+ GtkWidget *widget;
+ GtkWidget *table;
GSList *l;
- const gchar *working_day_names[] = {
- "sun_button",
- "mon_button",
- "tue_button",
- "wed_button",
- "thu_button",
- "fri_button",
- "sat_button",
- };
gchar *gladefile;
+ shell_settings = e_shell_get_shell_settings (shell);
+
+ locale_supports_12_hour_format =
+ calendar_config_locale_supports_12_hour_format ();
+
gladefile = g_build_filename (EVOLUTION_GLADEDIR,
"cal-prefs-dialog.glade",
NULL);
@@ -816,19 +613,97 @@ 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 (
+ G_OBJECT (shell_settings), "cal-timezone",
+ G_OBJECT (widget), "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");
- for (i = 0; i < 7; i++)
- prefs->working_days[i] = glade_xml_get_widget (gui, working_day_names[i]);
- prefs->week_start_day = glade_xml_get_widget (gui, "week_start_day");
- prefs->start_of_day = glade_xml_get_widget (gui, "start_of_day");
- prefs->end_of_day = glade_xml_get_widget (gui, "end_of_day");
- prefs->use_12_hour = glade_xml_get_widget (gui, "use_12_hour");
- prefs->use_24_hour = glade_xml_get_widget (gui, "use_24_hour");
- prefs->confirm_delete = glade_xml_get_widget (gui, "confirm_delete");
+
+ widget = glade_xml_get_widget (gui, "sun_button");
+ e_mutual_binding_new (
+ G_OBJECT (shell_settings), "cal-working-days-sunday",
+ G_OBJECT (widget), "active");
+
+ widget = glade_xml_get_widget (gui, "mon_button");
+ e_mutual_binding_new (
+ G_OBJECT (shell_settings), "cal-working-days-monday",
+ G_OBJECT (widget), "active");
+
+ widget = glade_xml_get_widget (gui, "tue_button");
+ e_mutual_binding_new (
+ G_OBJECT (shell_settings), "cal-working-days-tuesday",
+ G_OBJECT (widget), "active");
+
+ widget = glade_xml_get_widget (gui, "wed_button");
+ e_mutual_binding_new (
+ G_OBJECT (shell_settings), "cal-working-days-wednesday",
+ G_OBJECT (widget), "active");
+
+ widget = glade_xml_get_widget (gui, "thu_button");
+ e_mutual_binding_new (
+ G_OBJECT (shell_settings), "cal-working-days-thursday",
+ G_OBJECT (widget), "active");
+
+ widget = glade_xml_get_widget (gui, "fri_button");
+ e_mutual_binding_new (
+ G_OBJECT (shell_settings), "cal-working-days-friday",
+ G_OBJECT (widget), "active");
+
+ widget = glade_xml_get_widget (gui, "sat_button");
+ e_mutual_binding_new (
+ G_OBJECT (shell_settings), "cal-working-days-saturday",
+ G_OBJECT (widget), "active");
+
+ widget = glade_xml_get_widget (gui, "week_start_day");
+ e_mutual_binding_new (
+ G_OBJECT (shell_settings), "cal-week-start-day",
+ G_OBJECT (widget), "active");
+
+ widget = glade_xml_get_widget (gui, "start_of_day");
+ prefs->start_of_day = widget; /* XXX delete this */
+ if (locale_supports_12_hour_format)
+ e_binding_new (
+ G_OBJECT (shell_settings), "cal-use-24-hour-format",
+ G_OBJECT (widget), "use-24-hour-format");
+
+ widget = glade_xml_get_widget (gui, "end_of_day");
+ prefs->end_of_day = widget; /* XXX delete this */
+ if (locale_supports_12_hour_format)
+ e_binding_new (
+ G_OBJECT (shell_settings), "cal-use-24-hour-format",
+ G_OBJECT (widget), "use-24-hour-format");
+
+ widget = glade_xml_get_widget (gui, "use_12_hour");
+ gtk_widget_set_sensitive (widget, locale_supports_12_hour_format);
+ e_mutual_binding_new_with_negation (
+ G_OBJECT (shell_settings), "cal-use-24-hour-format",
+ G_OBJECT (widget), "active");
+
+ widget = glade_xml_get_widget (gui, "use_24_hour");
+ gtk_widget_set_sensitive (widget, locale_supports_12_hour_format);
+ e_mutual_binding_new (
+ G_OBJECT (shell_settings), "cal-use-24-hour-format",
+ G_OBJECT (widget), "active");
+
+ widget = glade_xml_get_widget (gui, "confirm_delete");
+ e_mutual_binding_new (
+ G_OBJECT (shell_settings), "cal-confirm-delete",
+ G_OBJECT (widget), "active");
+
prefs->default_reminder = glade_xml_get_widget (gui, "default_reminder");
prefs->default_reminder_interval = glade_xml_get_widget (gui, "default_reminder_interval");
prefs->default_reminder_units = glade_xml_get_widget (gui, "default_reminder_units");
@@ -838,13 +713,45 @@ calendar_prefs_dialog_construct (CalendarPrefsDialog *prefs)
/* Display tab */
prefs->time_divisions = glade_xml_get_widget (gui, "time_divisions");
- prefs->show_end_times = glade_xml_get_widget (gui, "show_end_times");
- prefs->compress_weekend = glade_xml_get_widget (gui, "compress_weekend");
- prefs->dnav_show_week_no = glade_xml_get_widget (gui, "dnav_show_week_no");
- prefs->dview_show_week_no = glade_xml_get_widget (gui, "dview_show_week_no");
+
+ widget = glade_xml_get_widget (gui, "show_end_times");
+ e_mutual_binding_new (
+ G_OBJECT (shell_settings), "cal-show-event-end-times",
+ G_OBJECT (widget), "active");
+
+ widget = glade_xml_get_widget (gui, "compress_weekend");
+ e_mutual_binding_new (
+ G_OBJECT (shell_settings), "cal-compress-weekend",
+ G_OBJECT (widget), "active");
+
+ widget = glade_xml_get_widget (gui, "dnav_show_week_no");
+ e_mutual_binding_new (
+ G_OBJECT (shell_settings), "cal-show-week-numbers",
+ G_OBJECT (widget), "active");
+
+ widget = glade_xml_get_widget (gui, "dview_show_week_no");
+ e_mutual_binding_new (
+ G_OBJECT (shell_settings), "cal-day-view-show-week-numbers",
+ G_OBJECT (widget), "active");
+
prefs->month_scroll_by_week = glade_xml_get_widget (gui, "month_scroll_by_week");
- prefs->tasks_due_today_color = glade_xml_get_widget (gui, "tasks_due_today_color");
- prefs->tasks_overdue_color = glade_xml_get_widget (gui, "tasks_overdue_color");
+
+ widget = glade_xml_get_widget (gui, "tasks_due_today_color");
+ e_mutual_binding_new_full (
+ G_OBJECT (shell_settings), "cal-tasks-color-due-today",
+ G_OBJECT (widget), "color",
+ e_binding_transform_string_to_color,
+ e_binding_transform_color_to_string,
+ (GDestroyNotify) NULL, NULL);
+
+ widget = glade_xml_get_widget (gui, "tasks_overdue_color");
+ e_mutual_binding_new_full (
+ G_OBJECT (shell_settings), "cal-tasks-color-overdue",
+ G_OBJECT (widget), "color",
+ e_binding_transform_string_to_color,
+ e_binding_transform_color_to_string,
+ (GDestroyNotify) NULL, NULL);
+
prefs->tasks_hide_completed = glade_xml_get_widget (gui, "tasks_hide_completed");
prefs->tasks_hide_completed_interval = glade_xml_get_widget (gui, "tasks_hide_completed_interval");
prefs->tasks_hide_completed_units = glade_xml_get_widget (gui, "tasks_hide_completed_units");
@@ -854,7 +761,10 @@ calendar_prefs_dialog_construct (CalendarPrefsDialog *prefs)
prefs->scrolled_window = glade_xml_get_widget (gui, "calendar-source-scrolled-window");
/* Free/Busy tab */
- prefs->template_url = glade_xml_get_widget (gui, "template_url");
+ widget = glade_xml_get_widget (gui, "template_url");
+ e_mutual_binding_new (
+ G_OBJECT (shell_settings), "cal-free-busy-template",
+ G_OBJECT (widget), "text");
target = e_cal_config_target_new_prefs (ec, prefs->gconf);
e_config_set_target ((EConfig *)ec, (EConfigTarget *) target);
toplevel = e_config_create_widget ((EConfig *)ec);
@@ -893,14 +803,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. */
@@ -912,7 +826,6 @@ cal_prefs_dialog_create_time_edit (void)
dedit = e_date_edit_new ();
gtk_widget_show (GTK_WIDGET (dedit));
- e_date_edit_set_use_24_hour_format (E_DATE_EDIT (dedit), calendar_config_get_24_hour_format ());
e_date_edit_set_time_popup_range (E_DATE_EDIT (dedit), 0, 24);
e_date_edit_set_show_date (E_DATE_EDIT (dedit), FALSE);
diff --git a/calendar/gui/dialogs/cal-prefs-dialog.h b/calendar/gui/dialogs/cal-prefs-dialog.h
index 611d4aabcc..ceaa379474 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,16 +62,12 @@ struct _CalendarPrefsDialog {
GConfClient *gconf;
/* General tab */
- GtkWidget *use_system_tz_check;
GtkWidget *system_tz_label;
- GtkWidget *timezone;
GtkWidget *day_second_zone;
GtkWidget *working_days[7];
GtkWidget *week_start_day;
GtkWidget *start_of_day;
GtkWidget *end_of_day;
- GtkWidget *use_12_hour;
- GtkWidget *use_24_hour;
GtkWidget *confirm_delete;
GtkWidget *default_reminder;
GtkWidget *default_reminder_interval;
@@ -68,8 +83,6 @@ struct _CalendarPrefsDialog {
GtkWidget *dnav_show_week_no;
GtkWidget *dview_show_week_no;
GtkWidget *month_scroll_by_week;
- GtkWidget *tasks_due_today_color;
- GtkWidget *tasks_overdue_color;
GtkWidget *tasks_hide_completed;
GtkWidget *tasks_hide_completed_interval;
GtkWidget *tasks_hide_completed_units;
@@ -96,9 +109,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-util.c b/calendar/gui/dialogs/comp-editor-util.c
index fa5d9a6583..6fc05d4a92 100644
--- a/calendar/gui/dialogs/comp-editor-util.c
+++ b/calendar/gui/dialogs/comp-editor-util.c
@@ -32,8 +32,9 @@
#include <glib/gi18n.h>
#include <libedataserver/e-time-utils.h>
#include <libecal/e-cal-time-util.h>
+#include "e-util/e-binding.h"
+#include "widgets/misc/e-dateedit.h"
#include "../calendar-config.h"
-#include "../e-date-edit-config.h"
#include "../itip-utils.h"
#include "comp-editor-util.h"
@@ -205,16 +206,9 @@ comp_editor_date_label (CompEditorPageDates *dates, GtkWidget *label)
gtk_label_set_text (GTK_LABEL (label), buffer);
}
-static void
-date_edit_destroy_cb (EDateEdit *date_edit, gpointer data)
-{
- EDateEditConfig *config = data;
-
- g_object_unref (config);
-}
-
/**
* comp_editor_new_date_edit:
+ * @shell_settings: an #EShellSettings
* @show_date: Whether to show a date picker in the widget.
* @show_time: Whether to show a time picker in the widget.
* @make_time_insensitive: Whether the time field is made insensitive rather
@@ -226,11 +220,14 @@ date_edit_destroy_cb (EDateEdit *date_edit, gpointer data)
* Return value: A newly-created #EDateEdit widget.
**/
GtkWidget *
-comp_editor_new_date_edit (gboolean show_date, gboolean show_time,
- gboolean make_time_insensitive)
+comp_editor_new_date_edit (EShellSettings *shell_settings,
+ gboolean show_date,
+ gboolean show_time,
+ gboolean make_time_insensitive)
{
EDateEdit *dedit;
- EDateEditConfig *config;
+
+ g_return_val_if_fail (E_IS_SHELL_SETTINGS (shell_settings), NULL);
dedit = E_DATE_EDIT (e_date_edit_new ());
@@ -242,8 +239,13 @@ comp_editor_new_date_edit (gboolean show_date, gboolean show_time,
e_date_edit_set_make_time_insensitive (dedit, FALSE);
#endif
- config = e_date_edit_config_new (dedit);
- g_signal_connect (G_OBJECT (dedit), "destroy", G_CALLBACK (date_edit_destroy_cb), config);
+ e_binding_new (
+ G_OBJECT (shell_settings), "cal-show-week-numbers",
+ G_OBJECT (dedit), "show-week-numbers");
+
+ e_binding_new (
+ G_OBJECT (shell_settings), "cal-week-start-day",
+ G_OBJECT (dedit), "week-start-day");
return GTK_WIDGET (dedit);
}
diff --git a/calendar/gui/dialogs/comp-editor-util.h b/calendar/gui/dialogs/comp-editor-util.h
index cebb8f74c1..ec481fa457 100644
--- a/calendar/gui/dialogs/comp-editor-util.h
+++ b/calendar/gui/dialogs/comp-editor-util.h
@@ -26,6 +26,7 @@
#define _COMP_EDITOR_UTIL_H_
#include <gtk/gtk.h>
+#include <shell/e-shell-settings.h>
#include "comp-editor-page.h"
#include "../e-meeting-attendee.h"
@@ -34,8 +35,10 @@ void comp_editor_free_dates (CompEditorPageDates *dates);
void comp_editor_date_label (CompEditorPageDates *dates, GtkWidget *label);
-GtkWidget *comp_editor_new_date_edit (gboolean show_date, gboolean show_time,
- gboolean make_time_insensitive);
+GtkWidget * comp_editor_new_date_edit (EShellSettings *shell_settings,
+ gboolean show_date,
+ gboolean show_time,
+ gboolean make_time_insensitive);
struct tm comp_editor_get_current_time (GtkObject *object, gpointer data);
diff --git a/calendar/gui/dialogs/comp-editor.c b/calendar/gui/dialogs/comp-editor.c
index 5097c9f336..8995b0eddc 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>
@@ -61,7 +61,6 @@
#include "recur-comp.h"
#include "comp-editor.h"
#include "comp-editor-util.h"
-#include "../e-cal-popup.h"
#include "../calendar-config-keys.h"
#include "cal-attachment-select-file.h"
#include "widgets/misc/e-attachment-view.h"
@@ -79,6 +78,9 @@ static gboolean comp_lite = FALSE;
/* Private part of the CompEditor structure */
struct _CompEditorPrivate {
+
+ gpointer shell; /* weak pointer */
+
/* Client to use */
ECal *client;
@@ -128,6 +130,7 @@ enum {
PROP_CHANGED,
PROP_CLIENT,
PROP_FLAGS,
+ PROP_SHELL,
PROP_SUMMARY
};
@@ -136,7 +139,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'>"
@@ -173,8 +179,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)
@@ -183,7 +189,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)
@@ -716,17 +730,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);
}
@@ -736,15 +755,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);
}
@@ -812,12 +838,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);
@@ -1199,6 +1223,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,
@@ -1223,6 +1258,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),
@@ -1258,6 +1299,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 (
@@ -1275,6 +1322,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;
@@ -1333,42 +1386,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);
@@ -1515,6 +1565,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",
@@ -1523,7 +1584,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,
@@ -1547,11 +1608,18 @@ comp_editor_init (CompEditor *editor)
GtkWidget *container;
GtkWidget *widget;
GtkWidget *scroll;
+ 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;
@@ -1734,6 +1802,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
@@ -1815,7 +1887,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)
@@ -1901,6 +1984,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)
@@ -2010,7 +2101,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;
}
@@ -2068,6 +2159,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
@@ -2391,8 +2496,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);
@@ -2415,12 +2526,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
@@ -2836,9 +2949,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;
@@ -2871,12 +2985,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 d95d496ffd..454f02b2e6 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 \
@@ -88,6 +89,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);
@@ -107,6 +110,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);
@@ -150,9 +154,11 @@ 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);
void comp_editor_set_lite (gboolean status);
gboolean comp_editor_get_lite (void);
+
G_END_DECLS
#endif
diff --git a/calendar/gui/dialogs/event-editor.c b/calendar/gui/dialogs/event-editor.c
index 7251123100..91c879928c 100644
--- a/calendar/gui/dialogs/event-editor.c
+++ b/calendar/gui/dialogs/event-editor.c
@@ -34,9 +34,9 @@
#include <glib/gi18n.h>
#include <misc/e-dateedit.h>
+#include <e-util/e-binding.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"
@@ -249,15 +249,6 @@ static GtkActionEntry meeting_entries[] = {
};
static void
-event_editor_client_changed_cb (EventEditor *ee)
-{
- ECal *client;
-
- client = comp_editor_get_client (COMP_EDITOR (ee));
- e_meeting_store_set_e_cal (ee->priv->model, client);
-}
-
-static void
event_editor_model_changed_cb (EventEditor *ee)
{
if (!ee->priv->updating) {
@@ -370,6 +361,31 @@ event_editor_dispose (GObject *object)
}
static void
+event_editor_constructed (GObject *object)
+{
+ EventEditorPrivate *priv;
+ EShellSettings *shell_settings;
+ EShell *shell;
+
+ priv = EVENT_EDITOR_GET_PRIVATE (object);
+
+ shell = comp_editor_get_shell (COMP_EDITOR (object));
+ shell_settings = e_shell_get_shell_settings (shell);
+
+ e_binding_new (
+ G_OBJECT (object), "client",
+ G_OBJECT (priv->model), "client");
+
+ e_binding_new (
+ G_OBJECT (shell_settings), "cal-free-busy-template",
+ G_OBJECT (priv->model), "free-busy-template");
+
+ e_binding_new (
+ G_OBJECT (shell_settings), "cal-timezone",
+ G_OBJECT (priv->model), "timezone");
+}
+
+static void
event_editor_show_categories (CompEditor *editor,
gboolean visible)
{
@@ -446,6 +462,7 @@ event_editor_class_init (EventEditorClass *class)
object_class = G_OBJECT_CLASS (class);
object_class->constructor = event_editor_constructor;
object_class->dispose = event_editor_dispose;
+ object_class->constructed = event_editor_constructed;
editor_class = COMP_EDITOR_CLASS (class);
editor_class->help_section = "usage-calendar-apts";
@@ -466,6 +483,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 +506,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);
@@ -499,10 +520,6 @@ event_editor_init (EventEditor *ee)
action = comp_editor_get_action (editor, "send-options");
gtk_action_set_visible (action, FALSE);
- g_signal_connect (
- ee, "notify::client",
- G_CALLBACK (event_editor_client_changed_cb), NULL);
-
g_signal_connect_swapped (
ee->priv->model, "row_changed",
G_CALLBACK (event_editor_model_changed_cb), ee);
@@ -637,7 +654,7 @@ event_editor_send_comp (CompEditor *editor, ECalComponentItipMethod method, gboo
ECal *client;
gboolean result;
- client = e_meeting_store_get_e_cal (priv->model);
+ client = e_meeting_store_get_client (priv->model);
result = itip_send_comp (E_CAL_COMPONENT_METHOD_CANCEL, comp,
client, NULL, NULL, NULL, strip_alarms, FALSE);
g_object_unref (comp);
@@ -663,13 +680,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 eb95245128..5a9b8ec47a 100644
--- a/calendar/gui/dialogs/event-page.c
+++ b/calendar/gui/dialogs/event-page.c
@@ -39,7 +39,6 @@
#include "common/authentication.h"
#include "e-util/e-categories-config.h"
#include "e-util/e-dialog-widgets.h"
-#include "e-util/e-popup.h"
#include "misc/e-dateedit.h"
#include "misc/e-send-options.h"
#include <libecal/e-cal-time-util.h>
@@ -52,7 +51,6 @@
#include "../e-meeting-attendee.h"
#include "../e-meeting-store.h"
#include "../e-meeting-list-view.h"
-#include "../e-cal-popup.h"
#include "comp-editor.h"
#include "comp-editor-util.h"
#include "../e-alarm-list.h"
@@ -384,9 +382,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);
@@ -458,7 +458,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);
@@ -1833,15 +1835,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
@@ -1884,102 +1881,6 @@ attendee_added_cb (EMeetingListView *emlv,
}
}
-/* Callbacks for list view*/
-static void
-popup_add_cb (EPopup *ep, EPopupItem *pitem, gpointer data)
-{
- EventPage *epage = data;
-
- add_clicked_cb (NULL, epage);
-}
-
-static void
-popup_delete_cb (EPopup *ep, EPopupItem *pitem, gpointer data)
-{
- EventPage *epage = data;
-
- remove_clicked_cb (NULL, epage);
-}
-
-enum {
- ATTENDEE_CAN_DELEGATE = 1<<1,
- ATTENDEE_CAN_DELETE = 1<<2,
- ATTENDEE_CAN_ADD = 1<<3,
- ATTENDEE_LAST = 1<<4
-};
-
-static EPopupItem context_menu_items[] = {
- { E_POPUP_ITEM, (gchar *) "10.delete", (gchar *) N_("_Remove"), popup_delete_cb, NULL, (gchar *) GTK_STOCK_REMOVE, ATTENDEE_CAN_DELETE },
- { E_POPUP_ITEM, (gchar *) "15.add", (gchar *) N_("_Add "), popup_add_cb, NULL, (gchar *) GTK_STOCK_ADD, ATTENDEE_CAN_ADD },
-};
-
-static void
-context_popup_free(EPopup *ep, GSList *items, gpointer data)
-{
- g_slist_free(items);
-}
-
-static gint
-button_press_event (GtkWidget *widget, GdkEventButton *event, EventPage *epage)
-{
- EventPagePrivate *priv = epage->priv;
- CompEditor *editor;
- CompEditorFlags flags;
- GtkMenu *menu;
- EMeetingAttendee *ia;
- GtkTreePath *path;
- GtkTreeIter iter;
- gchar *address;
- guint32 disable_mask = ~0;
- GSList *menus = NULL;
- ECalPopup *ep;
- gint i;
-
- /* only process right-clicks */
- if (event->button != 3 || event->type != GDK_BUTTON_PRESS)
- return FALSE;
-
- editor = comp_editor_page_get_editor (COMP_EDITOR_PAGE (epage));
- flags = comp_editor_get_flags (editor);
-
- /* only if we right-click on an attendee */
- if (gtk_tree_view_get_path_at_pos (GTK_TREE_VIEW (priv->list_view), event->x, event->y, &path, NULL, NULL, NULL)) {
- GtkTreeSelection *selection;
-
- if (gtk_tree_model_get_iter (GTK_TREE_MODEL (priv->model), &iter, path)) {
-
- gtk_tree_model_get (GTK_TREE_MODEL (priv->model), &iter, E_MEETING_STORE_ADDRESS_COL, &address, -1);
- ia = e_meeting_store_find_attendee (priv->model, address, &priv->row);
- g_free (address);
-
- if (ia) {
- selection = gtk_tree_view_get_selection (GTK_TREE_VIEW (priv->list_view));
- gtk_tree_selection_unselect_all (selection);
- gtk_tree_selection_select_path (selection, path);
-
- if (e_meeting_attendee_get_edit_level (ia) == E_MEETING_ATTENDEE_EDIT_FULL)
- disable_mask &= ~ATTENDEE_CAN_DELETE;
- }
- }
- }
-
- if (GTK_WIDGET_IS_SENSITIVE(priv->add))
- disable_mask &= ~ATTENDEE_CAN_ADD;
- else if (flags & COMP_EDITOR_USER_ORG)
- disable_mask &= ~ATTENDEE_CAN_ADD;
-
- ep = e_cal_popup_new("org.gnome.evolution.calendar.meeting.popup");
-
- for (i=0;i<sizeof(context_menu_items)/sizeof(context_menu_items[0]);i++)
- menus = g_slist_prepend(menus, &context_menu_items[i]);
-
- e_popup_add_items((EPopup *)ep, menus, NULL, context_popup_free, epage);
- menu = e_popup_create_menu_once((EPopup *)ep, NULL, disable_mask);
- gtk_menu_popup (menu, NULL, NULL, NULL, NULL, event->button, event->time);
-
- return TRUE;
-}
-
static gboolean
list_view_event (EMeetingListView *list_view, GdkEvent *event, EventPage *epage) {
@@ -2032,6 +1933,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));
@@ -2110,7 +2012,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);
@@ -2192,10 +2097,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;
@@ -2203,6 +2110,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;
@@ -2224,7 +2133,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 {
@@ -2503,14 +2413,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);
}
@@ -2518,12 +2424,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);
}
@@ -2532,15 +2435,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);
@@ -2557,17 +2457,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;
-
- epage = EVENT_PAGE (data);
- priv = epage->priv;
+ GtkEntry *entry;
- 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
@@ -2692,13 +2588,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;
@@ -2840,7 +2733,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));
@@ -2896,16 +2791,32 @@ 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);
- g_signal_connect (G_OBJECT (priv->list_view), "button_press_event", G_CALLBACK (button_press_event), epage);
g_signal_connect (G_OBJECT (priv->list_view), "event", G_CALLBACK (list_view_event), epage);
g_signal_connect (priv->list_view, "key_press_event", G_CALLBACK (list_key_press), epage);
@@ -2936,7 +2847,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 {
@@ -3030,7 +2942,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;
}
@@ -3194,7 +3108,13 @@ GtkWidget *make_date_edit (void);
GtkWidget *
make_date_edit (void)
{
- return comp_editor_new_date_edit (TRUE, TRUE, TRUE);
+ EShell *shell;
+ EShellSettings *shell_settings;
+
+ shell = e_shell_get_default ();
+ shell_settings = e_shell_get_shell_settings (shell);
+
+ return comp_editor_new_date_edit (shell_settings, TRUE, TRUE, TRUE);
}
GtkWidget *make_timezone_entry (void);
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 8026a467ee..595a0e409e 100644
--- a/calendar/gui/dialogs/memo-page.c
+++ b/calendar/gui/dialogs/memo-page.c
@@ -948,9 +948,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);
@@ -1015,8 +1020,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;
}
@@ -1215,9 +1221,14 @@ GtkWidget *memo_page_create_date_edit (void);
GtkWidget *
memo_page_create_date_edit (void)
{
+ EShell *shell;
+ EShellSettings *shell_settings;
GtkWidget *widget;
- widget = comp_editor_new_date_edit (TRUE, FALSE, TRUE);
+ shell = e_shell_get_default ();
+ shell_settings = e_shell_get_shell_settings (shell);
+
+ widget = comp_editor_new_date_edit (shell_settings, TRUE, FALSE, TRUE);
e_date_edit_set_allow_no_date_set (E_DATE_EDIT (widget), TRUE);
gtk_widget_show (widget);
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/recurrence-page.c b/calendar/gui/dialogs/recurrence-page.c
index 385b4eeea0..ca53a41737 100644
--- a/calendar/gui/dialogs/recurrence-page.c
+++ b/calendar/gui/dialogs/recurrence-page.c
@@ -34,6 +34,7 @@
#include <glib/gi18n.h>
#include <glade/glade.h>
#include <libedataserver/e-time-utils.h>
+#include <e-util/e-binding.h>
#include <e-util/e-dialog-widgets.h>
#include <e-util/e-util-private.h>
#include <misc/e-dateedit.h>
@@ -44,7 +45,6 @@
#include "../weekday-picker.h"
#include "comp-editor-util.h"
#include "../e-date-time-list.h"
-#include "../e-mini-calendar-config.h"
#include "recurrence-page.h"
#define RECURRENCE_PAGE_GET_PRIVATE(obj) \
@@ -188,7 +188,6 @@ struct _RecurrencePagePrivate {
/* For the recurrence preview, the actual widget */
GtkWidget *preview_calendar;
- EMiniCalendarConfig *preview_calendar_config;
};
@@ -323,11 +322,6 @@ recurrence_page_dispose (GObject *object)
priv->exception_list_store = NULL;
}
- if (priv->preview_calendar_config != NULL) {
- g_object_unref (priv->preview_calendar_config);
- priv->preview_calendar_config = NULL;
- }
-
/* Chain up to parent's dispose() method. */
G_OBJECT_CLASS (recurrence_page_parent_class)->dispose (object);
}
@@ -1338,6 +1332,8 @@ static void
make_ending_until_special (RecurrencePage *rpage)
{
RecurrencePagePrivate *priv = rpage->priv;
+ EShell *shell;
+ EShellSettings *shell_settings;
CompEditor *editor;
CompEditorFlags flags;
EDateEdit *de;
@@ -1349,10 +1345,13 @@ make_ending_until_special (RecurrencePage *rpage)
editor = comp_editor_page_get_editor (COMP_EDITOR_PAGE (rpage));
flags = comp_editor_get_flags (editor);
+ shell = comp_editor_get_shell (editor);
+ shell_settings = e_shell_get_shell_settings (shell);
+
/* Create the widget */
- priv->ending_date_edit = comp_editor_new_date_edit (TRUE, FALSE,
- FALSE);
+ priv->ending_date_edit = comp_editor_new_date_edit (
+ shell_settings, TRUE, FALSE, FALSE);
de = E_DATE_EDIT (priv->ending_date_edit);
gtk_container_add (GTK_CONTAINER (priv->ending_special),
@@ -2077,9 +2076,16 @@ create_exception_dialog (RecurrencePage *rpage, const gchar *title, GtkWidget **
{
RecurrencePagePrivate *priv;
GtkWidget *dialog, *toplevel;
+ CompEditor *editor;
+ EShell *shell;
+ EShellSettings *shell_settings;
priv = rpage->priv;
+ editor = comp_editor_page_get_editor (COMP_EDITOR_PAGE (rpage));
+ shell = comp_editor_get_shell (editor);
+ shell_settings = e_shell_get_shell_settings (shell);
+
toplevel = gtk_widget_get_toplevel (priv->main);
dialog = gtk_dialog_new_with_buttons (title, GTK_WINDOW (toplevel),
GTK_DIALOG_MODAL | GTK_DIALOG_DESTROY_WITH_PARENT,
@@ -2087,7 +2093,7 @@ create_exception_dialog (RecurrencePage *rpage, const gchar *title, GtkWidget **
GTK_STOCK_OK, GTK_RESPONSE_ACCEPT,
NULL);
- *date_edit = comp_editor_new_date_edit (TRUE, FALSE, TRUE);
+ *date_edit = comp_editor_new_date_edit (shell_settings, TRUE, FALSE, TRUE);
gtk_widget_show (*date_edit);
gtk_box_pack_start (GTK_BOX (GTK_DIALOG (dialog)->vbox), *date_edit, FALSE, TRUE, 6);
@@ -2243,6 +2249,9 @@ static void
init_widgets (RecurrencePage *rpage)
{
RecurrencePagePrivate *priv;
+ EShell *shell;
+ EShellSettings *shell_settings;
+ CompEditor *editor;
ECalendar *ecal;
GtkAdjustment *adj;
GtkTreeViewColumn *column;
@@ -2250,11 +2259,23 @@ init_widgets (RecurrencePage *rpage)
priv = rpage->priv;
+ editor = comp_editor_page_get_editor (COMP_EDITOR_PAGE (rpage));
+ shell = comp_editor_get_shell (editor);
+ shell_settings = e_shell_get_shell_settings (shell);
+
/* Recurrence preview */
priv->preview_calendar = e_calendar_new ();
ecal = E_CALENDAR (priv->preview_calendar);
- priv->preview_calendar_config = e_mini_calendar_config_new (ecal);
+
+ e_binding_new (
+ G_OBJECT (shell_settings), "cal-show-week-numbers",
+ G_OBJECT (ecal->calitem), "show-week-numbers");
+
+ e_binding_new (
+ G_OBJECT (shell_settings), "cal-week-start-day",
+ G_OBJECT (ecal->calitem), "week-start-day");
+
g_signal_connect((ecal->calitem), "date_range_changed",
G_CALLBACK (preview_date_range_changed_cb),
rpage);
@@ -2401,6 +2422,12 @@ GtkWidget *make_exdate_date_edit (void);
GtkWidget *
make_exdate_date_edit (void)
{
- return comp_editor_new_date_edit (TRUE, TRUE, FALSE);
+ EShell *shell;
+ EShellSettings *shell_settings;
+
+ shell = e_shell_get_default ();
+ shell_settings = e_shell_get_shell_settings (shell);
+
+ return comp_editor_new_date_edit (shell_settings, TRUE, TRUE, FALSE);
}
diff --git a/calendar/gui/dialogs/schedule-page.c b/calendar/gui/dialogs/schedule-page.c
index 712d2708b9..5a7277084b 100644
--- a/calendar/gui/dialogs/schedule-page.c
+++ b/calendar/gui/dialogs/schedule-page.c
@@ -32,6 +32,7 @@
#include <gtk/gtk.h>
#include <glib/gi18n.h>
#include <glade/glade.h>
+#include <e-util/e-binding.h>
#include <e-util/e-dialog-widgets.h>
#include <e-util/e-util-private.h>
#include <misc/e-dateedit.h>
@@ -218,7 +219,7 @@ update_time (SchedulePage *spage, ECalComponentDateTime *start_date, ECalCompone
if (start_zone != end_zone) {
icaltimezone_convert_time (&end_tt, end_zone, start_zone);
}
- e_meeting_store_set_zone (priv->model, priv->zone);
+ e_meeting_store_set_timezone (priv->model, priv->zone);
all_day = (start_tt.is_date && end_tt.is_date) ? TRUE : FALSE;
@@ -385,10 +386,14 @@ SchedulePage *
schedule_page_construct (SchedulePage *spage, EMeetingStore *ems)
{
SchedulePagePrivate *priv = spage->priv;
+ EShellSettings *shell_settings;
+ EShell *shell;
CompEditor *editor;
gchar *gladefile;
editor = comp_editor_page_get_editor (COMP_EDITOR_PAGE (spage));
+ shell = comp_editor_get_shell (editor);
+ shell_settings = e_shell_get_shell_settings (shell);
gladefile = g_build_filename (EVOLUTION_GLADEDIR,
"schedule-page.glade",
@@ -423,6 +428,18 @@ schedule_page_construct (SchedulePage *spage, EMeetingStore *ems)
gtk_widget_show (GTK_WIDGET (priv->sel));
gtk_box_pack_start (GTK_BOX (priv->main), GTK_WIDGET (priv->sel), TRUE, TRUE, 6);
+ e_binding_new (
+ G_OBJECT (shell_settings), "cal-show-week-numbers",
+ G_OBJECT (priv->sel), "show-week-numbers");
+
+ e_binding_new (
+ G_OBJECT (shell_settings), "cal-use-24-hour-format",
+ G_OBJECT (priv->sel), "use-24-hour-format");
+
+ e_binding_new (
+ G_OBJECT (shell_settings), "cal-week-start-day",
+ G_OBJECT (priv->sel), "week-start-day");
+
if (!init_widgets (spage)) {
g_message ("schedule_page_construct(): "
"Could not initialize the widgets!");
diff --git a/calendar/gui/dialogs/task-details-page.c b/calendar/gui/dialogs/task-details-page.c
index 8c63c4dd02..38faa99c0b 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)))
@@ -769,9 +768,14 @@ GtkWidget *task_details_page_create_date_edit (void);
GtkWidget *
task_details_page_create_date_edit (void)
{
+ EShell *shell;
+ EShellSettings *shell_settings;
GtkWidget *dedit;
- dedit = comp_editor_new_date_edit (TRUE, TRUE, FALSE);
+ shell = e_shell_get_default ();
+ shell_settings = e_shell_get_shell_settings (shell);
+
+ dedit = comp_editor_new_date_edit (shell_settings, TRUE, TRUE, FALSE);
e_date_edit_set_allow_no_date_set (E_DATE_EDIT (dedit), TRUE);
return dedit;
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 0ca6ff5a3d..edd54859d6 100644
--- a/calendar/gui/dialogs/task-editor.c
+++ b/calendar/gui/dialogs/task-editor.c
@@ -33,9 +33,9 @@
#include <glade/glade.h>
#include <glib/gi18n.h>
-#include <e-util/e-plugin-ui.h>
-#include <e-util/e-util-private.h>
-#include <evolution-shell-component-utils.h>
+#include "e-util/e-binding.h"
+#include "e-util/e-plugin-ui.h"
+#include "e-util/e-util-private.h"
#include "task-page.h"
#include "task-details-page.h"
@@ -127,15 +127,6 @@ static GtkActionEntry assigned_task_entries[] = {
};
static void
-task_editor_client_changed_cb (TaskEditor *te)
-{
- ECal *client;
-
- client = comp_editor_get_client (COMP_EDITOR (te));
- e_meeting_store_set_e_cal (te->priv->model, client);
-}
-
-static void
task_editor_model_changed_cb (TaskEditor *te)
{
if (!te->priv->updating) {
@@ -209,6 +200,31 @@ task_editor_dispose (GObject *object)
}
static void
+task_editor_constructed (GObject *object)
+{
+ TaskEditorPrivate *priv;
+ EShellSettings *shell_settings;
+ EShell *shell;
+
+ priv = TASK_EDITOR_GET_PRIVATE (object);
+
+ shell = comp_editor_get_shell (COMP_EDITOR (object));
+ shell_settings = e_shell_get_shell_settings (shell);
+
+ e_binding_new (
+ G_OBJECT (object), "client",
+ G_OBJECT (priv->model), "client");
+
+ e_binding_new (
+ G_OBJECT (shell_settings), "cal-free-busy-template",
+ G_OBJECT (priv->model), "free-busy-template");
+
+ e_binding_new (
+ G_OBJECT (shell_settings), "cal-timezone",
+ G_OBJECT (priv->model), "timezone");
+}
+
+static void
task_editor_show_categories (CompEditor *editor,
gboolean visible)
{
@@ -285,6 +301,7 @@ task_editor_class_init (TaskEditorClass *class)
object_class = G_OBJECT_CLASS (class);
object_class->constructor = task_editor_constructor;
object_class->dispose = task_editor_dispose;
+ object_class->constructed = task_editor_constructed;
editor_class = COMP_EDITOR_CLASS (class);
editor_class->help_section = "usage-calendar-todo";
@@ -304,6 +321,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,17 +364,16 @@ 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);
g_error_free (error);
}
- g_signal_connect (
- te, "notify::client",
- G_CALLBACK (task_editor_client_changed_cb), NULL);
-
g_signal_connect_swapped (
te->priv->model, "row_changed",
G_CALLBACK (task_editor_model_changed_cb), te);
@@ -462,7 +479,7 @@ task_editor_send_comp (CompEditor *editor, ECalComponentItipMethod method, gbool
ECal *client;
gboolean result;
- client = e_meeting_store_get_e_cal (priv->model);
+ client = e_meeting_store_get_client (priv->model);
result = itip_send_comp (E_CAL_COMPONENT_METHOD_CANCEL, comp,
client, NULL, NULL, NULL, strip_alarms, FALSE);
g_object_unref (comp);
@@ -488,13 +505,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 8b5c02843e..2f0c258f3a 100644
--- a/calendar/gui/dialogs/task-page.c
+++ b/calendar/gui/dialogs/task-page.c
@@ -39,7 +39,6 @@
#include <misc/e-dateedit.h>
#include <e-util/e-dialog-utils.h>
#include "common/authentication.h"
-#include "e-util/e-popup.h"
#include "e-util/e-dialog-widgets.h"
#include "e-util/e-categories-config.h"
#include "e-util/e-util-private.h"
@@ -53,7 +52,6 @@
#include "../e-meeting-attendee.h"
#include "../e-meeting-store.h"
#include "../e-meeting-list-view.h"
-#include "../e-cal-popup.h"
#define TASK_PAGE_GET_PRIVATE(obj) \
(G_TYPE_INSTANCE_GET_PRIVATE \
@@ -466,12 +464,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;
@@ -554,7 +554,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;
@@ -1140,15 +1143,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
@@ -1191,102 +1189,6 @@ attendee_added_cb (EMeetingListView *emlv,
}
}
-/* Callbacks for list view*/
-static void
-popup_add_cb (EPopup *ep, EPopupItem *pitem, gpointer data)
-{
- TaskPage *page = data;
-
- add_clicked_cb (NULL, page);
-}
-
-static void
-popup_delete_cb (EPopup *ep, EPopupItem *pitem, gpointer data)
-{
- TaskPage *page = data;
-
- remove_clicked_cb (NULL, page);
-}
-
-enum {
- ATTENDEE_CAN_DELEGATE = 1<<1,
- ATTENDEE_CAN_DELETE = 1<<2,
- ATTENDEE_CAN_ADD = 1<<3,
- ATTENDEE_LAST = 1<<4
-};
-
-static EPopupItem context_menu_items[] = {
- { E_POPUP_ITEM, (gchar *) "10.delete", (gchar *) N_("_Remove"), popup_delete_cb, NULL, (gchar *) GTK_STOCK_REMOVE, ATTENDEE_CAN_DELETE },
- { E_POPUP_ITEM, (gchar *) "15.add", (gchar *) N_("_Add "), popup_add_cb, NULL, (gchar *) GTK_STOCK_ADD, ATTENDEE_CAN_ADD },
-};
-
-static void
-context_popup_free(EPopup *ep, GSList *items, gpointer data)
-{
- g_slist_free(items);
-}
-
-static gint
-button_press_event (GtkWidget *widget, GdkEventButton *event, TaskPage *page)
-{
- TaskPagePrivate *priv = page->priv;
- CompEditor *editor;
- CompEditorFlags flags;
- GtkMenu *menu;
- EMeetingAttendee *ia;
- GtkTreePath *path;
- GtkTreeIter iter;
- gchar *address;
- guint32 disable_mask = ~0;
- GSList *menus = NULL;
- ECalPopup *ep;
- gint i;
-
- /* only process right-clicks */
- if (event->button != 3 || event->type != GDK_BUTTON_PRESS)
- return FALSE;
-
- editor = comp_editor_page_get_editor (COMP_EDITOR_PAGE (page));
- flags = comp_editor_get_flags (editor);
-
- /* only if we right-click on an attendee */
- if (gtk_tree_view_get_path_at_pos (GTK_TREE_VIEW (priv->list_view), event->x, event->y, &path, NULL, NULL, NULL)) {
- GtkTreeSelection *selection;
-
- if (gtk_tree_model_get_iter (GTK_TREE_MODEL (priv->model), &iter, path)) {
-
- gtk_tree_model_get (GTK_TREE_MODEL (priv->model), &iter, E_MEETING_STORE_ADDRESS_COL, &address, -1);
- ia = e_meeting_store_find_attendee (priv->model, address, &priv->row);
- g_free (address);
-
- if (ia) {
- selection = gtk_tree_view_get_selection ((GtkTreeView *) priv->list_view);
- gtk_tree_selection_unselect_all (selection);
- gtk_tree_selection_select_path (selection, path);
-
- if (e_meeting_attendee_get_edit_level (ia) == E_MEETING_ATTENDEE_EDIT_FULL)
- disable_mask &= ~ATTENDEE_CAN_DELETE;
- }
- }
- }
-
- if (GTK_WIDGET_IS_SENSITIVE(priv->add))
- disable_mask &= ~ATTENDEE_CAN_ADD;
- else if (flags & COMP_EDITOR_USER_ORG)
- disable_mask &= ~ATTENDEE_CAN_ADD;
-
- ep = e_cal_popup_new("org.gnome.evolution.calendar.task.popup");
-
- for (i=0;i<sizeof(context_menu_items)/sizeof(context_menu_items[0]);i++)
- menus = g_slist_prepend(menus, &context_menu_items[i]);
-
- e_popup_add_items((EPopup *)ep, menus, NULL, context_popup_free, page);
- menu = e_popup_create_menu_once((EPopup *)ep, NULL, disable_mask);
- gtk_menu_popup (menu, NULL, NULL, NULL, NULL, event->button, event->time);
-
- return TRUE;
-}
-
static gboolean
list_view_event (EMeetingListView *list_view, GdkEvent *event, TaskPage *page) {
@@ -1510,17 +1412,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)))
@@ -1579,33 +1480,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
@@ -1865,12 +1757,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),
@@ -1938,9 +1835,6 @@ init_widgets (TaskPage *tpage)
G_CALLBACK (comp_editor_page_changed), tpage);
g_signal_connect (
- priv->list_view, "button_press_event",
- G_CALLBACK (button_press_event), tpage);
- g_signal_connect (
priv->list_view, "event",
G_CALLBACK (list_view_event), tpage);
g_signal_connect (
@@ -1966,15 +1860,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);
- 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-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);
- task_page_set_show_categories (tpage, calendar_config_get_show_categories());
+ 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);
+
+ 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;
}
@@ -2159,9 +2074,14 @@ GtkWidget *task_page_create_date_edit (void);
GtkWidget *
task_page_create_date_edit (void)
{
+ EShell *shell;
+ EShellSettings *shell_settings;
GtkWidget *dedit;
- dedit = comp_editor_new_date_edit (TRUE, TRUE, TRUE);
+ shell = e_shell_get_default ();
+ shell_settings = e_shell_get_shell_settings (shell);
+
+ dedit = comp_editor_new_date_edit (shell_settings, TRUE, TRUE, TRUE);
e_date_edit_set_allow_no_date_set (E_DATE_EDIT (dedit), TRUE);
return dedit;
diff --git a/calendar/gui/e-attachment-handler-calendar.c b/calendar/gui/e-attachment-handler-calendar.c
deleted file mode 100644
index 601d1f5e3c..0000000000
--- a/calendar/gui/e-attachment-handler-calendar.c
+++ /dev/null
@@ -1,511 +0,0 @@
-/*
- * e-attachment-handler-calendar.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-attachment-handler-calendar.h"
-
-#include <glib/gi18n.h>
-#include <libical/ical.h>
-#include <libecal/e-cal.h>
-#include <camel/camel-stream-mem.h>
-#include <libedataserverui/e-source-selector.h>
-
-#include "calendar/common/authentication.h"
-
-#define E_ATTACHMENT_HANDLER_CALENDAR_GET_PRIVATE(obj) \
- (G_TYPE_INSTANCE_GET_PRIVATE \
- ((obj), E_TYPE_ATTACHMENT_HANDLER_CALENDAR, EAttachmentHandlerCalendarPrivate))
-
-typedef struct _ImportContext ImportContext;
-
-struct _EAttachmentHandlerCalendarPrivate {
- gint placeholder;
-};
-
-struct _ImportContext {
- ECal *client;
- icalcomponent *component;
- ECalSourceType source_type;
-};
-
-static gpointer parent_class;
-
-static const gchar *ui =
-"<ui>"
-" <popup name='context'>"
-" <placeholder name='custom-actions'>"
-" <menuitem action='import-to-calendar'/>"
-" <menuitem action='import-to-tasks'/>"
-" </placeholder>"
-" </popup>"
-"</ui>";
-
-static icalcomponent *
-attachment_handler_get_component (EAttachment *attachment)
-{
- CamelDataWrapper *wrapper;
- CamelMimePart *mime_part;
- CamelStream *stream;
- GByteArray *buffer;
- icalcomponent *component;
- const gchar *key = "__icalcomponent__";
-
- component = g_object_get_data (G_OBJECT (attachment), key);
- if (component != NULL)
- return component;
-
- mime_part = e_attachment_get_mime_part (attachment);
- if (!CAMEL_IS_MIME_PART (mime_part))
- return NULL;
-
- buffer = g_byte_array_new ();
- stream = camel_stream_mem_new ();
- camel_stream_mem_set_byte_array (CAMEL_STREAM_MEM (stream), buffer);
- wrapper = camel_medium_get_content_object (CAMEL_MEDIUM (mime_part));
- camel_data_wrapper_decode_to_stream (wrapper, stream);
- camel_object_unref (stream);
-
- component = e_cal_util_parse_ics_string ((gchar *) buffer->data);
-
- g_byte_array_free (buffer, TRUE);
-
- if (component == NULL)
- return NULL;
-
- g_object_set_data_full (
- G_OBJECT (attachment), key, component,
- (GDestroyNotify) icalcomponent_free);
-
- return component;
-}
-
-static gboolean
-attachment_handler_update_objects (ECal *client,
- icalcomponent *component)
-{
- icalcomponent_kind kind;
- icalcomponent *vcalendar;
- gboolean success;
-
- kind = icalcomponent_isa (component);
-
- switch (kind) {
- case ICAL_VTODO_COMPONENT:
- case ICAL_VEVENT_COMPONENT:
- vcalendar = e_cal_util_new_top_level ();
- if (icalcomponent_get_method (component) == ICAL_METHOD_CANCEL)
- icalcomponent_set_method (vcalendar, ICAL_METHOD_CANCEL);
- else
- icalcomponent_set_method (vcalendar, ICAL_METHOD_PUBLISH);
- icalcomponent_add_component (
- vcalendar, icalcomponent_new_clone (component));
- break;
-
- case ICAL_VCALENDAR_COMPONENT:
- vcalendar = icalcomponent_new_clone (component);
- if (!icalcomponent_get_first_property (vcalendar, ICAL_METHOD_PROPERTY))
- icalcomponent_set_method (vcalendar, ICAL_METHOD_PUBLISH);
- break;
-
- default:
- return FALSE;
- }
-
- success = e_cal_receive_objects (client, vcalendar, NULL);
-
- icalcomponent_free (vcalendar);
-
- return success;
-}
-
-static void
-attachment_handler_import_event (ECal *client,
- ECalendarStatus status,
- EAttachment *attachment)
-{
- icalcomponent *component;
- icalcomponent *subcomponent;
- icalcompiter iter;
-
- /* FIXME Notify the user somehow. */
- g_return_if_fail (status == E_CALENDAR_STATUS_OK);
-
- component = attachment_handler_get_component (attachment);
- g_return_if_fail (component != NULL);
-
- iter = icalcomponent_begin_component (component, ICAL_ANY_COMPONENT);
-
- while ((subcomponent = icalcompiter_deref (&iter)) != NULL) {
- icalcomponent_kind kind;
-
- kind = icalcomponent_isa (subcomponent);
- icalcompiter_next (&iter);
-
- if (kind == ICAL_VEVENT_COMPONENT)
- continue;
-
- if (kind == ICAL_VTIMEZONE_COMPONENT)
- continue;
-
- icalcomponent_remove_component (component, subcomponent);
- icalcomponent_free (subcomponent);
- }
-
- /* XXX Do something with the return value. */
- attachment_handler_update_objects (client, component);
-
- g_object_unref (attachment);
- g_object_unref (client);
-}
-
-static void
-attachment_handler_import_todo (ECal *client,
- ECalendarStatus status,
- EAttachment *attachment)
-{
- icalcomponent *component;
- icalcomponent *subcomponent;
- icalcompiter iter;
-
- /* FIXME Notify the user somehow. */
- g_return_if_fail (status == E_CALENDAR_STATUS_OK);
-
- component = attachment_handler_get_component (attachment);
- g_return_if_fail (component != NULL);
-
- iter = icalcomponent_begin_component (component, ICAL_ANY_COMPONENT);
-
- while ((subcomponent = icalcompiter_deref (&iter)) != NULL) {
- icalcomponent_kind kind;
-
- kind = icalcomponent_isa (subcomponent);
- icalcompiter_next (&iter);
-
- if (kind == ICAL_VTODO_COMPONENT)
- continue;
-
- if (kind == ICAL_VTIMEZONE_COMPONENT)
- continue;
-
- icalcomponent_remove_component (component, subcomponent);
- icalcomponent_free (subcomponent);
- }
-
- /* XXX Do something with the return value. */
- attachment_handler_update_objects (client, component);
-
- g_object_unref (attachment);
- g_object_unref (client);
-}
-
-static void
-attachment_handler_row_activated_cb (GtkDialog *dialog)
-{
- gtk_dialog_response (dialog, GTK_RESPONSE_OK);
-}
-
-static void
-attachment_handler_run_dialog (GtkWindow *parent,
- EAttachment *attachment,
- ECalSourceType source_type,
- const gchar *title)
-{
- GtkWidget *dialog;
- GtkWidget *container;
- GtkWidget *widget;
- GCallback callback;
- ESourceSelector *selector;
- ESourceList *source_list;
- ESource *source;
- ECal *client;
- icalcomponent *component;
- GError *error = NULL;
-
- component = attachment_handler_get_component (attachment);
- g_return_if_fail (component != NULL);
-
- e_cal_get_sources (&source_list, source_type, &error);
- if (error != NULL) {
- g_warning ("%s", error->message);
- g_error_free (error);
- return;
- }
-
- source = e_source_list_peek_source_any (source_list);
- g_return_if_fail (source != NULL);
-
- dialog = gtk_dialog_new_with_buttons (
- title, parent, GTK_DIALOG_DESTROY_WITH_PARENT,
- GTK_STOCK_CANCEL, GTK_RESPONSE_CANCEL, NULL);
-
- widget = gtk_button_new_with_mnemonic (_("I_mport"));
- gtk_button_set_image (
- GTK_BUTTON (widget), gtk_image_new_from_icon_name (
- "stock_mail-import", GTK_ICON_SIZE_MENU));
- gtk_dialog_add_action_widget (
- GTK_DIALOG (dialog), widget, GTK_RESPONSE_OK);
- gtk_widget_show (widget);
-
- gtk_dialog_set_has_separator (GTK_DIALOG (dialog), FALSE);
- gtk_window_set_default_size (GTK_WINDOW (dialog), 300, 400);
-
- container = gtk_dialog_get_content_area (GTK_DIALOG (dialog));
-
- widget = gtk_scrolled_window_new (NULL, NULL);
- gtk_scrolled_window_set_policy (
- GTK_SCROLLED_WINDOW (widget),
- GTK_POLICY_AUTOMATIC, GTK_POLICY_AUTOMATIC);
- gtk_scrolled_window_set_shadow_type (
- GTK_SCROLLED_WINDOW (widget), GTK_SHADOW_IN);
- gtk_box_pack_start (GTK_BOX (container), widget, TRUE, TRUE, 0);
- gtk_widget_show (widget);
-
- container = widget;
-
- widget = e_source_selector_new (source_list);
- selector = E_SOURCE_SELECTOR (widget);
- e_source_selector_set_primary_selection (selector, source);
- e_source_selector_show_selection (selector, FALSE);
- gtk_container_add (GTK_CONTAINER (container), widget);
- gtk_widget_show (widget);
-
- g_signal_connect_swapped (
- widget, "row-activated",
- G_CALLBACK (attachment_handler_row_activated_cb), dialog);
-
- if (gtk_dialog_run (GTK_DIALOG (dialog)) != GTK_RESPONSE_OK)
- goto exit;
-
- source = e_source_selector_peek_primary_selection (selector);
- if (source == NULL)
- goto exit;
-
- client = auth_new_cal_from_source (source, source_type);
- if (client == NULL)
- goto exit;
-
- if (source_type == E_CAL_SOURCE_TYPE_EVENT)
- callback = G_CALLBACK (attachment_handler_import_event);
- else if (source_type == E_CAL_SOURCE_TYPE_TODO)
- callback = G_CALLBACK (attachment_handler_import_todo);
- else
- goto exit;
-
- g_object_ref (attachment);
- g_signal_connect (client, "cal-opened", callback, attachment);
- e_cal_open_async (client, FALSE);
-
-exit:
- gtk_widget_destroy (dialog);
-}
-
-static void
-attachment_handler_import_to_calendar (GtkAction *action,
- EAttachmentHandler *handler)
-{
- EAttachment *attachment;
- EAttachmentView *view;
- GList *selected;
- gpointer parent;
-
- view = e_attachment_handler_get_view (handler);
-
- parent = gtk_widget_get_toplevel (GTK_WIDGET (view));
- parent = GTK_WIDGET_TOPLEVEL (parent) ? parent : NULL;
-
- selected = e_attachment_view_get_selected_attachments (view);
- g_return_if_fail (g_list_length (selected) == 1);
- attachment = E_ATTACHMENT (selected->data);
-
- attachment_handler_run_dialog (
- parent, attachment,
- E_CAL_SOURCE_TYPE_EVENT,
- _("Select a Calendar"));
-
- g_object_unref (attachment);
- g_list_free (selected);
-}
-
-static void
-attachment_handler_import_to_tasks (GtkAction *action,
- EAttachmentHandler *handler)
-{
- EAttachment *attachment;
- EAttachmentView *view;
- GList *selected;
- gpointer parent;
-
- view = e_attachment_handler_get_view (handler);
-
- parent = gtk_widget_get_toplevel (GTK_WIDGET (view));
- parent = GTK_WIDGET_TOPLEVEL (parent) ? parent : NULL;
-
- selected = e_attachment_view_get_selected_attachments (view);
- g_return_if_fail (g_list_length (selected) == 1);
- attachment = E_ATTACHMENT (selected->data);
-
- attachment_handler_run_dialog (
- parent, attachment,
- E_CAL_SOURCE_TYPE_TODO,
- _("Select a Task List"));
-
- g_object_unref (attachment);
- g_list_free (selected);
-}
-
-static GtkActionEntry standard_entries[] = {
-
- { "import-to-calendar",
- "stock_mail-import",
- N_("I_mport to Calendar"),
- NULL,
- NULL, /* XXX Add a tooltip! */
- G_CALLBACK (attachment_handler_import_to_calendar) },
-
- { "import-to-tasks",
- "stock_mail-import",
- N_("I_mport to Tasks"),
- NULL,
- NULL, /* XXX Add a tooltip! */
- G_CALLBACK (attachment_handler_import_to_tasks) }
-};
-
-static void
-attachment_handler_calendar_update_actions (EAttachmentView *view)
-{
- EAttachment *attachment;
- GtkAction *action;
- GList *selected;
- icalcomponent *component;
- icalcomponent *subcomponent;
- icalcomponent_kind kind;
- gboolean is_vevent = FALSE;
- gboolean is_vtodo = FALSE;
-
- selected = e_attachment_view_get_selected_attachments (view);
-
- if (g_list_length (selected) != 1)
- goto exit;
-
- attachment = E_ATTACHMENT (selected->data);
- component = attachment_handler_get_component (attachment);
-
- if (component == NULL)
- goto exit;
-
- subcomponent = icalcomponent_get_inner (component);
-
- if (subcomponent == NULL)
- goto exit;
-
- kind = icalcomponent_isa (subcomponent);
- is_vevent = (kind == ICAL_VEVENT_COMPONENT);
- is_vtodo = (kind == ICAL_VTODO_COMPONENT);
-
-exit:
- action = e_attachment_view_get_action (view, "import-to-calendar");
- gtk_action_set_visible (action, is_vevent);
-
- action = e_attachment_view_get_action (view, "import-to-tasks");
- gtk_action_set_visible (action, is_vtodo);
-
- g_list_foreach (selected, (GFunc) g_object_unref, NULL);
- g_list_free (selected);
-}
-
-static void
-attachment_handler_calendar_constructed (GObject *object)
-{
- EAttachmentHandler *handler;
- EAttachmentView *view;
- GtkActionGroup *action_group;
- GtkUIManager *ui_manager;
- GError *error = NULL;
-
- handler = E_ATTACHMENT_HANDLER (object);
-
- /* Chain up to parent's constructed() method. */
- G_OBJECT_CLASS (parent_class)->constructed (object);
-
- view = e_attachment_handler_get_view (handler);
-
- action_group = e_attachment_view_add_action_group (view, "calendar");
- gtk_action_group_add_actions (
- action_group, standard_entries,
- G_N_ELEMENTS (standard_entries), handler);
-
- ui_manager = e_attachment_view_get_ui_manager (view);
- gtk_ui_manager_add_ui_from_string (ui_manager, ui, -1, &error);
-
- if (error != NULL) {
- g_warning ("%s", error->message);
- g_error_free (error);
- }
-
- g_signal_connect (
- view, "update_actions",
- G_CALLBACK (attachment_handler_calendar_update_actions),
- NULL);
-}
-
-static void
-attachment_handler_calendar_class_init (EAttachmentHandlerCalendarClass *class)
-{
- GObjectClass *object_class;
-
- parent_class = g_type_class_peek_parent (class);
- g_type_class_add_private (class, sizeof (EAttachmentHandlerCalendarPrivate));
-
- object_class = G_OBJECT_CLASS (class);
- object_class->constructed = attachment_handler_calendar_constructed;
-}
-
-static void
-attachment_handler_calendar_init (EAttachmentHandlerCalendar *handler)
-{
- handler->priv = E_ATTACHMENT_HANDLER_CALENDAR_GET_PRIVATE (handler);
-}
-
-GType
-e_attachment_handler_calendar_get_type (void)
-{
- static GType type = 0;
-
- if (G_UNLIKELY (type == 0)) {
- static const GTypeInfo type_info = {
- sizeof (EAttachmentHandlerCalendarClass),
- (GBaseInitFunc) NULL,
- (GBaseFinalizeFunc) NULL,
- (GClassInitFunc) attachment_handler_calendar_class_init,
- (GClassFinalizeFunc) NULL,
- NULL, /* class_data */
- sizeof (EAttachmentHandlerCalendar),
- 0, /* n_preallocs */
- (GInstanceInitFunc) attachment_handler_calendar_init,
- NULL /* value_table */
- };
-
- type = g_type_register_static (
- E_TYPE_ATTACHMENT_HANDLER,
- "EAttachmentHandlerCalendar", &type_info, 0);
- }
-
- return type;
-}
diff --git a/calendar/gui/e-attachment-handler-calendar.h b/calendar/gui/e-attachment-handler-calendar.h
deleted file mode 100644
index f34cac14c3..0000000000
--- a/calendar/gui/e-attachment-handler-calendar.h
+++ /dev/null
@@ -1,65 +0,0 @@
-/*
- * e-attachment-handler-calendar.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_ATTACHMENT_HANDLER_CALENDAR_H
-#define E_ATTACHMENT_HANDLER_CALENDAR_H
-
-#include <misc/e-attachment-handler.h>
-
-/* Standard GObject macros */
-#define E_TYPE_ATTACHMENT_HANDLER_CALENDAR \
- (e_attachment_handler_calendar_get_type ())
-#define E_ATTACHMENT_HANDLER_CALENDAR(obj) \
- (G_TYPE_CHECK_INSTANCE_CAST \
- ((obj), E_TYPE_ATTACHMENT_HANDLER_CALENDAR, EAttachmentHandlerCalendar))
-#define E_ATTACHMENT_HANDLER_CALENDAR_CLASS(cls) \
- (G_TYPE_CHECK_CLASS_CAST \
- ((cls), E_TYPE_ATTACHMENT_HANDLER_CALENDAR, EAttachmentHandlerCalendarClass))
-#define E_IS_ATTACHMENT_HANDLER_CALENDAR(obj) \
- (G_TYPE_CHECK_INSTANCE_TYPE \
- ((obj), E_TYPE_ATTACHMENT_HANDLER_CALENDAR))
-#define E_IS_ATTACHMENT_HANDLER_CALENDAR_CLASS(cls) \
- (G_TYPE_CHECK_CLASS_TYPE \
- ((cls), E_TYPE_ATTACHMENT_HANDLER_CALENDAR))
-#define E_ATTACHMENT_HANDLER_CALENDAR_GET_CLASS(obj) \
- (G_TYPE_INSTANCE_GET_CLASS \
- ((obj), E_TYPE_ATTACHMENT_HANDLER_CALENDAR, EAttachmentHandlerCalendarClass))
-
-G_BEGIN_DECLS
-
-typedef struct _EAttachmentHandlerCalendar EAttachmentHandlerCalendar;
-typedef struct _EAttachmentHandlerCalendarClass EAttachmentHandlerCalendarClass;
-typedef struct _EAttachmentHandlerCalendarPrivate EAttachmentHandlerCalendarPrivate;
-
-struct _EAttachmentHandlerCalendar {
- EAttachmentHandler parent;
- EAttachmentHandlerCalendarPrivate *priv;
-};
-
-struct _EAttachmentHandlerCalendarClass {
- EAttachmentHandlerClass parent_class;
-};
-
-GType e_attachment_handler_calendar_get_type (void);
-
-G_END_DECLS
-
-#endif /* E_ATTACHMENT_HANDLER_CALENDAR_H */
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-config.c b/calendar/gui/e-cal-config.c
index 33b6bc9c46..a8d2ad169f 100644
--- a/calendar/gui/e-cal-config.c
+++ b/calendar/gui/e-cal-config.c
@@ -28,7 +28,6 @@
#include "e-cal-config.h"
static GObjectClass *ecp_parent_class;
-static GObjectClass *ecph_parent_class;
struct _ECalConfigPrivate {
guint source_changed_id;
@@ -166,49 +165,3 @@ e_cal_config_target_new_prefs (ECalConfig *ecp, struct _GConfClient *gconf)
return t;
}
-
-static const EConfigHookTargetMask ecph_no_masks[] = {
- { NULL }
-};
-
-static const EConfigHookTargetMap ecph_targets[] = {
- { "source", EC_CONFIG_TARGET_SOURCE, ecph_no_masks },
- { "prefs", EC_CONFIG_TARGET_PREFS, ecph_no_masks },
- { NULL },
-};
-
-static void
-ecph_class_init (EPluginHookClass *klass)
-{
- gint i;
-
- klass->id = "org.gnome.evolution.calendar.config:1.0";
-
- for (i = 0; ecph_targets[i].type; i++) {
- e_config_hook_class_add_target_map ((EConfigHookClass *)klass, &ecph_targets[i]);
- }
-
- ((EConfigHookClass *)klass)->config_class = g_type_class_ref (e_cal_config_get_type ());
-}
-
-GType
-e_cal_config_hook_get_type (void)
-{
- static GType type = 0;
-
- if (!type) {
- static const GTypeInfo info = {
- sizeof (ECalConfigHookClass),
- NULL, NULL,
- (GClassInitFunc) ecph_class_init,
- NULL, NULL,
- sizeof (ECalConfigHook), 0,
- (GInstanceInitFunc) NULL
- };
-
- ecph_parent_class = g_type_class_ref (e_config_hook_get_type ());
- type = g_type_register_static (e_config_hook_get_type (), "ECalConfigHook", &info, 0);
- }
-
- return type;
-}
diff --git a/calendar/gui/e-cal-config.h b/calendar/gui/e-cal-config.h
index 52989aa0e2..30e12bbf0c 100644
--- a/calendar/gui/e-cal-config.h
+++ b/calendar/gui/e-cal-config.h
@@ -71,21 +71,6 @@ ECalConfig *e_cal_config_new (gint type, const gchar *menuid);
ECalConfigTargetSource *e_cal_config_target_new_source (ECalConfig *ecp, struct _ESource *source);
ECalConfigTargetPrefs *e_cal_config_target_new_prefs (ECalConfig *ecp, struct _GConfClient *gconf);
-/* ********************************************************************** */
-
-typedef struct _ECalConfigHook ECalConfigHook;
-typedef struct _ECalConfigHookClass ECalConfigHookClass;
-
-struct _ECalConfigHook {
- EConfigHook hook;
-};
-
-struct _ECalConfigHookClass {
- EConfigHookClass hook_class;
-};
-
-GType e_cal_config_hook_get_type (void);
-
G_END_DECLS
#endif
diff --git a/calendar/gui/e-cal-event.c b/calendar/gui/e-cal-event.c
index 86bd20e4e7..7d0a9d196d 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_BACKEND: {
+ ECalEventTargetBackend *s = (ECalEventTargetBackend *) t;
+ if (s->shell_backend)
+ g_object_unref (s->shell_backend);
+ if (s->source_list)
+ g_object_unref (s->source_list);
break; }
}
@@ -92,69 +94,14 @@ e_cal_event_peek (void)
return e_cal_event;
}
-ECalEventTargetComponent *
-e_cal_event_target_new_component (ECalEvent *ece, struct _CalendarComponent *component, guint32 flags)
+ECalEventTargetBackend *
+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));
+ ECalEventTargetBackend *t = e_event_target_new (&ece->event, E_CAL_EVENT_TARGET_BACKEND, 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;
}
-
-/* ********************************************************************** */
-
-static gpointer eceh_parent_class;
-
-static const EEventHookTargetMask eceh_component_masks[] = {
- { "migration", E_CAL_EVENT_COMPONENT_MIGRATION },
- { NULL },
-};
-
-static const EEventHookTargetMap eceh_targets[] = {
- { "component", E_CAL_EVENT_TARGET_COMPONENT, eceh_component_masks },
- { NULL },
-};
-
-static void
-eceh_finalize (GObject *o)
-{
- ((GObjectClass *) eceh_parent_class)->finalize (o);
-}
-
-static void
-eceh_class_init (EPluginHookClass *klass)
-{
- gint i;
-
- ((GObjectClass *)klass)->finalize = eceh_finalize;
- ((EPluginHookClass *)klass)->id = "org.gnome.evolution.calendar.events:1.0";
-
- for (i = 0; eceh_targets[i].type; i++)
- e_event_hook_class_add_target_map ((EEventHookClass *)klass, &eceh_targets[i]);
-
- ((EEventHookClass *)klass)->event = (EEvent *) e_cal_event_peek ();
-}
-
-GType
-e_cal_event_hook_get_type (void)
-{
- static GType type = 0;
-
- if (!type) {
- static const GTypeInfo info = {
- sizeof (ECalEventHookClass),
- NULL, NULL,
- (GClassInitFunc) eceh_class_init,
- NULL, NULL,
- sizeof (ECalEventHook), 0,
- (GInstanceInitFunc) NULL,
- };
-
- eceh_parent_class = g_type_class_ref (e_event_hook_get_type ());
- type = g_type_register_static (e_event_hook_get_type (), "ECalEventHook", &info, 0);
- }
-
- return type;
-}
diff --git a/calendar/gui/e-cal-event.h b/calendar/gui/e-cal-event.h
index 8fb28dfd17..8d72a93fa5 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_BACKEND,
};
-/* Flags that describe TARGET_COMPONENT */
+/* Flags that describe TARGET_BACKEND */
enum {
- E_CAL_EVENT_COMPONENT_MIGRATION = 1 << 0
+ E_CAL_EVENT_MODULE_MIGRATION = 1 << 0,
};
-typedef struct _ECalEventTargetComponent ECalEventTargetComponent;
+typedef struct _ECalEventTargetBackend ECalEventTargetBackend;
-struct _ECalEventTargetComponent {
+struct _ECalEventTargetBackend {
EEventTarget target;
-
- struct _CalendarComponent *component;
+ EShellBackend *shell_backend;
+ ESourceList *source_list;
};
struct _ECalEvent {
@@ -62,22 +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);
-
-/* ********************************************************************** */
-
-typedef struct _ECalEventHook ECalEventHook;
-typedef struct _ECalEventHookClass ECalEventHookClass;
-
-struct _ECalEventHook {
- EEventHook hook;
-};
-
-struct _ECalEventHookClass {
- EEventHookClass hook_class;
-};
-
-GType e_cal_event_hook_get_type (void);
+ECalEventTargetBackend* e_cal_event_target_new_module (ECalEvent *ece, EShellBackend *shell_backend, ESourceList *source_list, guint32 flags);
G_END_DECLS
diff --git a/calendar/gui/e-cal-list-view-config.c b/calendar/gui/e-cal-list-view-config.c
deleted file mode 100644
index 543b5e8eb7..0000000000
--- a/calendar/gui/e-cal-list-view-config.c
+++ /dev/null
@@ -1,201 +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 "calendar-config.h"
-#include "e-cal-list-view-config.h"
-
-struct _ECalListViewConfigPrivate {
- ECalListView *view;
-
- GList *notifications;
-};
-
-/* Property IDs */
-enum props {
- PROP_0,
- PROP_VIEW
-};
-
-G_DEFINE_TYPE (ECalListViewConfig, e_cal_list_view_config, G_TYPE_OBJECT)
-
-static void
-e_cal_list_view_config_set_property (GObject *object, guint property_id, const GValue *value, GParamSpec *pspec)
-{
- ECalListViewConfig *view_config;
-
- view_config = E_CAL_LIST_VIEW_CONFIG (object);
-
- switch (property_id) {
- case PROP_VIEW:
- e_cal_list_view_config_set_view (view_config, g_value_get_object (value));
- break;
- default:
- G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
- break;
- }
-}
-
-static void
-e_cal_list_view_config_get_property (GObject *object, guint property_id, GValue *value, GParamSpec *pspec)
-{
- ECalListViewConfig *view_config;
-
- view_config = E_CAL_LIST_VIEW_CONFIG (object);
-
- switch (property_id) {
- case PROP_VIEW:
- g_value_set_object (value, e_cal_list_view_config_get_view (view_config));
- break;
- default:
- G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
- break;
- }
-}
-
-static void
-e_cal_list_view_config_dispose (GObject *object)
-{
- ECalListViewConfig *view_config = E_CAL_LIST_VIEW_CONFIG (object);
-
- e_cal_list_view_config_set_view (view_config, NULL);
-
- if (G_OBJECT_CLASS (e_cal_list_view_config_parent_class)->dispose)
- G_OBJECT_CLASS (e_cal_list_view_config_parent_class)->dispose (object);
-}
-
-static void
-e_cal_list_view_config_finalize (GObject *object)
-{
- ECalListViewConfig *view_config = E_CAL_LIST_VIEW_CONFIG (object);
- ECalListViewConfigPrivate *priv;
-
- priv = view_config->priv;
-
- g_free (priv);
-
- if (G_OBJECT_CLASS (e_cal_list_view_config_parent_class)->finalize)
- G_OBJECT_CLASS (e_cal_list_view_config_parent_class)->finalize (object);
-}
-
-static void
-e_cal_list_view_config_class_init (ECalListViewConfigClass *klass)
-{
- GObjectClass *gobject_class = G_OBJECT_CLASS (klass);
- GParamSpec *spec;
-
- /* Method override */
- gobject_class->set_property = e_cal_list_view_config_set_property;
- gobject_class->get_property = e_cal_list_view_config_get_property;
- gobject_class->dispose = e_cal_list_view_config_dispose;
- gobject_class->finalize = e_cal_list_view_config_finalize;
-
- spec = g_param_spec_object ("view", NULL, NULL, e_cal_list_view_get_type (),
- G_PARAM_READABLE | G_PARAM_WRITABLE | G_PARAM_CONSTRUCT);
- g_object_class_install_property (gobject_class, PROP_VIEW, spec);
-}
-
-static void
-e_cal_list_view_config_init (ECalListViewConfig *view_config)
-{
- view_config->priv = g_new0 (ECalListViewConfigPrivate, 1);
-
-}
-
-ECalListViewConfig *
-e_cal_list_view_config_new (ECalListView *list_view)
-{
- ECalListViewConfig *view_config;
-
- view_config = g_object_new (e_cal_list_view_config_get_type (), "view", list_view, NULL);
-
- return view_config;
-}
-
-ECalListView *
-e_cal_list_view_config_get_view (ECalListViewConfig *view_config)
-{
- ECalListViewConfigPrivate *priv;
-
- g_return_val_if_fail (view_config != NULL, NULL);
- g_return_val_if_fail (E_IS_CAL_LIST_VIEW_CONFIG (view_config), NULL);
-
- priv = view_config->priv;
-
- return priv->view;
-}
-
-static void
-set_twentyfour_hour (ECalListView *list_view)
-{
- gboolean use_24_hour;
-
- use_24_hour = calendar_config_get_24_hour_format ();
-
- e_calendar_view_set_use_24_hour_format (E_CALENDAR_VIEW (list_view), use_24_hour);
-}
-
-static void
-twentyfour_hour_changed_cb (GConfClient *client, guint id, GConfEntry *entry, gpointer data)
-{
- ECalListViewConfig *view_config = data;
- ECalListViewConfigPrivate *priv;
-
- priv = view_config->priv;
-
- set_twentyfour_hour (priv->view);
-}
-
-void
-e_cal_list_view_config_set_view (ECalListViewConfig *view_config, ECalListView *list_view)
-{
- ECalListViewConfigPrivate *priv;
- guint not;
- GList *l;
-
- g_return_if_fail (view_config != NULL);
- g_return_if_fail (E_IS_CAL_LIST_VIEW_CONFIG (view_config));
-
- priv = view_config->priv;
-
- if (priv->view) {
- g_object_unref (priv->view);
- priv->view = 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;
-
- /* If the new view is NULL, return right now */
- if (!list_view)
- return;
-
- priv->view = g_object_ref (list_view);
-
- /* 24 Hour format */
- set_twentyfour_hour (list_view);
-
- not = calendar_config_add_notification_24_hour_format (twentyfour_hour_changed_cb, view_config);
- priv->notifications = g_list_prepend (priv->notifications, GUINT_TO_POINTER (not));
-}
diff --git a/calendar/gui/e-cal-list-view-config.h b/calendar/gui/e-cal-list-view-config.h
deleted file mode 100644
index 270228bed6..0000000000
--- a/calendar/gui/e-cal-list-view-config.h
+++ /dev/null
@@ -1,56 +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:
- * JP Rosevear <jpr@ximian.com>
- *
- * Copyright (C) 1999-2008 Novell, Inc. (www.novell.com)
- *
- */
-
-#ifndef _E_CAL_LIST_VIEW_CONFIG_H_
-#define _E_CAL_LIST_VIEW_CONFIG_H_
-
-#include "e-cal-list-view.h"
-
-G_BEGIN_DECLS
-
-#define E_CAL_LIST_VIEW_CONFIG(obj) G_TYPE_CHECK_INSTANCE_CAST (obj, e_cal_list_view_config_get_type (), ECalListViewConfig)
-#define E_CAL_LIST_VIEW_CONFIG_CLASS(klass) G_TYPE_CHECK_CLASS_CAST (klass, e_cal_list_view_config_get_type (), ECalListViewConfigClass)
-#define E_IS_CAL_LIST_VIEW_CONFIG(obj) G_TYPE_CHECK_INSTANCE_TYPE (obj, e_cal_list_view_config_get_type ())
-
-typedef struct _ECalListViewConfig ECalListViewConfig;
-typedef struct _ECalListViewConfigClass ECalListViewConfigClass;
-typedef struct _ECalListViewConfigPrivate ECalListViewConfigPrivate;
-
-struct _ECalListViewConfig {
- GObject parent;
-
- ECalListViewConfigPrivate *priv;
-};
-
-struct _ECalListViewConfigClass {
- GObjectClass parent_class;
-};
-
-GType e_cal_list_view_config_get_type (void);
-ECalListViewConfig *e_cal_list_view_config_new (ECalListView *list_view);
-ECalListView *e_cal_list_view_config_get_view (ECalListViewConfig *view_config);
-void e_cal_list_view_config_set_view (ECalListViewConfig *view_config, ECalListView *list_view);
-
-G_END_DECLS
-
-#endif
diff --git a/calendar/gui/e-cal-list-view.c b/calendar/gui/e-cal-list-view.c
index d0771398c1..42e7f941eb 100644
--- a/calendar/gui/e-cal-list-view.c
+++ b/calendar/gui/e-cal-list-view.c
@@ -35,6 +35,7 @@
#include <glib/gstdio.h>
#include <gdk/gdkkeysyms.h>
#include <misc/e-gui-utils.h>
+#include <e-util/e-binding.h>
#include <table/e-table-memory-store.h>
#include <table/e-cell-checkbox.h>
#include <table/e-cell-toggle.h>
@@ -42,7 +43,7 @@
#include <table/e-cell-combo.h>
#include <table/e-cell-date.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>
@@ -57,7 +58,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"
@@ -72,7 +72,7 @@ static gboolean e_cal_list_view_get_visible_time_range (ECalendarView *cal_view
static gboolean e_cal_list_view_popup_menu (GtkWidget *widget);
static void e_cal_list_view_show_popup_menu (ECalListView *cal_list_view, gint row,
- GdkEvent *gdk_event);
+ GdkEventButton *event);
static gboolean e_cal_list_view_on_table_double_click (GtkWidget *table, gint row, gint col,
GdkEvent *event, gpointer data);
static gboolean e_cal_list_view_on_table_right_click (GtkWidget *table, gint row, gint col,
@@ -189,15 +189,15 @@ e_cal_list_view_save_state (ECalListView *cal_list_view, gchar *filename)
static void
setup_e_table (ECalListView *cal_list_view)
{
- ECalModelCalendar *model;
- ETableExtras *extras;
- GList *strings;
- ECell *cell, *popup_cell;
- GnomeCanvas *canvas;
- GtkStyle *style;
- gchar *etspecfile;
+ ECalModel *model;
+ ETableExtras *extras;
+ GList *strings;
+ ECell *cell, *popup_cell;
+ GnomeCanvas *canvas;
+ GtkStyle *style;
+ gchar *etspecfile;
- model = E_CAL_MODEL_CALENDAR (e_calendar_view_get_model (E_CALENDAR_VIEW (cal_list_view)));
+ model = e_calendar_view_get_model (E_CALENDAR_VIEW (cal_list_view));
/* Create the header columns */
@@ -219,9 +219,22 @@ setup_e_table (ECalListView *cal_list_view)
"bg_color_column", E_CAL_MODEL_FIELD_COLOR,
NULL);
+ e_mutual_binding_new (
+ G_OBJECT (model), "timezone",
+ G_OBJECT (cell), "timezone");
+
+ e_mutual_binding_new (
+ G_OBJECT (model), "use-24-hour-format",
+ G_OBJECT (cell), "use-24-hour-format");
+
popup_cell = e_cell_date_edit_new ();
e_cell_popup_set_child (E_CELL_POPUP (popup_cell), cell);
g_object_unref (cell);
+
+ e_mutual_binding_new (
+ G_OBJECT (model), "use-24-hour-format",
+ G_OBJECT (popup_cell), "use-24-hour-format");
+
e_table_extras_add_cell (extras, "dateedit", popup_cell);
cal_list_view->dates_cell = E_CELL_DATE_EDIT (popup_cell);
@@ -297,35 +310,24 @@ setup_e_table (ECalListView *cal_list_view)
gtk_widget_show (GTK_WIDGET (cal_list_view->table_scrolled));
}
-GtkWidget *
-e_cal_list_view_construct (ECalListView *cal_list_view)
-{
- setup_e_table (cal_list_view);
-
- return GTK_WIDGET (cal_list_view);
-}
-
/**
* e_cal_list_view_new:
* @Returns: a new #ECalListView.
*
* Creates a new #ECalListView.
**/
-GtkWidget *
+ECalendarView *
e_cal_list_view_new (ECalModel *model)
{
- ECalListView *cal_list_view;
+ ECalendarView *cal_list_view;
- cal_list_view = g_object_new (e_cal_list_view_get_type (), "model", model, NULL);
- if (!e_cal_list_view_construct (cal_list_view)) {
- g_message (G_STRLOC ": Could not construct the calendar list GUI");
- g_object_unref (cal_list_view);
- return NULL;
- }
+ cal_list_view = g_object_new (
+ E_TYPE_CAL_LIST_VIEW, "model", model, NULL);
+ setup_e_table (E_CAL_LIST_VIEW (cal_list_view));
g_object_unref (model);
- return GTK_WIDGET (cal_list_view);
+ return cal_list_view;
}
static void
@@ -361,12 +363,11 @@ 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)
+e_cal_list_view_show_popup_menu (ECalListView *cal_list_view,
+ gint row,
+ GdkEventButton *event)
{
- 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());
+ e_calendar_view_popup_event (E_CALENDAR_VIEW (cal_list_view), event);
}
static gboolean
@@ -408,7 +409,7 @@ e_cal_list_view_on_table_right_click (GtkWidget *table, gint row, gint col, GdkE
{
ECalListView *cal_list_view = E_CAL_LIST_VIEW (data);
- e_cal_list_view_show_popup_menu (cal_list_view, row, event);
+ e_cal_list_view_show_popup_menu (cal_list_view, row, (GdkEventButton *) event);
return TRUE;
}
diff --git a/calendar/gui/e-cal-list-view.h b/calendar/gui/e-cal-list-view.h
index df5b3dbeab..f4f71a6269 100644
--- a/calendar/gui/e-cal-list-view.h
+++ b/calendar/gui/e-cal-list-view.h
@@ -30,22 +30,36 @@
#include "e-calendar-view.h"
#include "gnome-cal.h"
-G_BEGIN_DECLS
-
/*
* ECalListView - displays calendar events in an ETable.
*/
-#define E_CAL_LIST_VIEW(obj) G_TYPE_CHECK_INSTANCE_CAST (obj, e_cal_list_view_get_type (), ECalListView)
-#define E_CAL_LIST_VIEW_CLASS(klass) G_TYPE_CHECK_CLASS_CAST (klass, e_cal_list_view_get_type (), ECalListViewClass)
-#define E_IS_CAL_LIST_VIEW(obj) G_TYPE_CHECK_INSTANCE_TYPE (obj, e_cal_list_view_get_type ())
+/* Standard GObject macros */
+#define E_TYPE_CAL_LIST_VIEW \
+ (e_cal_list_view_get_type ())
+#define E_CAL_LIST_VIEW(obj) \
+ (G_TYPE_CHECK_INSTANCE_CAST \
+ ((obj), E_TYPE_CAL_LIST_VIEW, ECalListView))
+#define E_CAL_LIST_VIEW_CLASS(cls) \
+ (G_TYPE_CHECK_CLASS_CAST \
+ ((cls), E_TYPE_CAL_LIST_VIEW, ECalListViewClass))
+#define E_IS_CAL_LIST_VIEW(obj) \
+ (G_TYPE_CHECK_INSTANCE_TYPE \
+ ((obj), E_TYPE_CAL_LIST_VIEW))
+#define E_IS_CAL_LIST_VIEW_CLASS(cls) \
+ (G_TYPE_CHECK_CLASS_TYPE \
+ ((cls), E_TYPE_CAL_LIST_VIEW))
+#define E_CAL_LIST_VIEW_GET_CLASS(obj) \
+ (G_TYPE_INSTANCE_GET_CLASS \
+ ((obj), E_TYPE_CAL_LIST_VIEW, ECalListViewClass))
+
+G_BEGIN_DECLS
typedef struct _ECalListView ECalListView;
typedef struct _ECalListViewClass ECalListViewClass;
-struct _ECalListView
-{
- ECalendarView cal_view;
+struct _ECalListView {
+ ECalendarView parent;
/* The main display table */
ETableScrolled *table_scrolled;
@@ -66,15 +80,12 @@ struct _ECalListView
gint set_table_id;
};
-struct _ECalListViewClass
-{
+struct _ECalListViewClass {
ECalendarViewClass parent_class;
};
GType e_cal_list_view_get_type (void);
-GtkWidget *e_cal_list_view_construct (ECalListView *cal_list_view);
-
-GtkWidget *e_cal_list_view_new (ECalModel *cal_model);
+ECalendarView *e_cal_list_view_new (ECalModel *cal_model);
void e_cal_list_view_load_state (ECalListView *cal_list_view, gchar *filename);
void e_cal_list_view_save_state (ECalListView *cal_list_view, gchar *filename);
diff --git a/calendar/gui/e-cal-menu.c b/calendar/gui/e-cal-menu.c
deleted file mode 100644
index 30d287ff6b..0000000000
--- a/calendar/gui/e-cal-menu.c
+++ /dev/null
@@ -1,293 +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:
- * Michael Zucchi <notzed@ximian.com>
- *
- * Copyright (C) 1999-2008 Novell, Inc. (www.novell.com)
- *
- */
-
-#ifdef HAVE_CONFIG_H
-#include <config.h>
-#endif
-
-#include <string.h>
-#include <stdlib.h>
-
-#include <glib.h>
-
-#include "e-cal-menu.h"
-#include "gui/e-cal-model.h"
-#include "itip-utils.h"
-
-static void ecalm_standard_menu_factory(EMenu *emp, gpointer data);
-
-static GObjectClass *ecalm_parent;
-
-static void
-ecalm_init(GObject *o)
-{
- /*ECalMenu *emp = (ECalMenu *)o; */
-}
-
-static void
-ecalm_finalise(GObject *o)
-{
- ((GObjectClass *)ecalm_parent)->finalize(o);
-}
-
-static void
-ecalm_target_free(EMenu *ep, EMenuTarget *t)
-{
- switch (t->type) {
- case E_CAL_MENU_TARGET_SELECT: {
- ECalMenuTargetSelect *s = (ECalMenuTargetSelect *)t;
- gint i;
-
- for (i=0;i<s->events->len;i++)
- e_cal_model_free_component_data(s->events->pdata[i]);
- g_ptr_array_free(s->events, TRUE);
- g_object_unref(s->model);
- break; }
- }
-
- ((EMenuClass *)ecalm_parent)->target_free(ep, t);
-}
-
-static void
-ecalm_class_init(GObjectClass *klass)
-{
- klass->finalize = ecalm_finalise;
- ((EMenuClass *)klass)->target_free = ecalm_target_free;
-
- e_menu_class_add_factory((EMenuClass *)klass, NULL, (EMenuFactoryFunc)ecalm_standard_menu_factory, NULL);
-}
-
-GType
-e_cal_menu_get_type(void)
-{
- static GType type = 0;
-
- if (type == 0) {
- static const GTypeInfo info = {
- sizeof(ECalMenuClass),
- NULL, NULL,
- (GClassInitFunc)ecalm_class_init,
- NULL, NULL,
- sizeof(ECalMenu), 0,
- (GInstanceInitFunc)ecalm_init
- };
- ecalm_parent = g_type_class_ref(e_menu_get_type());
- type = g_type_register_static(e_menu_get_type(), "ECalMenu", &info, 0);
- }
-
- return type;
-}
-
-ECalMenu *e_cal_menu_new(const gchar *menuid)
-{
- ECalMenu *emp = g_object_new(e_cal_menu_get_type(), NULL);
-
- e_menu_construct(&emp->menu, menuid);
-
- return emp;
-}
-
-/**
- * e_cal_menu_target_new_select:
- * @folder: The selection will ref this for the life of it.
- * @folder_uri:
- * @uids: The selection will free this when done with it.
- *
- * Create a new selection popup target.
- *
- * Return value:
- **/
-ECalMenuTargetSelect *
-e_cal_menu_target_new_select(ECalMenu *eabp, struct _ECalModel *model, GPtrArray *events)
-{
- ECalMenuTargetSelect *t = e_menu_target_new(&eabp->menu, E_CAL_MENU_TARGET_SELECT, sizeof(*t));
- guint32 mask = ~0;
- ECal *client;
- gboolean read_only;
-
- /* FIXME: This is duplicated in e-cal-popup */
-
- t->model = model;
- g_object_ref(t->model);
- t->events = events;
-
- if (t->events->len == 0) {
- client = e_cal_model_get_default_client(t->model);
- } else {
- ECalModelComponent *comp_data = (ECalModelComponent *)t->events->pdata[0];
-
- mask &= ~E_CAL_MENU_SELECT_ANY;
- if (t->events->len == 1)
- mask &= ~E_CAL_MENU_SELECT_ONE;
- else
- mask &= ~E_CAL_MENU_SELECT_MANY;
-
- if (icalcomponent_get_first_property (comp_data->icalcomp, ICAL_URL_PROPERTY))
- mask &= ~E_CAL_MENU_SELECT_HASURL;
-
- if (!e_cal_get_static_capability (comp_data->client, CAL_STATIC_CAPABILITY_NO_TASK_ASSIGNMENT)
- && !e_cal_get_static_capability (comp_data->client, CAL_STATIC_CAPABILITY_NO_CONV_TO_ASSIGN_TASK)
- && !icalcomponent_get_first_property (comp_data->icalcomp, ICAL_ATTENDEE_PROPERTY))
- mask &= ~E_CAL_MENU_SELECT_ASSIGNABLE;
-
- if (!icalcomponent_get_first_property (comp_data->icalcomp, ICAL_COMPLETED_PROPERTY))
- mask &= ~ E_CAL_MENU_SELECT_NOTCOMPLETE;
-
- if (e_cal_util_component_has_recurrences (comp_data->icalcomp))
- mask &= ~E_CAL_MENU_SELECT_RECURRING;
- else if (e_cal_util_component_is_instance (comp_data->icalcomp))
- mask &= ~E_CAL_MENU_SELECT_RECURRING;
- else
- mask &= ~E_CAL_MENU_SELECT_NONRECURRING;
-
- if (e_cal_util_component_is_instance (comp_data->icalcomp))
- mask &= ~E_CAL_MENU_SELECT_INSTANCE;
-
- if (e_cal_util_component_has_organizer (comp_data->icalcomp)) {
- ECalComponent *comp;
-
- comp = e_cal_component_new ();
- e_cal_component_set_icalcomponent (comp, icalcomponent_new_clone (comp_data->icalcomp));
- if (!itip_organizer_is_user (comp, comp_data->client))
- mask &= ~E_CAL_MENU_SELECT_ORGANIZER;
-
- g_object_unref (comp);
- } else {
- /* organiser is synonym for owner in this case */
- mask &= ~(E_CAL_MENU_SELECT_ORGANIZER|E_CAL_MENU_SELECT_NOTMEETING);
- }
-
- client = comp_data->client;
- }
-
- if (client) {
- e_cal_is_read_only(client, &read_only, NULL);
- if (!read_only)
- mask &= ~E_CAL_MENU_SELECT_EDITABLE;
- }
-
- /* This bit isn't implemented ... */
- mask &= ~E_CAL_MENU_SELECT_NOTEDITING;
-
- t->target.mask = mask;
-
- return t;
-}
-
-static void
-ecalm_standard_menu_factory(EMenu *emp, gpointer data)
-{
- /* noop */
-}
-
-/* ********************************************************************** */
-
-/* menu plugin handler */
-
-/*
-<e-plugin
- class="org.gnome.mail.plugin.popup:1.0"
- id="org.gnome.mail.plugin.popup.item:1.0"
- type="shlib"
- location="/opt/gnome2/lib/camel/1.0/libcamelimap.so"
- name="imap"
- description="IMAP4 and IMAP4v1 mail store">
- <hook class="org.gnome.mail.popupMenu:1.0"
- handler="HandlePopup">
- <menu id="any" target="select">
- <item
- type="item|toggle|radio|image|submenu|bar"
- active
- path="foo/bar"
- label="label"
- icon="foo"
- mask="select_one"
- activate="ecalm_view_emacs"/>
- </menu>
- </extension>
-
-*/
-
-static gpointer ecalph_parent_class;
-#define ecalph ((ECalMenuHook *)eph)
-
-static const EMenuHookTargetMask ecalph_select_masks[] = {
- { "one", E_CAL_MENU_SELECT_ONE },
- { "many", E_CAL_MENU_SELECT_MANY },
- { "editable", E_CAL_MENU_SELECT_EDITABLE },
- { "recurring", E_CAL_MENU_SELECT_RECURRING },
- { "non-recurring", E_CAL_MENU_SELECT_NONRECURRING },
- { "instance", E_CAL_MENU_SELECT_INSTANCE },
- { "organizer", E_CAL_MENU_SELECT_ORGANIZER },
- { "not-editing", E_CAL_MENU_SELECT_NOTEDITING },
- { "not-meeting", E_CAL_MENU_SELECT_NOTMEETING },
- { "assignable", E_CAL_MENU_SELECT_ASSIGNABLE },
- { "hasurl", E_CAL_MENU_SELECT_HASURL },
- { "not-complete", E_CAL_MENU_SELECT_NOTCOMPLETE },
- { NULL }
-};
-
-static const EMenuHookTargetMap ecalph_targets[] = {
- { "select", E_CAL_MENU_TARGET_SELECT, ecalph_select_masks },
- { NULL }
-};
-
-static void
-ecalph_finalise(GObject *o)
-{
- /*EPluginHook *eph = (EPluginHook *)o;*/
-
- ((GObjectClass *)ecalph_parent_class)->finalize(o);
-}
-
-static void
-ecalph_class_init(EPluginHookClass *klass)
-{
- gint i;
-
- ((GObjectClass *)klass)->finalize = ecalph_finalise;
- ((EPluginHookClass *)klass)->id = "org.gnome.evolution.calendar.bonobomenu:1.0";
-
- for (i = 0; ecalph_targets[i].type; i++)
- e_menu_hook_class_add_target_map((EMenuHookClass *)klass, &ecalph_targets[i]);
-
- /* FIXME: leaks parent set class? */
- ((EMenuHookClass *)klass)->menu_class = g_type_class_ref(e_cal_menu_get_type());
-}
-
-GType
-e_cal_menu_hook_get_type(void)
-{
- static GType type = 0;
-
- if (!type) {
- static const GTypeInfo info = {
- sizeof(ECalMenuHookClass), NULL, NULL, (GClassInitFunc) ecalph_class_init, NULL, NULL,
- sizeof(ECalMenuHook), 0, (GInstanceInitFunc) NULL,
- };
-
- ecalph_parent_class = g_type_class_ref(e_menu_hook_get_type());
- type = g_type_register_static(e_menu_hook_get_type(), "ECalMenuHook", &info, 0);
- }
-
- return type;
-}
diff --git a/calendar/gui/e-cal-menu.h b/calendar/gui/e-cal-menu.h
deleted file mode 100644
index 0667f92051..0000000000
--- a/calendar/gui/e-cal-menu.h
+++ /dev/null
@@ -1,121 +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:
- * Michel Zucchi <notzed@ximian.com>
- *
- * Copyright (C) 1999-2008 Novell, Inc. (www.novell.com)
- *
- */
-
-#ifndef __E_CAL_MENU_H__
-#define __E_CAL_MENU_H__
-
-#include <glib-object.h>
-
-#include "e-util/e-menu.h"
-
-G_BEGIN_DECLS
-
-typedef struct _ECalMenu ECalMenu;
-typedef struct _ECalMenuClass ECalMenuClass;
-
-/* Current target description */
-/* Types of popup tagets */
-enum _e_cal_menu_target_t {
- E_CAL_MENU_TARGET_SELECT
-};
-
-/**
- * enum _e_cal_menu_target_select_t - ECalPopupTargetSelect qualifiers.
- *
- * @E_CAL_MENU_SELECT_ONE: Only one item is selected.
- * @E_CAL_MENU_SELECT_MANY: More than one item selected.
- * @E_CAL_MENU_SELECT_ANY: One or more items selected.
- * @E_CAL_MENU_SELECT_EDITABLE: The selection is editable.
- * @E_CAL_MENU_SELECT_RECURRING: Is a recurring event.
- * @E_CAL_MENU_SELECT_NONRECURRING: Is not a recurring event.
- * @E_CAL_MENU_SELECT_INSTANCE: This is an instance event.
- * @E_CAL_MENU_SELECT_ORGANIZER: The user is the organiser of the event.
- * @E_CAL_MENU_SELECT_NOTEDITING: The event is not being edited already. Not implemented.
- * @E_CAL_MENU_SELECT_NOTMEETING: The event is not a meeting.
- * @E_CAL_MENU_SELECT_ASSIGNABLE: An assignable task.
- * @E_CAL_MENU_SELECT_HASURL: A task that contains a URL.
- **/
-enum _e_cal_menu_target_select_t {
- E_CAL_MENU_SELECT_ONE = 1<<0,
- E_CAL_MENU_SELECT_MANY = 1<<1,
- E_CAL_MENU_SELECT_ANY = 1<<2,
- E_CAL_MENU_SELECT_EDITABLE = 1<<3,
- E_CAL_MENU_SELECT_RECURRING = 1<<4,
- E_CAL_MENU_SELECT_NONRECURRING = 1<<5,
- E_CAL_MENU_SELECT_INSTANCE = 1<<6,
-
- E_CAL_MENU_SELECT_ORGANIZER = 1<<7,
- E_CAL_MENU_SELECT_NOTEDITING = 1<<8,
- E_CAL_MENU_SELECT_NOTMEETING = 1<<9,
-
- E_CAL_MENU_SELECT_ASSIGNABLE = 1<<10,
- E_CAL_MENU_SELECT_HASURL = 1<<11,
- E_CAL_MENU_SELECT_NOTCOMPLETE = 1<<12
-};
-
-typedef struct _ECalMenuTargetSelect ECalMenuTargetSelect;
-
-struct _ECalMenuTargetSelect {
- EMenuTarget target;
-
- struct _ECalModel *model;
- GPtrArray *events;
-};
-
-typedef struct _EMenuItem ECalMenuItem;
-
-/* The object */
-struct _ECalMenu {
- EMenu menu;
-
- struct _ECalMenuPrivate *priv;
-};
-
-struct _ECalMenuClass {
- EMenuClass menu_class;
-};
-
-GType e_cal_menu_get_type(void);
-
-ECalMenu *e_cal_menu_new(const gchar *menuid);
-
-ECalMenuTargetSelect *e_cal_menu_target_new_select(ECalMenu *emp, struct _ECalModel *model, GPtrArray *events);
-
-/* ********************************************************************** */
-
-typedef struct _ECalMenuHook ECalMenuHook;
-typedef struct _ECalMenuHookClass ECalMenuHookClass;
-
-struct _ECalMenuHook {
- EMenuHook hook;
-};
-
-struct _ECalMenuHookClass {
- EMenuHookClass hook_class;
-};
-
-GType e_cal_menu_hook_get_type(void);
-
-G_END_DECLS
-
-#endif /* __E_CAL_MENU_H__ */
diff --git a/calendar/gui/e-cal-model-calendar.c b/calendar/gui/e-cal-model-calendar.c
index fbf3235abf..9f94a601c1 100644
--- a/calendar/gui/e-cal-model-calendar.c
+++ b/calendar/gui/e-cal-model-calendar.c
@@ -570,8 +570,12 @@ ecmc_fill_component_from_model (ECalModel *model, ECalModelComponent *comp_data,
/**
* e_cal_model_calendar_new
*/
-ECalModelCalendar *
-e_cal_model_calendar_new (void)
+ECalModel *
+e_cal_model_calendar_new (EShellSettings *shell_settings)
{
- return g_object_new (E_TYPE_CAL_MODEL_CALENDAR, NULL);
+ g_return_val_if_fail (E_IS_SHELL_SETTINGS (shell_settings), NULL);
+
+ return g_object_new (
+ E_TYPE_CAL_MODEL_CALENDAR,
+ "shell-settings", shell_settings, NULL);
}
diff --git a/calendar/gui/e-cal-model-calendar.h b/calendar/gui/e-cal-model-calendar.h
index abe536399f..f1027032cb 100644
--- a/calendar/gui/e-cal-model-calendar.h
+++ b/calendar/gui/e-cal-model-calendar.h
@@ -28,14 +28,29 @@
#include "e-cal-model.h"
-G_BEGIN_DECLS
+/* Standard GObject macros */
+#define E_TYPE_CAL_MODEL_CALENDAR \
+ (e_cal_model_calendar_get_type ())
+#define E_CAL_MODEL_CALENDAR(obj) \
+ (G_TYPE_CHECK_INSTANCE_CAST \
+ ((obj), E_TYPE_CAL_MODEL_CALENDAR, ECalModelCalendar))
+#define E_CAL_MODEL_CALENDAR_CLASS(cls) \
+ (G_TYPE_CHECK_CLASS_CAST \
+ ((cls), E_TYPE_CAL_MODEL_CALENDAR, ECalModelCalendarClass))
+#define E_IS_CAL_MODEL_CALENDAR(obj) \
+ (G_TYPE_CHECK_INSTANCE_TYPE \
+ ((obj), E_TYPE_CAL_MODEL_CALENDAR))
+#define E_IS_CAL_MODEL_CALENDAR_CLASS(cls) \
+ (G_TYPE_CHECK_CLASS_TYPE \
+ ((cls), E_TYPE_CAL_MODEL_CALENDAR))
+#define E_CAL_MODEL_CALENDAR_GET_CLASS(obj) \
+ (G_TYPE_INSTANCE_GET_CLASS \
+ ((obj), E_TYPE_CAL_MODEL_CALENDAR, ECalModelCalendarClass))
-#define E_TYPE_CAL_MODEL_CALENDAR (e_cal_model_calendar_get_type ())
-#define E_CAL_MODEL_CALENDAR(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), E_TYPE_CAL_MODEL_CALENDAR, ECalModelCalendar))
-#define E_CAL_MODEL_CALENDAR_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), E_TYPE_CAL_MODEL_CALENDAR, ECalModelCalendarClass))
-#define E_IS_CAL_MODEL_CALENDAR(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), E_TYPE_CAL_MODEL_CALENDAR))
-#define E_IS_CAL_MODEL_CALENDAR_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), E_TYPE_CAL_MODEL_CALENDAR))
+G_BEGIN_DECLS
+typedef struct _ECalModelCalendar ECalModelCalendar;
+typedef struct _ECalModelCalendarClass ECalModelCalendarClass;
typedef struct _ECalModelCalendarPrivate ECalModelCalendarPrivate;
typedef enum {
@@ -47,18 +62,18 @@ typedef enum {
E_CAL_MODEL_CALENDAR_FIELD_LAST
} ECalModelCalendarField;
-typedef struct {
- ECalModel model;
+struct _ECalModelCalendar {
+ ECalModel parent;
ECalModelCalendarPrivate *priv;
-} ECalModelCalendar;
+};
-typedef struct {
+struct _ECalModelCalendarClass {
ECalModelClass parent_class;
-} ECalModelCalendarClass;
+};
-GType e_cal_model_calendar_get_type (void);
-ECalModelCalendar *e_cal_model_calendar_new (void);
+GType e_cal_model_calendar_get_type (void);
+ECalModel * e_cal_model_calendar_new (EShellSettings *shell_settings);
G_END_DECLS
-#endif
+#endif /* E_CAL_MODEL_CALENDAR_H */
diff --git a/calendar/gui/e-cal-model-memos.c b/calendar/gui/e-cal-model-memos.c
index dc21b9bdda..41f63700c8 100644
--- a/calendar/gui/e-cal-model-memos.c
+++ b/calendar/gui/e-cal-model-memos.c
@@ -260,8 +260,12 @@ ecmm_fill_component_from_model (ECalModel *model, ECalModelComponent *comp_data,
/**
* e_cal_model_memos_new
*/
-ECalModelMemos *
-e_cal_model_memos_new (void)
+ECalModel *
+e_cal_model_memos_new (EShellSettings *shell_settings)
{
- return g_object_new (E_TYPE_CAL_MODEL_MEMOS, NULL);
+ g_return_val_if_fail (E_IS_SHELL_SETTINGS (shell_settings), NULL);
+
+ return g_object_new (
+ E_TYPE_CAL_MODEL_MEMOS,
+ "shell-settings", shell_settings, NULL);
}
diff --git a/calendar/gui/e-cal-model-memos.h b/calendar/gui/e-cal-model-memos.h
index 34b8e5a14d..b58faa539b 100644
--- a/calendar/gui/e-cal-model-memos.h
+++ b/calendar/gui/e-cal-model-memos.h
@@ -29,14 +29,29 @@
#include "e-cal-model.h"
-G_BEGIN_DECLS
+/* Standard GObject macros */
+#define E_TYPE_CAL_MODEL_MEMOS \
+ (e_cal_model_memos_get_type ())
+#define E_CAL_MODEL_MEMOS(obj) \
+ (G_TYPE_CHECK_INSTANCE_CAST \
+ ((obj), E_TYPE_CAL_MODEL_MEMOS, ECalModelMemo))
+#define E_CAL_MODEL_MEMOS_CLASS(cls) \
+ (G_TYPE_CHECK_CLASS_CAST \
+ ((cls), E_TYPE_CAL_MODEL_MEMOS, ECalModelMemoClass))
+#define E_IS_CAL_MODEL_MEMOS(obj) \
+ (G_TYPE_CHECK_INSTANCE_TYPE \
+ ((obj), E_TYPE_CAL_MODEL_MEMOS))
+#define E_IS_CAL_MODEL_MEMOS_CLASS(cls) \
+ (G_TYPE_CHECK_CLASS_TYPE \
+ ((cls), E_TYPE_CAL_MODEL_MEMOS))
+#define E_CAL_MODEL_MEMOS_GET_CLASS(obj) \
+ (G_TYPE_INSTANCE_GET_CLASS \
+ ((obj), E_TYPE_CAL_MODEL_MEMOS, ECalModelMemoClass))
-#define E_TYPE_CAL_MODEL_MEMOS (e_cal_model_memos_get_type ())
-#define E_CAL_MODEL_MEMOS(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), E_TYPE_CAL_MODEL_MEMOS, ECalModelMemo))
-#define E_CAL_MODEL_MEMOS_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), E_TYPE_CAL_MODEL_MEMOS, ECalModelMemoClass))
-#define E_IS_CAL_MODEL_MEMOS(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), E_TYPE_CAL_MODEL_MEMOS))
-#define E_IS_CAL_MODEL_MEMOS_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), E_TYPE_CAL_MODEL_MEMOS))
+G_BEGIN_DECLS
+typedef struct _ECalModelMemos ECalModelMemos;
+typedef struct _ECalModelMemosClass ECalModelMemosClass;
typedef struct _ECalModelMemosPrivate ECalModelMemosPrivate;
typedef enum {
@@ -46,18 +61,18 @@ typedef enum {
} ECalModelMemoField;
-typedef struct {
- ECalModel model;
+struct _ECalModelMemos {
+ ECalModel parent;
ECalModelMemosPrivate *priv;
-} ECalModelMemos;
+};
-typedef struct {
+struct _ECalModelMemosClass {
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 (EShellSettings *shell_settings);
G_END_DECLS
-#endif
+#endif /* E_CAL_MODEL_MEMOS_H */
diff --git a/calendar/gui/e-cal-model-tasks.c b/calendar/gui/e-cal-model-tasks.c
index d951d13878..74647e46dc 100644
--- a/calendar/gui/e-cal-model-tasks.c
+++ b/calendar/gui/e-cal-model-tasks.c
@@ -31,17 +31,22 @@
#include <gtk/gtk.h>
#include <glib/gi18n.h>
#include <libedataserver/e-data-server-util.h>
+
+#include "e-util/e-binding.h"
#include "calendar-config.h"
#include "e-cal-model-tasks.h"
#include "e-cell-date-edit-text.h"
#include "misc.h"
+#define E_CAL_MODEL_TASKS_GET_PRIVATE(obj) \
+ (G_TYPE_INSTANCE_GET_PRIVATE \
+ ((obj), E_TYPE_CAL_MODEL_TASKS, ECalModelTasksPrivate))
+
struct _ECalModelTasksPrivate {
- guint reserved;
+ gchar *color_due_today;
+ gchar *color_overdue;
};
-static void e_cal_model_tasks_finalize (GObject *object);
-
static gint ecmt_column_count (ETableModel *etm);
static gpointer ecmt_value_at (ETableModel *etm, gint col, gint row);
static void ecmt_set_value_at (ETableModel *etm, gint col, gint row, gconstpointer value);
@@ -59,56 +64,153 @@ static void commit_component_changes (ECalModelComponent *comp_data);
G_DEFINE_TYPE (ECalModelTasks, e_cal_model_tasks, E_TYPE_CAL_MODEL)
+enum {
+ PROP_0,
+ PROP_COLOR_DUE_TODAY,
+ PROP_COLOR_OVERDUE
+};
+
static void
-e_cal_model_tasks_class_init (ECalModelTasksClass *klass)
+cal_model_tasks_set_property (GObject *object,
+ guint property_id,
+ const GValue *value,
+ GParamSpec *pspec)
{
- GObjectClass *object_class = G_OBJECT_CLASS (klass);
- ETableModelClass *etm_class = E_TABLE_MODEL_CLASS (klass);
- ECalModelClass *model_class = E_CAL_MODEL_CLASS (klass);
-
- object_class->finalize = e_cal_model_tasks_finalize;
-
- etm_class->column_count = ecmt_column_count;
- etm_class->value_at = ecmt_value_at;
- etm_class->set_value_at = ecmt_set_value_at;
- etm_class->is_cell_editable = ecmt_is_cell_editable;
- etm_class->duplicate_value = ecmt_duplicate_value;
- etm_class->free_value = ecmt_free_value;
- etm_class->initialize_value = ecmt_initialize_value;
- etm_class->value_is_empty = ecmt_value_is_empty;
- etm_class->value_to_string = ecmt_value_to_string;
-
- model_class->get_color_for_component = ecmt_get_color_for_component;
- model_class->fill_component_from_model = ecmt_fill_component_from_model;
+ switch (property_id) {
+ case PROP_COLOR_DUE_TODAY:
+ e_cal_model_tasks_set_color_due_today (
+ E_CAL_MODEL_TASKS (object),
+ g_value_get_string (value));
+ return;
+
+ case PROP_COLOR_OVERDUE:
+ e_cal_model_tasks_set_color_overdue (
+ E_CAL_MODEL_TASKS (object),
+ g_value_get_string (value));
+ return;
+ }
+
+ G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
}
static void
-e_cal_model_tasks_init (ECalModelTasks *model)
+cal_model_tasks_get_property (GObject *object,
+ guint property_id,
+ GValue *value,
+ GParamSpec *pspec)
+{
+ switch (property_id) {
+ case PROP_COLOR_DUE_TODAY:
+ g_value_set_string (
+ value,
+ e_cal_model_tasks_get_color_due_today (
+ E_CAL_MODEL_TASKS (object)));
+ return;
+
+ case PROP_COLOR_OVERDUE:
+ g_value_set_string (
+ value,
+ e_cal_model_tasks_get_color_overdue (
+ E_CAL_MODEL_TASKS (object)));
+ return;
+ }
+
+ G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
+}
+
+static void
+cal_model_tasks_finalize (GObject *object)
{
ECalModelTasksPrivate *priv;
- priv = g_new0 (ECalModelTasksPrivate, 1);
- model->priv = priv;
+ priv = E_CAL_MODEL_TASKS_GET_PRIVATE (object);
+
+ g_free (priv->color_due_today);
+ g_free (priv->color_overdue);
- e_cal_model_set_component_kind (E_CAL_MODEL (model), ICAL_VTODO_COMPONENT);
+ /* Chain up to parent's finalize() method. */
+ G_OBJECT_CLASS (e_cal_model_tasks_parent_class)->finalize (object);
}
static void
-e_cal_model_tasks_finalize (GObject *object)
+cal_model_tasks_constructed (GObject *object)
{
- ECalModelTasksPrivate *priv;
- ECalModelTasks *model = (ECalModelTasks *) object;
+ ECalModel *model;
+ EShellSettings *shell_settings;
- g_return_if_fail (E_IS_CAL_MODEL_TASKS (model));
+ model = E_CAL_MODEL (object);
+ shell_settings = e_cal_model_get_shell_settings (model);
- priv = model->priv;
- if (priv) {
- g_free (priv);
- model->priv = NULL;
- }
+ e_binding_new (
+ G_OBJECT (shell_settings), "cal-tasks-color-due-today",
+ G_OBJECT (model), "color-due-today");
+
+ e_binding_new (
+ G_OBJECT (shell_settings), "cal-tasks-color-overdue",
+ G_OBJECT (model), "color-overdue");
+
+ /* Chain up to parent's constructed() method. */
+ G_OBJECT_CLASS (e_cal_model_tasks_parent_class)->constructed (object);
+}
+
+static void
+e_cal_model_tasks_class_init (ECalModelTasksClass *class)
+{
+ GObjectClass *object_class;
+ ETableModelClass *table_model_class;
+ ECalModelClass *cal_model_class;
+
+ g_type_class_add_private (class, sizeof (ECalModelTasksPrivate));
+
+ object_class = G_OBJECT_CLASS (class);
+ object_class->set_property = cal_model_tasks_set_property;
+ object_class->get_property = cal_model_tasks_get_property;
+ object_class->finalize = cal_model_tasks_finalize;
+ object_class->constructed = cal_model_tasks_constructed;
+
+ table_model_class = E_TABLE_MODEL_CLASS (class);
+ table_model_class->column_count = ecmt_column_count;
+ table_model_class->value_at = ecmt_value_at;
+ table_model_class->set_value_at = ecmt_set_value_at;
+ table_model_class->is_cell_editable = ecmt_is_cell_editable;
+ table_model_class->duplicate_value = ecmt_duplicate_value;
+ table_model_class->free_value = ecmt_free_value;
+ table_model_class->initialize_value = ecmt_initialize_value;
+ table_model_class->value_is_empty = ecmt_value_is_empty;
+ table_model_class->value_to_string = ecmt_value_to_string;
+
+ cal_model_class = E_CAL_MODEL_CLASS (class);
+ cal_model_class->get_color_for_component = ecmt_get_color_for_component;
+ cal_model_class->fill_component_from_model = ecmt_fill_component_from_model;
+
+ g_object_class_install_property (
+ object_class,
+ PROP_COLOR_DUE_TODAY,
+ g_param_spec_string (
+ "color-due-today",
+ "Color Due Today",
+ NULL,
+ "#1e90ff",
+ G_PARAM_READWRITE));
+
+ g_object_class_install_property (
+ object_class,
+ PROP_COLOR_OVERDUE,
+ g_param_spec_string (
+ "color-overdue",
+ "Color Overdue",
+ NULL,
+ "#ff0000",
+ G_PARAM_READWRITE));
+}
+
+static void
+e_cal_model_tasks_init (ECalModelTasks *model)
+{
+ model->priv = E_CAL_MODEL_TASKS_GET_PRIVATE (model);
- if (G_OBJECT_CLASS (e_cal_model_tasks_parent_class)->finalize)
- G_OBJECT_CLASS (e_cal_model_tasks_parent_class)->finalize (object);
+ e_cal_model_set_component_kind (
+ E_CAL_MODEL (model), ICAL_VTODO_COMPONENT);
}
/* ETableModel methods */
@@ -1038,11 +1140,9 @@ ecmt_value_to_string (ETableModel *etm, gint col, gconstpointer value)
/* ECalModel class methods */
static const gchar *
-ecmt_get_color_for_component (ECalModel *model, ECalModelComponent *comp_data)
+ecmt_get_color_for_component (ECalModel *model,
+ ECalModelComponent *comp_data)
{
- static gchar color_spec[16];
- GdkColor color;
-
g_return_val_if_fail (E_IS_CAL_MODEL_TASKS (model), NULL);
g_return_val_if_fail (comp_data != NULL, NULL);
@@ -1051,24 +1151,19 @@ ecmt_get_color_for_component (ECalModel *model, ECalModelComponent *comp_data)
switch (get_due_status ((ECalModelTasks *) model, comp_data)) {
case E_CAL_MODEL_TASKS_DUE_TODAY:
- /* XXX ugly hack */
- calendar_config_get_tasks_due_today_color (&color);
- g_snprintf (color_spec, sizeof (color_spec), "#%04x%04x%04x",
- color.red, color.green, color.blue);
- return color_spec;
+ return e_cal_model_tasks_get_color_due_today (
+ E_CAL_MODEL_TASKS (model));
case E_CAL_MODEL_TASKS_DUE_OVERDUE:
- /* XXX ugly hack */
- calendar_config_get_tasks_overdue_color (&color);
- g_snprintf (color_spec, sizeof (color_spec), "#%04x%04x%04x",
- color.red, color.green, color.blue);
- return color_spec;
+ return e_cal_model_tasks_get_color_overdue (
+ E_CAL_MODEL_TASKS (model));
case E_CAL_MODEL_TASKS_DUE_NEVER:
case E_CAL_MODEL_TASKS_DUE_FUTURE:
case E_CAL_MODEL_TASKS_DUE_COMPLETE:
break;
}
- return E_CAL_MODEL_CLASS (e_cal_model_tasks_parent_class)->get_color_for_component (model, comp_data);
+ return E_CAL_MODEL_CLASS (e_cal_model_tasks_parent_class)->
+ get_color_for_component (model, comp_data);
}
static void
@@ -1103,13 +1198,56 @@ ecmt_fill_component_from_model (ECalModel *model, ECalModelComponent *comp_data,
e_table_model_value_at (source_model, E_CAL_MODEL_TASKS_FIELD_URL, row));
}
-/**
- * e_cal_model_tasks_new
- */
-ECalModelTasks *
-e_cal_model_tasks_new (void)
+ECalModel *
+e_cal_model_tasks_new (EShellSettings *shell_settings)
+{
+ g_return_val_if_fail (E_IS_SHELL_SETTINGS (shell_settings), NULL);
+
+ return g_object_new (
+ E_TYPE_CAL_MODEL_TASKS,
+ "shell-settings", shell_settings, NULL);
+}
+
+const gchar *
+e_cal_model_tasks_get_color_due_today (ECalModelTasks *model)
+{
+ g_return_val_if_fail (E_IS_CAL_MODEL_TASKS (model), NULL);
+
+ return model->priv->color_due_today;
+}
+
+void
+e_cal_model_tasks_set_color_due_today (ECalModelTasks *model,
+ const gchar *color_due_today)
+{
+ g_return_if_fail (E_IS_CAL_MODEL_TASKS (model));
+ g_return_if_fail (color_due_today != NULL);
+
+ g_free (model->priv->color_due_today);
+ model->priv->color_due_today = g_strdup (color_due_today);
+
+ g_object_notify (G_OBJECT (model), "color-due-today");
+}
+
+const gchar *
+e_cal_model_tasks_get_color_overdue (ECalModelTasks *model)
+{
+ g_return_val_if_fail (E_IS_CAL_MODEL_TASKS (model), NULL);
+
+ return model->priv->color_overdue;
+}
+
+void
+e_cal_model_tasks_set_color_overdue (ECalModelTasks *model,
+ const gchar *color_overdue)
{
- return g_object_new (E_TYPE_CAL_MODEL_TASKS, NULL);
+ g_return_if_fail (E_IS_CAL_MODEL_TASKS (model));
+ g_return_if_fail (color_overdue != NULL);
+
+ g_free (model->priv->color_overdue);
+ model->priv->color_overdue = g_strdup (color_overdue);
+
+ g_object_notify (G_OBJECT (model), "color-overdue");
}
/**
diff --git a/calendar/gui/e-cal-model-tasks.h b/calendar/gui/e-cal-model-tasks.h
index 0900d1e155..056325547d 100644
--- a/calendar/gui/e-cal-model-tasks.h
+++ b/calendar/gui/e-cal-model-tasks.h
@@ -28,14 +28,29 @@
#include "e-cal-model.h"
-G_BEGIN_DECLS
+/* Standard GObject macros */
+#define E_TYPE_CAL_MODEL_TASKS \
+ (e_cal_model_tasks_get_type ())
+#define E_CAL_MODEL_TASKS(obj) \
+ (G_TYPE_CHECK_INSTANCE_CAST \
+ ((obj), E_TYPE_CAL_MODEL_TASKS, ECalModelTasks))
+#define E_CAL_MODEL_TASKS_CLASS(cls) \
+ (G_TYPE_CHECK_CLASS_CAST \
+ ((cls), E_TYPE_CAL_MODEL_TASKS, ECalModelTasksClass))
+#define E_IS_CAL_MODEL_TASKS(obj) \
+ (G_TYPE_CHECK_INSTANCE_TYPE \
+ ((obj), E_TYPE_CAL_MODEL_TASKS))
+#define E_IS_CAL_MODEL_TASKS_CLASS(cls) \
+ (G_TYPE_CHECK_CLASS_TYPE \
+ ((cls), E_TYPE_CAL_MODEL_TASKS))
+#define E_CAL_MODEL_TASKS_GET_CLASS(obj) \
+ (G_TYPE_INSTANCE_GET_CLASS \
+ ((obj), E_TYPE_CAL_MODEL_TASKS, ECalModelTasksClass))
-#define E_TYPE_CAL_MODEL_TASKS (e_cal_model_tasks_get_type ())
-#define E_CAL_MODEL_TASKS(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), E_TYPE_CAL_MODEL_TASKS, ECalModelTasks))
-#define E_CAL_MODEL_TASKS_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), E_TYPE_CAL_MODEL_TASKS, ECalModelTasksClass))
-#define E_IS_CAL_MODEL_TASKS(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), E_TYPE_CAL_MODEL_TASKS))
-#define E_IS_CAL_MODEL_TASKS_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), E_TYPE_CAL_MODEL_TASKS))
+G_BEGIN_DECLS
+typedef struct _ECalModelTasks ECalModelTasks;
+typedef struct _ECalModelTasksClass ECalModelTasksClass;
typedef struct _ECalModelTasksPrivate ECalModelTasksPrivate;
typedef enum {
@@ -54,22 +69,36 @@ typedef enum {
E_CAL_MODEL_TASKS_FIELD_LAST
} ECalModelTasksField;
-typedef struct {
- ECalModel model;
+struct _ECalModelTasks {
+ ECalModel parent;
ECalModelTasksPrivate *priv;
-} ECalModelTasks;
+};
-typedef struct {
+struct _ECalModelTasksClass {
ECalModelClass parent_class;
-} ECalModelTasksClass;
-
-GType e_cal_model_tasks_get_type (void);
-ECalModelTasks *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);
-void e_cal_model_tasks_update_due_tasks (ECalModelTasks *model);
+GType e_cal_model_tasks_get_type (void);
+ECalModel * e_cal_model_tasks_new (EShellSettings *shell_settings);
+const gchar * e_cal_model_tasks_get_color_due_today
+ (ECalModelTasks *model);
+void e_cal_model_tasks_set_color_due_today
+ (ECalModelTasks *model,
+ const gchar *color_due_today);
+const gchar * e_cal_model_tasks_get_color_overdue
+ (ECalModelTasks *model);
+void e_cal_model_tasks_set_color_overdue
+ (ECalModelTasks *model,
+ const gchar *color_overdue);
+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);
+void e_cal_model_tasks_update_due_tasks
+ (ECalModelTasks *model);
G_END_DECLS
-#endif
+#endif /* E_CAL_MODEL_TASKS_H */
diff --git a/calendar/gui/e-cal-model.c b/calendar/gui/e-cal-model.c
index ff6ae4172a..c582b0fb78 100644
--- a/calendar/gui/e-cal-model.c
+++ b/calendar/gui/e-cal-model.c
@@ -35,8 +35,16 @@
#include "e-cal-model.h"
#include "itip-utils.h"
#include "misc.h"
+#include "e-util/e-binding.h"
#include "e-util/e-util.h"
-#include "calendar-config.h"
+
+#define E_CAL_MODEL_GET_PRIVATE(obj) \
+ (G_TYPE_INSTANCE_GET_PRIVATE \
+ ((obj), E_TYPE_CAL_MODEL, ECalModelPrivate))
+
+#define E_CAL_MODEL_COMPONENT_GET_PRIVATE(obj) \
+ (G_TYPE_INSTANCE_GET_PRIVATE \
+ ((obj), E_TYPE_CAL_MODEL_COMPONENT, ECalModelComponentPrivate))
typedef struct {
ECal *client;
@@ -46,6 +54,8 @@ typedef struct {
} ECalModelClient;
struct _ECalModelPrivate {
+ EShellSettings *shell_settings;
+
/* The list of clients we are managing. Each element is of type ECalModelClient */
GList *clients;
@@ -78,6 +88,9 @@ struct _ECalModelPrivate {
/* Whether we display dates in 24-hour format. */
gboolean use_24_hour_format;
+ /* First day of the week: 0 (Monday) to 6 (Sunday) */
+ gint week_start_day;
+
/* callback, to retrieve start time for newly added rows by click-to-add */
ECalModelDefaultTimeFunc get_default_time;
gpointer get_default_time_user_data;
@@ -93,13 +106,6 @@ struct _ECalModelPrivate {
GMutex *notify_lock;
};
-#define E_CAL_MODEL_COMPONENT_GET_PRIVATE(obj) \
- (G_TYPE_INSTANCE_GET_PRIVATE \
- ((obj), E_TYPE_CAL_MODEL_COMPONENT, ECalModelComponentPrivate))
-
-static void e_cal_model_dispose (GObject *object);
-static void e_cal_model_finalize (GObject *object);
-
static gint ecm_column_count (ETableModel *etm);
static gint ecm_row_count (ETableModel *etm);
static gpointer ecm_value_at (ETableModel *etm, gint col, gint row);
@@ -119,7 +125,14 @@ static ECalModelClient *find_client_data (ECalModel *model, ECal *client);
static void remove_client_objects (ECalModel *model, ECalModelClient *client_data);
static void remove_client (ECalModel *model, ECalModelClient *client_data);
-/* Signal IDs */
+enum {
+ PROP_0,
+ PROP_SHELL_SETTINGS,
+ PROP_TIMEZONE,
+ PROP_USE_24_HOUR_FORMAT,
+ PROP_WEEK_START_DAY
+};
+
enum {
TIME_RANGE_CHANGED,
ROW_APPENDED,
@@ -129,19 +142,203 @@ enum {
LAST_SIGNAL
};
-static guint signals[LAST_SIGNAL] = { 0 };
+static gpointer parent_class;
+static guint signals[LAST_SIGNAL];
G_DEFINE_TYPE (ECalModel, e_cal_model, E_TABLE_MODEL_TYPE)
static void
-e_cal_model_class_init (ECalModelClass *klass)
+cal_model_set_shell_settings (ECalModel *cal_model,
+ EShellSettings *shell_settings)
+{
+ g_return_if_fail (E_IS_SHELL_SETTINGS (shell_settings));
+ g_return_if_fail (cal_model->priv->shell_settings == NULL);
+
+ cal_model->priv->shell_settings = g_object_ref (shell_settings);
+}
+
+static void
+cal_model_set_property (GObject *object,
+ guint property_id,
+ const GValue *value,
+ GParamSpec *pspec)
+{
+ switch (property_id) {
+ case PROP_SHELL_SETTINGS:
+ cal_model_set_shell_settings (
+ E_CAL_MODEL (object),
+ g_value_get_object (value));
+ return;
+
+ case PROP_TIMEZONE:
+ e_cal_model_set_timezone (
+ E_CAL_MODEL (object),
+ g_value_get_pointer (value));
+ return;
+
+ case PROP_USE_24_HOUR_FORMAT:
+ e_cal_model_set_use_24_hour_format (
+ E_CAL_MODEL (object),
+ g_value_get_boolean (value));
+ return;
+
+ case PROP_WEEK_START_DAY:
+ e_cal_model_set_week_start_day (
+ E_CAL_MODEL (object),
+ g_value_get_int (value));
+ return;
+ }
+
+ G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
+}
+
+static void
+cal_model_get_property (GObject *object,
+ guint property_id,
+ GValue *value,
+ GParamSpec *pspec)
+{
+ switch (property_id) {
+ case PROP_SHELL_SETTINGS:
+ g_value_set_object (
+ value,
+ e_cal_model_get_shell_settings (
+ E_CAL_MODEL (object)));
+ return;
+
+ case PROP_TIMEZONE:
+ g_value_set_pointer (
+ value,
+ e_cal_model_get_timezone (
+ E_CAL_MODEL (object)));
+ return;
+
+ case PROP_USE_24_HOUR_FORMAT:
+ g_value_set_boolean (
+ value,
+ e_cal_model_get_use_24_hour_format (
+ E_CAL_MODEL (object)));
+ return;
+
+ case PROP_WEEK_START_DAY:
+ g_value_set_int (
+ value,
+ e_cal_model_get_week_start_day (
+ E_CAL_MODEL (object)));
+ return;
+ }
+
+ G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
+}
+
+static void
+cal_model_dispose (GObject *object)
{
- GObjectClass *object_class = G_OBJECT_CLASS (klass);
- ETableModelClass *etm_class = E_TABLE_MODEL_CLASS (klass);
+ ECalModelPrivate *priv;
+
+ priv = E_CAL_MODEL_GET_PRIVATE (object);
+
+ if (priv->shell_settings != NULL) {
+ g_object_unref (priv->shell_settings);
+ priv->shell_settings = NULL;
+ }
- object_class->dispose = e_cal_model_dispose;
- object_class->finalize = e_cal_model_finalize;
+ if (priv->clients) {
+ while (priv->clients != NULL) {
+ ECalModelClient *client_data = (ECalModelClient *) priv->clients->data;
+
+ g_signal_handlers_disconnect_matched (client_data->client, G_SIGNAL_MATCH_DATA,
+ 0, 0, NULL, NULL, object);
+ if (client_data->query)
+ g_signal_handlers_disconnect_matched (client_data->query, G_SIGNAL_MATCH_DATA,
+ 0, 0, NULL, NULL, object);
+
+ priv->clients = g_list_remove (priv->clients, client_data);
+
+ g_object_unref (client_data->client);
+ if (client_data->query)
+ g_object_unref (client_data->query);
+ g_free (client_data);
+ }
+
+ priv->clients = NULL;
+ priv->default_client = NULL;
+ }
+
+ /* Chain up to parent's dispose() method. */
+ G_OBJECT_CLASS (parent_class)->dispose (object);
+}
+static void
+cal_model_finalize (GObject *object)
+{
+ ECalModelPrivate *priv;
+ gint ii;
+
+ priv = E_CAL_MODEL_GET_PRIVATE (object);
+
+ g_free (priv->search_sexp);
+ g_free (priv->full_sexp);
+
+ g_free (priv->default_category);
+
+ for (ii = 0; ii < priv->objects->len; ii++) {
+ ECalModelComponent *comp_data;
+
+ comp_data = g_ptr_array_index (priv->objects, ii);
+ if (comp_data == NULL) {
+ g_warning ("comp_data is null\n");
+ continue;
+ }
+ e_cal_model_free_component_data (comp_data);
+ }
+ g_ptr_array_free (priv->objects, FALSE);
+
+ g_mutex_free (priv->notify_lock);
+
+ /* Chain up to parent's finalize() method. */
+ G_OBJECT_CLASS (parent_class)->finalize (object);
+}
+
+static void
+cal_model_constructed (GObject *object)
+{
+ ECalModel *model;
+ EShellSettings *shell_settings;
+
+ model = E_CAL_MODEL (object);
+ shell_settings = e_cal_model_get_shell_settings (model);
+
+ e_binding_new (
+ G_OBJECT (shell_settings), "cal-timezone",
+ G_OBJECT (model), "timezone");
+
+ e_binding_new (
+ G_OBJECT (shell_settings), "cal-use-24-hour-format",
+ G_OBJECT (model), "use-24-hour-format");
+
+ e_binding_new (
+ G_OBJECT (shell_settings), "cal-week-start-day",
+ G_OBJECT (model), "week-start-day");
+}
+
+static void
+e_cal_model_class_init (ECalModelClass *class)
+{
+ GObjectClass *object_class;
+ ETableModelClass *etm_class;
+
+ parent_class = g_type_class_peek_parent (class);
+ g_type_class_add_private (class, sizeof (ECalModelPrivate));
+
+ object_class = G_OBJECT_CLASS (class);
+ object_class->set_property = cal_model_set_property;
+ object_class->get_property = cal_model_get_property;
+ object_class->dispose = cal_model_dispose;
+ object_class->finalize = cal_model_finalize;
+ object_class->constructed = cal_model_constructed;
+
+ etm_class = E_TABLE_MODEL_CLASS (class);
etm_class->column_count = ecm_column_count;
etm_class->row_count = ecm_row_count;
etm_class->value_at = ecm_value_at;
@@ -154,12 +351,54 @@ e_cal_model_class_init (ECalModelClass *klass)
etm_class->value_is_empty = ecm_value_is_empty;
etm_class->value_to_string = ecm_value_to_string;
- klass->get_color_for_component = ecm_get_color_for_component;
- klass->fill_component_from_model = NULL;
+ class->get_color_for_component = ecm_get_color_for_component;
+ class->fill_component_from_model = NULL;
+
+ g_object_class_install_property (
+ object_class,
+ PROP_SHELL_SETTINGS,
+ g_param_spec_object (
+ "shell-settings",
+ _("Shell Settings"),
+ _("Application-wide settings"),
+ E_TYPE_SHELL_SETTINGS,
+ G_PARAM_READWRITE |
+ G_PARAM_CONSTRUCT_ONLY));
+
+ g_object_class_install_property (
+ object_class,
+ PROP_TIMEZONE,
+ g_param_spec_pointer (
+ "timezone",
+ "Time Zone",
+ NULL,
+ G_PARAM_READWRITE));
+
+ g_object_class_install_property (
+ object_class,
+ PROP_USE_24_HOUR_FORMAT,
+ g_param_spec_boolean (
+ "use-24-hour-format",
+ "Use 24-Hour Format",
+ NULL,
+ TRUE,
+ G_PARAM_READWRITE));
+
+ g_object_class_install_property (
+ object_class,
+ PROP_WEEK_START_DAY,
+ g_param_spec_int (
+ "week-start-day",
+ "Week Start Day",
+ NULL,
+ 0, /* Monday */
+ 6, /* Sunday */
+ 0,
+ G_PARAM_READWRITE));
signals[TIME_RANGE_CHANGED] =
g_signal_new ("time_range_changed",
- G_TYPE_FROM_CLASS (klass),
+ G_TYPE_FROM_CLASS (class),
G_SIGNAL_RUN_LAST,
G_STRUCT_OFFSET (ECalModelClass, time_range_changed),
NULL, NULL,
@@ -168,7 +407,7 @@ e_cal_model_class_init (ECalModelClass *klass)
signals[ROW_APPENDED] =
g_signal_new ("row_appended",
- G_TYPE_FROM_CLASS (klass),
+ G_TYPE_FROM_CLASS (class),
G_SIGNAL_RUN_LAST,
G_STRUCT_OFFSET (ECalModelClass, row_appended),
NULL, NULL,
@@ -177,7 +416,7 @@ e_cal_model_class_init (ECalModelClass *klass)
signals[COMPS_DELETED] =
g_signal_new ("comps_deleted",
- G_TYPE_FROM_CLASS (klass),
+ G_TYPE_FROM_CLASS (class),
G_SIGNAL_RUN_LAST,
G_STRUCT_OFFSET (ECalModelClass, comps_deleted),
NULL, NULL,
@@ -186,7 +425,7 @@ e_cal_model_class_init (ECalModelClass *klass)
signals[CAL_VIEW_PROGRESS] =
g_signal_new ("cal_view_progress",
- G_TYPE_FROM_CLASS (klass),
+ G_TYPE_FROM_CLASS (class),
G_SIGNAL_RUN_LAST,
G_STRUCT_OFFSET (ECalModelClass, cal_view_progress),
NULL, NULL,
@@ -194,7 +433,7 @@ e_cal_model_class_init (ECalModelClass *klass)
G_TYPE_NONE, 3, G_TYPE_STRING, G_TYPE_INT, G_TYPE_INT);
signals[CAL_VIEW_DONE] =
g_signal_new ("cal_view_done",
- G_TYPE_FROM_CLASS (klass),
+ G_TYPE_FROM_CLASS (class),
G_SIGNAL_RUN_LAST,
G_STRUCT_OFFSET (ECalModelClass, cal_view_done),
NULL, NULL,
@@ -206,112 +445,29 @@ e_cal_model_class_init (ECalModelClass *klass)
static void
e_cal_model_init (ECalModel *model)
{
- ECalModelPrivate *priv;
-
- priv = g_new0 (ECalModelPrivate, 1);
- model->priv = priv;
+ model->priv = E_CAL_MODEL_GET_PRIVATE (model);
/* match none by default */
- priv->start = -1;
- priv->end = -1;
- priv->search_sexp = NULL;
- priv->full_sexp = g_strdup ("#f");
-
- priv->objects = g_ptr_array_new ();
- priv->kind = ICAL_NO_COMPONENT;
- priv->flags = 0;
-
- priv->accounts = itip_addresses_get ();
-
- priv->use_24_hour_format = TRUE;
-
- priv->in_added = FALSE;
- priv->in_modified = FALSE;
- priv->in_removed = FALSE;
- priv->notify_added = NULL;
- priv->notify_modified = NULL;
- priv->notify_removed = NULL;
- priv->notify_lock = g_mutex_new ();
-}
-
-static void
-clear_objects_array (ECalModelPrivate *priv)
-{
- gint i;
-
- for (i = 0; i < priv->objects->len; i++) {
- ECalModelComponent *comp_data;
-
- comp_data = g_ptr_array_index (priv->objects, i);
- if (comp_data == NULL) {
- g_warning ("comp_data is null\n");
- continue;
- }
- e_cal_model_free_component_data (comp_data);
- }
-
- g_ptr_array_set_size (priv->objects, 0);
-}
-
-static void
-e_cal_model_dispose (GObject *object)
-{
- ECalModelPrivate *priv;
- ECalModel *model = (ECalModel *) object;
-
- g_return_if_fail (E_IS_CAL_MODEL (model));
-
- priv = model->priv;
-
- if (priv->clients) {
- while (priv->clients != NULL) {
- ECalModelClient *client_data = (ECalModelClient *) priv->clients->data;
-
- g_signal_handlers_disconnect_matched (client_data->client, G_SIGNAL_MATCH_DATA,
- 0, 0, NULL, NULL, model);
- if (client_data->query)
- g_signal_handlers_disconnect_matched (client_data->query, G_SIGNAL_MATCH_DATA,
- 0, 0, NULL, NULL, model);
-
- priv->clients = g_list_remove (priv->clients, client_data);
-
- g_object_unref (client_data->client);
- if (client_data->query)
- g_object_unref (client_data->query);
- g_free (client_data);
- }
+ model->priv->start = -1;
+ model->priv->end = -1;
+ model->priv->search_sexp = NULL;
+ model->priv->full_sexp = g_strdup ("#f");
- priv->clients = NULL;
- priv->default_client = NULL;
- }
+ model->priv->objects = g_ptr_array_new ();
+ model->priv->kind = ICAL_NO_COMPONENT;
+ model->priv->flags = 0;
- if (G_OBJECT_CLASS (e_cal_model_parent_class)->dispose)
- G_OBJECT_CLASS (e_cal_model_parent_class)->dispose (object);
-}
+ model->priv->accounts = itip_addresses_get ();
-static void
-e_cal_model_finalize (GObject *object)
-{
- ECalModelPrivate *priv;
- ECalModel *model = (ECalModel *) object;
-
- g_return_if_fail (E_IS_CAL_MODEL (model));
+ model->priv->use_24_hour_format = TRUE;
- priv = model->priv;
-
- g_free (priv->search_sexp);
- g_free (priv->full_sexp);
-
- g_free (priv->default_category);
-
- clear_objects_array (priv);
- g_ptr_array_free (priv->objects, FALSE);
- g_mutex_free (priv->notify_lock);
-
- g_free (priv);
-
- if (G_OBJECT_CLASS (e_cal_model_parent_class)->finalize)
- G_OBJECT_CLASS (e_cal_model_parent_class)->finalize (object);
+ model->priv->in_added = FALSE;
+ model->priv->in_modified = FALSE;
+ model->priv->in_removed = FALSE;
+ model->priv->notify_added = NULL;
+ model->priv->notify_modified = NULL;
+ model->priv->notify_removed = NULL;
+ model->priv->notify_lock = g_mutex_new ();
}
/* ETableModel methods */
@@ -1148,9 +1304,14 @@ ecm_get_color_for_component (ECalModel *model, ECalModelComponent *comp_data)
return assigned_colors[first_empty].color;
}
-/**
- * e_cal_model_get_component_kind
- */
+EShellSettings *
+e_cal_model_get_shell_settings (ECalModel *model)
+{
+ g_return_val_if_fail (E_IS_CAL_MODEL (model), NULL);
+
+ return model->priv->shell_settings;
+}
+
icalcomponent_kind
e_cal_model_get_component_kind (ECalModel *model)
{
@@ -1162,9 +1323,6 @@ e_cal_model_get_component_kind (ECalModel *model)
return priv->kind;
}
-/**
- * e_cal_model_set_component_kind
- */
void
e_cal_model_set_component_kind (ECalModel *model, icalcomponent_kind kind)
{
@@ -1176,82 +1334,59 @@ e_cal_model_set_component_kind (ECalModel *model, icalcomponent_kind kind)
priv->kind = kind;
}
-/**
- * e_cal_model_get_flags
- */
ECalModelFlags
e_cal_model_get_flags (ECalModel *model)
{
- ECalModelPrivate *priv;
-
- g_return_val_if_fail (E_IS_CAL_MODEL (model), E_CAL_MODEL_FLAGS_INVALID);
+ g_return_val_if_fail (E_IS_CAL_MODEL (model), 0);
- priv = model->priv;
- return priv->flags;
+ return model->priv->flags;
}
-/**
- * e_cal_model_set_flags
- */
void
e_cal_model_set_flags (ECalModel *model, ECalModelFlags flags)
{
- ECalModelPrivate *priv;
-
g_return_if_fail (E_IS_CAL_MODEL (model));
- priv = model->priv;
- priv->flags = flags;
+ model->priv->flags = flags;
}
-/**
- * e_cal_model_get_timezone
- */
icaltimezone *
e_cal_model_get_timezone (ECalModel *model)
{
g_return_val_if_fail (E_IS_CAL_MODEL (model), NULL);
+
return model->priv->zone;
}
-/**
- * e_cal_model_set_timezone
- */
void
-e_cal_model_set_timezone (ECalModel *model, icaltimezone *zone)
+e_cal_model_set_timezone (ECalModel *model,
+ icaltimezone *zone)
{
- ECalModelPrivate *priv;
-
g_return_if_fail (E_IS_CAL_MODEL (model));
- priv = model->priv;
- if (priv->zone != zone) {
- e_table_model_pre_change (E_TABLE_MODEL (model));
- priv->zone = zone;
+ if (model->priv->zone == zone)
+ return;
- /* the timezone affects the times shown for date fields,
- so we need to redisplay everything */
- e_table_model_changed (E_TABLE_MODEL (model));
- }
+ e_table_model_pre_change (E_TABLE_MODEL (model));
+ model->priv->zone = zone;
+
+ /* the timezone affects the times shown for date fields,
+ so we need to redisplay everything */
+ e_table_model_changed (E_TABLE_MODEL (model));
+
+ g_object_notify (G_OBJECT (model), "timezone");
}
-/**
- * e_cal_model_set_default_category
- */
void
-e_cal_model_set_default_category (ECalModel *model, const gchar *default_cat)
+e_cal_model_set_default_category (ECalModel *model,
+ const gchar *default_category)
{
g_return_if_fail (E_IS_CAL_MODEL (model));
- if (model->priv->default_category)
- g_free (model->priv->default_category);
-
- model->priv->default_category = g_strdup (default_cat);
+ g_free (model->priv->default_category);
+ model->priv->default_category = g_strdup (default_category);
}
-/**
- * e_cal_model_get_use_24_hour_format
- */
gboolean
e_cal_model_get_use_24_hour_format (ECalModel *model)
{
@@ -1260,25 +1395,48 @@ e_cal_model_get_use_24_hour_format (ECalModel *model)
return model->priv->use_24_hour_format;
}
-/**
- * e_cal_model_set_use_24_hour_format
- */
void
-e_cal_model_set_use_24_hour_format (ECalModel *model, gboolean use24)
+e_cal_model_set_use_24_hour_format (ECalModel *model,
+ gboolean use_24_hour_format)
{
g_return_if_fail (E_IS_CAL_MODEL (model));
- if (model->priv->use_24_hour_format != use24) {
- e_table_model_pre_change (E_TABLE_MODEL (model));
- model->priv->use_24_hour_format = use24;
- /* Get the views to redraw themselves. */
- e_table_model_changed (E_TABLE_MODEL (model));
- }
+ if (model->priv->use_24_hour_format == use_24_hour_format)
+ return;
+
+ e_table_model_pre_change (E_TABLE_MODEL (model));
+ model->priv->use_24_hour_format = use_24_hour_format;
+
+ /* Get the views to redraw themselves. */
+ e_table_model_changed (E_TABLE_MODEL (model));
+
+ g_object_notify (G_OBJECT (model), "use-24-hour-format");
+}
+
+gint
+e_cal_model_get_week_start_day (ECalModel *model)
+{
+ g_return_val_if_fail (E_IS_CAL_MODEL (model), 0);
+
+ return model->priv->week_start_day;
+}
+
+void
+e_cal_model_set_week_start_day (ECalModel *model,
+ gint week_start_day)
+{
+ g_return_if_fail (E_IS_CAL_MODEL (model));
+ g_return_if_fail (week_start_day >= 0);
+ g_return_if_fail (week_start_day < 7);
+
+ if (model->priv->week_start_day == week_start_day)
+ return;
+
+ model->priv->week_start_day = week_start_day;
+
+ g_object_notify (G_OBJECT (model), "week-start-day");
}
-/**
- * e_cal_model_get_default_client
- */
ECal *
e_cal_model_get_default_client (ECalModel *model)
{
@@ -1334,9 +1492,6 @@ e_cal_model_set_default_client (ECalModel *model, ECal *client)
priv->default_client = client_data->client;
}
-/**
- * e_cal_model_get_client_list
- */
GList *
e_cal_model_get_client_list (ECalModel *model)
{
@@ -1354,7 +1509,7 @@ e_cal_model_get_client_list (ECalModel *model)
}
/**
- * e_cal_model_get_client_for_uri
+ * e_cal_model_get_client_for_uri:
* @model: A calendar model.
* @uri: Uri for the client to get.
*/
@@ -1486,14 +1641,16 @@ add_instance_cb (ECalComponent *comp, time_t instance_start, time_t instance_end
return TRUE;
}
-/* We do this check since the calendar items are downloaded from the server in the open_method,
- since the default timezone might not be set there */
+/* We do this check since the calendar items are downloaded from the server
+ * in the open_method, since the default timezone might not be set there. */
static void
-ensure_dates_are_in_default_zone (icalcomponent *icalcomp)
+ensure_dates_are_in_default_zone (ECalModel *model,
+ icalcomponent *icalcomp)
{
icaltimetype dt;
- icaltimezone *zone = calendar_config_get_icaltimezone ();
+ icaltimezone *zone;
+ zone = e_cal_model_get_timezone (model);
if (!zone)
return;
@@ -1557,7 +1714,7 @@ process_added (ECalView *query, GList *objects, ECalModel *model)
e_cal_component_free_id (id);
g_object_unref (comp);
- ensure_dates_are_in_default_zone (l->data);
+ ensure_dates_are_in_default_zone (model, l->data);
if (e_cal_util_component_has_recurrences (l->data) && (priv->flags & E_CAL_MODEL_FLAGS_EXPAND_RECURRENCES)) {
RecurrenceExpansionData rdata;
@@ -2440,17 +2597,17 @@ struct _ECalModelComponentPrivate {
static void e_cal_model_component_finalize (GObject *object);
-static GObjectClass *parent_class;
+static GObjectClass *component_parent_class;
/* Class initialization function for the calendar component object */
static void
-e_cal_model_component_class_init (ECalModelComponentClass *klass)
+e_cal_model_component_class_init (ECalModelComponentClass *class)
{
GObjectClass *object_class;
- object_class = (GObjectClass *) klass;
+ object_class = (GObjectClass *) class;
- parent_class = g_type_class_peek_parent (klass);
+ component_parent_class = g_type_class_peek_parent (class);
object_class->finalize = e_cal_model_component_finalize;
}
@@ -2497,8 +2654,8 @@ e_cal_model_component_finalize (GObject *object)
comp_data->color = NULL;
}
- if (G_OBJECT_CLASS (parent_class)->finalize)
- (* G_OBJECT_CLASS (parent_class)->finalize) (object);
+ if (G_OBJECT_CLASS (component_parent_class)->finalize)
+ (* G_OBJECT_CLASS (component_parent_class)->finalize) (object);
}
/* Object initialization function for the calendar component object */
diff --git a/calendar/gui/e-cal-model.h b/calendar/gui/e-cal-model.h
index adaf736494..c5fffd3cd6 100644
--- a/calendar/gui/e-cal-model.h
+++ b/calendar/gui/e-cal-model.h
@@ -29,16 +29,47 @@
#include <table/e-table-model.h>
#include <libecal/e-cal.h>
#include "e-cell-date-edit-text.h"
+#include <shell/e-shell-settings.h>
-G_BEGIN_DECLS
+/* Standard GObject macros */
+#define E_TYPE_CAL_MODEL \
+ (e_cal_model_get_type ())
+#define E_CAL_MODEL(obj) \
+ (G_TYPE_CHECK_INSTANCE_CAST \
+ ((obj), E_TYPE_CAL_MODEL, ECalModel))
+#define E_CAL_MODEL_CLASS(cls) \
+ (G_TYPE_CHECK_CLASS_CAST \
+ ((cls), E_TYPE_CAL_MODEL, ECalModelClass))
+#define E_IS_CAL_MODEL(obj) \
+ (G_TYPE_CHECK_INSTANCE_TYPE \
+ ((obj), E_TYPE_CAL_MODEL))
+#define E_IS_CAL_MODEL_CLASS(cls) \
+ (G_TYPE_CHECK_CLASS_TYPE \
+ ((cls), E_TYPE_CAL_MODEL))
+#define E_CAL_MODEL_GET_CLASS(obj) \
+ (G_TYPE_INSTANCE_GET_CLASS \
+ ((obj), E_TYPE_CAL_MODEL, ECalModelClass))
-#define E_TYPE_CAL_MODEL (e_cal_model_get_type ())
-#define E_CAL_MODEL(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), E_TYPE_CAL_MODEL, ECalModel))
-#define E_CAL_MODEL_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), E_TYPE_CAL_MODEL, ECalModelClass))
-#define E_IS_CAL_MODEL(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), E_TYPE_CAL_MODEL))
-#define E_IS_CAL_MODEL_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), E_TYPE_CAL_MODEL))
+/* Standard GObject macros */
+#define E_TYPE_CAL_MODEL_COMPONENT \
+ (e_cal_model_component_get_type ())
+#define E_CAL_MODEL_COMPONENT(obj) \
+ (G_TYPE_CHECK_INSTANCE_CAST \
+ ((obj), E_TYPE_CAL_MODEL_COMPONENT, ECalModelComponent))
+#define E_CAL_MODEL_COMPONENT_CLASS(cls) \
+ (G_TYPE_CHECK_CLASS_CAST \
+ ((cls), E_TYPE_CAL_MODEL_COMPONENT, ECalModelComponentClass))
+#define E_IS_CAL_MODEL_COMPONENT(obj) \
+ (G_TYPE_CHECK_INSTANCE_TYPE \
+ ((obj), E_TYPE_CAL_MODEL_COMPONENT))
+#define E_IS_CAL_MODEL_COMPONENT_CLASS(cls) \
+ (G_TYPE_CHECK_CLASS_TYPE \
+ ((cls), E_TYPE_CAL_MODEL_COMPONENT))
+#define E_CAL_MODEL_COMPONENT_GET_CLASS(obj) \
+ (G_TYPE_INSTANCE_GET_CLASS \
+ ((obj), E_TYPE_CAL_MODEL_COMPONENT, ECalModelComponentClass))
-typedef struct _ECalModelPrivate ECalModelPrivate;
+G_BEGIN_DECLS
typedef enum {
/* If you add new items here or reorder them, you have to update the
@@ -63,12 +94,9 @@ typedef enum {
E_CAL_MODEL_FLAGS_EXPAND_RECURRENCES = 0x01
} ECalModelFlags;
-#define E_TYPE_CAL_MODEL_COMPONENT (e_cal_model_component_get_type ())
-#define E_CAL_MODEL_COMPONENT(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), E_TYPE_CAL_MODEL_COMPONENT, ECalModelComponent))
-#define E_CAL_MODEL_COMPONENT_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), E_TYPE_CAL_MODEL_COMPONENT, \
- ECalComponentClass))
-#define E_IS_CAL_MODEL_COMPONENT(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), E_TYPE_CAL_MODEL_COMPONENT))
-#define E_IS_CAL_MODEL_COMPONENT_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), E_TYPE_CAL_MODEL_COMPONENT))
+typedef struct _ECalModel ECalModel;
+typedef struct _ECalModelClass ECalModelClass;
+typedef struct _ECalModelPrivate ECalModelPrivate;
typedef struct _ECalModelComponent ECalModelComponent;
typedef struct _ECalModelComponentClass ECalModelComponentClass;
@@ -104,94 +132,129 @@ typedef struct {
gpointer cb_data;
} ECalModelGenerateInstancesData;
-typedef struct _ECalModel {
+struct _ECalModel {
ETableModel model;
ECalModelPrivate *priv;
-} ECalModel;
+};
-typedef struct {
+struct _ECalModelClass {
ETableModelClass parent_class;
/* virtual methods */
- const gchar * (* get_color_for_component) (ECalModel *model, ECalModelComponent *comp_data);
- void (* fill_component_from_model) (ECalModel *model, ECalModelComponent *comp_data,
- ETableModel *source_model, gint row);
+ const gchar * (*get_color_for_component)
+ (ECalModel *model,
+ ECalModelComponent *comp_data);
+ void (*fill_component_from_model)
+ (ECalModel *model,
+ ECalModelComponent *comp_data,
+ ETableModel *source_model,
+ gint row);
/* Signals */
- void (* time_range_changed) (ECalModel *model, time_t start, time_t end);
- void (* row_appended) (ECalModel *model);
- void (* comps_deleted) (ECalModel *model, gpointer list);
- void (* cal_view_progress) (ECalModel *model, const gchar *message, gint progress, ECalSourceType type);
- void (* cal_view_done) (ECalModel *model, ECalendarStatus status, ECalSourceType type);
-} ECalModelClass;
-
-typedef time_t (*ECalModelDefaultTimeFunc)(ECalModel *model, gpointer user_data);
-
-GType e_cal_model_get_type (void);
-GType e_cal_model_component_get_type (void);
-icalcomponent_kind e_cal_model_get_component_kind (ECalModel *model);
-void e_cal_model_set_component_kind (ECalModel *model,
- icalcomponent_kind kind);
-ECalModelFlags e_cal_model_get_flags (ECalModel *model);
-void e_cal_model_set_flags (ECalModel *model,
- ECalModelFlags flags);
-icaltimezone *e_cal_model_get_timezone (ECalModel *model);
-void e_cal_model_set_timezone (ECalModel *model,
- icaltimezone *zone);
-void e_cal_model_set_default_category (ECalModel *model,
- const gchar *default_cat);
-gboolean e_cal_model_get_use_24_hour_format (ECalModel *model);
-void e_cal_model_set_use_24_hour_format (ECalModel *model,
- gboolean use24);
-ECal *e_cal_model_get_default_client (ECalModel *model);
-void e_cal_model_set_default_client (ECalModel *model,
- ECal *client);
-GList *e_cal_model_get_client_list (ECalModel *model);
-ECal *e_cal_model_get_client_for_uri (ECalModel *model,
- const gchar *uri);
-void e_cal_model_add_client (ECalModel *model,
- ECal *client);
-void e_cal_model_remove_client (ECalModel *model,
- ECal *client);
-void e_cal_model_remove_all_clients (ECalModel *model);
-void e_cal_model_get_time_range (ECalModel *model,
- time_t *start,
- time_t *end);
-void e_cal_model_set_time_range (ECalModel *model,
- time_t start,
- time_t end);
-const gchar *e_cal_model_get_search_query (ECalModel *model);
-void e_cal_model_set_search_query (ECalModel *model,
- const gchar *sexp);
-icalcomponent *e_cal_model_create_component_with_defaults (ECalModel *model, gboolean all_day);
-const gchar *e_cal_model_get_color_for_component (ECalModel *model,
- ECalModelComponent *comp_data);
-gboolean e_cal_model_get_rgb_color_for_component (ECalModel *model,
- ECalModelComponent *comp_data,
- double *red,
- double *green,
- double *blue);
-ECalModelComponent *e_cal_model_get_component_at (ECalModel *model,
- gint row);
-ECalModelComponent *e_cal_model_get_component_for_uid (ECalModel *model,
- const ECalComponentId *id);
-gchar *e_cal_model_date_value_to_string (ECalModel *model,
- const void *value);
-ECalModelComponent *e_cal_model_copy_component_data (ECalModelComponent *comp_data);
-void e_cal_model_free_component_data (ECalModelComponent *comp_data);
-void e_cal_model_generate_instances (ECalModel *model,
- time_t start,
- time_t end,
- ECalRecurInstanceFn cb,
- gpointer cb_data);
-GPtrArray * e_cal_model_get_object_array (ECalModel *model);
-void e_cal_model_set_instance_times (ECalModelComponent *comp_data, const icaltimezone *zone);
-void e_cal_model_set_search_query_with_time_range (ECalModel *model, const gchar *sexp, time_t start, time_t end);
-
-gboolean e_cal_model_test_row_editable (ECalModel *model, gint row);
-
-void e_cal_model_set_default_time_func (ECalModel *model, ECalModelDefaultTimeFunc func, gpointer user_data);
+ void (*time_range_changed) (ECalModel *model,
+ time_t start,
+ time_t end);
+ void (*row_appended) (ECalModel *model);
+ void (*comps_deleted) (ECalModel *model,
+ gpointer list);
+ void (*cal_view_progress) (ECalModel *model,
+ const gchar *message,
+ gint progress,
+ ECalSourceType type);
+ void (*cal_view_done) (ECalModel *model,
+ ECalendarStatus status,
+ ECalSourceType type);
+};
+
+typedef time_t (*ECalModelDefaultTimeFunc) (ECalModel *model, gpointer user_data);
+
+GType e_cal_model_get_type (void);
+GType e_cal_model_component_get_type (void);
+EShellSettings *e_cal_model_get_shell_settings (ECalModel *model);
+icalcomponent_kind
+ e_cal_model_get_component_kind (ECalModel *model);
+void e_cal_model_set_component_kind (ECalModel *model,
+ icalcomponent_kind kind);
+ECalModelFlags e_cal_model_get_flags (ECalModel *model);
+void e_cal_model_set_flags (ECalModel *model,
+ ECalModelFlags flags);
+icaltimezone * e_cal_model_get_timezone (ECalModel *model);
+void e_cal_model_set_timezone (ECalModel *model,
+ icaltimezone *zone);
+void e_cal_model_set_default_category(ECalModel *model,
+ const gchar *default_cat);
+gboolean e_cal_model_get_use_24_hour_format
+ (ECalModel *model);
+void e_cal_model_set_use_24_hour_format
+ (ECalModel *model,
+ gboolean use24);
+gint e_cal_model_get_week_start_day (ECalModel *model);
+void e_cal_model_set_week_start_day (ECalModel *model,
+ gint week_start_day);
+ECal * e_cal_model_get_default_client (ECalModel *model);
+void e_cal_model_set_default_client (ECalModel *model,
+ ECal *client);
+GList * e_cal_model_get_client_list (ECalModel *model);
+ECal * e_cal_model_get_client_for_uri (ECalModel *model,
+ const gchar *uri);
+void e_cal_model_add_client (ECalModel *model,
+ ECal *client);
+void e_cal_model_remove_client (ECalModel *model,
+ ECal *client);
+void e_cal_model_remove_all_clients (ECalModel *model);
+void e_cal_model_get_time_range (ECalModel *model,
+ time_t *start,
+ time_t *end);
+void e_cal_model_set_time_range (ECalModel *model,
+ time_t start,
+ time_t end);
+const gchar * e_cal_model_get_search_query (ECalModel *model);
+void e_cal_model_set_search_query (ECalModel *model,
+ const gchar *sexp);
+icalcomponent * e_cal_model_create_component_with_defaults
+ (ECalModel *model,
+ gboolean all_day);
+const gchar * e_cal_model_get_color_for_component
+ (ECalModel *model,
+ ECalModelComponent *comp_data);
+gboolean e_cal_model_get_rgb_color_for_component
+ (ECalModel *model,
+ ECalModelComponent *comp_data,
+ gdouble *red,
+ gdouble *green,
+ gdouble *blue);
+ECalModelComponent *
+ e_cal_model_get_component_at (ECalModel *model,
+ gint row);
+ECalModelComponent *
+ e_cal_model_get_component_for_uid
+ (ECalModel *model,
+ const ECalComponentId *id);
+gchar * e_cal_model_date_value_to_string(ECalModel *model,
+ gconstpointer value);
+ECalModelComponent *
+ e_cal_model_copy_component_data (ECalModelComponent *comp_data);
+void e_cal_model_free_component_data (ECalModelComponent *comp_data);
+void e_cal_model_generate_instances (ECalModel *model,
+ time_t start,
+ time_t end,
+ ECalRecurInstanceFn cb,
+ gpointer cb_data);
+GPtrArray * e_cal_model_get_object_array (ECalModel *model);
+void e_cal_model_set_instance_times (ECalModelComponent *comp_data,
+ const icaltimezone *zone);
+void e_cal_model_set_search_query_with_time_range
+ (ECalModel *model,
+ const gchar *sexp,
+ time_t start,
+ time_t end);
+gboolean e_cal_model_test_row_editable (ECalModel *model,
+ gint row);
+void e_cal_model_set_default_time_func
+ (ECalModel *model,
+ ECalModelDefaultTimeFunc func,
+ gpointer user_data);
G_END_DECLS
-#endif
+#endif /* E_CAL_MODEL_H */
diff --git a/calendar/gui/e-cal-popup.c b/calendar/gui/e-cal-popup.c
deleted file mode 100644
index cdbce07ac7..0000000000
--- a/calendar/gui/e-cal-popup.c
+++ /dev/null
@@ -1,501 +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:
- * Michael Zucchi <notzed@ximian.com>
- *
- * Copyright (C) 1999-2008 Novell, Inc. (www.novell.com)
- *
- */
-
-#ifdef HAVE_CONFIG_H
-#include <config.h>
-#endif
-
-#include <string.h>
-#include <fcntl.h>
-#include <stdlib.h>
-
-#include <glib.h>
-#include <gio/gio.h>
-
-#include "e-cal-popup.h"
-#include <libedataserver/e-data-server-util.h>
-#include <libedataserverui/e-source-selector.h>
-
-#include <camel/camel-mime-part.h>
-#include <camel/camel-stream-vfs.h>
-#include "e-util/e-util.h"
-#include <glib/gi18n.h>
-#include "e-util/e-mktemp.h"
-#include "e-util/e-dialog-utils.h"
-
-#include "gui/e-calendar-view.h"
-#include "gui/e-cal-model.h"
-#include "itip-utils.h"
-#include "e-attachment.h"
-
-static GObjectClass *ecalp_parent;
-
-static void
-ecalp_init(GObject *o)
-{
- /*ECalPopup *eabp = (ECalPopup *)o; */
-}
-
-static void
-ecalp_finalise(GObject *o)
-{
- ((GObjectClass *)ecalp_parent)->finalize(o);
-}
-
-static void
-ecalp_target_free(EPopup *ep, EPopupTarget *t)
-{
- switch (t->type) {
- case E_CAL_POPUP_TARGET_SELECT: {
- ECalPopupTargetSelect *s = (ECalPopupTargetSelect *)t;
- gint i;
-
- for (i=0;i<s->events->len;i++)
- e_cal_model_free_component_data(s->events->pdata[i]);
- g_ptr_array_free(s->events, TRUE);
- g_object_unref(s->model);
- break; }
- case E_CAL_POPUP_TARGET_SOURCE: {
- ECalPopupTargetSource *s = (ECalPopupTargetSource *)t;
-
- g_object_unref(s->selector);
- break; }
- }
-
- ((EPopupClass *)ecalp_parent)->target_free(ep, t);
-}
-
-/* Standard menu code */
-
-static void
-ecalp_class_init(GObjectClass *klass)
-{
- klass->finalize = ecalp_finalise;
- ((EPopupClass *)klass)->target_free = ecalp_target_free;
-}
-
-GType
-e_cal_popup_get_type(void)
-{
- static GType type = 0;
-
- if (type == 0) {
- static const GTypeInfo info = {
- sizeof(ECalPopupClass),
- NULL, NULL,
- (GClassInitFunc)ecalp_class_init,
- NULL, NULL,
- sizeof(ECalPopup), 0,
- (GInstanceInitFunc)ecalp_init
- };
- ecalp_parent = g_type_class_ref(e_popup_get_type());
- type = g_type_register_static(e_popup_get_type(), "ECalPopup", &info, 0);
- }
-
- return type;
-}
-
-ECalPopup *e_cal_popup_new(const gchar *menuid)
-{
- ECalPopup *eabp = g_object_new(e_cal_popup_get_type(), NULL);
-
- e_popup_construct(&eabp->popup, menuid);
-
- return eabp;
-}
-
-static icalproperty *
-get_attendee_prop (icalcomponent *icalcomp, const gchar *address)
-{
-
- icalproperty *prop;
-
- if (!(address && *address))
- return NULL;
-
- for (prop = icalcomponent_get_first_property (icalcomp, ICAL_ATTENDEE_PROPERTY);
- prop;
- prop = icalcomponent_get_next_property (icalcomp, ICAL_ATTENDEE_PROPERTY)) {
- const gchar *attendee = icalproperty_get_attendee (prop);
-
- if (g_str_equal (itip_strip_mailto (attendee), address)) {
- return prop;
- }
- }
- return NULL;
-}
-
-static gboolean
-is_delegated (icalcomponent *icalcomp, gchar *user_email)
-{
- icalproperty *prop;
- icalparameter *param;
- const gchar *delto = NULL;
-
- prop = get_attendee_prop (icalcomp, user_email);
-
- if (prop) {
- param = icalproperty_get_first_parameter (prop, ICAL_DELEGATEDTO_PARAMETER);
- if (param)
- delto = icalparameter_get_delegatedto (param);
- } else
- return FALSE;
-
- prop = get_attendee_prop (icalcomp, itip_strip_mailto (delto));
-
- if (prop) {
- const gchar *delfrom = NULL;
- icalparameter_partstat status = ICAL_PARTSTAT_NONE;
-
- param = icalproperty_get_first_parameter (prop, ICAL_DELEGATEDFROM_PARAMETER);
- if (param)
- delfrom = icalparameter_get_delegatedfrom (param);
- param = icalproperty_get_first_parameter (prop, ICAL_PARTSTAT_PARAMETER);
- if (param)
- status = icalparameter_get_partstat (param);
- if ((delfrom && *delfrom) && g_str_equal (itip_strip_mailto (delfrom), user_email)
- && status != ICAL_PARTSTAT_DECLINED)
- return TRUE;
- }
-
- return FALSE;
-}
-
-static gboolean
-needs_to_accept (icalcomponent *icalcomp, gchar *user_email)
-{
- icalproperty *prop;
- icalparameter *param;
- icalparameter_partstat status = ICAL_PARTSTAT_NONE;
-
- prop = get_attendee_prop (icalcomp, user_email);
-
- /* It might be a mailing list */
- if (!prop)
- return TRUE;
- param = icalproperty_get_first_parameter (prop, ICAL_PARTSTAT_PARAMETER);
- if (param)
- status = icalparameter_get_partstat (param);
-
- if (status == ICAL_PARTSTAT_ACCEPTED || status == ICAL_PARTSTAT_TENTATIVE)
- return FALSE;
-
- return TRUE;
-}
-
-/**
- * e_cal_popup_target_new_select:
- * @eabp:
- * @model: The calendar model.
- * @events: An array of pointers to ECalModelComponent items. These
- * items must be copied. They, and the @events array will be freed by
- * the popup menu automatically.
- *
- * Create a new selection popup target.
- *
- * Return value:
- **/
-ECalPopupTargetSelect *
-e_cal_popup_target_new_select(ECalPopup *eabp, struct _ECalModel *model, GPtrArray *events)
-{
- ECalPopupTargetSelect *t = e_popup_target_new(&eabp->popup, E_CAL_POPUP_TARGET_SELECT, sizeof(*t));
- guint32 mask = ~0;
- ECal *client;
- gboolean read_only, user_org = FALSE;
-
- /* FIXME: This is duplicated in e-cal-menu */
-
- t->model = model;
- g_object_ref(t->model);
- t->events = events;
-
- if (t->events->len == 0) {
- client = e_cal_model_get_default_client(t->model);
- } else {
- ECalModelComponent *comp_data = (ECalModelComponent *)t->events->pdata[0];
- ECalComponent *comp;
- gchar *user_email = NULL;
-
- comp = e_cal_component_new ();
- e_cal_component_set_icalcomponent (comp, icalcomponent_new_clone (comp_data->icalcomp));
- user_email = itip_get_comp_attendee (comp, comp_data->client);
-
- mask &= ~E_CAL_POPUP_SELECT_ANY;
- if (t->events->len == 1)
- mask &= ~E_CAL_POPUP_SELECT_ONE;
- else {
- gint i=0;
-
- mask &= ~E_CAL_POPUP_SELECT_MANY;
- /* Now check for any incomplete tasks and set the flags*/
- for (; i < t->events->len; i++) {
- ECalModelComponent *comp_data = (ECalModelComponent *)t->events->pdata[i];
- if (!icalcomponent_get_first_property (comp_data->icalcomp, ICAL_COMPLETED_PROPERTY))
- mask &= ~E_CAL_POPUP_SELECT_NOTCOMPLETE;
- else
- mask &= ~E_CAL_POPUP_SELECT_COMPLETE;
- }
- }
-
- if (icalcomponent_get_first_property (comp_data->icalcomp, ICAL_URL_PROPERTY))
- mask &= ~E_CAL_POPUP_SELECT_HASURL;
-
- if (e_cal_util_component_has_recurrences (comp_data->icalcomp))
- mask &= ~E_CAL_POPUP_SELECT_RECURRING;
- else if (e_cal_util_component_is_instance (comp_data->icalcomp))
- mask &= ~E_CAL_POPUP_SELECT_RECURRING;
- else
- mask &= ~E_CAL_POPUP_SELECT_NONRECURRING;
-
- if (e_cal_util_component_is_instance (comp_data->icalcomp))
- mask &= ~E_CAL_POPUP_SELECT_INSTANCE;
-
- if (e_cal_util_component_has_attendee (comp_data->icalcomp))
- mask &= ~E_CAL_POPUP_SELECT_MEETING;
-
- if (!e_cal_get_save_schedules (comp_data->client))
- mask &= ~E_CAL_POPUP_SELECT_NOSAVESCHEDULES;
-
- if (e_cal_util_component_has_organizer (comp_data->icalcomp)) {
-
- if (itip_organizer_is_user (comp, comp_data->client)) {
- mask &= ~E_CAL_POPUP_SELECT_ORGANIZER;
- user_org = TRUE;
- }
-
- } else {
- /* organiser is synonym for owner in this case */
- mask &= ~(E_CAL_POPUP_SELECT_ORGANIZER|E_CAL_POPUP_SELECT_NOTMEETING);
- }
-
- client = comp_data->client;
-
- if (e_cal_get_static_capability (client, CAL_STATIC_CAPABILITY_DELEGATE_SUPPORTED)) {
-
- if (e_cal_get_static_capability (client, CAL_STATIC_CAPABILITY_DELEGATE_TO_MANY))
- mask &= ~E_CAL_POPUP_SELECT_DELEGATABLE;
- else if (!user_org && !is_delegated (comp_data->icalcomp, user_email))
- mask &= ~E_CAL_POPUP_SELECT_DELEGATABLE;
- }
-
- if (e_cal_get_static_capability (client, CAL_STATIC_CAPABILITY_HAS_UNACCEPTED_MEETING) &&
- needs_to_accept (comp_data->icalcomp, user_email))
- mask &= ~E_CAL_POPUP_SELECT_ACCEPTABLE;
-
- if (!icalcomponent_get_first_property (comp_data->icalcomp, ICAL_COMPLETED_PROPERTY))
- mask &= ~E_CAL_POPUP_SELECT_NOTCOMPLETE;
-
- if (icalcomponent_get_first_property (comp_data->icalcomp, ICAL_COMPLETED_PROPERTY))
- mask &= ~E_CAL_POPUP_SELECT_COMPLETE;
-
- g_object_unref (comp);
- g_free (user_email);
- }
-
- e_cal_is_read_only(client, &read_only, NULL);
- if (!read_only)
- mask &= ~E_CAL_POPUP_SELECT_EDITABLE;
-
- if (!e_cal_get_static_capability (client, CAL_STATIC_CAPABILITY_NO_TASK_ASSIGNMENT)
- && !e_cal_get_static_capability (client, CAL_STATIC_CAPABILITY_NO_CONV_TO_ASSIGN_TASK))
- mask &= ~E_CAL_POPUP_SELECT_ASSIGNABLE;
-
- /* This bit isn't implemented ... */
- mask &= ~E_CAL_POPUP_SELECT_NOTEDITING;
-
- t->target.mask = mask;
-
- return t;
-}
-
-ECalPopupTargetSource *
-e_cal_popup_target_new_source(ECalPopup *eabp, ESourceSelector *selector)
-{
- ECalPopupTargetSource *t = e_popup_target_new(&eabp->popup, E_CAL_POPUP_TARGET_SOURCE, sizeof(*t));
- guint32 mask = ~0;
- const gchar *relative_uri;
- gchar *uri;
- ESource *source;
- const gchar *offline = NULL;
- const gchar *delete = NULL;
-
- /* TODO: this is duplicated for addressbook too */
-
- t->selector = selector;
- g_object_ref(selector);
-
- /* TODO: perhaps we need to copy this so it doesn't change during the lifecycle */
- source = e_source_selector_peek_primary_selection(selector);
- if (source)
- mask &= ~E_CAL_POPUP_SOURCE_PRIMARY;
-
- /* FIXME Gross hack, should have a property or something */
- relative_uri = e_source_peek_relative_uri(source);
- if (relative_uri && !strcmp("system", relative_uri))
- mask &= ~E_CAL_POPUP_SOURCE_SYSTEM;
- else
- mask &= ~E_CAL_POPUP_SOURCE_USER;
-
- uri = e_source_get_uri (source);
- if (!uri || (g_ascii_strncasecmp (uri, "file://", 7) && g_ascii_strncasecmp (uri, "contacts://", 11))) {
- /* check for e_target_selector's offline_status property here */
- offline = e_source_get_property (source, "offline_sync");
- if (offline && strcmp (offline, "1") == 0)
- mask &= ~E_CAL_POPUP_SOURCE_NO_OFFLINE; /* set the menu item to Mark Offline */
- else
- mask &= ~E_CAL_POPUP_SOURCE_OFFLINE;
- } else {
- mask |= E_CAL_POPUP_SOURCE_NO_OFFLINE;
- mask |= E_CAL_POPUP_SOURCE_OFFLINE;
- }
- g_free (uri);
-
- /* check for delete_status property here */
- delete = e_source_get_property (source, "delete");
- if (delete && strcmp (delete, "no") == 0)
- mask &= ~E_CAL_POPUP_SOURCE_NO_DELETE; /* set the menu item to non deletable */
- else
- mask &= ~E_CAL_POPUP_SOURCE_DELETE;
-
- t->target.mask = mask;
-
- return t;
-}
-
-/* ********************************************************************** */
-/* Popup menu plugin handler */
-
-/*
-<e-plugin
- class="org.gnome.mail.plugin.popup:1.0"
- id="org.gnome.mail.plugin.popup.iteab:1.0"
- type="shlib"
- location="/opt/gnome2/lib/camel/1.0/libcamelimap.so"
- name="imap"
- description="IMAP4 and IMAP4v1 mail store">
- <hook class="org.gnome.mail.popupMenu:1.0"
- handler="HandlePopup">
- <menu id="any" target="select">
- <iteab
- type="iteab|toggle|radio|image|submenu|bar"
- active
- path="foo/bar"
- label="label"
- icon="foo"
- mask="select_one"
- activate="ecalp_view_eabacs"/>
- </menu>
- </extension>
-
-*/
-
-static gpointer ecalph_parent_class;
-#define ecalph ((ECalPopupHook *)eph)
-
-static const EPopupHookTargetMask ecalph_select_masks[] = {
- { "one", E_CAL_POPUP_SELECT_ONE },
- { "many", E_CAL_POPUP_SELECT_MANY },
- { "editable", E_CAL_POPUP_SELECT_EDITABLE },
- { "recurring", E_CAL_POPUP_SELECT_RECURRING },
- { "non-recurring", E_CAL_POPUP_SELECT_NONRECURRING },
- { "instance", E_CAL_POPUP_SELECT_INSTANCE },
- { "organizer", E_CAL_POPUP_SELECT_ORGANIZER },
- { "not-editing", E_CAL_POPUP_SELECT_NOTEDITING },
- { "not-meeting", E_CAL_POPUP_SELECT_NOTMEETING },
- { "meeting", E_CAL_POPUP_SELECT_MEETING },
- { "assignable", E_CAL_POPUP_SELECT_ASSIGNABLE },
- { "hasurl", E_CAL_POPUP_SELECT_HASURL },
- { "delegate", E_CAL_POPUP_SELECT_DELEGATABLE },
- { "accept", E_CAL_POPUP_SELECT_ACCEPTABLE },
- { "not-complete", E_CAL_POPUP_SELECT_NOTCOMPLETE },
- { "no-save-schedules", E_CAL_POPUP_SELECT_NOSAVESCHEDULES },
- { "complete" , E_CAL_POPUP_SELECT_COMPLETE},
- { NULL }
-};
-
-static const EPopupHookTargetMask ecalph_source_masks[] = {
- { "primary", E_CAL_POPUP_SOURCE_PRIMARY },
- { "system", E_CAL_POPUP_SOURCE_SYSTEM },
- { "user", E_CAL_POPUP_SOURCE_USER },
- { "offline", E_CAL_POPUP_SOURCE_OFFLINE},
- { "no-offline", E_CAL_POPUP_SOURCE_NO_OFFLINE},
- { "delete", E_CAL_POPUP_SOURCE_DELETE},
- { "no-delete", E_CAL_POPUP_SOURCE_NO_DELETE},
-
- { NULL }
-};
-
-static const EPopupHookTargetMask ecalph_attachments_masks[] = {
- { "one", E_CAL_POPUP_ATTACHMENTS_ONE },
- { "many", E_CAL_POPUP_ATTACHMENTS_MANY },
- { "modify", E_CAL_POPUP_ATTACHMENTS_MODIFY },
- { "multiple", E_CAL_POPUP_ATTACHMENTS_MULTIPLE },
- { "image", E_CAL_POPUP_ATTACHMENTS_IMAGE },
- { NULL }
-};
-
-static const EPopupHookTargetMap ecalph_targets[] = {
- { "select", E_CAL_POPUP_TARGET_SELECT, ecalph_select_masks },
- { "source", E_CAL_POPUP_TARGET_SOURCE, ecalph_source_masks },
- { "attachments", E_CAL_POPUP_TARGET_ATTACHMENTS, ecalph_attachments_masks },
- { NULL }
-};
-
-static void
-ecalph_finalise(GObject *o)
-{
- /*EPluginHook *eph = (EPluginHook *)o;*/
-
- ((GObjectClass *)ecalph_parent_class)->finalize(o);
-}
-
-static void
-ecalph_class_init(EPluginHookClass *klass)
-{
- gint i;
-
- ((GObjectClass *)klass)->finalize = ecalph_finalise;
- ((EPluginHookClass *)klass)->id = "org.gnome.evolution.calendar.popup:1.0";
-
- for (i=0;ecalph_targets[i].type;i++)
- e_popup_hook_class_add_target_map((EPopupHookClass *)klass, &ecalph_targets[i]);
-
- ((EPopupHookClass *)klass)->popup_class = g_type_class_ref(e_cal_popup_get_type());
-}
-
-GType
-e_cal_popup_hook_get_type(void)
-{
- static GType type = 0;
-
- if (!type) {
- static const GTypeInfo info = {
- sizeof(ECalPopupHookClass), NULL, NULL, (GClassInitFunc) ecalph_class_init, NULL, NULL,
- sizeof(ECalPopupHook), 0, (GInstanceInitFunc) NULL,
- };
-
- ecalph_parent_class = g_type_class_ref(e_popup_hook_get_type());
- type = g_type_register_static(e_popup_hook_get_type(), "ECalPopupHook", &info, 0);
- }
-
- return type;
-}
diff --git a/calendar/gui/e-cal-popup.h b/calendar/gui/e-cal-popup.h
deleted file mode 100644
index 2cd20ebd9d..0000000000
--- a/calendar/gui/e-cal-popup.h
+++ /dev/null
@@ -1,214 +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:
- * Michael Zucchi <notzed@ximian.com>
- *
- * Copyright (C) 1999-2008 Novell, Inc. (www.novell.com)
- *
- */
-
-#ifndef __E_CAL_POPUP_H__
-#define __E_CAL_POPUP_H__
-
-#include <glib-object.h>
-#include <libedataserverui/e-source-selector.h>
-
-#include <e-util/e-popup.h>
-#include "dialogs/comp-editor.h"
-#include "e-cal-model.h"
-
-G_BEGIN_DECLS
-
-/**
- * enum _e_cal_popup_target_t - A list of mail popup target types.
- *
- * @E_CAL_POPUP_TARGET_SELECT: A selection of cards
- * @E_CAL_POPUP_TARGET_SOURCE: A source selection.
- *
- * Defines the value of the targetid for all ECalPopup target types.
- **/
-enum _e_cal_popup_target_t {
- E_CAL_POPUP_TARGET_SELECT,
- E_CAL_POPUP_TARGET_SOURCE,
- E_CAL_POPUP_TARGET_ATTACHMENTS
-};
-
-/**
- * enum _e_cal_popup_target_select_t - ECalPopupTargetSelect qualifiers.
- *
- * @E_CAL_POPUP_SELECT_ONE: Only one item is selected.
- * @E_CAL_POPUP_SELECT_MANY: More than one item selected.
- * @E_CAL_POPUP_SELECT_ANY: One ore more items are selected.
- * @E_CAL_POPUP_SELECT_EDITABLE: The selection is editable.
- * @E_CAL_POPUP_SELECT_RECURRING: Is a recurring event.
- * @E_CAL_POPUP_SELECT_NONRECURRING: Is not a recurring event.
- * @E_CAL_POPUP_SELECT_INSTANCE: This is an instance event.
- * @E_CAL_POPUP_SELECT_ORGANIZER: The user is the organiser of the event.
- * @E_CAL_POPUP_SELECT_NOTEDITING: The event is not being edited already. Not implemented.
- * @E_CAL_POPUP_SELECT_NOTMEETING: The event is not a meeting.
- * @E_CAL_POPUP_SELECT_ASSIGNABLE: An assignable task.
- * @E_CAL_POPUP_SELECT_HASURL: A task that contains a URL.
- **/
-enum _e_cal_popup_target_select_t {
- E_CAL_POPUP_SELECT_ONE = 1<<0,
- E_CAL_POPUP_SELECT_MANY = 1<<1,
- E_CAL_POPUP_SELECT_ANY = 1<<2,
- E_CAL_POPUP_SELECT_EDITABLE = 1<<3,
- E_CAL_POPUP_SELECT_RECURRING = 1<<4,
- E_CAL_POPUP_SELECT_NONRECURRING = 1<<5,
- E_CAL_POPUP_SELECT_INSTANCE = 1<<6,
-
- E_CAL_POPUP_SELECT_ORGANIZER = 1<<7,
- E_CAL_POPUP_SELECT_NOTEDITING = 1<<8,
- E_CAL_POPUP_SELECT_NOTMEETING = 1<<9,
-
- E_CAL_POPUP_SELECT_ASSIGNABLE = 1<<10,
- E_CAL_POPUP_SELECT_HASURL = 1<<11,
- E_CAL_POPUP_SELECT_MEETING = 1 <<12,
- E_CAL_POPUP_SELECT_DELEGATABLE = 1<<13,
- E_CAL_POPUP_SELECT_ACCEPTABLE = 1<<14,
- E_CAL_POPUP_SELECT_NOTCOMPLETE = 1<<15,
- E_CAL_POPUP_SELECT_NOSAVESCHEDULES = 1<<16,
- E_CAL_POPUP_SELECT_COMPLETE = 1<<17
-};
-
-/**
- * enum _e_cal_popup_target_source_t - ECalPopupTargetSource qualifiers.
- *
- * @E_CAL_POPUP_SOURCE_PRIMARY: Has a primary selection.
- * @E_CAL_POPUP_SOURCE_SYSTEM: Is a 'system' folder.
- *
- **/
-enum _e_cal_popup_target_source_t {
- E_CAL_POPUP_SOURCE_PRIMARY = 1<<0,
- E_CAL_POPUP_SOURCE_SYSTEM = 1<<1, /* system folder */
- E_CAL_POPUP_SOURCE_USER = 1<<2, /* user folder (!system) */
- E_CAL_POPUP_SOURCE_OFFLINE = 1 <<3,
- E_CAL_POPUP_SOURCE_NO_OFFLINE = 1 <<4,
- E_CAL_POPUP_SOURCE_DELETE = 1<<5,
- E_CAL_POPUP_SOURCE_NO_DELETE = 1<<6
-};
-
-/**
- * enum _e_cal_popup_target_attachments_t - ECalPopupTargetAttachments qualifiers.
- *
- * @E_CAL_POPUP_ATTACHMENTS_ONE: There is one and only one attachment selected.
- * @E_CAL_POPUP_ATTACHMENTS_MANY: There is one or more attachments selected.
- *
- **/
-enum _e_cal_popup_target_attachments_t {
- E_CAL_POPUP_ATTACHMENTS_ONE = 1<<0, /* only 1 selected */
- E_CAL_POPUP_ATTACHMENTS_MANY = 1<<1, /* one or more selected */
- E_CAL_POPUP_ATTACHMENTS_MODIFY = 1<<2, /* check for modify operation */
- E_CAL_POPUP_ATTACHMENTS_MULTIPLE = 1<<3,
- E_CAL_POPUP_ATTACHMENTS_IMAGE = 1<<4
-};
-
-typedef struct _ECalPopupTargetSelect ECalPopupTargetSelect;
-typedef struct _ECalPopupTargetSource ECalPopupTargetSource;
-typedef struct _ECalPopupTargetAttachments ECalPopupTargetAttachments;
-
-/**
- * struct _ECalPopupTargetSelect - A list of address cards.
- *
- * @target: Superclass. target.widget is an ECalendarView.
- * @model: The ECalModel.
- * @events: The selected events. These are ECalModelComponent's.
- *
- * Used to represent a selection of appointments as context for a popup
- * menu.
- *
- * TODO: For maximum re-usability references to the view could be removed
- * from this structure.
- **/
-struct _ECalPopupTargetSelect {
- EPopupTarget target;
-
- ECalModel *model;
- GPtrArray *events;
-};
-
-/**
- * struct _ECalPopupTargetSource - A source target.
- *
- * @target: Superclass.
- * @selector: Selector holding the source selection.
- *
- * This target is used to represent a source selection.
- **/
-struct _ECalPopupTargetSource {
- EPopupTarget target;
-
- ESourceSelector *selector;
-};
-
-/**
- * struct _ECalPopupTargetAttachments - A list of calendar attachments.
- *
- * @target: Superclass.
- * @attachments: A GSList list of CalAttachments.
- *
- * This target is used to represent a selected list of attachments in
- * the calendar attachment area.
- **/
-struct _ECalPopupTargetAttachments {
- EPopupTarget target;
- GSList *attachments;
-};
-
-typedef struct _EPopupItem ECalPopupItem;
-
-typedef struct _ECalPopup ECalPopup;
-typedef struct _ECalPopupClass ECalPopupClass;
-typedef struct _ECalPopupPrivate ECalPopupPrivate;
-
-/* The object */
-struct _ECalPopup {
- EPopup popup;
-
- ECalPopupPrivate *priv;
-};
-
-struct _ECalPopupClass {
- EPopupClass popup_class;
-};
-
-GType e_cal_popup_get_type(void);
-
-ECalPopup *e_cal_popup_new(const gchar *menuid);
-
-ECalPopupTargetSelect *e_cal_popup_target_new_select(ECalPopup *eabp, ECalModel *model, GPtrArray *events);
-ECalPopupTargetSource *e_cal_popup_target_new_source(ECalPopup *eabp, ESourceSelector *selector);
-
-/* ********************************************************************** */
-
-typedef struct _ECalPopupHook ECalPopupHook;
-typedef struct _ECalPopupHookClass ECalPopupHookClass;
-
-struct _ECalPopupHook {
- EPopupHook hook;
-};
-
-struct _ECalPopupHookClass {
- EPopupHookClass hook_class;
-};
-
-GType e_cal_popup_hook_get_type(void);
-
-G_END_DECLS
-
-#endif /* __E_CAL_POPUP_H__ */
diff --git a/calendar/gui/e-calendar-selector.c b/calendar/gui/e-calendar-selector.c
new file mode 100644
index 0000000000..94bd5ae339
--- /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[] = {
+ { (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
+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
deleted file mode 100644
index fb8d18c189..0000000000
--- a/calendar/gui/e-calendar-table-config.c
+++ /dev/null
@@ -1,244 +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:
- * JP Rosevear <jpr@ximian.com>
- *
- * Copyright (C) 1999-2008 Novell, Inc. (www.novell.com)
- *
- */
-
-#include "calendar-config.h"
-#include "e-cell-date-edit-config.h"
-#include "e-calendar-table-config.h"
-
-struct _ECalendarTableConfigPrivate {
- ECalendarTable *table;
-
- ECellDateEditConfig *cell_config;
-
- GList *notifications;
-};
-
-/* Property IDs */
-enum props {
- PROP_0,
- PROP_TABLE
-};
-
-G_DEFINE_TYPE (ECalendarTableConfig, e_calendar_table_config, G_TYPE_OBJECT)
-
-static void
-e_calendar_table_config_set_property (GObject *object, guint property_id, const GValue *value, GParamSpec *pspec)
-{
- ECalendarTableConfig *table_config;
-
- table_config = E_CALENDAR_TABLE_CONFIG (object);
-
- 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;
- }
-}
-
-static void
-e_calendar_table_config_get_property (GObject *object, guint property_id, GValue *value, GParamSpec *pspec)
-{
- ECalendarTableConfig *table_config;
-
- table_config = E_CALENDAR_TABLE_CONFIG (object);
-
- 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;
- }
-}
-
-static void
-e_calendar_table_config_dispose (GObject *object)
-{
- ECalendarTableConfig *table_config = E_CALENDAR_TABLE_CONFIG (object);
-
- e_calendar_table_config_set_table (table_config, NULL);
-
- if (G_OBJECT_CLASS (e_calendar_table_config_parent_class)->dispose)
- G_OBJECT_CLASS (e_calendar_table_config_parent_class)->dispose (object);
-}
-
-static void
-e_calendar_table_config_finalize (GObject *object)
-{
- ECalendarTableConfig *table_config = E_CALENDAR_TABLE_CONFIG (object);
- ECalendarTableConfigPrivate *priv;
-
- priv = table_config->priv;
-
- g_free (priv);
-
- if (G_OBJECT_CLASS (e_calendar_table_config_parent_class)->finalize)
- G_OBJECT_CLASS (e_calendar_table_config_parent_class)->finalize (object);
-}
-
-static void
-e_calendar_table_config_class_init (ECalendarTableConfigClass *klass)
-{
- 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);
-}
-
-static void
-e_calendar_table_config_init (ECalendarTableConfig *table_config)
-{
- table_config->priv = g_new0 (ECalendarTableConfigPrivate, 1);
-
-}
-
-ECalendarTableConfig *
-e_calendar_table_config_new (ECalendarTable *table)
-{
- ECalendarTableConfig *table_config;
-
- table_config = g_object_new (e_calendar_table_config_get_type (), "table", table, NULL);
-
- return table_config;
-}
-
-ECalendarTable *
-e_calendar_table_config_get_table (ECalendarTableConfig *table_config)
-{
- 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;
-}
-
-static void
-set_timezone (ECalendarTable *table)
-{
- 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);
-}
-
-static void
-timezone_changed_cb (GConfClient *client, guint id, GConfEntry *entry, gpointer data)
-{
- ECalendarTableConfig *table_config = data;
- ECalendarTableConfigPrivate *priv;
-
- priv = table_config->priv;
-
- set_timezone (priv->table);
-}
-
-static void
-set_twentyfour_hour (ECalendarTable *table)
-{
- ECalModel *model;
- gboolean use_24_hour;
-
- 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);
-}
-
-static void
-twentyfour_hour_changed_cb (GConfClient *client, guint id, GConfEntry *entry, gpointer data)
-{
- ECalendarTableConfig *table_config = data;
- ECalendarTableConfigPrivate *priv;
-
- priv = table_config->priv;
-
- set_twentyfour_hour (priv->table);
-}
-
-void
-e_calendar_table_config_set_table (ECalendarTableConfig *table_config, ECalendarTable *table)
-{
- ECalendarTableConfigPrivate *priv;
- guint not;
- GList *l;
-
- 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 (priv->cell_config) {
- g_object_unref (priv->cell_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;
-
- /* If the new view is NULL, return right now */
- if (!table)
- return;
-
- priv->table = g_object_ref (table);
-
- /* Time zone */
- 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));
-
- /* 24 Hour format */
- 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));
-
- /* Date cell */
- 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
deleted file mode 100644
index 93588a6e57..0000000000
--- a/calendar/gui/e-calendar-table-config.h
+++ /dev/null
@@ -1,56 +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:
- * JP Rosevear <jpr@ximian.com>
- *
- * Copyright (C) 1999-2008 Novell, Inc. (www.novell.com)
- *
- */
-
-#ifndef _E_CALENDAR_TABLE_CONFIG_H_
-#define _E_CALENDAR_TABLE_CONFIG_H_
-
-#include "e-calendar-table.h"
-
-G_BEGIN_DECLS
-
-#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 ())
-
-typedef struct _ECalendarTableConfig ECalendarTableConfig;
-typedef struct _ECalendarTableConfigClass ECalendarTableConfigClass;
-typedef struct _ECalendarTableConfigPrivate ECalendarTableConfigPrivate;
-
-struct _ECalendarTableConfig {
- GObject parent;
-
- ECalendarTableConfigPrivate *priv;
-};
-
-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);
-
-G_END_DECLS
-
-#endif
diff --git a/calendar/gui/e-calendar-table.c b/calendar/gui/e-calendar-table.c
index 284922c029..1122310a49 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>
@@ -43,14 +42,14 @@
#include <table/e-cell-text.h>
#include <table/e-cell-combo.h>
#include <table/e-cell-date.h>
+#include <e-util/e-binding.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"
@@ -59,103 +58,97 @@
#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);
-
-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);
+enum {
+ PROP_0,
+ PROP_MODEL,
+ PROP_SHELL_VIEW
+};
-/* 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[] = {
+ { (gchar *) "text/calendar", 0, TARGET_TYPE_VCALENDAR },
+ { (gchar *) "text/x-calendar", 0, TARGET_TYPE_VCALENDAR }
+};
+
+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
-static const gchar * icon_names[E_CALENDAR_MODEL_NUM_ICONS] = {
- "stock_task", "stock_task-recurring", "stock_task-assigned", "stock_task-assigned-to"
+#define NUM_ICONS 4
+static const gchar *icon_names[NUM_ICONS] = {
+ "stock_task",
+ "stock_task-recurring",
+ "stock_task-assigned",
+ "stock_task-assigned-to"
};
-static GdkPixbuf* icon_pixbufs[E_CALENDAR_MODEL_NUM_ICONS] = { NULL };
+static GdkPixbuf *icon_pixbufs[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;
@@ -183,24 +176,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;
@@ -214,71 +201,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 ();
@@ -287,47 +288,48 @@ ec_query_tooltip (GtkWidget *widget, gint x, gint y, gboolean keyboard_mode, Gtk
GString *tmp2;
gchar buff[1001];
gboolean free_text = FALSE;
+ gboolean use_24_hour_format;
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);
@@ -367,7 +369,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 */
@@ -384,12 +386,14 @@ 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);
+ use_24_hour_format = e_cal_model_get_use_24_hour_format (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 {
@@ -399,7 +403,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, use_24_hour_format,
+ FALSE, FALSE, buff, 1000);
if (buff [0]) {
g_string_append (tmp2, _("Start: "));
@@ -408,7 +418,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, use_24_hour_format,
+ FALSE, FALSE, buff, 1000);
if (buff [0]) {
if (tmp2->len)
@@ -430,7 +446,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);
@@ -475,22 +492,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;
+}
- g_return_val_if_fail (E_IS_CALENDAR_TABLE (user_data), FALSE);
+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;
+ }
- cal_table = E_CALENDAR_TABLE (user_data);
+ G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
+}
+
+static void
+calendar_table_dispose (GObject *object)
+{
+ ECalendarTablePrivate *priv;
+
+ priv = E_CALENDAR_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_calendar_table_get_table (cal_table)), cal_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_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;
@@ -499,22 +629,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,
@@ -526,21 +652,34 @@ 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,
NULL);
+ e_mutual_binding_new (
+ G_OBJECT (model), "timezone",
+ G_OBJECT (cell), "timezone");
+
+ e_mutual_binding_new (
+ G_OBJECT (model), "use-24-hour-format",
+ G_OBJECT (cell), "use-24-hour-format");
+
popup_cell = e_cell_date_edit_new ();
e_cell_popup_set_child (E_CELL_POPUP (popup_cell), cell);
g_object_unref (cell);
+
+ e_mutual_binding_new (
+ G_OBJECT (model), "use-24-hour-format",
+ G_OBJECT (popup_cell), "use-24-hour-format");
+
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.
@@ -548,7 +687,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,
@@ -665,22 +804,22 @@ 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 */
if (!icon_pixbufs[0])
- for (i = 0; i < E_CALENDAR_MODEL_NUM_ICONS; i++) {
+ for (i = 0; i < NUM_ICONS; i++) {
icon_pixbufs[i] = e_icon_factory_get_icon (icon_names[i], GTK_ICON_SIZE_MENU);
}
- cell = e_cell_toggle_new (0, E_CALENDAR_MODEL_NUM_ICONS, icon_pixbufs);
+ cell = e_cell_toggle_new (0, NUM_ICONS, icon_pixbufs);
e_table_extras_add_cell(extras, "icon", cell);
e_table_extras_add_pixbuf(extras, "icon", icon_pixbufs[0]);
@@ -694,51 +833,166 @@ 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
*
- * Creates a new #ECalendarTable.
+ * Returns 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;
-
- cal_table = GTK_WIDGET (g_object_new (e_calendar_table_get_type (), NULL));
+ g_return_val_if_fail (E_IS_SHELL_VIEW (shell_view), NULL);
+ g_return_val_if_fail (E_IS_CAL_MODEL (model), NULL);
- return cal_table;
+ return g_object_new (
+ E_TYPE_CALENDAR_TABLE,
+ "model", model, "shell-view", shell_view, NULL);
}
/**
@@ -752,25 +1006,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;
}
/**
@@ -785,37 +1023,21 @@ 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);
+ ETableScrolled *table_scrolled;
- return e_table_scrolled_get_table (E_TABLE_SCROLLED (cal_table->etable));
-}
+ g_return_val_if_fail (E_IS_CALENDAR_TABLE (cal_table), NULL);
-void
-e_calendar_table_open_selected (ECalendarTable *cal_table)
-{
- ECalModelComponent *comp_data;
- icalproperty *prop;
+ table_scrolled = E_TABLE_SCROLLED (cal_table->etable);
- 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);
+ return e_table_scrolled_get_table (table_scrolled);
}
-/**
- * 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)
+EShellView *
+e_calendar_table_get_shell_view (ECalendarTable *cal_table)
{
- g_return_if_fail (cal_table != NULL);
- g_return_if_fail (E_IS_CALENDAR_TABLE (cal_table));
+ g_return_val_if_fail (E_IS_CALENDAR_TABLE (cal_table), NULL);
- mark_as_complete_cb (NULL, NULL, cal_table);
+ return cal_table->priv->shell_view;
}
/* Used from e_table_selected_row_foreach(); puts the selected row number in an
@@ -830,16 +1052,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;
@@ -849,7 +1074,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 {
@@ -861,40 +1086,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;
@@ -906,7 +1118,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);
}
@@ -967,14 +1179,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;
@@ -1038,7 +1250,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;
}
/**
@@ -1082,6 +1303,7 @@ copy_row_cb (gint model_row, gpointer data)
{
ECalendarTable *cal_table;
ECalModelComponent *comp_data;
+ ECalModel *model;
gchar *comp_str;
icalcomponent *child;
@@ -1089,7 +1311,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;
@@ -1125,17 +1348,18 @@ 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)) {
-
+ if (!gtk_clipboard_set_with_data (
+ clipboard, target_types, G_N_ELEMENTS (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);
+ gtk_clipboard_set_can_store (
+ clipboard, target_types + 1,
+ G_N_ELEMENTS (target_types) - 1);
}
/* free memory */
@@ -1150,8 +1374,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));
@@ -1171,9 +1397,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;
@@ -1218,7 +1446,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
@@ -1227,7 +1455,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;
@@ -1262,446 +1490,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, FALSE);
-
- 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
@@ -1792,28 +1589,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.
@@ -1822,12 +1621,15 @@ e_calendar_table_save_state (ECalendarTable *cal_table,
static struct tm
e_calendar_table_get_current_time (ECellDateEdit *ecde, gpointer data)
{
+ ECalendarTable *cal_table = data;
+ ECalModel *model;
icaltimezone *zone;
struct tm tmp_tm = { 0 };
struct icaltimetype tt;
/* Get the current timezone. */
- zone = calendar_config_get_icaltimezone ();
+ model = e_calendar_table_get_model (cal_table);
+ zone = e_cal_model_get_timezone (model);
tt = icaltime_from_timet_with_zone (time (NULL), FALSE, zone);
@@ -1843,56 +1645,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.
@@ -1901,7 +1653,9 @@ e_calendar_table_set_status_message (ECalendarTable *cal_table, const gchar *mes
* Hide completed tasks.
*/
void
-e_calendar_table_process_completed_tasks (ECalendarTable *table, GList *clients_list, gboolean config_changed)
+e_calendar_table_process_completed_tasks (ECalendarTable *table,
+ GList *clients_list,
+ gboolean config_changed)
{
ECalModel *model;
static GMutex *mutex = NULL;
diff --git a/calendar/gui/e-calendar-table.h b/calendar/gui/e-calendar-table.h
index 0abcd4be0e..d2b376ba9d 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,62 +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);
-
-gboolean ec_query_tooltip (GtkWidget *widget, gint x, gint y, gboolean keyboard_mode, GtkTooltip *tooltip, GtkWidget *etable_wgt, ECalModel *model);
+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);
G_END_DECLS
diff --git a/calendar/gui/e-calendar-view.c b/calendar/gui/e-calendar-view.c
index 286db6b5f1..7450cd1221 100644
--- a/calendar/gui/e-calendar-view.c
+++ b/calendar/gui/e-calendar-view.c
@@ -38,15 +38,14 @@
#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 "ea-calendar.h"
#include "e-cal-model-calendar.h"
#include "e-calendar-view.h"
-#include "e-comp-editor-registry.h"
#include "itip-utils.h"
#include "dialogs/comp-editor-util.h"
#include "dialogs/delete-comp.h"
@@ -58,10 +57,12 @@
#include "dialogs/select-source-dialog.h"
#include "print.h"
#include "goto.h"
-#include "ea-calendar.h"
-#include "e-cal-popup.h"
#include "misc.h"
+#define E_CALENDAR_VIEW_GET_PRIVATE(obj) \
+ (G_TYPE_INSTANCE_GET_PRIVATE \
+ ((obj), E_TYPE_CALENDAR_VIEW, ECalendarViewPrivate))
+
struct _ECalendarViewPrivate {
/* The GnomeCalendar we are associated to */
GnomeCalendar *calendar;
@@ -69,22 +70,11 @@ 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;
};
-static void e_calendar_view_get_property (GObject *object, guint property_id, GValue *value, GParamSpec *pspec);
-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 {
+enum {
PROP_0,
PROP_MODEL
};
@@ -92,6 +82,7 @@ enum props {
/* FIXME Why are we emitting these event signals here? Can't the model just be listened to? */
/* Signal IDs */
enum {
+ POPUP_EVENT,
SELECTION_CHANGED,
SELECTED_TIME_CHANGED,
TIMEZONE_CHANGED,
@@ -102,7 +93,7 @@ enum {
LAST_SIGNAL
};
-static guint e_calendar_view_signals[LAST_SIGNAL] = { 0 };
+static guint signals[LAST_SIGNAL];
G_DEFINE_TYPE (ECalendarView, e_calendar_view, GTK_TYPE_TABLE)
@@ -115,151 +106,227 @@ static GtkTargetEntry target_types[] = {
{ (gchar *) "text/calendar", 0, TARGET_TYPE_VCALENDAR }
};
-static guint n_target_types = G_N_ELEMENTS (target_types);
+static void
+calendar_view_set_model (ECalendarView *calendar_view,
+ ECalModel *model)
+{
+ g_return_if_fail (calendar_view->priv->model == NULL);
+ g_return_if_fail (E_IS_CAL_MODEL (model));
+
+ calendar_view->priv->model = g_object_ref (model);
+}
static void
-e_calendar_view_set_property (GObject *object, guint property_id, const GValue *value, GParamSpec *pspec)
+calendar_view_set_property (GObject *object,
+ guint property_id,
+ const GValue *value,
+ GParamSpec *pspec)
{
- ECalendarView *cal_view;
+ switch (property_id) {
+ case PROP_MODEL:
+ calendar_view_set_model (
+ E_CALENDAR_VIEW (object),
+ g_value_get_object (value));
+ return;
+ }
- cal_view = E_CALENDAR_VIEW (object);
+ G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
+}
+static void
+calendar_view_get_property (GObject *object,
+ guint property_id,
+ GValue *value,
+ GParamSpec *pspec)
+{
switch (property_id) {
- case PROP_MODEL:
- e_calendar_view_set_model (cal_view, E_CAL_MODEL (g_value_get_object (value)));
- break;
- default:
- G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
- break;
+ case PROP_MODEL:
+ g_value_set_object (
+ value, e_calendar_view_get_model (
+ E_CALENDAR_VIEW (object)));
+ return;
}
+
+ G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
}
static void
-e_calendar_view_get_property (GObject *object, guint property_id, GValue *value, GParamSpec *pspec)
+calendar_view_dispose (GObject *object)
{
- ECalendarView *cal_view;
+ ECalendarViewPrivate *priv;
- cal_view = E_CALENDAR_VIEW (object);
+ priv = E_CALENDAR_VIEW_GET_PRIVATE (object);
- switch (property_id) {
- case PROP_MODEL:
- g_value_set_object (value, e_calendar_view_get_model (cal_view));
- break;
- default:
- G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
- break;
+ if (priv->model != NULL) {
+ g_signal_handlers_disconnect_matched (
+ priv->model, G_SIGNAL_MATCH_DATA,
+ 0, 0, NULL, NULL, object);
+ g_object_unref (priv->model);
+ priv->model = NULL;
}
+
+ /* Chain up to parent's dispose() method. */
+ G_OBJECT_CLASS (e_calendar_view_parent_class)->dispose (object);
}
static void
-e_calendar_view_class_init (ECalendarViewClass *klass)
+calendar_view_finalize (GObject *object)
{
- GObjectClass *gobject_class = G_OBJECT_CLASS (klass);
- GtkObjectClass *object_class = GTK_OBJECT_CLASS (klass);
+ ECalendarViewPrivate *priv;
+
+ priv = E_CALENDAR_VIEW_GET_PRIVATE (object);
+ g_free (priv->default_category);
+
+ /* Chain up to parent's finalize() method. */
+ G_OBJECT_CLASS (e_calendar_view_parent_class)->finalize (object);
+}
+
+static void
+e_calendar_view_class_init (ECalendarViewClass *class)
+{
+ GObjectClass *object_class;
GtkBindingSet *binding_set;
- /* Method override */
- gobject_class->set_property = e_calendar_view_set_property;
- gobject_class->get_property = e_calendar_view_get_property;
- object_class->destroy = e_calendar_view_destroy;
-
- klass->selection_changed = NULL;
- klass->selected_time_changed = NULL;
- klass->event_changed = NULL;
- klass->event_added = NULL;
- klass->user_created = NULL;
-
- klass->get_selected_events = NULL;
- klass->get_selected_time_range = NULL;
- klass->set_selected_time_range = NULL;
- klass->get_visible_time_range = NULL;
- klass->update_query = NULL;
- klass->open_event = e_calendar_view_open_event;
- klass->paste_text = NULL;
-
- g_object_class_install_property (gobject_class, PROP_MODEL,
- g_param_spec_object ("model", NULL, NULL, E_TYPE_CAL_MODEL,
- G_PARAM_READABLE | G_PARAM_WRITABLE));
-
- /* Create class' signals */
- e_calendar_view_signals[SELECTION_CHANGED] =
- g_signal_new ("selection_changed",
- G_TYPE_FROM_CLASS (klass),
- G_SIGNAL_RUN_LAST,
- G_STRUCT_OFFSET (ECalendarViewClass, selection_changed),
- NULL, NULL,
- g_cclosure_marshal_VOID__VOID,
- G_TYPE_NONE, 0);
- e_calendar_view_signals[SELECTED_TIME_CHANGED] =
- g_signal_new ("selected_time_changed",
- G_TYPE_FROM_CLASS (klass),
- G_SIGNAL_RUN_LAST,
- G_STRUCT_OFFSET (ECalendarViewClass, selected_time_changed),
- NULL, NULL,
- g_cclosure_marshal_VOID__VOID,
- G_TYPE_NONE, 0);
- e_calendar_view_signals[TIMEZONE_CHANGED] =
- g_signal_new ("timezone_changed",
- G_TYPE_FROM_CLASS (klass),
- G_SIGNAL_RUN_LAST,
- G_STRUCT_OFFSET (ECalendarViewClass, timezone_changed),
- NULL, NULL,
- e_marshal_VOID__POINTER_POINTER,
- G_TYPE_NONE, 2, G_TYPE_POINTER, G_TYPE_POINTER);
-
- e_calendar_view_signals[EVENT_CHANGED] =
- g_signal_new ("event_changed",
- G_TYPE_FROM_CLASS (object_class),
- G_SIGNAL_RUN_FIRST | G_SIGNAL_ACTION,
- G_STRUCT_OFFSET (ECalendarViewClass, event_changed),
- NULL, NULL,
- g_cclosure_marshal_VOID__POINTER,
- G_TYPE_NONE, 1,
- G_TYPE_POINTER);
-
- e_calendar_view_signals[EVENT_ADDED] =
- g_signal_new ("event_added",
- G_TYPE_FROM_CLASS (object_class),
- G_SIGNAL_RUN_FIRST | G_SIGNAL_ACTION,
- G_STRUCT_OFFSET (ECalendarViewClass, event_added),
- NULL, NULL,
- g_cclosure_marshal_VOID__POINTER,
- G_TYPE_NONE, 1,
- G_TYPE_POINTER);
-
- e_calendar_view_signals[USER_CREATED] =
- g_signal_new ("user_created",
- G_TYPE_FROM_CLASS (klass),
- G_SIGNAL_RUN_LAST,
- G_STRUCT_OFFSET (ECalendarViewClass, user_created),
- NULL, NULL,
- g_cclosure_marshal_VOID__VOID,
- G_TYPE_NONE, 0);
-
- e_calendar_view_signals[OPEN_EVENT] =
- g_signal_new ("open_event",
- G_TYPE_FROM_CLASS (klass),
- G_SIGNAL_RUN_FIRST | G_SIGNAL_ACTION,
- G_STRUCT_OFFSET (ECalendarViewClass, open_event),
- NULL, NULL,
- g_cclosure_marshal_VOID__VOID,
- G_TYPE_NONE, 0);
+ g_type_class_add_private (class, sizeof (ECalendarViewPrivate));
+
+ object_class = G_OBJECT_CLASS (class);
+ object_class->set_property = calendar_view_set_property;
+ object_class->get_property = calendar_view_get_property;
+ object_class->dispose = calendar_view_dispose;
+ object_class->finalize = calendar_view_finalize;
+
+ class->selection_changed = NULL;
+ class->selected_time_changed = NULL;
+ class->event_changed = NULL;
+ class->event_added = NULL;
+ class->user_created = NULL;
+
+ class->get_selected_events = NULL;
+ class->get_selected_time_range = NULL;
+ class->set_selected_time_range = NULL;
+ class->get_visible_time_range = NULL;
+ class->update_query = NULL;
+ class->open_event = e_calendar_view_open_event;
+ class->paste_text = NULL;
+
+ 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));
+
+ signals[POPUP_EVENT] = g_signal_new (
+ "popup-event",
+ G_TYPE_FROM_CLASS (class),
+ G_SIGNAL_RUN_FIRST,
+ G_STRUCT_OFFSET (ECalendarViewClass, popup_event),
+ NULL, NULL,
+ g_cclosure_marshal_VOID__BOXED,
+ G_TYPE_NONE, 1,
+ GDK_TYPE_EVENT | G_SIGNAL_TYPE_STATIC_SCOPE);
+
+ signals[SELECTION_CHANGED] = g_signal_new (
+ "selection-changed",
+ G_TYPE_FROM_CLASS (class),
+ G_SIGNAL_RUN_LAST,
+ G_STRUCT_OFFSET (ECalendarViewClass, selection_changed),
+ NULL, NULL,
+ g_cclosure_marshal_VOID__VOID,
+ G_TYPE_NONE, 0);
+
+ signals[SELECTED_TIME_CHANGED] = g_signal_new (
+ "selected-time-changed",
+ G_TYPE_FROM_CLASS (class),
+ G_SIGNAL_RUN_LAST,
+ G_STRUCT_OFFSET (ECalendarViewClass, selected_time_changed),
+ NULL, NULL,
+ g_cclosure_marshal_VOID__VOID,
+ G_TYPE_NONE, 0);
+
+ signals[TIMEZONE_CHANGED] = g_signal_new (
+ "timezone-changed",
+ G_TYPE_FROM_CLASS (class),
+ G_SIGNAL_RUN_LAST,
+ G_STRUCT_OFFSET (ECalendarViewClass, timezone_changed),
+ NULL, NULL,
+ e_marshal_VOID__POINTER_POINTER,
+ G_TYPE_NONE, 2,
+ G_TYPE_POINTER,
+ G_TYPE_POINTER);
+
+ signals[EVENT_CHANGED] = g_signal_new (
+ "event-changed",
+ G_TYPE_FROM_CLASS (object_class),
+ G_SIGNAL_RUN_FIRST | G_SIGNAL_ACTION,
+ G_STRUCT_OFFSET (ECalendarViewClass, event_changed),
+ NULL, NULL,
+ g_cclosure_marshal_VOID__POINTER,
+ G_TYPE_NONE, 1,
+ G_TYPE_POINTER);
+
+ signals[EVENT_ADDED] = g_signal_new (
+ "event-added",
+ G_TYPE_FROM_CLASS (object_class),
+ G_SIGNAL_RUN_FIRST | G_SIGNAL_ACTION,
+ G_STRUCT_OFFSET (ECalendarViewClass, event_added),
+ NULL, NULL,
+ g_cclosure_marshal_VOID__POINTER,
+ G_TYPE_NONE, 1,
+ G_TYPE_POINTER);
+
+ signals[USER_CREATED] = g_signal_new (
+ "user-created",
+ G_TYPE_FROM_CLASS (class),
+ G_SIGNAL_RUN_LAST,
+ G_STRUCT_OFFSET (ECalendarViewClass, user_created),
+ NULL, NULL,
+ g_cclosure_marshal_VOID__VOID,
+ G_TYPE_NONE, 0);
+
+ signals[OPEN_EVENT] = g_signal_new (
+ "open-event",
+ G_TYPE_FROM_CLASS (class),
+ G_SIGNAL_RUN_FIRST | G_SIGNAL_ACTION,
+ G_STRUCT_OFFSET (ECalendarViewClass, open_event),
+ NULL, NULL,
+ g_cclosure_marshal_VOID__VOID,
+ G_TYPE_NONE, 0);
/*
* Key bindings
*/
- binding_set = gtk_binding_set_by_class (klass);
+ binding_set = gtk_binding_set_by_class (class);
- gtk_binding_entry_add_signal (binding_set, GDK_o,
- GDK_CONTROL_MASK,
- "open_event", 0);
+ gtk_binding_entry_add_signal (
+ binding_set, GDK_o, GDK_CONTROL_MASK, "open-event", 0);
/* init the accessibility support for e_day_view */
e_cal_view_a11y_init ();
}
+static void
+e_calendar_view_init (ECalendarView *calendar_view)
+{
+ calendar_view->priv = E_CALENDAR_VIEW_GET_PRIVATE (calendar_view);
+}
+
+void
+e_calendar_view_popup_event (ECalendarView *calendar_view,
+ GdkEventButton *event)
+{
+ g_return_if_fail (E_IS_CALENDAR_VIEW (calendar_view));
+ g_return_if_fail (event != NULL);
+
+ g_signal_emit (calendar_view, signals[POPUP_EVENT], 0, event);
+}
+
void
e_calendar_view_add_event (ECalendarView *cal_view, ECal *client, time_t dtstart,
icaltimezone *default_zone, icalcomponent *icalcomp, gboolean in_top_canvas)
@@ -383,41 +450,6 @@ e_calendar_view_add_event (ECalendarView *cal_view, ECal *client, time_t dtstart
g_object_unref (comp);
}
-static void
-e_calendar_view_init (ECalendarView *cal_view)
-{
- cal_view->priv = g_new0 (ECalendarViewPrivate, 1);
-}
-
-static void
-e_calendar_view_destroy (GtkObject *object)
-{
- ECalendarView *cal_view = (ECalendarView *) object;
-
- g_return_if_fail (E_IS_CALENDAR_VIEW (cal_view));
-
- if (cal_view->priv) {
- if (cal_view->priv->model) {
- g_signal_handlers_disconnect_matched (cal_view->priv->model,
- G_SIGNAL_MATCH_DATA,
- 0, 0, NULL, NULL, cal_view);
- g_object_unref (cal_view->priv->model);
- cal_view->priv->model = NULL;
- }
-
- if (cal_view->priv->default_category) {
- g_free (cal_view->priv->default_category);
- cal_view->priv->default_category = NULL;
- }
-
- g_free (cal_view->priv);
- cal_view->priv = NULL;
- }
-
- if (GTK_OBJECT_CLASS (e_calendar_view_parent_class)->destroy)
- GTK_OBJECT_CLASS (e_calendar_view_parent_class)->destroy (object);
-}
-
GnomeCalendar *
e_calendar_view_get_calendar (ECalendarView *cal_view)
{
@@ -442,21 +474,6 @@ e_calendar_view_get_model (ECalendarView *cal_view)
return cal_view->priv->model;
}
-void
-e_calendar_view_set_model (ECalendarView *cal_view, ECalModel *model)
-{
- g_return_if_fail (E_IS_CALENDAR_VIEW (cal_view));
- g_return_if_fail (E_IS_CAL_MODEL (model));
-
- if (cal_view->priv->model) {
- g_signal_handlers_disconnect_matched (cal_view->priv->model, G_SIGNAL_MATCH_DATA,
- 0, 0, NULL, NULL, cal_view);
- g_object_unref (cal_view->priv->model);
- }
-
- cal_view->priv->model = g_object_ref (model);
-}
-
icaltimezone *
e_calendar_view_get_timezone (ECalendarView *cal_view)
{
@@ -476,7 +493,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);
}
@@ -506,142 +523,75 @@ e_calendar_view_set_default_category (ECalendarView *cal_view, const gchar *cate
cal_view->priv->default_category = g_strdup (category);
}
-/**
- * e_calendar_view_get_use_24_hour_format:
- * @cal_view: A calendar view.
- *
- * Gets whether the view is using 24 hour times or not.
- *
- * Returns: the 24 hour setting.
- */
-gboolean
-e_calendar_view_get_use_24_hour_format (ECalendarView *cal_view)
-{
- g_return_val_if_fail (E_IS_CALENDAR_VIEW (cal_view), FALSE);
-
- return e_cal_model_get_use_24_hour_format (cal_view->priv->model);
-}
-
-/**
- * e_calendar_view_set_use_24_hour_format
- * @cal_view: A calendar view.
- * @use_24_hour: Whether to use 24 hour times or not.
- *
- * Sets the 12/24 hour times setting for the given view.
- */
-void
-e_calendar_view_set_use_24_hour_format (ECalendarView *cal_view, gboolean use_24_hour)
-{
- g_return_if_fail (E_IS_CALENDAR_VIEW (cal_view));
-
- 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)
{
+ ECalendarViewClass *class;
+
g_return_val_if_fail (E_IS_CALENDAR_VIEW (cal_view), NULL);
- if (E_CALENDAR_VIEW_CLASS (G_OBJECT_GET_CLASS (cal_view))->get_selected_events)
- return E_CALENDAR_VIEW_CLASS (G_OBJECT_GET_CLASS (cal_view))->get_selected_events (cal_view);
+ class = E_CALENDAR_VIEW_GET_CLASS (cal_view);
+ g_return_val_if_fail (class->get_selected_events != NULL, NULL);
- return NULL;
+ return class->get_selected_events (cal_view);
}
gboolean
-e_calendar_view_get_selected_time_range (ECalendarView *cal_view, time_t *start_time, time_t *end_time)
+e_calendar_view_get_selected_time_range (ECalendarView *cal_view,
+ time_t *start_time,
+ time_t *end_time)
{
+ ECalendarViewClass *class;
+
g_return_val_if_fail (E_IS_CALENDAR_VIEW (cal_view), FALSE);
- if (E_CALENDAR_VIEW_CLASS (G_OBJECT_GET_CLASS (cal_view))->get_selected_time_range) {
- return E_CALENDAR_VIEW_CLASS (G_OBJECT_GET_CLASS (cal_view))->get_selected_time_range (
- cal_view, start_time, end_time);
- }
+ class = E_CALENDAR_VIEW_GET_CLASS (cal_view);
+ g_return_val_if_fail (class->get_selected_time_range != NULL, FALSE);
- return FALSE;
+ return class->get_selected_time_range (cal_view, start_time, end_time);
}
void
-e_calendar_view_set_selected_time_range (ECalendarView *cal_view, time_t start_time, time_t end_time)
+e_calendar_view_set_selected_time_range (ECalendarView *cal_view,
+ time_t start_time,
+ time_t end_time)
{
+ ECalendarViewClass *class;
+
g_return_if_fail (E_IS_CALENDAR_VIEW (cal_view));
- if (E_CALENDAR_VIEW_CLASS (G_OBJECT_GET_CLASS (cal_view))->set_selected_time_range) {
- E_CALENDAR_VIEW_CLASS (G_OBJECT_GET_CLASS (cal_view))->set_selected_time_range (
- cal_view, start_time, end_time);
- }
+ class = E_CALENDAR_VIEW_GET_CLASS (cal_view);
+ g_return_if_fail (class->set_selected_time_range != NULL);
+
+ class->set_selected_time_range (cal_view, start_time, end_time);
}
gboolean
-e_calendar_view_get_visible_time_range (ECalendarView *cal_view, time_t *start_time, time_t *end_time)
+e_calendar_view_get_visible_time_range (ECalendarView *cal_view,
+ time_t *start_time,
+ time_t *end_time)
{
+ ECalendarViewClass *class;
+
g_return_val_if_fail (E_IS_CALENDAR_VIEW (cal_view), FALSE);
- if (E_CALENDAR_VIEW_CLASS (G_OBJECT_GET_CLASS (cal_view))->get_visible_time_range) {
- return E_CALENDAR_VIEW_CLASS (G_OBJECT_GET_CLASS (cal_view))->get_visible_time_range (
- cal_view, start_time, end_time);
- }
+ class = E_CALENDAR_VIEW_GET_CLASS (cal_view);
+ g_return_val_if_fail (class->get_visible_time_range != NULL, FALSE);
- return FALSE;
+ return class->get_visible_time_range (cal_view, start_time, end_time);
}
void
e_calendar_view_update_query (ECalendarView *cal_view)
{
+ ECalendarViewClass *class;
+
g_return_if_fail (E_IS_CALENDAR_VIEW (cal_view));
- if (E_CALENDAR_VIEW_CLASS (G_OBJECT_GET_CLASS (cal_view))->update_query) {
- E_CALENDAR_VIEW_CLASS (G_OBJECT_GET_CLASS (cal_view))->update_query (cal_view);
- }
+ class = E_CALENDAR_VIEW_GET_CLASS (cal_view);
+ g_return_if_fail (class->update_query != NULL);
+
+ class->update_query (cal_view);
}
void
@@ -656,7 +606,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) {
@@ -701,7 +653,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);
}
@@ -828,13 +782,13 @@ e_calendar_view_copy_clipboard (ECalendarView *cal_view)
clipboard = gtk_widget_get_clipboard (GTK_WIDGET (cal_view), GDK_SELECTION_CLIPBOARD);
comp_str = icalcomponent_as_ical_string_r (vcal_comp);
- if (!gtk_clipboard_set_with_data (clipboard, target_types, n_target_types,
+ if (!gtk_clipboard_set_with_data (clipboard, target_types, G_N_ELEMENTS (target_types),
clipboard_get_calendar_cb,
clipboard_clear_calendar_cb,
comp_str)) {
g_free (comp_str);
} else {
- gtk_clipboard_set_can_store (clipboard, target_types + 1, n_target_types - 1);
+ gtk_clipboard_set_can_store (clipboard, target_types + 1, G_N_ELEMENTS (target_types) - 1);
}
/* free memory */
@@ -870,7 +824,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)
@@ -918,16 +874,22 @@ 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
e_calendar_view_paste_text (ECalendarView *cal_view)
{
+ ECalendarViewClass *class;
+
g_return_if_fail (E_IS_CALENDAR_VIEW (cal_view));
- if (E_CALENDAR_VIEW_CLASS (G_OBJECT_GET_CLASS (cal_view))->paste_text)
- E_CALENDAR_VIEW_CLASS (G_OBJECT_GET_CLASS (cal_view))->paste_text (cal_view);
+ class = E_CALENDAR_VIEW_GET_CLASS (cal_view);
+ g_return_if_fail (class->paste_text != NULL);
+
+ class->paste_text (cal_view);
}
static void
@@ -1240,660 +1202,6 @@ e_calendar_view_delete_selected_occurrence (ECalendarView *cal_view)
g_object_unref (comp);
}
-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)
-{
- 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);
-}
-
-static void
-on_edit_appointment (EPopup *ep, EPopupItem *pitem, gpointer data)
-{
- ECalendarView *cal_view = data;
- GList *selected;
-
- selected = e_calendar_view_get_selected_events (cal_view);
- if (selected) {
- ECalendarViewEvent *event = (ECalendarViewEvent *) selected->data;
-
- if (event)
- e_calendar_view_edit_appointment (cal_view, event->comp_data->client,
- event->comp_data->icalcomp,
- icalcomponent_get_first_property(event->comp_data->icalcomp, ICAL_ATTENDEE_PROPERTY) != NULL);
-
- g_list_free (selected);
- }
-}
-
-static void
-on_print (EPopup *ep, EPopupItem *pitem, gpointer data)
-{
- ECalendarView *cal_view = data;
-
- calendar_command_print (cal_view->priv->calendar, GTK_PRINT_OPERATION_ACTION_PRINT_DIALOG);
-}
-
-static void
-on_save_as (EPopup *ep, EPopupItem *pitem, gpointer data)
-{
- ECalendarView *cal_view = data;
- GList *selected;
- gchar *filename;
- gchar *ical_string;
- ECalendarViewEvent *event;
-
- selected = e_calendar_view_get_selected_events (cal_view);
- if (!selected)
- return;
-
- filename = e_file_dialog_save (_("Save as..."), NULL);
- if (filename == NULL)
- return;
-
- event = (ECalendarViewEvent *) selected->data;
- ical_string = e_cal_get_component_as_string (event->comp_data->client, event->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);
-
- g_list_free (selected);
-}
-
-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;
- gchar *new_uid;
- icalcomponent *orig_icalcomp;
- icalproperty *icalprop;
-
- uid = icalcomponent_get_uid (event->comp_data->icalcomp);
-
- /* put the new object into the destination calendar */
- if (e_cal_get_object (dest_client, uid, NULL, &orig_icalcomp, NULL)) {
- icalcomponent_free (orig_icalcomp);
-
- if (!e_cal_modify_object (dest_client, event->comp_data->icalcomp, CALOBJ_MOD_ALL, NULL))
- return;
- } else {
- if (e_cal_util_component_is_instance (event->comp_data->icalcomp)) {
- icalcomponent *icalcomp = NULL;
-
- if (e_cal_get_object (event->comp_data->client, uid, NULL, &icalcomp, NULL)) {
- /* use master object when working with recurring event */
- orig_icalcomp = icalcomponent_new_clone (icalcomp);
- icalcomponent_free (icalcomp);
- } else {
- /* ... or remove the recurrence id property... */
- orig_icalcomp = icalcomponent_new_clone (event->comp_data->icalcomp);
-
- if (e_cal_util_component_has_recurrences (orig_icalcomp)) {
- /* ... for non-detached instances, to make it a master object */
- icalproperty *prop;
-
- prop = icalcomponent_get_first_property (orig_icalcomp, ICAL_RECURRENCEID_PROPERTY);
- if (prop)
- icalcomponent_remove_property (orig_icalcomp, prop);
- }
- }
- } else
- orig_icalcomp = icalcomponent_new_clone (event->comp_data->icalcomp);
-
- icalprop = icalproperty_new_x ("1");
- icalproperty_set_x_name (icalprop, "X-EVOLUTION-MOVE-CALENDAR");
- icalcomponent_add_property (orig_icalcomp, icalprop);
-
- if (!remove_item) {
- /* change the UID to avoid problems with duplicated UIDs */
- new_uid = e_cal_component_gen_uid ();
- icalcomponent_set_uid (orig_icalcomp, new_uid);
-
- g_free (new_uid);
- }
-
- new_uid = NULL;
- if (!e_cal_create_object (dest_client, orig_icalcomp, &new_uid, NULL)) {
- icalcomponent_free (orig_icalcomp);
- return;
- }
-
- if (new_uid)
- g_free (new_uid);
- icalcomponent_free (orig_icalcomp);
- }
-
- /* remove the item from the source calendar */
- if (remove_item) {
- if (e_cal_util_component_is_instance (event->comp_data->icalcomp) || e_cal_util_component_has_recurrences (event->comp_data->icalcomp)) {
- gchar *rid = NULL;
- struct icaltimetype recur_id = icalcomponent_get_recurrenceid (event->comp_data->icalcomp);
-
- if (!icaltime_is_null_time (recur_id))
- rid = icaltime_as_ical_string_r (recur_id);
-
- e_cal_remove_object_with_mod (event->comp_data->client, uid, rid, CALOBJ_MOD_ALL, NULL);
- g_free (rid);
- } else
- e_cal_remove_object (event->comp_data->client, uid, NULL);
- }
-}
-
-static void
-transfer_selected_items (ECalendarView *cal_view, gboolean remove_item)
-{
- GList *selected, *l;
- ESource *destination_source;
- ECal *dest_client;
-
- selected = e_calendar_view_get_selected_events (cal_view);
- if (!selected)
- return;
-
- /* prompt the user for destination source */
- destination_source = select_source_dialog ((GtkWindow *) gtk_widget_get_toplevel ((GtkWidget *)cal_view), E_CAL_SOURCE_TYPE_EVENT);
- if (!destination_source)
- return;
-
- /* open the destination calendar */
- dest_client = auth_new_cal_from_source (destination_source, E_CAL_SOURCE_TYPE_EVENT);
- if (!dest_client || !e_cal_open (dest_client, FALSE, NULL)) {
- if (dest_client)
- g_object_unref (dest_client);
- g_object_unref (destination_source);
- return;
- }
-
- /* 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);
-
- for (l = selected; l != NULL; l = l->next)
- transfer_item_to ((ECalendarViewEvent *) l->data, dest_client, remove_item);
-
- e_calendar_view_set_status_message (cal_view, NULL, -1);
-
- /* free memory */
- g_object_unref (destination_source);
- g_object_unref (dest_client);
- g_list_free (selected);
-}
-
-static void
-on_copy_to (EPopup *ep, EPopupItem *pitem, gpointer data)
-{
- ECalendarView *cal_view = data;
-
- transfer_selected_items (cal_view, FALSE);
-}
-
-static void
-on_move_to (EPopup *ep, EPopupItem *pitem, gpointer data)
-{
- ECalendarView *cal_view = data;
-
- transfer_selected_items (cal_view, TRUE);
-}
-
-static void
-on_meeting (EPopup *ep, EPopupItem *pitem, gpointer data)
-{
- ECalendarView *cal_view = data;
- GList *selected;
-
- selected = e_calendar_view_get_selected_events (cal_view);
- if (selected) {
- ECalendarViewEvent *event = (ECalendarViewEvent *) selected->data;
- e_calendar_view_edit_appointment (cal_view, event->comp_data->client, event->comp_data->icalcomp, TRUE);
-
- g_list_free (selected);
- }
-}
-
-static void
-set_attendee_status_for_delegate (icalcomponent *icalcomp, ECal *client)
-{
- icalproperty *prop;
- icalparameter *param;
- gchar *address = NULL;
- ECalComponent *comp;
- gboolean found = FALSE;
-
- comp = e_cal_component_new ();
- e_cal_component_set_icalcomponent (comp, icalcomponent_new_clone (icalcomp));
-
- address = itip_get_comp_attendee (comp, client);
-
- for (prop = icalcomponent_get_first_property (icalcomp, ICAL_ATTENDEE_PROPERTY);
- prop;
- prop = icalcomponent_get_next_property (icalcomp, ICAL_ATTENDEE_PROPERTY)) {
- const gchar *attendee = icalproperty_get_attendee (prop);
-
- if (!g_ascii_strcasecmp (itip_strip_mailto (attendee), address)) {
- param = icalparameter_new_role (ICAL_ROLE_NONPARTICIPANT);
- icalproperty_set_parameter (prop, param);
-
- param = icalparameter_new_partstat (ICAL_PARTSTAT_DELEGATED);
- icalproperty_set_parameter (prop, param);
-
- found = TRUE;
- break;
- }
-
- }
-
- /* We couldn find the attendee in the component, so add a new attendee */
- if (!found) {
- gchar *temp = g_strdup_printf ("MAILTO:%s", address);
-
- prop = icalproperty_new_attendee ((const gchar *) temp);
- icalcomponent_add_property (icalcomp, prop);
-
- param = icalparameter_new_partstat (ICAL_PARTSTAT_DELEGATED);
- icalproperty_add_parameter (prop, param);
-
- param = icalparameter_new_role (ICAL_ROLE_NONPARTICIPANT);
- icalproperty_add_parameter (prop, param);
-
- param = icalparameter_new_cutype (ICAL_CUTYPE_INDIVIDUAL);
- icalproperty_add_parameter (prop, param);
-
- param = icalparameter_new_rsvp (ICAL_RSVP_TRUE);
- icalproperty_add_parameter (prop, param);
-
- g_free (temp);
- }
-
- g_free (address);
- g_object_unref (comp);
-}
-
-static void
-on_delegate (EPopup *ep, EPopupItem *pitem, gpointer data)
-{
- ECalendarView *cal_view = data;
- GList *selected;
- guint32 flags = 0;
- icalcomponent *clone;
-
- selected = e_calendar_view_get_selected_events (cal_view);
- if (selected) {
- ECalendarViewEvent *event = (ECalendarViewEvent *) selected->data;
-
- clone = icalcomponent_new_clone (event->comp_data->icalcomp);
- set_attendee_status_for_delegate (clone, event->comp_data->client);
-
- flags |= COMP_EDITOR_MEETING | COMP_EDITOR_DELEGATE;
-
- e_calendar_view_open_event_with_flags (cal_view, event->comp_data->client, clone, flags);
-
- icalcomponent_free (clone);
- g_list_free (selected);
- }
-}
-
-static void
-on_forward (EPopup *ep, EPopupItem *pitem, gpointer data)
-{
- ECalendarView *cal_view = data;
- GList *selected;
-
- selected = e_calendar_view_get_selected_events (cal_view);
- if (selected) {
- ECalComponent *comp;
- ECalendarViewEvent *event = (ECalendarViewEvent *) selected->data;
-
- comp = e_cal_component_new ();
- e_cal_component_set_icalcomponent (comp, icalcomponent_new_clone (event->comp_data->icalcomp));
- itip_send_comp (E_CAL_COMPONENT_METHOD_PUBLISH, comp, event->comp_data->client, NULL, NULL, NULL, TRUE, FALSE);
-
- g_list_free (selected);
- g_object_unref (comp);
- }
-}
-
-static void
-on_reply (EPopup *ep, EPopupItem *pitem, gpointer data)
-{
- ECalendarView *cal_view = data;
- GList *selected;
- gboolean reply_all = FALSE;
-
- selected = e_calendar_view_get_selected_events (cal_view);
- if (selected) {
- ECalComponent *comp;
- ECalendarViewEvent *event = (ECalendarViewEvent *) selected->data;
-
- comp = e_cal_component_new ();
- e_cal_component_set_icalcomponent (comp, icalcomponent_new_clone (event->comp_data->icalcomp));
- reply_to_calendar_comp (E_CAL_COMPONENT_METHOD_REPLY, comp, event->comp_data->client, reply_all, NULL, NULL);
-
- g_list_free (selected);
- g_object_unref (comp);
- }
-}
-
-static void
-on_reply_all (EPopup *ep, EPopupItem *pitem, gpointer data)
-{
- ECalendarView *cal_view = data;
- GList *selected;
- gboolean reply_all = TRUE;
-
- selected = e_calendar_view_get_selected_events (cal_view);
- if (selected) {
- ECalComponent *comp;
- ECalendarViewEvent *event = (ECalendarViewEvent *) selected->data;
-
- comp = e_cal_component_new ();
- e_cal_component_set_icalcomponent (comp, icalcomponent_new_clone (event->comp_data->icalcomp));
- reply_to_calendar_comp (E_CAL_COMPONENT_METHOD_REPLY, comp, event->comp_data->client, reply_all, NULL, NULL);
-
- g_list_free (selected);
- g_object_unref (comp);
- }
-}
-
-static void
-on_delete_appointment (EPopup *ep, EPopupItem *pitem, gpointer data)
-{
- ECalendarView *cal_view = data;
-
- e_calendar_view_delete_selected_event (cal_view);
-}
-
-static void
-on_unrecur_appointment (EPopup *ep, EPopupItem *pitem, gpointer data)
-{
- ECalendarView *cal_view = data;
- ECalendarViewEvent *event;
- ECalComponent *comp, *new_comp;
- ECalComponentDateTime date;
- struct icaltimetype itt;
- GList *selected;
- ECal *client;
- gchar *new_uid;
- ECalComponentId *id = NULL;
-
- selected = e_calendar_view_get_selected_events (cal_view);
- if (!selected)
- return;
-
- event = (ECalendarViewEvent *) selected->data;
- client = g_object_ref (event->comp_data->client);
-
- date.value = &itt;
- date.tzid = NULL;
-
- /* For the recurring object, we add an exception to get rid of the
- instance. */
-
- comp = e_cal_component_new ();
- e_cal_component_set_icalcomponent (comp, icalcomponent_new_clone (event->comp_data->icalcomp));
- id = e_cal_component_get_id (comp);
-
- /* For the unrecurred instance we duplicate the original object,
- create a new uid for it, get rid of the recurrence rules, and set
- the start & end times to the instances times. */
- new_comp = e_cal_component_new ();
- e_cal_component_set_icalcomponent (new_comp, icalcomponent_new_clone (event->comp_data->icalcomp));
-
- new_uid = e_cal_component_gen_uid ();
- e_cal_component_set_uid (new_comp, new_uid);
- g_free (new_uid);
- e_cal_component_set_recurid (new_comp, NULL);
- e_cal_component_set_rdate_list (new_comp, NULL);
- e_cal_component_set_rrule_list (new_comp, NULL);
- e_cal_component_set_exdate_list (new_comp, NULL);
- e_cal_component_set_exrule_list (new_comp, NULL);
-
- date.value = &itt;
- date.tzid = icaltimezone_get_tzid (e_calendar_view_get_timezone (cal_view));
-
- *date.value = icaltime_from_timet_with_zone (event->comp_data->instance_start, FALSE,
- e_calendar_view_get_timezone (cal_view));
- cal_comp_set_dtstart_with_oldzone (client, new_comp, &date);
- *date.value = icaltime_from_timet_with_zone (event->comp_data->instance_end, FALSE,
- e_calendar_view_get_timezone (cal_view));
- cal_comp_set_dtend_with_oldzone (client, new_comp, &date);
- e_cal_component_commit_sequence (new_comp);
-
- /* Now update both ECalComponents. Note that we do this last since at
- * present the updates happen synchronously so our event may disappear.
- */
-
- if (!e_cal_remove_object_with_mod (client, id->uid, id->rid, CALOBJ_MOD_THIS,
- NULL))
- g_message ("on_unrecur_appointment(): Could not remove the old object!");
-
- e_cal_component_free_id (id);
- g_object_unref (comp);
-
- if (!e_cal_create_object (client, e_cal_component_get_icalcomponent (new_comp), &new_uid, NULL))
- g_message ("on_unrecur_appointment(): Could not update the object!");
- else
- g_free (new_uid);
-
- g_object_unref (new_comp);
- g_object_unref (client);
- g_list_free (selected);
-}
-
-static void
-on_delete_occurrence (EPopup *ep, EPopupItem *pitem, gpointer data)
-{
- ECalendarView *cal_view = data;
-
- e_calendar_view_delete_selected_occurrence (cal_view);
-}
-
-static void
-on_cut (EPopup *ep, EPopupItem *pitem, gpointer data)
-{
- ECalendarView *cal_view = data;
-
- e_calendar_view_cut_clipboard (cal_view);
-}
-
-static void
-on_copy (EPopup *ep, EPopupItem *pitem, gpointer data)
-{
- ECalendarView *cal_view = data;
-
- e_calendar_view_copy_clipboard (cal_view);
-}
-
-static void
-on_paste (EPopup *ep, EPopupItem *pitem, gpointer data)
-{
- ECalendarView *cal_view = data;
-
- e_calendar_view_paste_clipboard (cal_view);
-}
-
-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."},
- { E_POPUP_ITEM, (gchar *) "40.print", (gchar *) N_("P_rint..."), on_print, NULL, (gchar *) GTK_STOCK_PRINT, 0, 0 },
-
- { E_POPUP_BAR, (gchar *) "50." },
- { E_POPUP_ITEM, (gchar *) "50.paste", (gchar *) N_("_Paste"), on_paste, NULL, (gchar *) GTK_STOCK_PASTE, 0, E_CAL_POPUP_SELECT_EDITABLE },
-
- { 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." },
-
- { E_POPUP_ITEM, (gchar *) "31.cut", (gchar *) N_("C_ut"), on_cut, NULL, (gchar *) GTK_STOCK_CUT, 0, E_CAL_POPUP_SELECT_NOTEDITING|E_CAL_POPUP_SELECT_EDITABLE|E_CAL_POPUP_SELECT_ORGANIZER },
- { E_POPUP_ITEM, (gchar *) "32.copy", (gchar *) N_("_Copy"), on_copy, NULL, (gchar *) GTK_STOCK_COPY, 0, E_CAL_POPUP_SELECT_NOTEDITING|E_CAL_POPUP_SELECT_ORGANIZER },
- { E_POPUP_ITEM, (gchar *) "33.paste", (gchar *) N_("_Paste"), on_paste, NULL, (gchar *) GTK_STOCK_PASTE, 0, E_CAL_POPUP_SELECT_EDITABLE },
-
- { E_POPUP_BAR, (gchar *) "40." },
-
- { E_POPUP_ITEM, (gchar *) "43.copyto", (gchar *) N_("Cop_y to Calendar..."), on_copy_to, NULL, NULL, 0, E_CAL_POPUP_SELECT_NOTEDITING },
- { E_POPUP_ITEM, (gchar *) "44.moveto", (gchar *) N_("Mo_ve to Calendar..."), on_move_to, NULL, NULL, 0, E_CAL_POPUP_SELECT_NOTEDITING | E_CAL_POPUP_SELECT_EDITABLE },
- { E_POPUP_ITEM, (gchar *) "45.delegate", (gchar *) N_("_Delegate Meeting..."), on_delegate, NULL, NULL, 0, E_CAL_POPUP_SELECT_NOTEDITING | E_CAL_POPUP_SELECT_EDITABLE | E_CAL_POPUP_SELECT_DELEGATABLE | E_CAL_POPUP_SELECT_MEETING},
- { E_POPUP_ITEM, (gchar *) "46.schedule", (gchar *) N_("_Schedule Meeting..."), on_meeting, NULL, NULL, 0, E_CAL_POPUP_SELECT_NOTEDITING | E_CAL_POPUP_SELECT_EDITABLE | E_CAL_POPUP_SELECT_NOTMEETING },
- { E_POPUP_ITEM, (gchar *) "47.forward", (gchar *) N_("_Forward as iCalendar..."), on_forward, NULL, (gchar *) "mail-forward", 0, E_CAL_POPUP_SELECT_NOTEDITING },
- { E_POPUP_ITEM, (gchar *) "48.reply", (gchar *) N_("_Reply"), on_reply, NULL, (gchar *) "mail-reply-sender", E_CAL_POPUP_SELECT_MEETING | E_CAL_POPUP_SELECT_NOTEDITING },
- { E_POPUP_ITEM, (gchar *) "49.reply-all", (gchar *) N_("Reply to _All"), on_reply_all, NULL, (gchar *) "mail-reply-all", E_CAL_POPUP_SELECT_MEETING, E_CAL_POPUP_SELECT_NOTEDITING },
-
- { E_POPUP_BAR, (gchar *) "50." },
-
- { E_POPUP_ITEM, (gchar *) "51.delete", (gchar *) N_("_Delete"), on_delete_appointment, NULL, (gchar *) GTK_STOCK_DELETE, E_CAL_POPUP_SELECT_NONRECURRING, E_CAL_POPUP_SELECT_NOTEDITING | E_CAL_POPUP_SELECT_EDITABLE },
- { E_POPUP_ITEM, (gchar *) "52.move", (gchar *) N_("Make this Occurrence _Movable"), on_unrecur_appointment, NULL, NULL, E_CAL_POPUP_SELECT_RECURRING | E_CAL_POPUP_SELECT_INSTANCE, E_CAL_POPUP_SELECT_NOTEDITING | E_CAL_POPUP_SELECT_EDITABLE },
- { E_POPUP_ITEM, (gchar *) "53.delete", (gchar *) N_("Delete this _Occurrence"), on_delete_occurrence, NULL, (gchar *) GTK_STOCK_DELETE, E_CAL_POPUP_SELECT_RECURRING, E_CAL_POPUP_SELECT_NOTEDITING | E_CAL_POPUP_SELECT_EDITABLE },
- { 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)
{
@@ -2092,7 +1400,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 *
@@ -2101,12 +1409,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);
@@ -2116,8 +1428,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);
}
@@ -2601,6 +1911,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)
@@ -2650,36 +1968,6 @@ draw_curved_rectangle (cairo_t *cr, double x0, double y0,
cairo_close_path (cr);
}
-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);
-}
-
/* returns either light or dark yellow, based on the base_background,
which is the default background color */
GdkColor
diff --git a/calendar/gui/e-calendar-view.h b/calendar/gui/e-calendar-view.h
index ae0703addd..5af1d77801 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 <misc/e-activity-handler.h>
#include "dialogs/comp-editor.h"
-G_BEGIN_DECLS
-
-/*
- * EView - base widget class for the calendar views.
- */
+/* 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))
-#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;
};
@@ -100,6 +108,7 @@ struct _ECalendarViewClass {
GtkTableClass parent_class;
/* Notification signals */
+ void (* popup_event) (ECalendarView *cal_view, GdkEventButton *event);
void (* selection_changed) (ECalendarView *cal_view);
void (* selected_time_changed) (ECalendarView *cal_view);
void (* timezone_changed) (ECalendarView *cal_view, icaltimezone *old_zone, icaltimezone *new_zone);
@@ -122,15 +131,10 @@ GType e_calendar_view_get_type (void);
GnomeCalendar *e_calendar_view_get_calendar (ECalendarView *cal_view);
void e_calendar_view_set_calendar (ECalendarView *cal_view, GnomeCalendar *calendar);
ECalModel *e_calendar_view_get_model (ECalendarView *cal_view);
-void e_calendar_view_set_model (ECalendarView *cal_view, ECalModel *model);
icaltimezone *e_calendar_view_get_timezone (ECalendarView *cal_view);
void e_calendar_view_set_timezone (ECalendarView *cal_view, icaltimezone *zone);
const gchar *e_calendar_view_get_default_category (ECalendarView *cal_view);
void e_calendar_view_set_default_category (ECalendarView *cal_view, const gchar *category);
-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);
@@ -147,7 +151,8 @@ void e_calendar_view_delete_selected_events (ECalendarView *cal_view);
void e_calendar_view_delete_selected_occurrence (ECalendarView *cal_view);
CompEditor* e_calendar_view_open_event_with_flags (ECalendarView *cal_view, ECal *client, icalcomponent *icalcomp, guint32 flags);
-GtkMenu *e_calendar_view_create_popup_menu (ECalendarView *cal_view);
+void e_calendar_view_popup_event (ECalendarView *cal_view,
+ GdkEventButton *event);
void e_calendar_view_add_event (ECalendarView *cal_view, ECal *client, time_t dtstart,
icaltimezone *default_zone, icalcomponent *icalcomp, gboolean in_top_canvas);
@@ -181,6 +186,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 +200,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.c b/calendar/gui/e-cell-date-edit-config.c
deleted file mode 100644
index 5b04791412..0000000000
--- a/calendar/gui/e-cell-date-edit-config.c
+++ /dev/null
@@ -1,321 +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:
- * JP Rosevear <jpr@ximian.com>
- *
- * Copyright (C) 1999-2008 Novell, Inc. (www.novell.com)
- *
- */
-
-#include "calendar-config.h"
-#include "e-mini-calendar-config.h"
-#include "e-cell-date-edit-config.h"
-
-struct _ECellDateEditConfigPrivate {
- ECellDateEdit *cell;
-
- EMiniCalendarConfig *mini_config;
-
- GList *notifications;
-};
-
-/* Property IDs */
-enum props {
- PROP_0,
- PROP_CELL
-};
-
-G_DEFINE_TYPE (ECellDateEditConfig, e_cell_date_edit_config, G_TYPE_OBJECT)
-
-static void
-e_cell_date_edit_config_set_property (GObject *object, guint property_id, const GValue *value, GParamSpec *pspec)
-{
- ECellDateEditConfig *view_config;
-
- view_config = E_CELL_DATE_EDIT_CONFIG (object);
-
- switch (property_id) {
- case PROP_CELL:
- e_cell_date_edit_config_set_cell (view_config, g_value_get_object (value));
- break;
- default:
- G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
- break;
- }
-}
-
-static void
-e_cell_date_edit_config_get_property (GObject *object, guint property_id, GValue *value, GParamSpec *pspec)
-{
- ECellDateEditConfig *view_config;
-
- view_config = E_CELL_DATE_EDIT_CONFIG (object);
-
- switch (property_id) {
- case PROP_CELL:
- g_value_set_object (value, e_cell_date_edit_config_get_cell (view_config));
- break;
- default:
- G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
- break;
- }
-}
-
-static void
-e_cell_date_edit_config_dispose (GObject *object)
-{
- ECellDateEditConfig *view_config = E_CELL_DATE_EDIT_CONFIG (object);
-
- e_cell_date_edit_config_set_cell (view_config, NULL);
-
- if (G_OBJECT_CLASS (e_cell_date_edit_config_parent_class)->dispose)
- G_OBJECT_CLASS (e_cell_date_edit_config_parent_class)->dispose (object);
-}
-
-static void
-e_cell_date_edit_config_finalize (GObject *object)
-{
- ECellDateEditConfig *view_config = E_CELL_DATE_EDIT_CONFIG (object);
- ECellDateEditConfigPrivate *priv;
-
- priv = view_config->priv;
-
- g_free (priv);
-
- if (G_OBJECT_CLASS (e_cell_date_edit_config_parent_class)->finalize)
- G_OBJECT_CLASS (e_cell_date_edit_config_parent_class)->finalize (object);
-}
-
-static void
-e_cell_date_edit_config_class_init (ECellDateEditConfigClass *klass)
-{
- GObjectClass *gobject_class = G_OBJECT_CLASS (klass);
- GParamSpec *spec;
-
- /* Method override */
- gobject_class->set_property = e_cell_date_edit_config_set_property;
- gobject_class->get_property = e_cell_date_edit_config_get_property;
- gobject_class->dispose = e_cell_date_edit_config_dispose;
- gobject_class->finalize = e_cell_date_edit_config_finalize;
-
- spec = g_param_spec_object ("cell", NULL, NULL, e_cell_date_edit_get_type (),
- G_PARAM_READABLE | G_PARAM_WRITABLE | G_PARAM_CONSTRUCT);
- g_object_class_install_property (gobject_class, PROP_CELL, spec);
-}
-
-static void
-e_cell_date_edit_config_init (ECellDateEditConfig *view_config)
-{
- view_config->priv = g_new0 (ECellDateEditConfigPrivate, 1);
-
-}
-
-ECellDateEditConfig *
-e_cell_date_edit_config_new (ECellDateEdit *cell)
-{
- ECellDateEditConfig *view_config;
-
- view_config = g_object_new (e_cell_date_edit_config_get_type (), "cell", cell, NULL);
-
- return view_config;
-}
-
-ECellDateEdit *
-e_cell_date_edit_config_get_cell (ECellDateEditConfig *view_config)
-{
- ECellDateEditConfigPrivate *priv;
-
- g_return_val_if_fail (view_config != NULL, NULL);
- g_return_val_if_fail (E_IS_CELL_DATE_EDIT_CONFIG (view_config), NULL);
-
- priv = view_config->priv;
-
- return priv->cell;
-}
-
-static void
-set_timezone (ECellDateEdit *cell)
-{
- ECellDateEditText *cell_text;
- ECellPopup *cell_popup;
- icaltimezone *zone;
-
- zone = calendar_config_get_icaltimezone ();
-
- cell_popup = E_CELL_POPUP (cell);
- cell_text = E_CELL_DATE_EDIT_TEXT (cell_popup->child);
- e_cell_date_edit_text_set_timezone (cell_text, zone);
-}
-
-static void
-timezone_changed_cb (GConfClient *client, guint id, GConfEntry *entry, gpointer data)
-{
- ECellDateEditConfig *view_config = data;
- ECellDateEditConfigPrivate *priv;
-
- priv = view_config->priv;
-
- set_timezone (priv->cell);
-}
-
-static void
-set_twentyfour_hour (ECellDateEdit *cell)
-{
- ECellDateEditText *cell_text;
- ECellPopup *cell_popup;
- gboolean use_24_hour;
-
- use_24_hour = calendar_config_get_24_hour_format ();
-
- e_cell_date_edit_freeze (cell);
- g_object_set (G_OBJECT (cell),
- "use_24_hour_format", use_24_hour,
- NULL);
- e_cell_date_edit_thaw (cell);
-
- cell_popup = E_CELL_POPUP (cell);
- cell_text = E_CELL_DATE_EDIT_TEXT (cell_popup->child);
- e_cell_date_edit_text_set_use_24_hour_format (cell_text, use_24_hour);
-}
-
-static void
-twentyfour_hour_changed_cb (GConfClient *client, guint id, GConfEntry *entry, gpointer data)
-{
- ECellDateEditConfig *view_config = data;
- ECellDateEditConfigPrivate *priv;
-
- priv = view_config->priv;
-
- set_twentyfour_hour (priv->cell);
-}
-
-static void
-set_range (ECellDateEdit *cell)
-{
- gint start_hour, end_hour;
-
- start_hour = calendar_config_get_day_start_hour ();
- end_hour = calendar_config_get_day_end_hour ();
-
- /* Round up the end hour. */
- if (calendar_config_get_day_end_minute () != 0)
- end_hour++;
-
- /* Make sure the start hour is ok */
- if (start_hour > end_hour)
- start_hour = end_hour;
-
- /* We use the default 0 - 24 now. */
-#if 0
- g_object_set (G_OBJECT (cell),
- "lower_hour", start_hour,
- "upper_hour", end_hour,
- NULL);
-#endif
-}
-
-static void
-day_start_hour_changed_cb (GConfClient *client, guint id, GConfEntry *entry, gpointer data)
-{
- ECellDateEditConfig *view_config = data;
- ECellDateEditConfigPrivate *priv;
-
- priv = view_config->priv;
-
- set_range (priv->cell);
-}
-
-static void
-day_end_hour_changed_cb (GConfClient *client, guint id, GConfEntry *entry, gpointer data)
-{
- ECellDateEditConfig *view_config = data;
- ECellDateEditConfigPrivate *priv;
-
- priv = view_config->priv;
-
- set_range (priv->cell);
-}
-
-static void
-day_end_minute_changed_cb (GConfClient *client, guint id, GConfEntry *entry, gpointer data)
-{
- ECellDateEditConfig *view_config = data;
- ECellDateEditConfigPrivate *priv;
-
- priv = view_config->priv;
-
- set_range (priv->cell);
-}
-
-void
-e_cell_date_edit_config_set_cell (ECellDateEditConfig *view_config, ECellDateEdit *cell)
-{
- ECellDateEditConfigPrivate *priv;
- guint not;
- GList *l;
-
- g_return_if_fail (view_config != NULL);
- g_return_if_fail (E_IS_CELL_DATE_EDIT_CONFIG (view_config));
-
- priv = view_config->priv;
-
- if (priv->cell) {
- g_object_unref (priv->cell);
- priv->cell = NULL;
- }
-
- if (priv->mini_config) {
- g_object_unref (priv->mini_config);
- priv->mini_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;
-
- /* If the new view is NULL, return right now */
- if (!cell)
- return;
-
- priv->cell = g_object_ref (cell);
-
- /* Time zone */
- set_timezone (cell);
-
- not = calendar_config_add_notification_timezone (timezone_changed_cb, view_config);
- priv->notifications = g_list_prepend (priv->notifications, GUINT_TO_POINTER (not));
-
- /* 24 Hour format */
- set_twentyfour_hour (cell);
-
- not = calendar_config_add_notification_24_hour_format (twentyfour_hour_changed_cb, view_config);
- priv->notifications = g_list_prepend (priv->notifications, GUINT_TO_POINTER (not));
-
- /* Popup time range */
- set_range (cell);
-
- not = calendar_config_add_notification_day_start_hour (day_start_hour_changed_cb, view_config);
- priv->notifications = g_list_prepend (priv->notifications, GUINT_TO_POINTER (not));
- not = calendar_config_add_notification_day_end_hour (day_end_hour_changed_cb, view_config);
- priv->notifications = g_list_prepend (priv->notifications, GUINT_TO_POINTER (not));
- not = calendar_config_add_notification_day_end_minute (day_end_minute_changed_cb, view_config);
- priv->notifications = g_list_prepend (priv->notifications, GUINT_TO_POINTER (not));
-
- /* The mini calendar */
- priv->mini_config = e_mini_calendar_config_new (E_CALENDAR (cell->calendar));
-}
diff --git a/calendar/gui/e-cell-date-edit-config.h b/calendar/gui/e-cell-date-edit-config.h
deleted file mode 100644
index 455cca7287..0000000000
--- a/calendar/gui/e-cell-date-edit-config.h
+++ /dev/null
@@ -1,57 +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:
- * JP Rosevear <jpr@ximian.com>
- *
- * Copyright (C) 1999-2008 Novell, Inc. (www.novell.com)
- *
- */
-
-#ifndef _E_CELL_DATE_EDIT_CONFIG_H_
-#define _E_CELL_DATE_EDIT_CONFIG_H_
-
-#include <misc/e-cell-date-edit.h>
-#include "e-cell-date-edit-text.h"
-
-G_BEGIN_DECLS
-
-#define E_CELL_DATE_EDIT_CONFIG(obj) G_TYPE_CHECK_INSTANCE_CAST (obj, e_cell_date_edit_config_get_type (), ECellDateEditConfig)
-#define E_CELL_DATE_EDIT_CONFIG_CLASS(klass) G_TYPE_CHECK_CLASS_CAST (klass, e_cell_date_edit_config_get_type (), ECellDateEditConfigClass)
-#define E_IS_CELL_DATE_EDIT_CONFIG(obj) G_TYPE_CHECK_INSTANCE_TYPE (obj, e_cell_date_edit_config_get_type ())
-
-typedef struct _ECellDateEditConfig ECellDateEditConfig;
-typedef struct _ECellDateEditConfigClass ECellDateEditConfigClass;
-typedef struct _ECellDateEditConfigPrivate ECellDateEditConfigPrivate;
-
-struct _ECellDateEditConfig {
- GObject parent;
-
- ECellDateEditConfigPrivate *priv;
-};
-
-struct _ECellDateEditConfigClass {
- GObjectClass parent_class;
-};
-
-GType e_cell_date_edit_config_get_type (void);
-ECellDateEditConfig *e_cell_date_edit_config_new (ECellDateEdit *cell);
-ECellDateEdit *e_cell_date_edit_config_get_cell (ECellDateEditConfig *cell_config);
-void e_cell_date_edit_config_set_cell (ECellDateEditConfig *view_config, ECellDateEdit *cell);
-
-G_END_DECLS
-
-#endif
diff --git a/calendar/gui/e-cell-date-edit-text.c b/calendar/gui/e-cell-date-edit-text.c
index 5836b8ac66..97dee085ea 100644
--- a/calendar/gui/e-cell-date-edit-text.c
+++ b/calendar/gui/e-cell-date-edit-text.c
@@ -38,47 +38,107 @@
#include "e-cell-date-edit-text.h"
-G_DEFINE_TYPE (ECellDateEditText, e_cell_date_edit_text, E_CELL_TEXT_TYPE)
+#define E_CELL_DATE_EDIT_TEXT_GET_PRIVATE(obj) \
+ (G_TYPE_INSTANCE_GET_PRIVATE \
+ ((obj), E_TYPE_CELL_DATE_EDIT_TEXT, ECellDateEditTextPrivate))
-void
-e_cell_date_edit_text_set_timezone (ECellDateEditText *ecd,
- icaltimezone *zone)
+struct _ECellDateEditTextPrivate {
+
+ /* The timezone to display the date in. */
+ icaltimezone *timezone;
+
+ /* Whether to display in 24-hour format. */
+ gboolean use_24_hour_format;
+};
+
+enum {
+ PROP_0,
+ PROP_TIMEZONE,
+ PROP_USE_24_HOUR_FORMAT
+};
+
+static gpointer parent_class;
+
+static void
+cell_date_edit_text_set_property (GObject *object,
+ guint property_id,
+ const GValue *value,
+ GParamSpec *pspec)
{
- g_return_if_fail (E_IS_CELL_DATE_EDIT_TEXT (ecd));
+ switch (property_id) {
+ case PROP_TIMEZONE:
+ e_cell_date_edit_text_set_timezone (
+ E_CELL_DATE_EDIT_TEXT (object),
+ g_value_get_pointer (value));
+ return;
- ecd->zone = zone;
+ case PROP_USE_24_HOUR_FORMAT:
+ e_cell_date_edit_text_set_use_24_hour_format (
+ E_CELL_DATE_EDIT_TEXT (object),
+ g_value_get_boolean (value));
+ return;
+ }
+
+ G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
}
-void
-e_cell_date_edit_text_set_use_24_hour_format (ECellDateEditText *ecd,
- gboolean use_24_hour)
+static void
+cell_date_edit_text_get_property (GObject *object,
+ guint property_id,
+ GValue *value,
+ GParamSpec *pspec)
{
- g_return_if_fail (E_IS_CELL_DATE_EDIT_TEXT (ecd));
+ switch (property_id) {
+ case PROP_TIMEZONE:
+ g_value_set_pointer (
+ value,
+ e_cell_date_edit_text_get_timezone (
+ E_CELL_DATE_EDIT_TEXT (object)));
+ return;
+
+ case PROP_USE_24_HOUR_FORMAT:
+ g_value_set_boolean (
+ value,
+ e_cell_date_edit_text_get_use_24_hour_format (
+ E_CELL_DATE_EDIT_TEXT (object)));
+ return;
+ }
- ecd->use_24_hour_format = use_24_hour;
+ G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
}
static gchar *
-ecd_get_text (ECellText *cell, ETableModel *model, gint col, gint row)
+cell_date_edit_text_get_text (ECellText *cell,
+ ETableModel *model,
+ gint col,
+ gint row)
{
ECellDateEditText *ecd = E_CELL_DATE_EDIT_TEXT (cell);
ECellDateEditValue *dv = e_table_model_value_at (model, col, row);
+ gboolean use_24_hour_format;
+ icaltimezone *timezone;
struct tm tmp_tm;
if (!dv)
return g_strdup ("");
+ timezone = e_cell_date_edit_text_get_timezone (ecd);
+ use_24_hour_format = e_cell_date_edit_text_get_use_24_hour_format (ecd);
+
/* Note that although the property may be in a different
timezone, we convert it to the current timezone to display
it in the table. If the user actually edits the value,
it will be set to the current timezone. See set_value(). */
- tmp_tm = icaltimetype_to_tm_with_zone (&dv->tt, dv->zone, ecd->zone);
+ tmp_tm = icaltimetype_to_tm_with_zone (&dv->tt, dv->zone, timezone);
- return e_datetime_format_format_tm ("calendar", "table", dv->tt.is_date ? DTFormatKindDate : DTFormatKindDateTime, &tmp_tm);
+ return e_datetime_format_format_tm (
+ "calendar", "table", dv->tt.is_date ?
+ DTFormatKindDate : DTFormatKindDateTime, &tmp_tm);
}
static void
-ecd_free_text (ECellText *cell, gchar *text)
+cell_date_edit_text_free_text (ECellText *cell,
+ gchar *text)
{
g_free (text);
}
@@ -97,7 +157,7 @@ show_date_warning (ECellDateEditText *ecd)
matter. */
tmp_tm = localtime (&t);
- if (ecd->use_24_hour_format)
+ if (e_cell_date_edit_text_get_use_24_hour_format (ecd))
/* strftime format of a weekday, a date and a time, 24-hour. */
format = _("%a %m/%d/%Y %H:%M:%S");
else
@@ -117,8 +177,11 @@ show_date_warning (ECellDateEditText *ecd)
}
static void
-ecd_set_value (ECellText *cell, ETableModel *model, gint col, gint row,
- const gchar *text)
+cell_date_edit_text_set_value (ECellText *cell,
+ ETableModel *model,
+ gint col,
+ gint row,
+ const gchar *text)
{
ECellDateEditText *ecd = E_CELL_DATE_EDIT_TEXT (cell);
ETimeParseStatus status;
@@ -159,7 +222,7 @@ ecd_set_value (ECellText *cell, ETableModel *model, gint col, gint row,
if (is_date) {
dv.zone = NULL;
} else {
- dv.zone = ecd->zone;
+ dv.zone = e_cell_date_edit_text_get_timezone (ecd);
}
value = &dv;
@@ -169,20 +232,76 @@ ecd_set_value (ECellText *cell, ETableModel *model, gint col, gint row,
}
static void
-e_cell_date_edit_text_class_init (ECellDateEditTextClass *ecdet)
+cell_date_edit_text_class_init (ECellDateEditTextClass *class)
{
- ECellTextClass *ectc = E_CELL_TEXT_CLASS (ecdet);
-
- ectc->get_text = ecd_get_text;
- ectc->free_text = ecd_free_text;
- ectc->set_value = ecd_set_value;
+ GObjectClass *object_class;
+ ECellTextClass *cell_text_class;
+
+ parent_class = g_type_class_peek_parent (class);
+ g_type_class_add_private (class, sizeof (ECellDateEditTextPrivate));
+
+ object_class = G_OBJECT_CLASS (class);
+ object_class->set_property = cell_date_edit_text_set_property;
+ object_class->get_property = cell_date_edit_text_get_property;
+
+ cell_text_class = E_CELL_TEXT_CLASS (class);
+ cell_text_class->get_text = cell_date_edit_text_get_text;
+ cell_text_class->free_text = cell_date_edit_text_free_text;
+ cell_text_class->set_value = cell_date_edit_text_set_value;
+
+ g_object_class_install_property (
+ object_class,
+ PROP_TIMEZONE,
+ g_param_spec_pointer (
+ "timezone",
+ "Time Zone",
+ NULL,
+ G_PARAM_READWRITE));
+
+ g_object_class_install_property (
+ object_class,
+ PROP_USE_24_HOUR_FORMAT,
+ g_param_spec_boolean (
+ "use-24-hour-format",
+ "Use 24-Hour Format",
+ NULL,
+ TRUE,
+ G_PARAM_READWRITE));
}
static void
-e_cell_date_edit_text_init (ECellDateEditText *ecd)
+cell_date_edit_text_init (ECellDateEditText *ecd)
{
- ecd->zone = icaltimezone_get_utc_timezone ();
- ecd->use_24_hour_format = TRUE;
+ ecd->priv = E_CELL_DATE_EDIT_TEXT_GET_PRIVATE (ecd);
+
+ ecd->priv->timezone = icaltimezone_get_utc_timezone ();
+ ecd->priv->use_24_hour_format = TRUE;
+}
+
+GType
+e_cell_date_edit_text_get_type (void)
+{
+ static GType type = 0;
+
+ if (G_UNLIKELY (type == 0)) {
+ const GTypeInfo type_info = {
+ sizeof (ECellDateEditTextClass),
+ (GBaseInitFunc) NULL,
+ (GBaseFinalizeFunc) NULL,
+ (GClassInitFunc) cell_date_edit_text_class_init,
+ (GClassFinalizeFunc) NULL,
+ NULL, /* class_data */
+ sizeof (ECellDateEditText),
+ 0, /* n_preallocs */
+ (GInstanceInitFunc) cell_date_edit_text_init,
+ NULL /* value_table */
+ };
+
+ type = g_type_register_static (
+ E_CELL_TEXT_TYPE, "ECellDateEditText", &type_info, 0);
+ }
+
+ return type;
}
/**
@@ -198,10 +317,49 @@ ECell *
e_cell_date_edit_text_new (const gchar *fontname,
GtkJustification justify)
{
- ECellDateEditText *ecd = g_object_new (e_cell_date_edit_text_get_type (), NULL);
+ ECell *cell;
+
+ cell = g_object_new (E_TYPE_CELL_DATE_EDIT_TEXT, NULL);
+ e_cell_text_construct (E_CELL_TEXT (cell), fontname, justify);
+
+ return cell;
+}
+
+icaltimezone *
+e_cell_date_edit_text_get_timezone (ECellDateEditText *ecd)
+{
+ g_return_val_if_fail (E_IS_CELL_DATE_EDIT_TEXT (ecd), NULL);
+
+ return ecd->priv->timezone;
+}
+
+void
+e_cell_date_edit_text_set_timezone (ECellDateEditText *ecd,
+ icaltimezone *timezone)
+{
+ g_return_if_fail (E_IS_CELL_DATE_EDIT_TEXT (ecd));
+
+ ecd->priv->timezone = timezone;
+
+ g_object_notify (G_OBJECT (ecd), "timezone");
+}
+
+gboolean
+e_cell_date_edit_text_get_use_24_hour_format (ECellDateEditText *ecd)
+{
+ g_return_val_if_fail (E_IS_CELL_DATE_EDIT_TEXT (ecd), FALSE);
+
+ return ecd->priv->use_24_hour_format;
+}
+
+void
+e_cell_date_edit_text_set_use_24_hour_format (ECellDateEditText *ecd,
+ gboolean use_24_hour)
+{
+ g_return_if_fail (E_IS_CELL_DATE_EDIT_TEXT (ecd));
- e_cell_text_construct (E_CELL_TEXT (ecd), fontname, justify);
+ ecd->priv->use_24_hour_format = use_24_hour;
- return (ECell *) ecd;
+ g_object_notify (G_OBJECT (ecd), "use-24-hour-format");
}
diff --git a/calendar/gui/e-cell-date-edit-text.h b/calendar/gui/e-cell-date-edit-text.h
index 5dc1f0c4bd..a49b68d36b 100644
--- a/calendar/gui/e-cell-date-edit-text.h
+++ b/calendar/gui/e-cell-date-edit-text.h
@@ -27,42 +27,60 @@
#include <libical/ical.h>
#include <table/e-cell-text.h>
-G_BEGIN_DECLS
+/* Standard GObject macros */
+#define E_TYPE_CELL_DATE_EDIT_TEXT \
+ (e_cell_date_edit_text_get_type ())
+#define E_CELL_DATE_EDIT_TEXT(obj) \
+ (G_TYPE_CHECK_INSTANCE_CAST \
+ ((obj), E_TYPE_CELL_DATE_EDIT_TEXT, ECellDateEditText))
+#define E_CELL_DATE_EDIT_TEXT_CLASS(cls) \
+ (G_TYPE_CHECK_CLASS_CAST \
+ ((cls), E_TYPE_CELL_DATE_EDIT_TEXT, ECellDateEditTextClass))
+#define E_IS_CELL_DATE_EDIT_TEXT(obj) \
+ (G_TYPE_CHECK_INSTANCE_TYPE \
+ ((obj), E_TYPE_CELL_DATE_EDIT_TEXT))
+#define E_IS_CELL_DATE_EDIT_TEXT_CLASS(cls) \
+ (G_TYPE_CHECK_CLASS_TYPE \
+ ((cls), E_TYPE_CELL_DATE_EDIT_TEXT))
+#define E_CELL_DATE_EDIT_TEXT_GET_CLASS(obj) \
+ (G_TYPE_INSTANCE_GET_CLASS \
+ ((obj), E_TYPE_CELL_DATE_EDIT_TEXT, ECellDateEditTextClass))
-#define E_CELL_DATE_EDIT_TEXT_TYPE (e_cell_date_edit_text_get_type ())
-#define E_CELL_DATE_EDIT_TEXT(o) (G_TYPE_CHECK_INSTANCE_CAST ((o), E_CELL_DATE_EDIT_TEXT_TYPE, ECellDateEditText))
-#define E_CELL_DATE_EDIT_TEXT_CLASS(k) (G_TYPE_CHECK_CLASS_CAST((k), E_CELL_DATE_EDIT_TEXT_TYPE, ECellDateEditTextClass))
-#define E_IS_CELL_DATE_EDIT_TEXT(o) (G_TYPE_CHECK_INSTANCE_TYPE ((o), E_CELL_DATE_EDIT_TEXT_TYPE))
-#define E_IS_CELL_DATE_EDIT_TEXT_CLASS(k) (G_TYPE_CHECK_CLASS_TYPE ((k), E_CELL_DATE_EDIT_TEXT_TYPE))
+G_BEGIN_DECLS
+typedef struct _ECellDateEditText ECellDateEditText;
+typedef struct _ECellDateEditTextClass ECellDateEditTextClass;
+typedef struct _ECellDateEditTextPrivate ECellDateEditTextPrivate;
typedef struct _ECellDateEditValue ECellDateEditValue;
+
struct _ECellDateEditValue {
struct icaltimetype tt;
icaltimezone *zone;
};
-typedef struct {
- ECellText base;
-
- /* The timezone to display the date in. */
- icaltimezone *zone;
-
- /* Whether to display in 24-hour format. */
- gboolean use_24_hour_format;
-} ECellDateEditText;
+struct _ECellDateEditText {
+ ECellText parent;
+ ECellDateEditTextPrivate *priv;
+};
-typedef struct {
+struct _ECellDateEditTextClass {
ECellTextClass parent_class;
-} ECellDateEditTextClass;
+};
-GType e_cell_date_edit_text_get_type (void);
-ECell *e_cell_date_edit_text_new (const gchar *fontname,
- GtkJustification justify);
+GType e_cell_date_edit_text_get_type (void);
+ECell * e_cell_date_edit_text_new (const gchar *fontname,
+ GtkJustification justify);
+icaltimezone * e_cell_date_edit_text_get_timezone
+ (ECellDateEditText *ecd);
+void e_cell_date_edit_text_set_timezone
+ (ECellDateEditText *ecd,
+ icaltimezone *timezone);
+gboolean e_cell_date_edit_text_get_use_24_hour_format
+ (ECellDateEditText *ecd);
+void e_cell_date_edit_text_set_use_24_hour_format
+ (ECellDateEditText *ecd,
+ gboolean use_24_hour);
-void e_cell_date_edit_text_set_timezone (ECellDateEditText *ecd,
- icaltimezone *zone);
-void e_cell_date_edit_text_set_use_24_hour_format (ECellDateEditText *ecd,
- gboolean use_24_hour);
G_END_DECLS
#endif /* _E_CELL_DATE_EDIT_TEXT_H_ */
diff --git a/calendar/gui/e-date-edit-config.c b/calendar/gui/e-date-edit-config.c
deleted file mode 100644
index bead58f5d2..0000000000
--- a/calendar/gui/e-date-edit-config.c
+++ /dev/null
@@ -1,257 +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:
- * JP Rosevear <jpr@ximian.com>
- *
- * Copyright (C) 1999-2008 Novell, Inc. (www.novell.com)
- *
- */
-
-#include "calendar-config.h"
-#include "e-date-edit-config.h"
-
-struct _EDateEditConfigPrivate {
- EDateEdit *edit;
-
- GList *notifications;
-};
-
-/* Property IDs */
-enum props {
- PROP_0,
- PROP_EDIT
-};
-
-G_DEFINE_TYPE (EDateEditConfig, e_date_edit_config, G_TYPE_OBJECT)
-
-static void
-e_date_edit_config_set_property (GObject *object, guint property_id, const GValue *value, GParamSpec *pspec)
-{
- EDateEditConfig *edit_config;
-
- edit_config = E_DATE_EDIT_CONFIG (object);
-
- switch (property_id) {
- case PROP_EDIT:
- e_date_edit_config_set_edit (edit_config, g_value_get_object (value));
- break;
- default:
- G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
- break;
- }
-}
-
-static void
-e_date_edit_config_get_property (GObject *object, guint property_id, GValue *value, GParamSpec *pspec)
-{
- EDateEditConfig *edit_config;
-
- edit_config = E_DATE_EDIT_CONFIG (object);
-
- switch (property_id) {
- case PROP_EDIT:
- g_value_set_object (value, e_date_edit_config_get_edit (edit_config));
- break;
- default:
- G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
- break;
- }
-}
-
-static void
-e_date_edit_config_dispose (GObject *object)
-{
- EDateEditConfig *edit_config = E_DATE_EDIT_CONFIG (object);
-
- e_date_edit_config_set_edit (edit_config, NULL);
-
- if (G_OBJECT_CLASS (e_date_edit_config_parent_class)->dispose)
- G_OBJECT_CLASS (e_date_edit_config_parent_class)->dispose (object);
-}
-
-static void
-e_date_edit_config_finalize (GObject *object)
-{
- EDateEditConfig *edit_config = E_DATE_EDIT_CONFIG (object);
- EDateEditConfigPrivate *priv;
-
- priv = edit_config->priv;
-
- g_free (priv);
-
- if (G_OBJECT_CLASS (e_date_edit_config_parent_class)->finalize)
- G_OBJECT_CLASS (e_date_edit_config_parent_class)->finalize (object);
-}
-
-static void
-e_date_edit_config_class_init (EDateEditConfigClass *klass)
-{
- GObjectClass *gobject_class = G_OBJECT_CLASS (klass);
- GParamSpec *spec;
-
- /* Method override */
- gobject_class->set_property = e_date_edit_config_set_property;
- gobject_class->get_property = e_date_edit_config_get_property;
- gobject_class->dispose = e_date_edit_config_dispose;
- gobject_class->finalize = e_date_edit_config_finalize;
-
- spec = g_param_spec_object ("edit", NULL, NULL, e_date_edit_get_type (),
- G_PARAM_READABLE | G_PARAM_WRITABLE | G_PARAM_CONSTRUCT);
- g_object_class_install_property (gobject_class, PROP_EDIT, spec);
-}
-
-static void
-e_date_edit_config_init (EDateEditConfig *edit_config)
-{
- edit_config->priv = g_new0 (EDateEditConfigPrivate, 1);
-
-}
-
-EDateEditConfig *
-e_date_edit_config_new (EDateEdit *date_edit)
-{
- EDateEditConfig *edit_config;
-
- edit_config = g_object_new (e_date_edit_config_get_type (), "edit", date_edit, NULL);
-
- return edit_config;
-}
-
-EDateEdit *
-e_date_edit_config_get_edit (EDateEditConfig *edit_config)
-{
- EDateEditConfigPrivate *priv;
-
- g_return_val_if_fail (edit_config != NULL, NULL);
- g_return_val_if_fail (E_IS_DATE_EDIT_CONFIG (edit_config), NULL);
-
- priv = edit_config->priv;
-
- return priv->edit;
-}
-
-static void
-set_week_start (EDateEdit *date_edit)
-{
- gint week_start_day;
-
- week_start_day = calendar_config_get_week_start_day ();
-
- /* Convert it to 0 (Mon) to 6 (Sun), which is what we use. */
- week_start_day = (week_start_day + 6) % 7;
-
- e_date_edit_set_week_start_day (date_edit, week_start_day);
-}
-
-static void
-week_start_changed_cb (GConfClient *client, guint id, GConfEntry *entry, gpointer data)
-{
- EDateEditConfig *edit_config = data;
- EDateEditConfigPrivate *priv;
-
- priv = edit_config->priv;
-
- set_week_start (priv->edit);
-}
-
-static void
-set_twentyfour_hour (EDateEdit *date_edit)
-{
- gboolean use_24_hour;
-
- use_24_hour = calendar_config_get_24_hour_format ();
-
- e_date_edit_set_use_24_hour_format (date_edit, use_24_hour);
-}
-
-static void
-twentyfour_hour_changed_cb (GConfClient *client, guint id, GConfEntry *entry, gpointer data)
-{
- EDateEditConfig *edit_config = data;
- EDateEditConfigPrivate *priv;
-
- priv = edit_config->priv;
-
- set_twentyfour_hour (priv->edit);
-}
-
-static void
-set_dnav_show_week_no (EDateEdit *date_edit)
-{
- gboolean show_week_no;
-
- show_week_no = calendar_config_get_dnav_show_week_no ();
-
- e_date_edit_set_show_week_numbers (date_edit, show_week_no);
-}
-
-static void
-dnav_show_week_no_changed_cb (GConfClient *client, guint id, GConfEntry *entry, gpointer data)
-{
- EDateEditConfig *edit_config = data;
- EDateEditConfigPrivate *priv;
-
- priv = edit_config->priv;
-
- set_dnav_show_week_no (priv->edit);
-}
-void
-e_date_edit_config_set_edit (EDateEditConfig *edit_config, EDateEdit *date_edit)
-{
- EDateEditConfigPrivate *priv;
- guint not;
- GList *l;
-
- g_return_if_fail (edit_config != NULL);
- g_return_if_fail (E_IS_DATE_EDIT_CONFIG (edit_config));
-
- priv = edit_config->priv;
-
- if (priv->edit) {
- g_object_unref (priv->edit);
- priv->edit = 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;
-
- /* If the new edit is NULL, return right now */
- if (!date_edit)
- return;
-
- priv->edit = g_object_ref (date_edit);
-
- /* Week start */
- set_week_start (date_edit);
-
- not = calendar_config_add_notification_week_start_day (week_start_changed_cb, edit_config);
- priv->notifications = g_list_prepend (priv->notifications, GUINT_TO_POINTER (not));
-
- /* 24 Hour format */
- set_twentyfour_hour (date_edit);
-
- not = calendar_config_add_notification_24_hour_format (twentyfour_hour_changed_cb, edit_config);
- priv->notifications = g_list_prepend (priv->notifications, GUINT_TO_POINTER (not));
-
- /* Show week numbers */
- set_dnav_show_week_no (date_edit);
-
- not = calendar_config_add_notification_dnav_show_week_no (dnav_show_week_no_changed_cb, edit_config);
- priv->notifications = g_list_prepend (priv->notifications, GUINT_TO_POINTER (not));
-}
diff --git a/calendar/gui/e-date-edit-config.h b/calendar/gui/e-date-edit-config.h
deleted file mode 100644
index 4065ec74e7..0000000000
--- a/calendar/gui/e-date-edit-config.h
+++ /dev/null
@@ -1,56 +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:
- * JP Rosevear <jpr@ximian.com>
- *
- * Copyright (C) 1999-2008 Novell, Inc. (www.novell.com)
- *
- */
-
-#ifndef _E_DATE_EDIT_CONFIG_H_
-#define _E_DATE_EDIT_CONFIG_H_
-
-#include <misc/e-dateedit.h>
-
-G_BEGIN_DECLS
-
-#define E_DATE_EDIT_CONFIG(obj) G_TYPE_CHECK_INSTANCE_CAST (obj, e_date_edit_config_get_type (), EDateEditConfig)
-#define E_DATE_EDIT_CONFIG_CLASS(klass) G_TYPE_CHECK_CLASS_CAST (klass, e_date_edit_config_get_type (), EDateEditConfigClass)
-#define E_IS_DATE_EDIT_CONFIG(obj) G_TYPE_CHECK_INSTANCE_TYPE (obj, e_date_edit_config_get_type ())
-
-typedef struct _EDateEditConfig EDateEditConfig;
-typedef struct _EDateEditConfigClass EDateEditConfigClass;
-typedef struct _EDateEditConfigPrivate EDateEditConfigPrivate;
-
-struct _EDateEditConfig {
- GObject parent;
-
- EDateEditConfigPrivate *priv;
-};
-
-struct _EDateEditConfigClass {
- GObjectClass parent_class;
-};
-
-GType e_date_edit_config_get_type (void);
-EDateEditConfig *e_date_edit_config_new (EDateEdit *date_edit);
-EDateEdit *e_date_edit_config_get_edit (EDateEditConfig *edit_config);
-void e_date_edit_config_set_edit (EDateEditConfig *edit_config, EDateEdit *date_edit);
-
-G_END_DECLS
-
-#endif
diff --git a/calendar/gui/e-day-view-config.c b/calendar/gui/e-day-view-config.c
deleted file mode 100644
index a193e7bfa0..0000000000
--- a/calendar/gui/e-day-view-config.c
+++ /dev/null
@@ -1,462 +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 "calendar-config.h"
-#include "e-day-view-config.h"
-
-struct _EDayViewConfigPrivate {
- EDayView *view;
-
- GList *notifications;
-};
-
-/* Property IDs */
-enum props {
- PROP_0,
- PROP_VIEW
-};
-
-G_DEFINE_TYPE (EDayViewConfig, e_day_view_config, G_TYPE_OBJECT)
-
-static void
-e_day_view_config_set_property (GObject *object, guint property_id, const GValue *value, GParamSpec *pspec)
-{
- EDayViewConfig *view_config;
-
- view_config = E_DAY_VIEW_CONFIG (object);
-
- switch (property_id) {
- case PROP_VIEW:
- e_day_view_config_set_view (view_config, g_value_get_object (value));
- break;
- default:
- G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
- break;
- }
-}
-
-static void
-e_day_view_config_get_property (GObject *object, guint property_id, GValue *value, GParamSpec *pspec)
-{
- EDayViewConfig *view_config;
-
- view_config = E_DAY_VIEW_CONFIG (object);
-
- switch (property_id) {
- case PROP_VIEW:
- g_value_set_object (value, e_day_view_config_get_view (view_config));
- break;
- default:
- G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
- break;
- }
-}
-
-static void
-e_day_view_config_dispose (GObject *object)
-{
- EDayViewConfig *view_config = E_DAY_VIEW_CONFIG (object);
-
- e_day_view_config_set_view (view_config, NULL);
-
- if (G_OBJECT_CLASS (e_day_view_config_parent_class)->dispose)
- G_OBJECT_CLASS (e_day_view_config_parent_class)->dispose (object);
-}
-
-static void
-e_day_view_config_finalize (GObject *object)
-{
- EDayViewConfig *view_config = E_DAY_VIEW_CONFIG (object);
- EDayViewConfigPrivate *priv;
-
- priv = view_config->priv;
-
- g_free (priv);
-
- if (G_OBJECT_CLASS (e_day_view_config_parent_class)->finalize)
- G_OBJECT_CLASS (e_day_view_config_parent_class)->finalize (object);
-}
-
-static void
-e_day_view_config_class_init (EDayViewConfigClass *klass)
-{
- GObjectClass *gobject_class = G_OBJECT_CLASS (klass);
- GParamSpec *spec;
-
- /* Method override */
- gobject_class->set_property = e_day_view_config_set_property;
- gobject_class->get_property = e_day_view_config_get_property;
- gobject_class->dispose = e_day_view_config_dispose;
- gobject_class->finalize = e_day_view_config_finalize;
-
- spec = g_param_spec_object ("view", NULL, NULL, e_day_view_get_type (),
- G_PARAM_READABLE | G_PARAM_WRITABLE | G_PARAM_CONSTRUCT);
- g_object_class_install_property (gobject_class, PROP_VIEW, spec);
-}
-
-static void
-e_day_view_config_init (EDayViewConfig *view_config)
-{
- view_config->priv = g_new0 (EDayViewConfigPrivate, 1);
-
-}
-
-EDayViewConfig *
-e_day_view_config_new (EDayView *day_view)
-{
- EDayViewConfig *view_config;
-
- view_config = g_object_new (e_day_view_config_get_type (), "view", day_view, NULL);
-
- return view_config;
-}
-
-EDayView *
-e_day_view_config_get_view (EDayViewConfig *view_config)
-{
- EDayViewConfigPrivate *priv;
-
- g_return_val_if_fail (view_config != NULL, NULL);
- g_return_val_if_fail (E_IS_DAY_VIEW_CONFIG (view_config), NULL);
-
- priv = view_config->priv;
-
- return priv->view;
-}
-
-static void
-set_week_start (EDayView *day_view)
-{
- gint week_start_day;
-
- week_start_day = calendar_config_get_week_start_day ();
-
- /* Convert it to 0 (Mon) to 6 (Sun), which is what we use. */
- week_start_day = (week_start_day + 6) % 7;
-
- e_day_view_set_week_start_day (day_view, week_start_day);
-}
-
-static void
-week_start_changed_cb (GConfClient *client, guint id, GConfEntry *entry, gpointer data)
-{
- EDayViewConfig *view_config = data;
- EDayViewConfigPrivate *priv;
-
- priv = view_config->priv;
-
- set_week_start (priv->view);
-}
-
-static void
-set_twentyfour_hour (EDayView *day_view)
-{
- gboolean use_24_hour;
-
- use_24_hour = calendar_config_get_24_hour_format ();
-
- e_calendar_view_set_use_24_hour_format (E_CALENDAR_VIEW (day_view), use_24_hour);
-
- /* To redraw the times */
- gtk_widget_queue_draw (day_view->time_canvas);
-}
-
-static void
-twentyfour_hour_changed_cb (GConfClient *client, guint id, GConfEntry *entry, gpointer data)
-{
- EDayViewConfig *view_config = data;
- EDayViewConfigPrivate *priv;
-
- priv = view_config->priv;
-
- set_twentyfour_hour (priv->view);
-}
-
-static void
-set_working_days (EDayView *day_view)
-{
- CalWeekdays working_days;
-
- working_days = calendar_config_get_working_days ();
-
- e_day_view_set_working_days (day_view, working_days);
-}
-
-static void
-working_days_changed_cb (GConfClient *client, guint id, GConfEntry *entry, gpointer data)
-{
- EDayViewConfig *view_config = data;
- EDayViewConfigPrivate *priv;
-
- priv = view_config->priv;
-
- set_working_days (priv->view);
-}
-
-static void
-set_day_start_hour (EDayView *day_view)
-{
- gint start_hour, start_minute, end_hour, end_minute;
-
- e_day_view_get_working_day (day_view, &start_hour, &start_minute, &end_hour, &end_minute);
-
- start_hour = calendar_config_get_day_start_hour ();
-
- e_day_view_set_working_day (day_view, start_hour, start_minute, end_hour, end_minute);
-}
-
-static void
-day_start_hour_changed_cb (GConfClient *client, guint id, GConfEntry *entry, gpointer data)
-{
- EDayViewConfig *view_config = data;
- EDayViewConfigPrivate *priv;
-
- priv = view_config->priv;
-
- set_day_start_hour (priv->view);
-}
-
-static void
-set_day_start_minute (EDayView *day_view)
-{
- gint start_hour, start_minute, end_hour, end_minute;
-
- e_day_view_get_working_day (day_view, &start_hour, &start_minute, &end_hour, &end_minute);
-
- start_minute = calendar_config_get_day_start_minute ();
-
- e_day_view_set_working_day (day_view, start_hour, start_minute, end_hour, end_minute);
-}
-
-static void
-day_start_minute_changed_cb (GConfClient *client, guint id, GConfEntry *entry, gpointer data)
-{
- EDayViewConfig *view_config = data;
- EDayViewConfigPrivate *priv;
-
- priv = view_config->priv;
-
- set_day_start_minute (priv->view);
-}
-
-static void
-set_day_end_hour (EDayView *day_view)
-{
- gint start_hour, start_minute, end_hour, end_minute;
-
- e_day_view_get_working_day (day_view, &start_hour, &start_minute, &end_hour, &end_minute);
-
- end_hour = calendar_config_get_day_end_hour ();
-
- e_day_view_set_working_day (day_view, start_hour, start_minute, end_hour, end_minute);
-}
-
-static void
-day_end_hour_changed_cb (GConfClient *client, guint id, GConfEntry *entry, gpointer data)
-{
- EDayViewConfig *view_config = data;
- EDayViewConfigPrivate *priv;
-
- priv = view_config->priv;
-
- set_day_end_hour (priv->view);
-}
-
-static void
-set_day_end_minute (EDayView *day_view)
-{
- gint start_hour, start_minute, end_hour, end_minute;
-
- e_day_view_get_working_day (day_view, &start_hour, &start_minute, &end_hour, &end_minute);
-
- end_minute = calendar_config_get_day_end_minute ();
-
- e_day_view_set_working_day (day_view, start_hour, start_minute, end_hour, end_minute);
-}
-
-static void
-day_end_minute_changed_cb (GConfClient *client, guint id, GConfEntry *entry, gpointer data)
-{
- EDayViewConfig *view_config = data;
- EDayViewConfigPrivate *priv;
-
- priv = view_config->priv;
-
- set_day_end_minute (priv->view);
-}
-
-static void
-set_time_divisions (EDayView *day_view)
-{
- gint time_divisions;
-
- time_divisions = calendar_config_get_time_divisions ();
-
- e_day_view_set_mins_per_row (day_view, time_divisions);
-}
-
-static void
-time_divisions_changed_cb (GConfClient *client, guint id, GConfEntry *entry, gpointer data)
-{
- EDayViewConfig *view_config = data;
- EDayViewConfigPrivate *priv;
-
- priv = view_config->priv;
-
- set_time_divisions (priv->view);
-}
-
-static void
-set_marcus_bains (EDayView *day_view)
-{
- gboolean show_marcus_bains_line;
- const gchar *dayview_color, *timebar_color;
-
- calendar_config_get_marcus_bains (&show_marcus_bains_line, &dayview_color, &timebar_color);
-
- e_day_view_set_marcus_bains (day_view, show_marcus_bains_line, dayview_color, timebar_color);
-}
-
-static void
-marcus_bains_changed_cb (GConfClient *client, guint id, GConfEntry *entry, gpointer data)
-{
- EDayViewConfig *view_config = data;
- EDayViewConfigPrivate *priv;
-
- priv = view_config->priv;
-
- set_marcus_bains (priv->view);
-}
-
-static void
-set_show_event_end (EDayView *day_view)
-{
- gboolean show_event_end;
-
- show_event_end = calendar_config_get_show_event_end ();
-
- e_day_view_set_show_event_end_times (day_view, show_event_end);
-}
-
-static void
-show_event_end_changed_cb (GConfClient *client, guint id, GConfEntry *entry, gpointer data)
-{
- EDayViewConfig *view_config = data;
- EDayViewConfigPrivate *priv;
-
- priv = view_config->priv;
-
- set_show_event_end (priv->view);
-}
-
-void
-e_day_view_config_set_view (EDayViewConfig *view_config, EDayView *day_view)
-{
- EDayViewConfigPrivate *priv;
- gint not_1, not_2, mbnot;
- guint not;
- GList *l;
-
- g_return_if_fail (view_config != NULL);
- g_return_if_fail (E_IS_DAY_VIEW_CONFIG (view_config));
-
- priv = view_config->priv;
-
- if (priv->view) {
- g_object_unref (priv->view);
- priv->view = 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;
-
- /* If the new view is NULL, return right now */
- if (!day_view)
- return;
-
- priv->view = g_object_ref (day_view);
-
- /* Week start */
- set_week_start (day_view);
-
- not = calendar_config_add_notification_week_start_day (week_start_changed_cb, view_config);
- priv->notifications = g_list_prepend (priv->notifications, GUINT_TO_POINTER (not));
-
- /* 24 Hour format */
- set_twentyfour_hour (day_view);
-
- not = calendar_config_add_notification_24_hour_format (twentyfour_hour_changed_cb, view_config);
- priv->notifications = g_list_prepend (priv->notifications, GUINT_TO_POINTER (not));
-
- /* Working days */
- set_working_days (day_view);
-
- not = calendar_config_add_notification_working_days (working_days_changed_cb, view_config);
- priv->notifications = g_list_prepend (priv->notifications, GUINT_TO_POINTER (not));
-
- /* Day start hour */
- set_day_start_hour (day_view);
-
- not = calendar_config_add_notification_day_start_hour (day_start_hour_changed_cb, view_config);
- priv->notifications = g_list_prepend (priv->notifications, GUINT_TO_POINTER (not));
-
- /* Day start minute */
- set_day_start_minute (day_view);
-
- not = calendar_config_add_notification_day_start_minute (day_start_minute_changed_cb, view_config);
- priv->notifications = g_list_prepend (priv->notifications, GUINT_TO_POINTER (not));
-
- /* Day end hour */
- set_day_end_hour (day_view);
-
- not = calendar_config_add_notification_day_end_hour (day_end_hour_changed_cb, view_config);
- priv->notifications = g_list_prepend (priv->notifications, GUINT_TO_POINTER (not));
-
- /* Day start minute */
- set_day_end_minute (day_view);
-
- not = calendar_config_add_notification_day_end_minute (day_end_minute_changed_cb, view_config);
- priv->notifications = g_list_prepend (priv->notifications, GUINT_TO_POINTER (not));
-
- /* Time divisions */
- set_time_divisions (day_view);
-
- not = calendar_config_add_notification_time_divisions (time_divisions_changed_cb, view_config);
- priv->notifications = g_list_prepend (priv->notifications, GUINT_TO_POINTER (not));
-
- /* Showing Marcus Bains Line */
- set_marcus_bains (day_view);
-
- calendar_config_add_notification_marcus_bains (marcus_bains_changed_cb, view_config, &mbnot, &not_1, &not_2);
- priv->notifications = g_list_prepend (priv->notifications, GUINT_TO_POINTER (mbnot));
- priv->notifications = g_list_prepend (priv->notifications, GUINT_TO_POINTER (not_1));
- priv->notifications = g_list_prepend (priv->notifications, GUINT_TO_POINTER (not_2));
-
- /* Showing event end */
- set_show_event_end (day_view);
-
- not = calendar_config_add_notification_show_event_end (show_event_end_changed_cb, view_config);
- priv->notifications = g_list_prepend (priv->notifications, GUINT_TO_POINTER (not));
-}
diff --git a/calendar/gui/e-day-view-config.h b/calendar/gui/e-day-view-config.h
deleted file mode 100644
index 25d208b432..0000000000
--- a/calendar/gui/e-day-view-config.h
+++ /dev/null
@@ -1,56 +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:
- * JP Rosevear <jpr@ximian.com>
- *
- * Copyright (C) 1999-2008 Novell, Inc. (www.novell.com)
- *
- */
-
-#ifndef _E_DAY_VIEW_CONFIG_H_
-#define _E_DAY_VIEW_CONFIG_H_
-
-#include "e-day-view.h"
-
-G_BEGIN_DECLS
-
-#define E_DAY_VIEW_CONFIG(obj) G_TYPE_CHECK_INSTANCE_CAST (obj, e_day_view_config_get_type (), EDayViewConfig)
-#define E_DAY_VIEW_CONFIG_CLASS(klass) G_TYPE_CHECK_CLASS_CAST (klass, e_day_view_config_get_type (), EDayViewConfigClass)
-#define E_IS_DAY_VIEW_CONFIG(obj) G_TYPE_CHECK_INSTANCE_TYPE (obj, e_day_view_config_get_type ())
-
-typedef struct _EDayViewConfig EDayViewConfig;
-typedef struct _EDayViewConfigClass EDayViewConfigClass;
-typedef struct _EDayViewConfigPrivate EDayViewConfigPrivate;
-
-struct _EDayViewConfig {
- GObject parent;
-
- EDayViewConfigPrivate *priv;
-};
-
-struct _EDayViewConfigClass {
- GObjectClass parent_class;
-};
-
-GType e_day_view_config_get_type (void);
-EDayViewConfig *e_day_view_config_new (EDayView *day_view);
-EDayView *e_day_view_config_get_view (EDayViewConfig *view_config);
-void e_day_view_config_set_view (EDayViewConfig *view_config, EDayView *day_view);
-
-G_END_DECLS
-
-#endif
diff --git a/calendar/gui/e-day-view-main-item.c b/calendar/gui/e-day-view-main-item.c
index c211a456f8..a3f951b276 100644
--- a/calendar/gui/e-day-view-main-item.c
+++ b/calendar/gui/e-day-view-main-item.c
@@ -392,7 +392,7 @@ e_day_view_main_item_draw (GnomeCanvasItem *canvas_item, GdkDrawable *drawable,
day, draw_region);
}
- if (e_day_view_get_show_marcus_bains (day_view)) {
+ if (e_day_view_marcus_bains_get_show_line (day_view)) {
icaltimezone *zone;
struct icaltimetype time_now, day_start;
gint marcus_bains_y;
@@ -610,6 +610,7 @@ e_day_view_main_item_draw_day_event (EDayViewMainItem *dvmitem,
{
EDayView *day_view;
EDayViewEvent *event;
+ ECalModel *model;
gint item_x, item_y, item_w, item_h, bar_y1, bar_y2;
GdkGC *gc;
GdkColor bg_color;
@@ -643,6 +644,7 @@ e_day_view_main_item_draw_day_event (EDayViewMainItem *dvmitem,
gint row_y;
day_view = dvmitem->day_view;
+ model = e_calendar_view_get_model (E_CALENDAR_VIEW (day_view));
/* If the event is currently being dragged, don't draw it. It will
be drawn in the special drag items. */
@@ -975,7 +977,7 @@ e_day_view_main_item_draw_day_event (EDayViewMainItem *dvmitem,
cairo_clip (cr);
cairo_new_path (cr);
- if (e_calendar_view_get_use_24_hour_format (E_CALENDAR_VIEW (day_view))) {
+ if (e_cal_model_get_use_24_hour_format (model)) {
cairo_translate (cr, item_x + item_w - E_DAY_VIEW_BAR_WIDTH - 32, item_y + item_h - 8);
end_regsizeime = g_strdup_printf ("%2i:%02i",
end_display_hour, end_minute);
@@ -1177,7 +1179,7 @@ e_day_view_main_item_draw_day_event (EDayViewMainItem *dvmitem,
&end_suffix,
&end_suffix_width);
- if (e_calendar_view_get_use_24_hour_format (E_CALENDAR_VIEW (day_view))) {
+ if (e_cal_model_get_use_24_hour_format (model)) {
if (day_view->show_event_end_times && show_span) {
/* 24 hour format with end time. */
text = g_strdup_printf
diff --git a/calendar/gui/e-day-view-time-item.c b/calendar/gui/e-day-view-time-item.c
index 7d0b5a6467..8c4a2fdf07 100644
--- a/calendar/gui/e-day-view-time-item.c
+++ b/calendar/gui/e-day-view-time-item.c
@@ -279,6 +279,7 @@ edvti_draw_zone (GnomeCanvasItem *canvas_item,
{
EDayView *day_view;
EDayViewTimeItem *dvtmitem;
+ ECalModel *model;
GtkStyle *style;
const gchar *suffix;
gchar buffer[64], *midnight_day = NULL, *midnight_month = NULL;
@@ -302,6 +303,8 @@ edvti_draw_zone (GnomeCanvasItem *canvas_item,
day_view = dvtmitem->day_view;
g_return_if_fail (day_view != NULL);
+ model = e_calendar_view_get_model (E_CALENDAR_VIEW (day_view));
+
style = gtk_widget_get_style (GTK_WIDGET (day_view));
small_font_desc = style->font_desc;
@@ -410,7 +413,7 @@ edvti_draw_zone (GnomeCanvasItem *canvas_item,
E_DVTMI_LARGE_HOUR_Y_PAD);
/* Draw the Marcus Bains Line first, so it appears under other elements. */
- if (e_day_view_get_show_marcus_bains (day_view)) {
+ if (e_day_view_marcus_bains_get_show_line (day_view)) {
struct icaltimetype time_now;
gint marcus_bains_y;
@@ -485,7 +488,7 @@ edvti_draw_zone (GnomeCanvasItem *canvas_item,
strcpy (buffer, midnight_day);
strcat (buffer, " ");
strcat (buffer, midnight_month);
- } else if (e_calendar_view_get_use_24_hour_format (E_CALENDAR_VIEW (day_view))) {
+ } else if (e_cal_model_get_use_24_hour_format (model)) {
g_snprintf (buffer, sizeof (buffer), "%i:%02i",
display_hour, minute);
} else {
@@ -565,7 +568,7 @@ edvti_draw_zone (GnomeCanvasItem *canvas_item,
if (show_midnight_date)
strcpy (buffer, midnight_month);
else if (minute == 0
- && !e_calendar_view_get_use_24_hour_format (E_CALENDAR_VIEW (day_view))) {
+ && !e_cal_model_get_use_24_hour_format (model)) {
strcpy (buffer, suffix);
} else {
g_snprintf (buffer, sizeof (buffer),
diff --git a/calendar/gui/e-day-view-top-item.c b/calendar/gui/e-day-view-top-item.c
index 6ebbde46a5..a1f083e1b8 100644
--- a/calendar/gui/e-day-view-top-item.c
+++ b/calendar/gui/e-day-view-top-item.c
@@ -369,6 +369,7 @@ e_day_view_top_item_draw_long_event (EDayViewTopItem *dvtitem,
gint start_day, end_day;
gint item_x, item_y, item_w, item_h;
gint text_x, icon_x, icon_y, icon_x_inc;
+ ECalModel *model;
ECalComponent *comp;
gchar buffer[16];
gint hour, display_hour, minute, offset, time_width, time_x;
@@ -389,6 +390,8 @@ e_day_view_top_item_draw_long_event (EDayViewTopItem *dvtitem,
gdouble x0, y0, rect_height, rect_width, radius;
day_view = dvtitem->day_view;
+ model = e_calendar_view_get_model (E_CALENDAR_VIEW (day_view));
+
cr = gdk_cairo_create (drawable);
gradient = calendar_config_get_display_events_gradient ();
@@ -561,7 +564,7 @@ e_day_view_top_item_draw_long_event (EDayViewTopItem *dvtitem,
e_day_view_convert_time_to_display (day_view, hour,
&display_hour,
&suffix, &suffix_width);
- if (e_calendar_view_get_use_24_hour_format (E_CALENDAR_VIEW (day_view))) {
+ if (e_cal_model_get_use_24_hour_format (model)) {
g_snprintf (buffer, sizeof (buffer), "%i:%02i",
display_hour, minute);
} else {
@@ -610,7 +613,7 @@ e_day_view_top_item_draw_long_event (EDayViewTopItem *dvtitem,
&display_hour,
&suffix,
&suffix_width);
- if (e_calendar_view_get_use_24_hour_format (E_CALENDAR_VIEW (day_view))) {
+ if (e_cal_model_get_use_24_hour_format (model)) {
g_snprintf (buffer, sizeof (buffer),
"%i:%02i", display_hour, minute);
} else {
diff --git a/calendar/gui/e-day-view.c b/calendar/gui/e-day-view.c
index ed83c9d855..cb69eecf50 100644
--- a/calendar/gui/e-day-view.c
+++ b/calendar/gui/e-day-view.c
@@ -35,9 +35,10 @@
#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-binding.h>
#include <e-util/e-categories-config.h>
#include <e-util/e-dialog-utils.h>
@@ -51,7 +52,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"
@@ -261,7 +261,7 @@ static void e_day_view_on_event_right_click (EDayView *day_view,
gint day,
gint event_num);
static void e_day_view_show_popup_menu (EDayView *day_view,
- GdkEvent *gdk_event,
+ GdkEventButton *event,
gint day,
gint event_num);
@@ -432,38 +432,364 @@ static void e_day_view_queue_layout (EDayView *day_view);
static void e_day_view_cancel_layout (EDayView *day_view);
static gboolean e_day_view_layout_timeout_cb (gpointer data);
+enum {
+ PROP_0,
+ PROP_MARCUS_BAINS_SHOW_LINE,
+ PROP_MARCUS_BAINS_DAY_VIEW_COLOR,
+ PROP_MARCUS_BAINS_TIME_BAR_COLOR,
+ PROP_MINS_PER_ROW,
+ PROP_WORK_DAY_END_HOUR,
+ PROP_WORK_DAY_END_MINUTE,
+ PROP_WORK_DAY_START_HOUR,
+ PROP_WORK_DAY_START_MINUTE,
+ PROP_WORKING_DAYS
+};
+
G_DEFINE_TYPE (EDayView, e_day_view, E_TYPE_CALENDAR_VIEW)
static void
-e_day_view_class_init (EDayViewClass *class)
+day_view_notify_week_start_day_cb (EDayView *day_view)
{
- GtkObjectClass *object_class;
- GtkWidgetClass *widget_class;
- ECalendarViewClass *view_class;
+ /* XXX Write a EWorkWeekView subclass, like EMonthView. */
+
+ if (day_view->work_week_view)
+ e_day_view_recalc_work_week (day_view);
+}
+
+static void
+day_view_set_property (GObject *object,
+ guint property_id,
+ const GValue *value,
+ GParamSpec *pspec)
+{
+ switch (property_id) {
+ case PROP_MARCUS_BAINS_SHOW_LINE:
+ e_day_view_marcus_bains_set_show_line (
+ E_DAY_VIEW (object),
+ g_value_get_boolean (value));
+ return;
+
+ case PROP_MARCUS_BAINS_DAY_VIEW_COLOR:
+ e_day_view_marcus_bains_set_day_view_color (
+ E_DAY_VIEW (object),
+ g_value_get_string (value));
+ return;
+
+ case PROP_MARCUS_BAINS_TIME_BAR_COLOR:
+ e_day_view_marcus_bains_set_time_bar_color (
+ E_DAY_VIEW (object),
+ g_value_get_string (value));
+ return;
+
+ case PROP_MINS_PER_ROW:
+ e_day_view_set_mins_per_row (
+ E_DAY_VIEW (object),
+ g_value_get_int (value));
+ return;
+
+ case PROP_WORK_DAY_END_HOUR:
+ e_day_view_set_work_day_end_hour (
+ E_DAY_VIEW (object),
+ g_value_get_int (value));
+ return;
+
+ case PROP_WORK_DAY_END_MINUTE:
+ e_day_view_set_work_day_end_minute (
+ E_DAY_VIEW (object),
+ g_value_get_int (value));
+ return;
+
+ case PROP_WORK_DAY_START_HOUR:
+ e_day_view_set_work_day_start_hour (
+ E_DAY_VIEW (object),
+ g_value_get_int (value));
+ return;
+
+ case PROP_WORK_DAY_START_MINUTE:
+ e_day_view_set_work_day_start_minute (
+ E_DAY_VIEW (object),
+ g_value_get_int (value));
+ return;
+
+ case PROP_WORKING_DAYS:
+ e_day_view_set_working_days (
+ E_DAY_VIEW (object),
+ g_value_get_int (value));
+ return;
+ }
+
+ G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
+}
+
+static void
+day_view_get_property (GObject *object,
+ guint property_id,
+ GValue *value,
+ GParamSpec *pspec)
+{
+ switch (property_id) {
+ case PROP_MARCUS_BAINS_SHOW_LINE:
+ g_value_set_boolean (
+ value,
+ e_day_view_marcus_bains_get_show_line (
+ E_DAY_VIEW (object)));
+ return;
+
+ case PROP_MARCUS_BAINS_DAY_VIEW_COLOR:
+ g_value_set_string (
+ value,
+ e_day_view_marcus_bains_get_day_view_color (
+ E_DAY_VIEW (object)));
+ return;
+
+ case PROP_MARCUS_BAINS_TIME_BAR_COLOR:
+ g_value_set_string (
+ value,
+ e_day_view_marcus_bains_get_time_bar_color (
+ E_DAY_VIEW (object)));
+ return;
+
+ case PROP_MINS_PER_ROW:
+ g_value_set_int (
+ value,
+ e_day_view_get_mins_per_row (
+ E_DAY_VIEW (object)));
+ return;
+
+ case PROP_WORK_DAY_END_HOUR:
+ g_value_set_int (
+ value,
+ e_day_view_get_work_day_end_hour (
+ E_DAY_VIEW (object)));
+ return;
+
+ case PROP_WORK_DAY_END_MINUTE:
+ g_value_set_int (
+ value,
+ e_day_view_get_work_day_end_minute (
+ E_DAY_VIEW (object)));
+ return;
+
+ case PROP_WORK_DAY_START_HOUR:
+ g_value_set_int (
+ value,
+ e_day_view_get_work_day_start_hour (
+ E_DAY_VIEW (object)));
+ return;
+
+ case PROP_WORK_DAY_START_MINUTE:
+ g_value_set_int (
+ value,
+ e_day_view_get_work_day_start_minute (
+ E_DAY_VIEW (object)));
+ return;
+
+ case PROP_WORKING_DAYS:
+ g_value_set_int (
+ value,
+ e_day_view_get_working_days (
+ E_DAY_VIEW (object)));
+ return;
+ }
+
+ G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
+}
+
+static void
+day_view_constructed (GObject *object)
+{
+ ECalModel *model;
+ EDayView *day_view;
+ EShellSettings *shell_settings;
+
+ day_view = E_DAY_VIEW (object);
+ model = e_calendar_view_get_model (E_CALENDAR_VIEW (day_view));
+ shell_settings = e_cal_model_get_shell_settings (model);
+
+ e_binding_new (
+ G_OBJECT (shell_settings), "cal-day-view-show-week-numbers",
+ G_OBJECT (day_view->week_number_label), "visible");
+
+ e_binding_new (
+ G_OBJECT (shell_settings), "cal-marcus-bains-show-line",
+ G_OBJECT (day_view), "marcus-bains-show-line");
+
+ e_binding_new (
+ G_OBJECT (shell_settings), "cal-marcus-bains-day-view-color",
+ G_OBJECT (day_view), "marcus-bains-day-view-color");
+
+ e_binding_new (
+ G_OBJECT (shell_settings), "cal-marcus-bains-time-bar-color",
+ G_OBJECT (day_view), "marcus-bains-time-bar-color");
+
+ e_binding_new (
+ G_OBJECT (shell_settings), "cal-time-divisions",
+ G_OBJECT (day_view), "mins-per-row");
- object_class = (GtkObjectClass *) class;
- widget_class = (GtkWidgetClass *) class;
- view_class = (ECalendarViewClass *) class;
+ e_binding_new (
+ G_OBJECT (shell_settings), "cal-work-day-end-hour",
+ G_OBJECT (day_view), "work-day-end-hour");
- /* Method override */
- object_class->destroy = e_day_view_destroy;
+ e_binding_new (
+ G_OBJECT (shell_settings), "cal-work-day-end-minute",
+ G_OBJECT (day_view), "work-day-end-minute");
- widget_class->realize = e_day_view_realize;
- widget_class->unrealize = e_day_view_unrealize;
- widget_class->style_set = e_day_view_style_set;
- widget_class->size_allocate = e_day_view_size_allocate;
- widget_class->focus_in_event = e_day_view_focus_in;
- widget_class->focus_out_event = e_day_view_focus_out;
- widget_class->key_press_event = e_day_view_key_press;
- widget_class->focus = e_day_view_focus;
- widget_class->popup_menu = e_day_view_popup_menu;
+ e_binding_new (
+ G_OBJECT (shell_settings), "cal-work-day-start-hour",
+ G_OBJECT (day_view), "work-day-start-hour");
+ e_binding_new (
+ G_OBJECT (shell_settings), "cal-work-day-start-minute",
+ G_OBJECT (day_view), "work-day-start-minute");
+
+ e_binding_new (
+ G_OBJECT (shell_settings), "cal-working-days-bitset",
+ G_OBJECT (day_view), "working-days");
+
+ g_signal_connect_swapped (
+ model, "notify::week-start-day",
+ G_CALLBACK (day_view_notify_week_start_day_cb), day_view);
+}
+
+static void
+e_day_view_class_init (EDayViewClass *class)
+{
+ GObjectClass *object_class;
+ GtkObjectClass *gtk_object_class;
+ GtkWidgetClass *widget_class;
+ ECalendarViewClass *view_class;
+
+ object_class = G_OBJECT_CLASS (class);
+ object_class->set_property = day_view_set_property;
+ object_class->get_property = day_view_get_property;
+ object_class->constructed = day_view_constructed;
+
+ gtk_object_class = GTK_OBJECT_CLASS (class);
+ gtk_object_class->destroy = e_day_view_destroy;
+
+ widget_class = GTK_WIDGET_CLASS (class);
+ widget_class->realize = e_day_view_realize;
+ widget_class->unrealize = e_day_view_unrealize;
+ widget_class->style_set = e_day_view_style_set;
+ widget_class->size_allocate = e_day_view_size_allocate;
+ widget_class->focus_in_event = e_day_view_focus_in;
+ widget_class->focus_out_event = e_day_view_focus_out;
+ widget_class->key_press_event = e_day_view_key_press;
+ widget_class->focus = e_day_view_focus;
+ widget_class->popup_menu = e_day_view_popup_menu;
+
+ view_class = E_CALENDAR_VIEW_CLASS (class);
view_class->get_selected_events = e_day_view_get_selected_events;
view_class->get_selected_time_range = e_day_view_get_selected_time_range;
view_class->set_selected_time_range = e_day_view_set_selected_time_range;
view_class->get_visible_time_range = e_day_view_get_visible_time_range;
view_class->paste_text = e_day_view_paste_text;
+ /* XXX Should these be constructor properties? */
+
+ g_object_class_install_property (
+ object_class,
+ PROP_MARCUS_BAINS_SHOW_LINE,
+ g_param_spec_boolean (
+ "marcus-bains-show-line",
+ "Marcus Bains Show Line",
+ NULL,
+ TRUE,
+ G_PARAM_READWRITE));
+
+ g_object_class_install_property (
+ object_class,
+ PROP_MARCUS_BAINS_DAY_VIEW_COLOR,
+ g_param_spec_string (
+ "marcus-bains-day-view-color",
+ "Marcus Bains Day View Color",
+ NULL,
+ NULL,
+ G_PARAM_READWRITE));
+
+ g_object_class_install_property (
+ object_class,
+ PROP_MARCUS_BAINS_TIME_BAR_COLOR,
+ g_param_spec_string (
+ "marcus-bains-time-bar-color",
+ "Marcus Bains Time Bar Color",
+ NULL,
+ NULL,
+ G_PARAM_READWRITE));
+
+ g_object_class_install_property (
+ object_class,
+ PROP_MINS_PER_ROW,
+ g_param_spec_int (
+ "mins-per-row",
+ "Minutes Per Row",
+ NULL,
+ 5, /* not a continuous range */
+ 60, /* valid values: 5, 10, 15, 30, 60 */
+ 30,
+ G_PARAM_READWRITE));
+
+ g_object_class_install_property (
+ object_class,
+ PROP_WORK_DAY_END_HOUR,
+ g_param_spec_int (
+ "work-day-end-hour",
+ "Work Day End Hour",
+ NULL,
+ G_MININT,
+ G_MAXINT,
+ 0,
+ G_PARAM_READWRITE));
+
+ g_object_class_install_property (
+ object_class,
+ PROP_WORK_DAY_END_MINUTE,
+ g_param_spec_int (
+ "work-day-end-minute",
+ "Work Day End Minute",
+ NULL,
+ G_MININT,
+ G_MAXINT,
+ 0,
+ G_PARAM_READWRITE));
+
+ g_object_class_install_property (
+ object_class,
+ PROP_WORK_DAY_START_HOUR,
+ g_param_spec_int (
+ "work-day-start-hour",
+ "Work Day Start Hour",
+ NULL,
+ G_MININT,
+ G_MAXINT,
+ 0,
+ G_PARAM_READWRITE));
+
+ g_object_class_install_property (
+ object_class,
+ PROP_WORK_DAY_START_MINUTE,
+ g_param_spec_int (
+ "work-day-start-minute",
+ "Work Day Start Minute",
+ NULL,
+ G_MININT,
+ G_MAXINT,
+ 0,
+ G_PARAM_READWRITE));
+
+ /* FIXME Make this a real GFlags type. */
+ g_object_class_install_property (
+ object_class,
+ PROP_WORKING_DAYS,
+ g_param_spec_int (
+ "working-days",
+ "Working Days",
+ NULL,
+ 0x00,
+ 0x7f,
+ 0,
+ G_PARAM_READWRITE));
+
/* init the accessibility support for e_day_view */
e_day_view_a11y_init ();
}
@@ -703,12 +1029,6 @@ timezone_changed_cb (ECalendarView *cal_view, icaltimezone *old_zone,
}
static void
-dview_show_week_no_changed_cb (GConfClient *client, guint id, GConfEntry *entry, gpointer data)
-{
- e_day_view_set_show_week_number (data, calendar_config_get_dview_show_week_no ());
-}
-
-static void
e_day_view_init (EDayView *day_view)
{
gint day;
@@ -764,10 +1084,9 @@ e_day_view_init (EDayView *day_view)
day_view->work_day_end_hour = 17;
day_view->work_day_end_minute = 0;
day_view->show_event_end_times = TRUE;
- day_view->week_start_day = 0;
day_view->scroll_to_work_day = TRUE;
- day_view->show_marcus_bains_line = TRUE;
+ day_view->marcus_bains_show_line = TRUE;
day_view->marcus_bains_day_view_color = NULL;
day_view->marcus_bains_time_bar_color = NULL;
@@ -813,9 +1132,6 @@ e_day_view_init (EDayView *day_view)
day_view->week_number_label = gtk_label_new ("");
gtk_table_attach (GTK_TABLE (day_view), day_view->week_number_label, 0, 1, 0, 1, GTK_FILL, GTK_FILL, 0, 0);
- day_view->wn_notif_id = calendar_config_add_notification_dview_show_week_no (dview_show_week_no_changed_cb, day_view);
- if (calendar_config_get_dview_show_week_no ())
- gtk_widget_show (day_view->week_number_label);
/*
* Top Canvas
@@ -1064,16 +1380,17 @@ e_day_view_on_canvas_realized (GtkWidget *widget,
*
* Creates a new #EDayView.
**/
-GtkWidget *
+ECalendarView *
e_day_view_new (ECalModel *model)
{
- GObject *day_view;
+ ECalendarView *day_view;
- day_view = g_object_new (e_day_view_get_type (), NULL);
- e_calendar_view_set_model ((ECalendarView *)day_view, model);
- init_model ((EDayView *) day_view, model);
+ g_return_val_if_fail (E_IS_CAL_MODEL (model), NULL);
- return GTK_WIDGET (day_view);
+ day_view = g_object_new (E_TYPE_DAY_VIEW, "model", model, NULL);
+ init_model (E_DAY_VIEW (day_view), model);
+
+ return day_view;
}
static void
@@ -1088,11 +1405,6 @@ e_day_view_destroy (GtkObject *object)
e_day_view_stop_auto_scroll (day_view);
- if (day_view->wn_notif_id) {
- calendar_config_remove_notification (day_view->wn_notif_id);
- day_view->wn_notif_id = 0;
- }
-
if (day_view->large_font_desc) {
pango_font_description_free (day_view->large_font_desc);
day_view->large_font_desc = NULL;
@@ -2127,10 +2439,15 @@ e_day_view_find_work_week_start (EDayView *day_view,
time_t start_time)
{
GDate date;
+ ECalModel *model;
+ gint week_start_day;
gint weekday, day, i;
guint offset;
struct icaltimetype tt = icaltime_null_time ();
+ model = e_calendar_view_get_model (E_CALENDAR_VIEW (day_view));
+ week_start_day = e_cal_model_get_week_start_day (model);
+
time_to_gdate_with_zone (&date, start_time, e_calendar_view_get_timezone (E_CALENDAR_VIEW (day_view)));
/* The start of the work-week is the first working day after the
@@ -2142,7 +2459,7 @@ e_day_view_find_work_week_start (EDayView *day_view,
/* Calculate the first working day of the week, 0 (Sun) to 6 (Sat).
It will automatically default to the week start day if no days
are set as working days. */
- day = (day_view->week_start_day + 1) % 7;
+ day = (week_start_day + 1) % 7;
for (i = 0; i < 7; i++) {
if (day_view->working_days & (1 << day))
break;
@@ -2311,27 +2628,6 @@ e_day_view_recalc_day_starts (EDayView *day_view,
g_free (str);
}
-gboolean
-e_day_view_get_show_week_number (EDayView *day_view)
-{
- g_return_val_if_fail (day_view != NULL, FALSE);
-
- return GTK_WIDGET_VISIBLE (day_view->week_number_label);
-}
-
-void
-e_day_view_set_show_week_number (EDayView *day_view, gboolean show)
-{
- g_return_if_fail (day_view != NULL);
-
- if (e_day_view_get_show_week_number (day_view) != show) {
- if (show)
- gtk_widget_show (day_view->week_number_label);
- else
- gtk_widget_hide (day_view->week_number_label);
- }
-}
-
/* Whether we are displaying a work-week, in which case the display always
starts on the first day of the working week. */
gboolean
@@ -2389,7 +2685,7 @@ e_day_view_set_days_shown (EDayView *day_view,
}
gint
-e_day_view_get_mins_per_row (EDayView *day_view)
+e_day_view_get_mins_per_row (EDayView *day_view)
{
g_return_val_if_fail (E_IS_DAY_VIEW (day_view), -1);
@@ -2397,8 +2693,8 @@ e_day_view_get_mins_per_row (EDayView *day_view)
}
void
-e_day_view_set_mins_per_row (EDayView *day_view,
- gint mins_per_row)
+e_day_view_set_mins_per_row (EDayView *day_view,
+ gint mins_per_row)
{
gint day;
@@ -2416,6 +2712,8 @@ e_day_view_set_mins_per_row (EDayView *day_view,
day_view->mins_per_row = mins_per_row;
e_day_view_recalc_num_rows (day_view);
+ g_object_notify (G_OBJECT (day_view), "mins-per-row");
+
/* If we aren't visible, we'll sort it out later. */
if (!E_CALENDAR_VIEW (day_view)->in_focus)
return;
@@ -2440,7 +2738,7 @@ e_day_view_set_mins_per_row (EDayView *day_view,
/* This specifies the working days in the week. The value is a bitwise
combination of day flags. Defaults to Mon-Fri. */
EDayViewDays
-e_day_view_get_working_days (EDayView *day_view)
+e_day_view_get_working_days (EDayView *day_view)
{
g_return_val_if_fail (E_IS_DAY_VIEW (day_view), 0);
@@ -2448,8 +2746,8 @@ e_day_view_get_working_days (EDayView *day_view)
}
void
-e_day_view_set_working_days (EDayView *day_view,
- EDayViewDays days)
+e_day_view_set_working_days (EDayView *day_view,
+ EDayViewDays days)
{
g_return_if_fail (E_IS_DAY_VIEW (day_view));
@@ -2464,16 +2762,23 @@ e_day_view_set_working_days (EDayView *day_view,
/* We have to do this, as the new working days may have no effect on
the days shown, but we still want the background color to change. */
gtk_widget_queue_draw (day_view->main_canvas);
+
+ g_object_notify (G_OBJECT (day_view), "working-days");
}
static void
e_day_view_recalc_work_week_days_shown (EDayView *day_view)
{
+ ECalModel *model;
+ gint week_start_day;
gint first_day, last_day, i, days_shown;
gboolean has_working_days = FALSE;
+ model = e_calendar_view_get_model (E_CALENDAR_VIEW (day_view));
+ week_start_day = e_cal_model_get_week_start_day (model);
+
/* Find the first working day in the week, 0 (Sun) to 6 (Sat). */
- first_day = (day_view->week_start_day + 1) % 7;
+ first_day = (week_start_day + 1) % 7;
for (i = 0; i < 7; i++) {
if (day_view->working_days & (1 << first_day)) {
has_working_days = TRUE;
@@ -2484,7 +2789,7 @@ e_day_view_recalc_work_week_days_shown (EDayView *day_view)
if (has_working_days) {
/* Now find the last working day of the week, backwards. */
- last_day = day_view->week_start_day % 7;
+ last_day = week_start_day % 7;
for (i = 0; i < 7; i++) {
if (day_view->working_days & (1 << last_day))
break;
@@ -2503,86 +2808,162 @@ e_day_view_recalc_work_week_days_shown (EDayView *day_view)
/* The start and end time of the working day. This only affects the background
colors. */
+gint
+e_day_view_get_work_day_start_hour (EDayView *day_view)
+{
+ g_return_val_if_fail (E_IS_DAY_VIEW (day_view), -1);
+
+ return day_view->work_day_start_hour;
+}
+
void
-e_day_view_get_working_day (EDayView *day_view,
- gint *start_hour,
- gint *start_minute,
- gint *end_hour,
- gint *end_minute)
+e_day_view_set_work_day_start_hour (EDayView *day_view,
+ gint work_day_start_hour)
{
g_return_if_fail (E_IS_DAY_VIEW (day_view));
- *start_hour = day_view->work_day_start_hour;
- *start_minute = day_view->work_day_start_minute;
- *end_hour = day_view->work_day_end_hour;
- *end_minute = day_view->work_day_end_minute;
+ day_view->work_day_start_hour = work_day_start_hour;
+
+ gtk_widget_queue_draw (day_view->main_canvas);
+
+ g_object_notify (G_OBJECT (day_view), "work-day-start-hour");
+}
+
+gint
+e_day_view_get_work_day_start_minute (EDayView *day_view)
+{
+ g_return_val_if_fail (E_IS_DAY_VIEW (day_view), -1);
+
+ return day_view->work_day_start_minute;
}
void
-e_day_view_set_working_day (EDayView *day_view,
- gint start_hour,
- gint start_minute,
- gint end_hour,
- gint end_minute)
+e_day_view_set_work_day_start_minute (EDayView *day_view,
+ gint work_day_start_minute)
{
g_return_if_fail (E_IS_DAY_VIEW (day_view));
- day_view->work_day_start_hour = start_hour;
- day_view->work_day_start_minute = start_minute;
- day_view->work_day_end_hour = end_hour;
- day_view->work_day_end_minute = end_minute;
+ day_view->work_day_start_minute = work_day_start_minute;
gtk_widget_queue_draw (day_view->main_canvas);
+
+ g_object_notify (G_OBJECT (day_view), "work-day-start-minute");
}
-/* Whether we display the Marcus Bains Line in the main canvas and time canvas. */
-gboolean
-e_day_view_get_show_marcus_bains (EDayView *day_view)
+gint
+e_day_view_get_work_day_end_hour (EDayView *day_view)
{
- g_return_val_if_fail (E_IS_DAY_VIEW (day_view), TRUE);
- return day_view->show_marcus_bains_line;
+ g_return_val_if_fail (E_IS_DAY_VIEW (day_view), -1);
+
+ return day_view->work_day_end_hour;
+}
+
+void
+e_day_view_set_work_day_end_hour (EDayView *day_view,
+ gint work_day_end_hour)
+{
+ g_return_if_fail (E_IS_DAY_VIEW (day_view));
+
+ day_view->work_day_end_hour = work_day_end_hour;
+
+ gtk_widget_queue_draw (day_view->main_canvas);
+
+ g_object_notify (G_OBJECT (day_view), "work-day-end-hour");
+}
+
+gint
+e_day_view_get_work_day_end_minute (EDayView *day_view)
+{
+ g_return_val_if_fail (E_IS_DAY_VIEW (day_view), -1);
+
+ return day_view->work_day_end_minute;
+}
+
+void
+e_day_view_set_work_day_end_minute (EDayView *day_view,
+ gint work_day_end_minute)
+{
+ g_return_if_fail (E_IS_DAY_VIEW (day_view));
+
+ day_view->work_day_end_minute = work_day_end_minute;
+
+ gtk_widget_queue_draw (day_view->main_canvas);
+
+ g_object_notify (G_OBJECT (day_view), "work-day-end-minute");
}
/* Force a redraw of the Marcus Bains Lines */
void
-e_day_view_update_marcus_bains (EDayView *day_view)
+e_day_view_marcus_bains_update (EDayView *day_view)
{
g_return_if_fail (E_IS_DAY_VIEW (day_view));
gtk_widget_queue_draw (day_view->main_canvas);
gtk_widget_queue_draw (day_view->time_canvas);
}
-/* Update the variables controlling the Marcus Bains Line (display toggle, and colors). */
+gboolean
+e_day_view_marcus_bains_get_show_line (EDayView *day_view)
+{
+ g_return_val_if_fail (E_IS_DAY_VIEW (day_view), FALSE);
+
+ return day_view->marcus_bains_show_line;
+}
+
void
-e_day_view_set_marcus_bains (EDayView *day_view,
- gboolean show_line,
- const gchar *dayview_color,
- const gchar *timebar_color)
+e_day_view_marcus_bains_set_show_line (EDayView *day_view,
+ gboolean show_line)
{
g_return_if_fail (E_IS_DAY_VIEW (day_view));
- if ((day_view->show_marcus_bains_line != show_line) |
- (day_view->marcus_bains_day_view_color != dayview_color) |
- (day_view->marcus_bains_time_bar_color != timebar_color)) {
+ day_view->marcus_bains_show_line = show_line;
- if (day_view->marcus_bains_day_view_color)
- g_free (day_view->marcus_bains_day_view_color);
- if (day_view->marcus_bains_time_bar_color)
- g_free (day_view->marcus_bains_time_bar_color);
+ e_day_view_marcus_bains_update (day_view);
- day_view->show_marcus_bains_line = show_line;
- if (dayview_color)
- day_view->marcus_bains_day_view_color = g_strdup (dayview_color);
- else
- day_view->marcus_bains_day_view_color = NULL;
+ g_object_notify (G_OBJECT (day_view), "marcus-bains-show-line");
+}
- if (timebar_color)
- day_view->marcus_bains_time_bar_color = g_strdup (timebar_color);
- else
- day_view->marcus_bains_time_bar_color = NULL;
+const gchar *
+e_day_view_marcus_bains_get_day_view_color (EDayView *day_view)
+{
+ g_return_val_if_fail (E_IS_DAY_VIEW (day_view), NULL);
- e_day_view_update_marcus_bains (day_view);
- }
+ return day_view->marcus_bains_day_view_color;
+}
+
+void
+e_day_view_marcus_bains_set_day_view_color (EDayView *day_view,
+ const gchar *day_view_color)
+{
+ g_return_if_fail (E_IS_DAY_VIEW (day_view));
+
+ g_free (day_view->marcus_bains_day_view_color);
+ day_view->marcus_bains_day_view_color = g_strdup (day_view_color);
+
+ e_day_view_marcus_bains_update (day_view);
+
+ g_object_notify (G_OBJECT (day_view), "marcus-bains-day-view-color");
+}
+
+const gchar *
+e_day_view_marcus_bains_get_time_bar_color (EDayView *day_view)
+{
+ g_return_val_if_fail (E_IS_DAY_VIEW (day_view), NULL);
+
+ return day_view->marcus_bains_time_bar_color;
+}
+
+void
+e_day_view_marcus_bains_set_time_bar_color (EDayView *day_view,
+ const gchar *time_bar_color)
+{
+ g_return_if_fail (E_IS_DAY_VIEW (day_view));
+
+ g_free (day_view->marcus_bains_time_bar_color);
+ day_view->marcus_bains_time_bar_color = g_strdup (time_bar_color);
+
+ e_day_view_marcus_bains_update (day_view);
+
+ g_object_notify (G_OBJECT (day_view), "marcus-bains-time-bar-color");
}
/* Whether we display event end times in the main canvas. */
@@ -2621,32 +3002,6 @@ e_day_view_set_show_times_cb (EDayView *day_view,
return TRUE;
}
-/* The first day of the week, 0 (Monday) to 6 (Sunday). */
-gint
-e_day_view_get_week_start_day (EDayView *day_view)
-{
- g_return_val_if_fail (E_IS_DAY_VIEW (day_view), 0);
-
- return day_view->week_start_day;
-}
-
-void
-e_day_view_set_week_start_day (EDayView *day_view,
- gint week_start_day)
-{
- g_return_if_fail (E_IS_DAY_VIEW (day_view));
- g_return_if_fail (week_start_day >= 0);
- g_return_if_fail (week_start_day < 7);
-
- if (day_view->week_start_day == week_start_day)
- return;
-
- day_view->week_start_day = week_start_day;
-
- if (day_view->work_week_view)
- e_day_view_recalc_work_week (day_view);
-}
-
static void
e_day_view_recalc_work_week (EDayView *day_view)
{
@@ -3345,28 +3700,15 @@ e_day_view_on_event_double_click (EDayView *day_view,
}
static void
-popup_destroyed_cb (gpointer data, GObject *where_object_was)
-{
- EDayView *day_view = data;
-
- day_view->popup_event_day = -1;
- day_view->popup_event_num = -1;
-}
-
-static void
e_day_view_show_popup_menu (EDayView *day_view,
- GdkEvent *gdk_event,
+ GdkEventButton *event,
gint day,
gint event_num)
{
- GtkMenu *popup;
-
day_view->popup_event_day = day;
day_view->popup_event_num = event_num;
- 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());
+ e_calendar_view_popup_event (E_CALENDAR_VIEW (day_view), event);
}
static gboolean
@@ -3448,8 +3790,7 @@ e_day_view_on_event_right_click (EDayView *day_view,
gint day,
gint event_num)
{
- e_day_view_show_popup_menu (day_view, (GdkEvent*)bevent,
- day, event_num);
+ e_day_view_show_popup_menu (day_view, bevent, day, event_num);
}
static gboolean
@@ -3521,8 +3862,7 @@ e_day_view_update_calendar_selection_time (EDayView *day_view)
#if 0
calendar = e_calendar_view_get_calendar (E_CALENDAR_VIEW (day_view));
if (calendar)
- gnome_calendar_set_selected_time_range (calendar,
- start, end);
+ gnome_calendar_set_selected_time_range (calendar, start);
#endif
}
@@ -6322,7 +6662,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);
@@ -7776,10 +8117,14 @@ e_day_view_convert_time_to_display (EDayView *day_view,
const gchar **suffix,
gint *suffix_width)
{
+ ECalModel *model;
+
+ model = e_calendar_view_get_model (E_CALENDAR_VIEW (day_view));
+
/* Calculate the actual hour number to display. For 12-hour
format we convert 0-23 to 12-11am/12-11pm. */
*display_hour = hour;
- if (e_calendar_view_get_use_24_hour_format (E_CALENDAR_VIEW (day_view))) {
+ if (e_cal_model_get_use_24_hour_format (model)) {
*suffix = "";
*suffix_width = 0;
} else {
@@ -7801,11 +8146,13 @@ e_day_view_convert_time_to_display (EDayView *day_view,
gint
e_day_view_get_time_string_width (EDayView *day_view)
{
+ ECalModel *model;
gint time_width;
+ model = e_calendar_view_get_model (E_CALENDAR_VIEW (day_view));
time_width = day_view->digit_width * 4 + day_view->colon_width;
- if (!e_calendar_view_get_use_24_hour_format (E_CALENDAR_VIEW (day_view)))
+ if (!e_cal_model_get_use_24_hour_format (model))
time_width += MAX (day_view->am_string_width,
day_view->pm_string_width);
diff --git a/calendar/gui/e-day-view.h b/calendar/gui/e-day-view.h
index d4f1ca680c..6729186b21 100644
--- a/calendar/gui/e-day-view.h
+++ b/calendar/gui/e-day-view.h
@@ -182,16 +182,30 @@ struct _EDayViewEvent {
guint8 num_columns;
};
-#define E_DAY_VIEW(obj) G_TYPE_CHECK_INSTANCE_CAST (obj, e_day_view_get_type (), EDayView)
-#define E_DAY_VIEW_CLASS(klass) G_TYPE_CHECK_CLASS_CAST (klass, e_day_view_get_type (), EDayViewClass)
-#define E_IS_DAY_VIEW(obj) G_TYPE_CHECK_INSTANCE_TYPE (obj, e_day_view_get_type ())
+/* Standard GObject macros */
+#define E_TYPE_DAY_VIEW \
+ (e_day_view_get_type ())
+#define E_DAY_VIEW(obj) \
+ (G_TYPE_CHECK_INSTANCE_CAST \
+ ((obj), E_TYPE_DAY_VIEW, EDayView))
+#define E_DAY_VIEW_CLASS(cls) \
+ (G_TYPE_CHECK_CLASS_CAST \
+ ((cls), E_TYPE_DAY_VIEW, EDayViewClass))
+#define E_IS_DAY_VIEW(obj) \
+ (G_TYPE_CHECK_INSTANCE_TYPE \
+ ((obj), E_TYPE_DAY_VIEW))
+#define E_IS_DAY_VIEW_CLASS(cls) \
+ (G_TYPE_CHECK_CLASS_TYPE \
+ ((cls), E_TYPE_DAY_VIEW))
+#define E_DAY_VIEW_GET_CLASS(obj) \
+ (G_TYPE_INSTANCE_GET_CLASS \
+ ((obj), E_TYPE_DAY_VIEW, EDayViewClass))
typedef struct _EDayView EDayView;
typedef struct _EDayViewClass EDayViewClass;
-struct _EDayView
-{
- ECalendarView cal_view;
+struct _EDayView {
+ ECalendarView parent;
/* The top canvas where the dates are shown. */
GtkWidget *top_dates_canvas;
@@ -219,8 +233,6 @@ struct _EDayView
/* label showing week number in upper-left corner */
GtkWidget *week_number_label;
- /* option change notification id for week number */
- guint wn_notif_id;
/* S-expression for query and the query object */
ECalView *query;
@@ -295,16 +307,13 @@ struct _EDayView
gint work_day_end_minute;
/* Whether we show the Marcus Bains Line in the main canvas and time canvas. */
- gboolean show_marcus_bains_line;
+ gboolean marcus_bains_show_line;
gchar *marcus_bains_day_view_color;
gchar *marcus_bains_time_bar_color;
/* Whether we use show event end times in the main canvas. */
gboolean show_event_end_times;
- /* The first day of the week, 0 (Monday) to 6 (Sunday). */
- gint week_start_day;
-
/* This is set to TRUE when the widget is created, so it scrolls to
the start of the working day when first shown. */
gboolean scroll_to_work_day;
@@ -483,7 +492,7 @@ struct _EDayViewClass
};
GType e_day_view_get_type (void);
-GtkWidget* e_day_view_new (ECalModel *model);
+ECalendarView * e_day_view_new (ECalModel *model);
/* Whether we are displaying a work-week, in which case the display always
starts on the first day of the working week. */
@@ -511,34 +520,42 @@ void e_day_view_set_working_days (EDayView *day_view,
/* The start and end time of the working day. This only affects the background
colors. */
-void e_day_view_get_working_day (EDayView *day_view,
- gint *start_hour,
- gint *start_minute,
- gint *end_hour,
- gint *end_minute);
-void e_day_view_set_working_day (EDayView *day_view,
- gint start_hour,
- gint start_minute,
- gint end_hour,
- gint end_minute);
+gint e_day_view_get_work_day_start_hour (EDayView *day_view);
+void e_day_view_set_work_day_start_hour (EDayView *day_view,
+ gint work_day_start_hour);
+gint e_day_view_get_work_day_start_minute (EDayView *day_view);
+void e_day_view_set_work_day_start_minute (EDayView *day_view,
+ gint work_day_start_minute);
+gint e_day_view_get_work_day_end_hour (EDayView *day_view);
+void e_day_view_set_work_day_end_hour (EDayView *day_view,
+ gint work_day_end_hour);
+gint e_day_view_get_work_day_end_minute (EDayView *day_view);
+void e_day_view_set_work_day_end_minute (EDayView *day_view,
+ gint work_day_end_minute);
/* Whether we display the Marcus Bains Line in the main canvas and time canvas. */
-gboolean e_day_view_get_show_marcus_bains (EDayView *day_view);
-void e_day_view_set_marcus_bains (EDayView *day_view,
- gboolean show_line,
- const gchar *dayview_color,
- const gchar *timebar_color);
+void e_day_view_marcus_bains_update (EDayView *day_view);
+gboolean e_day_view_marcus_bains_get_show_line(EDayView *day_view);
+void e_day_view_marcus_bains_set_show_line(EDayView *day_view,
+ gboolean show_line);
+const gchar *
+ e_day_view_marcus_bains_get_day_view_color
+ (EDayView *day_view);
+void e_day_view_marcus_bains_set_day_view_color
+ (EDayView *day_view,
+ const gchar *day_view_color);
+const gchar *
+ e_day_view_marcus_bains_get_time_bar_color
+ (EDayView *day_view);
+void e_day_view_marcus_bains_set_time_bar_color
+ (EDayView *day_view,
+ const gchar *time_bar_color);
/* Whether we display event end times in the main canvas. */
gboolean e_day_view_get_show_event_end_times (EDayView *day_view);
void e_day_view_set_show_event_end_times (EDayView *day_view,
gboolean show);
-/* The first day of the week, 0 (Monday) to 6 (Sunday). */
-gint e_day_view_get_week_start_day (EDayView *day_view);
-void e_day_view_set_week_start_day (EDayView *day_view,
- gint week_start_day);
-
void e_day_view_delete_occurrence (EDayView *day_view);
/* Returns the number of selected events (0 or 1 at present). */
@@ -607,12 +624,6 @@ void e_day_view_ensure_rows_visible (EDayView *day_view,
gint start_row,
gint end_row);
-void e_day_view_update_marcus_bains (EDayView *day_view);
-
-/* Week number in upper-left corner of the day view widget */
-gboolean e_day_view_get_show_week_number (EDayView *day_view);
-void e_day_view_set_show_week_number (EDayView *day_view, gboolean show);
-
G_END_DECLS
#endif /* _E_DAY_VIEW_H_ */
diff --git a/calendar/gui/e-itip-control.c b/calendar/gui/e-itip-control.c
index 85b0accc33..dd231548e1 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-list-view.c b/calendar/gui/e-meeting-list-view.c
index 29a4f535d3..980370e3af 100644
--- a/calendar/gui/e-meeting-list-view.c
+++ b/calendar/gui/e-meeting-list-view.c
@@ -27,9 +27,6 @@
#include <string.h>
#include <gtk/gtk.h>
-#include <bonobo/bonobo-control.h>
-#include <bonobo/bonobo-widget.h>
-#include <bonobo/bonobo-exception.h>
#include <glib/gi18n.h>
#include <libebook/e-book.h>
#include <libebook/e-vcard.h>
@@ -830,7 +827,7 @@ process_section (EMeetingListView *view, GList *destinations, icalparameter_role
name = e_destination_get_name (dest);
/* Get the field as attendee from the backend */
- if (e_cal_get_ldap_attribute (e_meeting_store_get_e_cal (priv->store),
+ if (e_cal_get_ldap_attribute (e_meeting_store_get_client (priv->store),
&attr, NULL)) {
/* FIXME this should be more general */
if (!g_ascii_strcasecmp (attr, "icscalendar")) {
diff --git a/calendar/gui/e-meeting-store.c b/calendar/gui/e-meeting-store.c
index 20bc6388da..8b9f02c5a5 100644
--- a/calendar/gui/e-meeting-store.c
+++ b/calendar/gui/e-meeting-store.c
@@ -31,13 +31,17 @@
#include <libecal/e-cal-util.h>
#include <libecal/e-cal-time-util.h>
#include <libedataserver/e-data-server-util.h>
-#include "calendar-config.h"
#include "itip-utils.h"
#include "e-meeting-utils.h"
#include "e-meeting-attendee.h"
#include "e-meeting-store.h"
-#define ROW_VALID(store, row) (row >= 0 && row < store->priv->attendees->len)
+#define ROW_VALID(store, row) \
+ (row >= 0 && row < store->priv->attendees->len)
+
+#define E_MEETING_STORE_GET_PRIVATE(obj) \
+ (G_TYPE_INSTANCE_GET_PRIVATE \
+ ((obj), E_TYPE_MEETING_STORE, EMeetingStorePrivate))
struct _EMeetingStorePrivate {
GPtrArray *attendees;
@@ -76,7 +80,14 @@ struct _EMeetingStoreQueueData {
GPtrArray *data;
};
-static GObjectClass *parent_class = NULL;
+enum {
+ PROP_0,
+ PROP_CLIENT,
+ PROP_FREE_BUSY_TEMPLATE,
+ PROP_TIMEZONE
+};
+
+static gpointer parent_class;
static icalparameter_cutype
text_to_type (const gchar *type)
@@ -523,13 +534,73 @@ refresh_queue_remove (EMeetingStore *store, EMeetingAttendee *attendee)
}
static void
-ems_finalize (GObject *obj)
+meeting_store_set_property (GObject *object,
+ guint property_id,
+ const GValue *value,
+ GParamSpec *pspec)
+{
+ switch (property_id) {
+ case PROP_CLIENT:
+ e_meeting_store_set_client (
+ E_MEETING_STORE (object),
+ g_value_get_object (value));
+ return;
+
+ case PROP_FREE_BUSY_TEMPLATE:
+ e_meeting_store_set_free_busy_template (
+ E_MEETING_STORE (object),
+ g_value_get_string (value));
+ return;
+
+ case PROP_TIMEZONE:
+ e_meeting_store_set_timezone (
+ E_MEETING_STORE (object),
+ g_value_get_pointer (value));
+ return;
+ }
+
+ G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
+}
+
+static void
+meeting_store_get_property (GObject *object,
+ guint property_id,
+ GValue *value,
+ GParamSpec *pspec)
+{
+ switch (property_id) {
+ case PROP_CLIENT:
+ g_value_set_object (
+ value,
+ e_meeting_store_get_client (
+ E_MEETING_STORE (object)));
+ return;
+
+ case PROP_FREE_BUSY_TEMPLATE:
+ g_value_set_string (
+ value,
+ e_meeting_store_get_free_busy_template (
+ E_MEETING_STORE (object)));
+ return;
+
+ case PROP_TIMEZONE:
+ g_value_set_pointer (
+ value,
+ e_meeting_store_get_timezone (
+ E_MEETING_STORE (object)));
+ return;
+ }
+
+ G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
+}
+
+static void
+meeting_store_finalize (GObject *object)
{
- EMeetingStore *store = E_MEETING_STORE (obj);
EMeetingStorePrivate *priv;
gint i;
- priv = store->priv;
+ priv = E_MEETING_STORE_GET_PRIVATE (object);
for (i = 0; i < priv->attendees->len; i++)
g_object_unref (g_ptr_array_index (priv->attendees, i));
@@ -539,7 +610,9 @@ ems_finalize (GObject *obj)
g_object_unref (priv->client);
while (priv->refresh_queue->len > 0)
- refresh_queue_remove (store, g_ptr_array_index (priv->refresh_queue, 0));
+ refresh_queue_remove (
+ E_MEETING_STORE (object),
+ g_ptr_array_index (priv->refresh_queue, 0));
g_ptr_array_free (priv->refresh_queue, TRUE);
g_hash_table_destroy (priv->refresh_data);
@@ -550,75 +623,100 @@ ems_finalize (GObject *obj)
g_mutex_free (priv->mutex);
- g_free (priv);
-
- if (G_OBJECT_CLASS (parent_class)->finalize)
- (* G_OBJECT_CLASS (parent_class)->finalize) (obj);
+ /* Chain up to parent's finalize() method. */
+ G_OBJECT_CLASS (parent_class)->finalize (object);
}
static void
-ems_class_init (GObjectClass *klass)
+meeting_store_class_init (GObjectClass *class)
{
- parent_class = g_type_class_peek_parent (klass);
-
- klass->finalize = ems_finalize;
+ GObjectClass *object_class;
+
+ parent_class = g_type_class_peek_parent (class);
+ g_type_class_add_private (class, sizeof (EMeetingStorePrivate));
+
+ object_class = G_OBJECT_CLASS (class);
+ object_class->set_property = meeting_store_set_property;
+ object_class->get_property = meeting_store_get_property;
+ object_class->finalize = meeting_store_finalize;
+
+ g_object_class_install_property (
+ object_class,
+ PROP_CLIENT,
+ g_param_spec_object (
+ "client",
+ "Client",
+ NULL,
+ E_TYPE_CAL,
+ G_PARAM_READWRITE));
+
+ g_object_class_install_property (
+ object_class,
+ PROP_FREE_BUSY_TEMPLATE,
+ g_param_spec_string (
+ "free-busy-template",
+ "Free/Busy Template",
+ NULL,
+ NULL,
+ G_PARAM_READWRITE));
+
+ g_object_class_install_property (
+ object_class,
+ PROP_TIMEZONE,
+ g_param_spec_pointer (
+ "timezone",
+ "Timezone",
+ NULL,
+ G_PARAM_READWRITE));
}
static void
-ems_init (EMeetingStore *store)
+meeting_store_init (EMeetingStore *store)
{
- EMeetingStorePrivate *priv;
-
- priv = g_new0 (EMeetingStorePrivate, 1);
-
- store->priv = priv;
-
- priv->attendees = g_ptr_array_new ();
-
- priv->zone = calendar_config_get_icaltimezone ();
+ store->priv = E_MEETING_STORE_GET_PRIVATE (store);
- priv->fb_uri = calendar_config_get_free_busy_template ();
+ store->priv->attendees = g_ptr_array_new ();
+ store->priv->refresh_queue = g_ptr_array_new ();
+ store->priv->refresh_data = g_hash_table_new (g_str_hash, g_str_equal);
- priv->refresh_queue = g_ptr_array_new ();
- priv->refresh_data = g_hash_table_new (g_str_hash, g_str_equal);
+ store->priv->mutex = g_mutex_new ();
- priv->mutex = g_mutex_new ();
-
- priv->num_queries = 0;
+ store->priv->num_queries = 0;
}
GType
e_meeting_store_get_type (void)
{
- static GType ems_type = 0;
-
- if (!ems_type) {
- static const GTypeInfo ems_info = {
- sizeof (EMeetingStoreClass),
- NULL, /* base_init */
- NULL, /* base_finalize */
- (GClassInitFunc) ems_class_init,
- NULL, /* class_finalize */
- NULL, /* class_data */
- sizeof (EMeetingStore),
- 0,
- (GInstanceInitFunc) ems_init };
+ static GType type = 0;
+
+ if (G_UNLIKELY (type == 0)) {
+ static const GTypeInfo type_info = {
+ sizeof (EMeetingStoreClass),
+ (GBaseInitFunc) NULL,
+ (GBaseFinalizeFunc) NULL,
+ (GClassInitFunc) meeting_store_class_init,
+ (GClassFinalizeFunc) NULL,
+ NULL, /* class_data */
+ sizeof (EMeetingStore),
+ 0, /* n_preallocs */
+ (GInstanceInitFunc) meeting_store_init,
+ NULL /* value_table */
+ };
static const GInterfaceInfo tree_model_info = {
- (GInterfaceInitFunc) ems_tree_model_init,
- NULL,
- NULL };
+ (GInterfaceInitFunc) ems_tree_model_init,
+ NULL,
+ NULL
+ };
- ems_type = g_type_register_static (GTK_TYPE_LIST_STORE,
- "EMeetingStore",
- &ems_info, 0);
+ type = g_type_register_static (
+ GTK_TYPE_LIST_STORE, "EMeetingStore", &type_info, 0);
- g_type_add_interface_static (ems_type,
- GTK_TYPE_TREE_MODEL,
- &tree_model_info);
+ g_type_add_interface_static (
+ type, GTK_TYPE_TREE_MODEL, &tree_model_info);
}
- return ems_type;
+ return type;
}
GObject *
@@ -628,53 +726,69 @@ e_meeting_store_new (void)
}
ECal *
-e_meeting_store_get_e_cal (EMeetingStore *store)
+e_meeting_store_get_client (EMeetingStore *store)
{
+ g_return_val_if_fail (E_IS_MEETING_STORE (store), NULL);
+
return store->priv->client;
}
void
-e_meeting_store_set_e_cal (EMeetingStore *store, ECal *client)
+e_meeting_store_set_client (EMeetingStore *store,
+ ECal *client)
{
+ g_return_if_fail (E_IS_MEETING_STORE (store));
+
+ if (client != NULL) {
+ g_return_if_fail (E_IS_CAL (client));
+ g_object_ref (client);
+ }
+
if (store->priv->client != NULL)
g_object_unref (store->priv->client);
- if (client != NULL)
- g_object_ref (client);
store->priv->client = client;
+
+ g_object_notify (G_OBJECT (store), "client");
}
-icaltimezone *
-e_meeting_store_get_zone (EMeetingStore *store)
+const gchar *
+e_meeting_store_get_free_busy_template (EMeetingStore *store)
{
g_return_val_if_fail (E_IS_MEETING_STORE (store), NULL);
- return store->priv->zone;
+ return store->priv->fb_uri;
}
void
-e_meeting_store_set_zone (EMeetingStore *store, icaltimezone *zone)
+e_meeting_store_set_free_busy_template (EMeetingStore *store,
+ const gchar *free_busy_template)
{
g_return_if_fail (E_IS_MEETING_STORE (store));
- store->priv->zone = zone;
+ g_free (store->priv->fb_uri);
+ store->priv->fb_uri = g_strdup (free_busy_template);
+
+ g_object_notify (G_OBJECT (store), "free-busy-template");
}
-gchar *
-e_meeting_store_get_fb_uri (EMeetingStore *store)
+icaltimezone *
+e_meeting_store_get_timezone (EMeetingStore *store)
{
g_return_val_if_fail (E_IS_MEETING_STORE (store), NULL);
- return g_strdup (store->priv->fb_uri);
+ return store->priv->zone;
}
void
-e_meeting_store_set_fb_uri (EMeetingStore *store, const gchar *fb_uri)
+e_meeting_store_set_timezone (EMeetingStore *store,
+ icaltimezone *timezone)
{
g_return_if_fail (E_IS_MEETING_STORE (store));
- g_free (store->priv->fb_uri);
- store->priv->fb_uri = g_strdup (fb_uri);
+ store->priv->zone = timezone;
+
+ g_object_notify (G_OBJECT (store), "timezone");
}
static void
diff --git a/calendar/gui/e-meeting-store.h b/calendar/gui/e-meeting-store.h
index f67ad92ddd..62287a7b7e 100644
--- a/calendar/gui/e-meeting-store.h
+++ b/calendar/gui/e-meeting-store.h
@@ -20,24 +20,37 @@
*
*/
-#ifndef _E_MEETING_STORE_H_
-#define _E_MEETING_STORE_H_
+#ifndef E_MEETING_STORE_H
+#define E_MEETING_STORE_H
#include <gtk/gtk.h>
#include <libecal/e-cal.h>
#include "e-meeting-attendee.h"
-G_BEGIN_DECLS
+/* Standard GObject macros */
+#define E_TYPE_MEETING_STORE \
+ (e_meeting_store_get_type ())
+#define E_MEETING_STORE(obj) \
+ (G_TYPE_CHECK_INSTANCE_CAST \
+ ((obj), E_TYPE_MEETING_STORE, EMeetingStore))
+#define E_MEETING_STORE_CLASS(cls) \
+ (G_TYPE_CHECK_CLASS_CAST \
+ ((cls), E_TYPE_MEETING_STORE, EMeetingStoreClass))
+#define E_IS_MEETING_STORE(obj) \
+ (G_TYPE_CHECK_INSTANCE_TYPE \
+ ((obj), E_TYPE_MEETING_STORE))
+#define E_IS_MEETING_STORE_CLASS(cls) \
+ (G_TYPE_CHECK_CLASS_TYPE \
+ ((obj), E_TYPE_MEETING_STORE))
+#define E_MEETING_STORE_GET_CLASS(obj) \
+ (G_TYPE_INSTANCE_GET_CLASS \
+ ((obj), E_TYPE_MEETING_STORE, EMeetingStoreClass))
-#define E_TYPE_MEETING_STORE (e_meeting_store_get_type ())
-#define E_MEETING_STORE(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), E_TYPE_MEETING_STORE, EMeetingStore))
-#define E_MEETING_STORE_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), E_TYPE_MEETING_STORE, EMeetingStoreClass))
-#define E_IS_MEETING_STORE(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), E_TYPE_MEETING_STORE))
-#define E_IS_MEETING_STORE_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((obj), E_TYPE_MEETING_STORE))
+G_BEGIN_DECLS
-typedef struct _EMeetingStore EMeetingStore;
+typedef struct _EMeetingStore EMeetingStore;
+typedef struct _EMeetingStoreClass EMeetingStoreClass;
typedef struct _EMeetingStorePrivate EMeetingStorePrivate;
-typedef struct _EMeetingStoreClass EMeetingStoreClass;
typedef enum {
E_MEETING_STORE_ADDRESS_COL,
@@ -57,7 +70,6 @@ typedef enum {
struct _EMeetingStore {
GtkListStore parent;
-
EMeetingStorePrivate *priv;
};
@@ -65,48 +77,64 @@ struct _EMeetingStoreClass {
GtkListStoreClass parent_class;
};
-typedef gboolean (* EMeetingStoreRefreshCallback) (gpointer data);
-
-GType e_meeting_store_get_type (void);
-GObject *e_meeting_store_new (void);
-
-void e_meeting_store_set_value (EMeetingStore *im, gint row, gint col, const gchar *val);
-
-ECal *e_meeting_store_get_e_cal (EMeetingStore *im);
-void e_meeting_store_set_e_cal (EMeetingStore *im, ECal *client);
-
-icaltimezone *e_meeting_store_get_zone (EMeetingStore *im);
-void e_meeting_store_set_zone (EMeetingStore *im, icaltimezone *zone);
-
-gchar *e_meeting_store_get_fb_uri (EMeetingStore *im);
-void e_meeting_store_set_fb_uri (EMeetingStore *im, const gchar *fb_uri);
-
-void e_meeting_store_add_attendee (EMeetingStore *im, EMeetingAttendee *ia);
-EMeetingAttendee *e_meeting_store_add_attendee_with_defaults (EMeetingStore *im);
-
-void e_meeting_store_remove_attendee (EMeetingStore *im, EMeetingAttendee *ia);
-void e_meeting_store_remove_all_attendees (EMeetingStore *im);
-
-EMeetingAttendee *e_meeting_store_find_attendee (EMeetingStore *im, const gchar *address, gint *row);
-EMeetingAttendee *e_meeting_store_find_attendee_at_row (EMeetingStore *im, gint row);
-GtkTreePath *e_meeting_store_find_attendee_path (EMeetingStore *store, EMeetingAttendee *attendee);
-
-gint e_meeting_store_count_actual_attendees (EMeetingStore *im);
-const GPtrArray *e_meeting_store_get_attendees (EMeetingStore *im);
-
-void e_meeting_store_refresh_all_busy_periods (EMeetingStore *im,
- EMeetingTime *start,
- EMeetingTime *end,
- EMeetingStoreRefreshCallback call_back,
- gpointer data);
-void e_meeting_store_refresh_busy_periods (EMeetingStore *im,
- gint row,
- EMeetingTime *start,
- EMeetingTime *end,
- EMeetingStoreRefreshCallback call_back,
- gpointer data);
-
-guint e_meeting_store_get_num_queries (EMeetingStore *store);
+typedef gboolean (*EMeetingStoreRefreshCallback) (gpointer data);
+
+GType e_meeting_store_get_type (void);
+GObject * e_meeting_store_new (void);
+void e_meeting_store_set_value (EMeetingStore *meeting_store,
+ gint row,
+ gint col,
+ const gchar *val);
+ECal * e_meeting_store_get_client (EMeetingStore *meeting_store);
+void e_meeting_store_set_client (EMeetingStore *meeting_store,
+ ECal *client);
+const gchar * e_meeting_store_get_free_busy_template
+ (EMeetingStore *meeting_store);
+void e_meeting_store_set_free_busy_template
+ (EMeetingStore *meeting_store,
+ const gchar *free_busy_template);
+icaltimezone * e_meeting_store_get_timezone (EMeetingStore *meeting_store);
+void e_meeting_store_set_timezone (EMeetingStore *meeting_store,
+ icaltimezone *timezone);
+void e_meeting_store_add_attendee (EMeetingStore *meeting_store,
+ EMeetingAttendee *attendee);
+EMeetingAttendee *
+ e_meeting_store_add_attendee_with_defaults
+ (EMeetingStore *meeting_store);
+void e_meeting_store_remove_attendee (EMeetingStore *meeting_store,
+ EMeetingAttendee *attendee);
+void e_meeting_store_remove_all_attendees
+ (EMeetingStore *meeting_store);
+EMeetingAttendee *
+ e_meeting_store_find_attendee (EMeetingStore *meeting_store,
+ const gchar *address,
+ gint *row);
+EMeetingAttendee *
+ e_meeting_store_find_attendee_at_row
+ (EMeetingStore *meeting_store,
+ gint row);
+GtkTreePath * e_meeting_store_find_attendee_path
+ (EMeetingStore *meeting_store,
+ EMeetingAttendee *attendee);
+gint e_meeting_store_count_actual_attendees
+ (EMeetingStore *meeting_store);
+const GPtrArray *
+ e_meeting_store_get_attendees (EMeetingStore *meeting_store);
+void e_meeting_store_refresh_all_busy_periods
+ (EMeetingStore *meeting_store,
+ EMeetingTime *start,
+ EMeetingTime *end,
+ EMeetingStoreRefreshCallback call_back,
+ gpointer data);
+void e_meeting_store_refresh_busy_periods
+ (EMeetingStore *meeting_store,
+ gint row,
+ EMeetingTime *start,
+ EMeetingTime *end,
+ EMeetingStoreRefreshCallback call_back,
+ gpointer data);
+
+guint e_meeting_store_get_num_queries (EMeetingStore *meeting_store);
G_END_DECLS
diff --git a/calendar/gui/e-meeting-time-sel.c b/calendar/gui/e-meeting-time-sel.c
index 1f4f953c9c..ea6fca83c9 100644
--- a/calendar/gui/e-meeting-time-sel.c
+++ b/calendar/gui/e-meeting-time-sel.c
@@ -35,19 +35,28 @@
#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-binding.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"
#include "e-meeting-time-sel-item.h"
+#define E_MEETING_TIME_SELECTOR_GET_PRIVATE(obj) \
+ (G_TYPE_INSTANCE_GET_PRIVATE \
+ ((obj), E_TYPE_MEETING_TIME_SELECTOR, EMeetingTimeSelectorPrivate))
+
+struct _EMeetingTimeSelectorPrivate {
+ gint week_start_day;
+ guint show_week_numbers : 1;
+ guint use_24_hour_format : 1;
+};
+
/* An array of hour strings for 24 hour time, "0:00" .. "23:00". */
const gchar *EMeetingTimeSelectorHours[24] = {
"0:00", "1:00", "2:00", "3:00", "4:00", "5:00", "6:00", "7:00",
@@ -76,15 +85,20 @@ const gchar *EMeetingTimeSelectorHours12[24] = {
/* This is the maximum scrolling speed. */
#define E_MEETING_TIME_SELECTOR_MAX_SCROLL_SPEED 4
-/* Signals */
+enum {
+ PROP_0,
+ PROP_SHOW_WEEK_NUMBERS,
+ PROP_USE_24_HOUR_FORMAT,
+ PROP_WEEK_START_DAY
+};
+
enum {
CHANGED,
LAST_SIGNAL
};
-static gint mts_signals [LAST_SIGNAL] = { 0 };
+static gint signals [LAST_SIGNAL] = { 0 };
-static void e_meeting_time_selector_destroy (GtkObject *object);
static void e_meeting_time_selector_alloc_named_color (EMeetingTimeSelector * mts,
const gchar *name, GdkColor *c);
static void e_meeting_time_selector_add_key_color (EMeetingTimeSelector * mts,
@@ -188,40 +202,179 @@ static void row_inserted_cb (GtkTreeModel *model, GtkTreePath *path, GtkTreeIter
static void row_changed_cb (GtkTreeModel *model, GtkTreePath *path, GtkTreeIter *iter, gpointer data);
static void row_deleted_cb (GtkTreeModel *model, GtkTreePath *path, gpointer data);
-static void free_busy_template_changed_cb (GConfClient *client, guint cnxn_id,
- GConfEntry *entry, gpointer user_data);
+static void free_busy_template_changed_cb (EMeetingTimeSelector *mts);
G_DEFINE_TYPE (EMeetingTimeSelector, e_meeting_time_selector, GTK_TYPE_TABLE)
static void
-e_meeting_time_selector_class_init (EMeetingTimeSelectorClass * klass)
+meeting_time_selector_set_property (GObject *object,
+ guint property_id,
+ const GValue *value,
+ GParamSpec *pspec)
+{
+ switch (property_id) {
+ case PROP_SHOW_WEEK_NUMBERS:
+ e_meeting_time_selector_set_show_week_numbers (
+ E_MEETING_TIME_SELECTOR (object),
+ g_value_get_boolean (value));
+ return;
+
+ case PROP_USE_24_HOUR_FORMAT:
+ e_meeting_time_selector_set_use_24_hour_format (
+ E_MEETING_TIME_SELECTOR (object),
+ g_value_get_boolean (value));
+ return;
+
+ case PROP_WEEK_START_DAY:
+ e_meeting_time_selector_set_week_start_day (
+ E_MEETING_TIME_SELECTOR (object),
+ g_value_get_int (value));
+ return;
+ }
+
+ G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
+}
+
+static void
+meeting_time_selector_get_property (GObject *object,
+ guint property_id,
+ GValue *value,
+ GParamSpec *pspec)
+{
+ switch (property_id) {
+ case PROP_SHOW_WEEK_NUMBERS:
+ g_value_set_boolean (
+ value,
+ e_meeting_time_selector_get_show_week_numbers (
+ E_MEETING_TIME_SELECTOR (object)));
+ return;
+
+ case PROP_USE_24_HOUR_FORMAT:
+ g_value_set_boolean (
+ value,
+ e_meeting_time_selector_get_use_24_hour_format (
+ E_MEETING_TIME_SELECTOR (object)));
+ return;
+
+ case PROP_WEEK_START_DAY:
+ g_value_set_int (
+ value,
+ e_meeting_time_selector_get_week_start_day (
+ E_MEETING_TIME_SELECTOR (object)));
+ return;
+ }
+
+ G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
+}
+
+static void
+meeting_time_selector_destroy (GtkObject *object)
+{
+ EMeetingTimeSelector *mts;
+
+ mts = E_MEETING_TIME_SELECTOR (object);
+
+ e_meeting_time_selector_remove_timeout (mts);
+
+ if (mts->stipple) {
+ g_object_unref (mts->stipple);
+ mts->stipple = NULL;
+ }
+
+ if (mts->model) {
+ g_signal_handlers_disconnect_matched (
+ mts->model, G_SIGNAL_MATCH_DATA,
+ 0, 0, NULL, NULL, mts);
+ g_object_unref (mts->model);
+ mts->model = NULL;
+ }
+
+ mts->display_top = NULL;
+ mts->display_main = NULL;
+
+ if (mts->fb_refresh_not != 0) {
+ g_source_remove (mts->fb_refresh_not);
+ mts->fb_refresh_not = 0;
+ }
+
+ if (mts->style_change_idle_id != 0) {
+ g_source_remove (mts->style_change_idle_id);
+ mts->style_change_idle_id = 0;
+ }
+
+ if (GTK_OBJECT_CLASS (e_meeting_time_selector_parent_class)->destroy)
+ (*GTK_OBJECT_CLASS (e_meeting_time_selector_parent_class)->destroy)(object);
+}
+
+static void
+e_meeting_time_selector_class_init (EMeetingTimeSelectorClass * class)
{
- GtkObjectClass *object_class;
+ GObjectClass *object_class;
+ GtkObjectClass *gtk_object_class;
GtkWidgetClass *widget_class;
- object_class = (GtkObjectClass *) klass;
- widget_class = (GtkWidgetClass *) klass;
+ g_type_class_add_private (class, sizeof (EMeetingTimeSelectorPrivate));
- mts_signals [CHANGED] =
- g_signal_new ("changed",
- G_TYPE_FROM_CLASS (object_class),
- G_SIGNAL_RUN_FIRST,
- G_STRUCT_OFFSET (EMeetingTimeSelectorClass, changed),
- NULL, NULL,
- g_cclosure_marshal_VOID__VOID,
- G_TYPE_NONE, 0);
+ object_class = G_OBJECT_CLASS (class);
+ object_class->set_property = meeting_time_selector_set_property;
+ object_class->get_property = meeting_time_selector_get_property;
- object_class->destroy = e_meeting_time_selector_destroy;
+ gtk_object_class = GTK_OBJECT_CLASS (class);
+ gtk_object_class->destroy = meeting_time_selector_destroy;
- widget_class->realize = e_meeting_time_selector_realize;
- widget_class->unrealize = e_meeting_time_selector_unrealize;
- widget_class->style_set = e_meeting_time_selector_style_set;
+ widget_class = GTK_WIDGET_CLASS (class);
+ widget_class->realize = e_meeting_time_selector_realize;
+ widget_class->unrealize = e_meeting_time_selector_unrealize;
+ widget_class->style_set = e_meeting_time_selector_style_set;
widget_class->expose_event = e_meeting_time_selector_expose_event;
+
+ g_object_class_install_property (
+ object_class,
+ PROP_SHOW_WEEK_NUMBERS,
+ g_param_spec_boolean (
+ "show-week-numbers",
+ "Show Week Numbers",
+ NULL,
+ TRUE,
+ G_PARAM_READWRITE));
+
+ g_object_class_install_property (
+ object_class,
+ PROP_USE_24_HOUR_FORMAT,
+ g_param_spec_boolean (
+ "use-24-hour-format",
+ "Use 24-Hour Format",
+ NULL,
+ TRUE,
+ G_PARAM_READWRITE));
+
+ g_object_class_install_property (
+ object_class,
+ PROP_WEEK_START_DAY,
+ g_param_spec_int (
+ "week-start-day",
+ "Week Start Day",
+ NULL,
+ 0, /* Monday */
+ 6, /* Sunday */
+ 0,
+ G_PARAM_READWRITE));
+
+ signals[CHANGED] = g_signal_new (
+ "changed",
+ G_TYPE_FROM_CLASS (object_class),
+ G_SIGNAL_RUN_FIRST,
+ G_STRUCT_OFFSET (EMeetingTimeSelectorClass, changed),
+ NULL, NULL,
+ g_cclosure_marshal_VOID__VOID,
+ G_TYPE_NONE, 0);
}
static void
e_meeting_time_selector_init (EMeetingTimeSelector * mts)
{
+ mts->priv = E_MEETING_TIME_SELECTOR_GET_PRIVATE (mts);
+
/* The shadow is drawn in the border so it must be >= 2 pixels. */
gtk_container_set_border_width (GTK_CONTAINER (mts), 2);
@@ -237,10 +390,6 @@ e_meeting_time_selector_init (EMeetingTimeSelector * mts)
mts->list_view = NULL;
- mts->fb_uri_not =
- calendar_config_add_notification_free_busy_template ((GConfClientNotifyFunc) free_busy_template_changed_cb,
- mts);
-
mts->fb_refresh_not = 0;
mts->style_change_idle_id = 0;
}
@@ -301,6 +450,10 @@ e_meeting_time_selector_construct (EMeetingTimeSelector * mts, EMeetingStore *em
if (mts->model)
g_object_ref (mts->model);
+ g_signal_connect_swapped (
+ mts->model, "notify::free-busy-template",
+ G_CALLBACK (free_busy_template_changed_cb), mts);
+
g_signal_connect (mts->model, "row_inserted", G_CALLBACK (row_inserted_cb), mts);
g_signal_connect (mts->model, "row_changed", G_CALLBACK (row_changed_cb), mts);
g_signal_connect (mts->model, "row_deleted", G_CALLBACK (row_deleted_cb), mts);
@@ -587,8 +740,18 @@ e_meeting_time_selector_construct (EMeetingTimeSelector * mts, EMeetingStore *em
a11y_label);
}
e_date_edit_set_show_time (E_DATE_EDIT (mts->start_date_edit), TRUE);
- e_date_edit_set_use_24_hour_format (E_DATE_EDIT (mts->start_date_edit),
- calendar_config_get_24_hour_format ());
+
+ e_binding_new (
+ G_OBJECT (mts), "show-week-numbers",
+ G_OBJECT (mts->start_date_edit), "show-week-numbers");
+
+ e_binding_new (
+ G_OBJECT (mts), "use-24-hour-format",
+ G_OBJECT (mts->start_date_edit), "use-24-hour-format");
+
+ e_binding_new (
+ G_OBJECT (mts), "week-start-day",
+ G_OBJECT (mts->start_date_edit), "week-start-day");
gtk_table_attach (GTK_TABLE (table), mts->start_date_edit,
1, 2, 0, 1, GTK_FILL, 0, 0, 0);
@@ -614,8 +777,18 @@ e_meeting_time_selector_construct (EMeetingTimeSelector * mts, EMeetingStore *em
a11y_label);
}
e_date_edit_set_show_time (E_DATE_EDIT (mts->end_date_edit), TRUE);
- e_date_edit_set_use_24_hour_format (E_DATE_EDIT (mts->end_date_edit),
- calendar_config_get_24_hour_format ());
+
+ e_binding_new (
+ G_OBJECT (mts), "show-week-numbers",
+ G_OBJECT (mts->end_date_edit), "show-week-numbers");
+
+ e_binding_new (
+ G_OBJECT (mts), "use-24-hour-format",
+ G_OBJECT (mts->end_date_edit), "use-24-hour-format");
+
+ e_binding_new (
+ G_OBJECT (mts), "week-start-day",
+ G_OBJECT (mts->end_date_edit), "week-start-day");
gtk_table_attach (GTK_TABLE (table), mts->end_date_edit,
1, 2, 1, 2, GTK_FILL, 0, 0, 0);
@@ -667,7 +840,7 @@ e_meeting_time_selector_construct (EMeetingTimeSelector * mts, EMeetingStore *em
e_meeting_time_selector_update_end_date_edit (mts);
e_meeting_time_selector_update_date_popup_menus (mts);
- g_signal_emit (mts, mts_signals [CHANGED], 0);
+ g_signal_emit (mts, signals [CHANGED], 0);
}
/* This adds a color to the color key beneath the main display. If color is
@@ -755,7 +928,7 @@ e_meeting_time_selector_options_menu_detacher (GtkWidget *widget,
EMeetingTimeSelector *mts;
g_return_if_fail (widget != NULL);
- g_return_if_fail (IS_E_MEETING_TIME_SELECTOR (widget));
+ g_return_if_fail (E_IS_MEETING_TIME_SELECTOR (widget));
mts = E_MEETING_TIME_SELECTOR (widget);
g_return_if_fail (mts->options_menu == (GtkWidget*) menu);
@@ -770,7 +943,7 @@ e_meeting_time_selector_autopick_menu_detacher (GtkWidget *widget,
EMeetingTimeSelector *mts;
g_return_if_fail (widget != NULL);
- g_return_if_fail (IS_E_MEETING_TIME_SELECTOR (widget));
+ g_return_if_fail (E_IS_MEETING_TIME_SELECTOR (widget));
mts = E_MEETING_TIME_SELECTOR (widget);
g_return_if_fail (mts->autopick_menu == (GtkWidget*) menu);
@@ -783,52 +956,68 @@ e_meeting_time_selector_new (EMeetingStore *ems)
{
GtkWidget *mts;
- mts = GTK_WIDGET (g_object_new (e_meeting_time_selector_get_type (), NULL));
+ mts = g_object_new (E_TYPE_MEETING_TIME_SELECTOR, NULL);
e_meeting_time_selector_construct (E_MEETING_TIME_SELECTOR (mts), ems);
return mts;
}
-static void
-e_meeting_time_selector_destroy (GtkObject *object)
+gboolean
+e_meeting_time_selector_get_show_week_numbers (EMeetingTimeSelector *mts)
{
- EMeetingTimeSelector *mts;
+ g_return_val_if_fail (E_IS_MEETING_TIME_SELECTOR (mts), FALSE);
- mts = E_MEETING_TIME_SELECTOR (object);
+ return mts->priv->show_week_numbers;
+}
- e_meeting_time_selector_remove_timeout (mts);
+void
+e_meeting_time_selector_set_show_week_numbers (EMeetingTimeSelector *mts,
+ gboolean show_week_numbers)
+{
+ g_return_if_fail (E_IS_MEETING_TIME_SELECTOR (mts));
- if (mts->stipple) {
- g_object_unref (mts->stipple);
- mts->stipple = NULL;
- }
+ mts->priv->show_week_numbers = show_week_numbers;
- if (mts->model) {
- g_object_unref (mts->model);
- mts->model = NULL;
- }
+ g_object_notify (G_OBJECT (mts), "show-week-numbers");
+}
- mts->display_top = NULL;
- mts->display_main = NULL;
+gboolean
+e_meeting_time_selector_get_use_24_hour_format (EMeetingTimeSelector *mts)
+{
+ g_return_val_if_fail (E_IS_MEETING_TIME_SELECTOR (mts), FALSE);
- if (mts->fb_uri_not) {
- calendar_config_remove_notification (mts->fb_uri_not);
- mts->fb_uri_not = 0;
- }
+ return mts->priv->use_24_hour_format;
+}
- if (mts->fb_refresh_not != 0) {
- g_source_remove (mts->fb_refresh_not);
- mts->fb_refresh_not = 0;
- }
+void
+e_meeting_time_selector_set_use_24_hour_format (EMeetingTimeSelector *mts,
+ gboolean use_24_hour_format)
+{
+ g_return_if_fail (E_IS_MEETING_TIME_SELECTOR (mts));
- if (mts->style_change_idle_id != 0) {
- g_source_remove (mts->style_change_idle_id);
- mts->style_change_idle_id = 0;
- }
+ mts->priv->use_24_hour_format = use_24_hour_format;
- if (GTK_OBJECT_CLASS (e_meeting_time_selector_parent_class)->destroy)
- (*GTK_OBJECT_CLASS (e_meeting_time_selector_parent_class)->destroy)(object);
+ g_object_notify (G_OBJECT (mts), "use-24-hour-format");
+}
+
+gint
+e_meeting_time_selector_get_week_start_day (EMeetingTimeSelector *mts)
+{
+ g_return_val_if_fail (E_IS_MEETING_TIME_SELECTOR (mts), 0);
+
+ return mts->priv->week_start_day;
+}
+
+void
+e_meeting_time_selector_set_week_start_day (EMeetingTimeSelector *mts,
+ gint week_start_day)
+{
+ g_return_if_fail (E_IS_MEETING_TIME_SELECTOR (mts));
+
+ mts->priv->week_start_day = week_start_day;
+
+ g_object_notify (G_OBJECT (mts), "week-start-day");
}
static void
@@ -896,7 +1085,7 @@ style_change_idle_func (gpointer widget)
/* Calculate the widths of the hour strings in the style's font. */
max_hour_width = 0;
for (hour = 0; hour < 24; hour++) {
- if (calendar_config_get_24_hour_format ())
+ if (e_meeting_time_selector_get_use_24_hour_format (mts))
pango_layout_set_text (layout, EMeetingTimeSelectorHours [hour], -1);
else
pango_layout_set_text (layout, EMeetingTimeSelectorHours12 [hour], -1);
@@ -1054,7 +1243,7 @@ e_meeting_time_selector_set_meeting_time (EMeetingTimeSelector *mts,
gint end_hour,
gint end_minute)
{
- g_return_val_if_fail (IS_E_MEETING_TIME_SELECTOR (mts), FALSE);
+ g_return_val_if_fail (E_IS_MEETING_TIME_SELECTOR (mts), FALSE);
/* Check the dates are valid. */
if (!g_date_valid_dmy (start_day, start_month, start_year)
@@ -1083,7 +1272,7 @@ e_meeting_time_selector_set_meeting_time (EMeetingTimeSelector *mts,
e_meeting_time_selector_update_start_date_edit (mts);
e_meeting_time_selector_update_end_date_edit (mts);
- g_signal_emit (mts, mts_signals [CHANGED], 0);
+ g_signal_emit (mts, signals [CHANGED], 0);
return TRUE;
}
@@ -1116,7 +1305,7 @@ e_meeting_time_selector_set_working_hours_only (EMeetingTimeSelector *mts,
{
EMeetingTime saved_time;
- g_return_if_fail (IS_E_MEETING_TIME_SELECTOR (mts));
+ g_return_if_fail (E_IS_MEETING_TIME_SELECTOR (mts));
if (mts->working_hours_only == working_hours_only)
return;
@@ -1141,7 +1330,7 @@ e_meeting_time_selector_set_working_hours (EMeetingTimeSelector *mts,
{
EMeetingTime saved_time;
- g_return_if_fail (IS_E_MEETING_TIME_SELECTOR (mts));
+ g_return_if_fail (E_IS_MEETING_TIME_SELECTOR (mts));
if (mts->day_start_hour == day_start_hour
&& mts->day_start_minute == day_start_minute
@@ -1176,7 +1365,7 @@ e_meeting_time_selector_set_zoomed_out (EMeetingTimeSelector *mts,
{
EMeetingTime saved_time;
- g_return_if_fail (IS_E_MEETING_TIME_SELECTOR (mts));
+ g_return_if_fail (E_IS_MEETING_TIME_SELECTOR (mts));
if (mts->zoomed_out == zoomed_out)
return;
@@ -1270,7 +1459,7 @@ void
e_meeting_time_selector_set_autopick_option (EMeetingTimeSelector *mts,
EMeetingTimeSelectorAutopickOption autopick_option)
{
- g_return_if_fail (IS_E_MEETING_TIME_SELECTOR (mts));
+ g_return_if_fail (E_IS_MEETING_TIME_SELECTOR (mts));
switch (autopick_option) {
case E_MEETING_TIME_SELECTOR_ALL_PEOPLE_AND_RESOURCES:
@@ -1295,7 +1484,7 @@ e_meeting_time_selector_attendee_set_send_meeting_to (EMeetingTimeSelector *mts,
{
EMeetingTimeSelectorAttendee *attendee;
- g_return_if_fail (IS_E_MEETING_TIME_SELECTOR (mts));
+ g_return_if_fail (E_IS_MEETING_TIME_SELECTOR (mts));
g_return_if_fail (row >= 0);
g_return_if_fail (row < mts->attendees->len);
@@ -1308,7 +1497,7 @@ e_meeting_time_selector_attendee_set_send_meeting_to (EMeetingTimeSelector *mts,
void
e_meeting_time_selector_set_read_only (EMeetingTimeSelector *mts, gboolean read_only)
{
- g_return_if_fail (IS_E_MEETING_TIME_SELECTOR (mts));
+ g_return_if_fail (E_IS_MEETING_TIME_SELECTOR (mts));
gtk_widget_set_sensitive (GTK_WIDGET (mts->list_view), !read_only);
gtk_widget_set_sensitive (mts->display_main, !read_only);
@@ -1335,7 +1524,7 @@ e_meeting_time_selector_dump (EMeetingTimeSelector *mts)
gint row, period_num;
gchar buffer[128];
- g_return_if_fail (IS_E_MEETING_TIME_SELECTOR (mts));
+ g_return_if_fail (E_IS_MEETING_TIME_SELECTOR (mts));
g_print ("\n\nAttendee Information:\n");
@@ -1628,7 +1817,7 @@ e_meeting_time_selector_autopick (EMeetingTimeSelector *mts,
e_meeting_time_selector_update_start_date_edit (mts);
e_meeting_time_selector_update_end_date_edit (mts);
- g_signal_emit (mts, mts_signals [CHANGED], 0);
+ g_signal_emit (mts, signals [CHANGED], 0);
return;
}
@@ -2181,7 +2370,7 @@ e_meeting_time_selector_on_start_time_changed (GtkWidget *widget,
gtk_widget_queue_draw (mts->display_top);
gtk_widget_queue_draw (mts->display_main);
- g_signal_emit (mts, mts_signals [CHANGED], 0);
+ g_signal_emit (mts, signals [CHANGED], 0);
}
/* This is called when the meeting end time GnomeDateEdit is changed,
@@ -2230,7 +2419,7 @@ e_meeting_time_selector_on_end_time_changed (GtkWidget *widget,
gtk_widget_queue_draw (mts->display_top);
gtk_widget_queue_draw (mts->display_main);
- g_signal_emit (mts, mts_signals [CHANGED], 0);
+ g_signal_emit (mts, signals [CHANGED], 0);
}
/* This updates the ranges shown in the GnomeDateEdit popup menus, according
@@ -2444,7 +2633,7 @@ e_meeting_time_selector_drag_meeting_time (EMeetingTimeSelector *mts,
if (set_both_times
|| mts->dragging_position == E_MEETING_TIME_SELECTOR_POS_END
|| mts->dragging_position == E_MEETING_TIME_SELECTOR_POS_START)
- g_signal_emit (mts, mts_signals [CHANGED], 0);
+ g_signal_emit (mts, signals [CHANGED], 0);
}
/* This is the timeout function which handles auto-scrolling when the user is
@@ -2583,7 +2772,7 @@ e_meeting_time_selector_timeout_handler (gpointer data)
if (set_both_times
|| mts->dragging_position == E_MEETING_TIME_SELECTOR_POS_END
|| mts->dragging_position == E_MEETING_TIME_SELECTOR_POS_START)
- g_signal_emit (mts, mts_signals [CHANGED], 0);
+ g_signal_emit (mts, signals [CHANGED], 0);
scroll:
/* Redraw the canvases. We freeze and thaw the layouts so that they
@@ -2862,14 +3051,8 @@ row_deleted_cb (GtkTreeModel *model, GtkTreePath *path, gpointer data)
static gboolean
free_busy_timeout_refresh (gpointer data)
{
- gchar *fb_uri;
-
EMeetingTimeSelector *mts = E_MEETING_TIME_SELECTOR (data);
- fb_uri = calendar_config_get_free_busy_template ();
- e_meeting_store_set_fb_uri (mts->model, fb_uri);
- g_free (fb_uri);
-
/* Update all free/busy info, so we use the new template uri */
e_meeting_time_selector_refresh_free_busy (mts, 0, TRUE);
@@ -2879,19 +3062,12 @@ free_busy_timeout_refresh (gpointer data)
}
static void
-free_busy_template_changed_cb (GConfClient *client,
- guint cnxn_id,
- GConfEntry *entry,
- gpointer data)
+free_busy_template_changed_cb (EMeetingTimeSelector *mts)
{
- EMeetingTimeSelector *mts = E_MEETING_TIME_SELECTOR (data);
-
/* Wait REFRESH_PAUSE before refreshing, using the latest uri value */
- if (mts->fb_refresh_not != 0) {
+ if (mts->fb_refresh_not != 0)
g_source_remove (mts->fb_refresh_not);
- }
- mts->fb_refresh_not = g_timeout_add_seconds (REFRESH_PAUSE,
- free_busy_timeout_refresh,
- data);
+ mts->fb_refresh_not = g_timeout_add_seconds (
+ REFRESH_PAUSE, free_busy_timeout_refresh, mts);
}
diff --git a/calendar/gui/e-meeting-time-sel.h b/calendar/gui/e-meeting-time-sel.h
index b38dd98f74..1c61353c7b 100644
--- a/calendar/gui/e-meeting-time-sel.h
+++ b/calendar/gui/e-meeting-time-sel.h
@@ -20,8 +20,8 @@
*
*/
-#ifndef _E_MEETING_TIME_SELECTOR_H_
-#define _E_MEETING_TIME_SELECTOR_H_
+#ifndef E_MEETING_TIME_SELECTOR_H
+#define E_MEETING_TIME_SELECTOR_H
#include <gtk/gtk.h>
#include <libgnomecanvas/gnome-canvas.h>
@@ -31,14 +31,31 @@
#include "e-meeting-store.h"
#include "e-meeting-list-view.h"
-G_BEGIN_DECLS
-
/*
* EMeetingTimeSelector displays a list of attendees for a meeting and a
* graphical summary of the times which they are free and busy, allowing the
* user to select an appropriate time for a meeting.
*/
+/* Standard GObject macros */
+#define E_TYPE_MEETING_TIME_SELECTOR \
+ (e_meeting_time_selector_get_type ())
+#define E_MEETING_TIME_SELECTOR(obj) \
+ (G_TYPE_CHECK_INSTANCE_CAST \
+ ((obj), E_TYPE_MEETING_TIME_SELECTOR, EMeetingTimeSelector))
+#define E_MEETING_TIME_SELECTOR_CLASS(cls) \
+ (G_TYPE_CHECK_CLASS_CAST \
+ ((cls), E_TYPE_MEETING_TIME_SELECTOR, EMeetingTimeSelectorClass))
+#define E_IS_MEETING_TIME_SELECTOR(obj) \
+ (G_TYPE_CHECK_INSTANCE_TYPE \
+ ((obj), E_TYPE_MEETING_TIME_SELECTOR))
+#define E_IS_MEETING_TIME_SELECTOR_CLASS(cls) \
+ (G_TYPE_CHECK_CLASS_TYPE \
+ ((cls), E_TYPE_MEETING_TIME_SELECTOR))
+#define E_MEETING_TIME_SELECTOR_GET_CLASS(obj) \
+ (G_TYPE_INSTANCE_GET_CLASS \
+ ((obj), E_TYPE_MEETING_TIME_SELECTOR))
+
/* Define this to include the debugging functions. */
#undef E_MEETING_TIME_SELECTOR_DEBUG
@@ -48,6 +65,8 @@ G_BEGIN_DECLS
#define E_MEETING_TIME_SELECTOR_TEXT_Y_PAD 3
#define E_MEETING_TIME_SELECTOR_TEXT_X_PAD 2
+G_BEGIN_DECLS
+
/* This is used to specify the format used when displaying the dates.
The full format is like 'Sunday, September 12, 1999'. The abbreviated format
is like 'Sun 12/9/99'. The short format is like '12/9/99'. The actual
@@ -84,19 +103,17 @@ extern const gchar *EMeetingTimeSelectorHours[24];
/* An array of hour strings for 12 hour time, "12:00am" .. "11:00pm". */
extern const gchar *EMeetingTimeSelectorHours12[24];
-#define E_MEETING_TIME_SELECTOR(obj) G_TYPE_CHECK_INSTANCE_CAST (obj, e_meeting_time_selector_get_type (), EMeetingTimeSelector)
-#define E_MEETING_TIME_SELECTOR_CLASS(klass) G_TYPE_CHECK_CLASS_CAST (klass, e_meeting_time_selector_get_type (), EMeetingTimeSelectorClass)
-#define IS_E_MEETING_TIME_SELECTOR(obj) G_TYPE_CHECK_INSTANCE_TYPE (obj, e_meeting_time_selector_get_type ())
+typedef struct _EMeetingTimeSelector EMeetingTimeSelector;
+typedef struct _EMeetingTimeSelectorClass EMeetingTimeSelectorClass;
+typedef struct _EMeetingTimeSelectorPrivate EMeetingTimeSelectorPrivate;
-typedef struct _EMeetingTimeSelector EMeetingTimeSelector;
-typedef struct _EMeetingTimeSelectorClass EMeetingTimeSelectorClass;
-
-struct _EMeetingTimeSelector
-{
+struct _EMeetingTimeSelector {
/* We subclass a GtkTable which makes it easy to add extra widgets
if neccesary. */
GtkTable table;
+ EMeetingTimeSelectorPrivate *priv;
+
/*
* User Interface stuff - widgets, colors etc.
*/
@@ -246,9 +263,6 @@ struct _EMeetingTimeSelector
/* This is used to determine the delay between scrolls. */
gint scroll_count;
- /* The notification function id for Free/Busy template uri changes */
- guint fb_uri_not;
-
/* The notification function id for Free/Busy refreshes */
gboolean fb_refresh_not;
@@ -257,8 +271,7 @@ struct _EMeetingTimeSelector
guint style_change_idle_id;
};
-struct _EMeetingTimeSelectorClass
-{
+struct _EMeetingTimeSelectorClass {
GtkTableClass parent_class;
void (* changed) (EMeetingTimeSelector *mts);
@@ -269,9 +282,26 @@ struct _EMeetingTimeSelectorClass
* know where the data is coming from. This is mainly just for testing for now.
*/
-GType e_meeting_time_selector_get_type (void);
-GtkWidget* e_meeting_time_selector_new (EMeetingStore *ems);
-void e_meeting_time_selector_construct (EMeetingTimeSelector * mts, EMeetingStore *ems);
+GType e_meeting_time_selector_get_type (void);
+GtkWidget * e_meeting_time_selector_new (EMeetingStore *ems);
+void e_meeting_time_selector_construct
+ (EMeetingTimeSelector *mts,
+ EMeetingStore *ems);
+gboolean e_meeting_time_selector_get_show_week_numbers
+ (EMeetingTimeSelector *mts);
+void e_meeting_time_selector_set_show_week_numbers
+ (EMeetingTimeSelector *mts,
+ gboolean show_week_numbers);
+gboolean e_meeting_time_selector_get_use_24_hour_format
+ (EMeetingTimeSelector *mts);
+void e_meeting_time_selector_set_use_24_hour_format
+ (EMeetingTimeSelector *mts,
+ gboolean use_24_hour_format);
+gint e_meeting_time_selector_get_week_start_day
+ (EMeetingTimeSelector *mts);
+void e_meeting_time_selector_set_week_start_day
+ (EMeetingTimeSelector *mts,
+ gint week_start_day);
/* This returns the currently selected meeting time.
Note that months are 1-12 and days are 1-31. The start time is guaranteed to
@@ -383,4 +413,4 @@ gchar * e_meeting_time_selector_dump_date (GDate *date);
G_END_DECLS
-#endif /* _E_MEETING_TIME_SELECTOR_H_ */
+#endif /* E_MEETING_TIME_SELECTOR_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-config.c b/calendar/gui/e-memo-table-config.c
deleted file mode 100644
index d79dac7073..0000000000
--- a/calendar/gui/e-memo-table-config.c
+++ /dev/null
@@ -1,245 +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:
- * JP Rosevear <jpr@ximian.com>
- * Nathan Owens <pianocomp81@yahoo.com>
- *
- * Copyright (C) 1999-2008 Novell, Inc. (www.novell.com)
- *
- */
-
-#include "calendar-config.h"
-#include "e-cell-date-edit-config.h"
-#include "e-memo-table-config.h"
-
-struct _EMemoTableConfigPrivate {
- EMemoTable *table;
-
- ECellDateEditConfig *cell_config;
-
- GList *notifications;
-};
-
-G_DEFINE_TYPE (EMemoTableConfig, e_memo_table_config, G_TYPE_OBJECT)
-
-/* Property IDs */
-enum props {
- PROP_0,
- PROP_TABLE
-};
-
-static void
-e_memo_table_config_set_property (GObject *object, guint property_id, const GValue *value, GParamSpec *pspec)
-{
- EMemoTableConfig *table_config;
-
- table_config = E_MEMO_TABLE_CONFIG (object);
-
- switch (property_id) {
- case PROP_TABLE:
- e_memo_table_config_set_table (table_config, g_value_get_object (value));
- break;
- default:
- G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
- break;
- }
-}
-
-static void
-e_memo_table_config_get_property (GObject *object, guint property_id, GValue *value, GParamSpec *pspec)
-{
- EMemoTableConfig *table_config;
-
- table_config = E_MEMO_TABLE_CONFIG (object);
-
- switch (property_id) {
- case PROP_TABLE:
- g_value_set_object (value, e_memo_table_config_get_table (table_config));
- break;
- default:
- G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
- break;
- }
-}
-
-static void
-e_memo_table_config_dispose (GObject *object)
-{
- EMemoTableConfig *table_config = E_MEMO_TABLE_CONFIG (object);
-
- e_memo_table_config_set_table (table_config, NULL);
-
- if (G_OBJECT_CLASS (e_memo_table_config_parent_class)->dispose)
- G_OBJECT_CLASS (e_memo_table_config_parent_class)->dispose (object);
-}
-
-static void
-e_memo_table_config_finalize (GObject *object)
-{
- EMemoTableConfig *table_config = E_MEMO_TABLE_CONFIG (object);
- EMemoTableConfigPrivate *priv;
-
- priv = table_config->priv;
-
- g_free (priv);
-
- if (G_OBJECT_CLASS (e_memo_table_config_parent_class)->finalize)
- G_OBJECT_CLASS (e_memo_table_config_parent_class)->finalize (object);
-}
-
-static void
-e_memo_table_config_class_init (EMemoTableConfigClass *klass)
-{
- GObjectClass *gobject_class = G_OBJECT_CLASS (klass);
- GParamSpec *spec;
-
- /* Method override */
- gobject_class->set_property = e_memo_table_config_set_property;
- gobject_class->get_property = e_memo_table_config_get_property;
- gobject_class->dispose = e_memo_table_config_dispose;
- gobject_class->finalize = e_memo_table_config_finalize;
-
- spec = g_param_spec_object ("table", NULL, NULL, e_memo_table_get_type (),
- G_PARAM_READABLE | G_PARAM_WRITABLE | G_PARAM_CONSTRUCT);
- g_object_class_install_property (gobject_class, PROP_TABLE, spec);
-}
-
-static void
-e_memo_table_config_init (EMemoTableConfig *table_config)
-{
- table_config->priv = g_new0 (EMemoTableConfigPrivate, 1);
-
-}
-
-EMemoTableConfig *
-e_memo_table_config_new (EMemoTable *table)
-{
- EMemoTableConfig *table_config;
-
- table_config = g_object_new (e_memo_table_config_get_type (), "table", table, NULL);
-
- return table_config;
-}
-
-EMemoTable *
-e_memo_table_config_get_table (EMemoTableConfig *table_config)
-{
- EMemoTableConfigPrivate *priv;
-
- g_return_val_if_fail (table_config != NULL, NULL);
- g_return_val_if_fail (E_IS_MEMO_TABLE_CONFIG (table_config), NULL);
-
- priv = table_config->priv;
-
- return priv->table;
-}
-
-static void
-set_timezone (EMemoTable *table)
-{
- ECalModel *model;
- icaltimezone *zone;
-
- zone = calendar_config_get_icaltimezone ();
- model = e_memo_table_get_model (table);
- if (model)
- e_cal_model_set_timezone (model, zone);
-}
-
-static void
-timezone_changed_cb (GConfClient *client, guint id, GConfEntry *entry, gpointer data)
-{
- EMemoTableConfig *table_config = data;
- EMemoTableConfigPrivate *priv;
-
- priv = table_config->priv;
-
- set_timezone (priv->table);
-}
-
-static void
-set_twentyfour_hour (EMemoTable *table)
-{
- ECalModel *model;
- gboolean use_24_hour;
-
- use_24_hour = calendar_config_get_24_hour_format ();
-
- model = e_memo_table_get_model (table);
- if (model)
- e_cal_model_set_use_24_hour_format (model, use_24_hour);
-}
-
-static void
-twentyfour_hour_changed_cb (GConfClient *client, guint id, GConfEntry *entry, gpointer data)
-{
- EMemoTableConfig *table_config = data;
- EMemoTableConfigPrivate *priv;
-
- priv = table_config->priv;
-
- set_twentyfour_hour (priv->table);
-}
-
-void
-e_memo_table_config_set_table (EMemoTableConfig *table_config, EMemoTable *table)
-{
- EMemoTableConfigPrivate *priv;
- guint not;
- GList *l;
-
- g_return_if_fail (table_config != NULL);
- g_return_if_fail (E_IS_MEMO_TABLE_CONFIG (table_config));
-
- priv = table_config->priv;
-
- if (priv->table) {
- g_object_unref (priv->table);
- priv->table = NULL;
- }
-
- if (priv->cell_config) {
- g_object_unref (priv->cell_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;
-
- /* If the new view is NULL, return right now */
- if (!table)
- return;
-
- priv->table = g_object_ref (table);
-
- /* Time zone */
- 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));
-
- /* 24 Hour format */
- 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));
-
- /* Date cell */
- priv->cell_config = e_cell_date_edit_config_new (table->dates_cell);
-}
diff --git a/calendar/gui/e-memo-table-config.h b/calendar/gui/e-memo-table-config.h
deleted file mode 100644
index 68960d58dc..0000000000
--- a/calendar/gui/e-memo-table-config.h
+++ /dev/null
@@ -1,56 +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:
- * JP Rosevear <jpr@ximian.com>
- * Nathan Owens <pianocomp81@yahoo.com>
- *
- * Copyright (C) 1999-2008 Novell, Inc. (www.novell.com)
- *
- */
-
-#ifndef _E_MEMO_TABLE_CONFIG_H_
-#define _E_MEMO_TABLE_CONFIG_H_
-
-#include "e-memo-table.h"
-
-G_BEGIN_DECLS
-
-#define E_MEMO_TABLE_CONFIG(obj) G_TYPE_CHECK_INSTANCE_CAST (obj, e_memo_table_config_get_type (), EMemoTableConfig)
-#define E_MEMO_TABLE_CONFIG_CLASS(klass) G_TYPE_CHECK_CLASS_CAST (klass, e_memo_table_config_get_type (), EMemoTableConfigClass)
-#define E_IS_MEMO_TABLE_CONFIG(obj) G_TYPE_CHECK_INSTANCE_TYPE (obj, e_memo_table_config_get_type ())
-
-typedef struct _EMemoTableConfig EMemoTableConfig;
-typedef struct _EMemoTableConfigClass EMemoTableConfigClass;
-typedef struct _EMemoTableConfigPrivate EMemoTableConfigPrivate;
-
-struct _EMemoTableConfig {
- GObject parent;
-
- EMemoTableConfigPrivate *priv;
-};
-
-struct _EMemoTableConfigClass {
- GObjectClass parent_class;
-};
-
-GType e_memo_table_config_get_type (void);
-EMemoTableConfig *e_memo_table_config_new (EMemoTable *table);
-EMemoTable *e_memo_table_config_get_table (EMemoTableConfig *view_config);
-void e_memo_table_config_set_table (EMemoTableConfig *view_config, EMemoTable *table);
-
-G_END_DECLS
-
-#endif
diff --git a/calendar/gui/e-memo-table.c b/calendar/gui/e-memo-table.c
index 50158899ac..dddaa52132 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,7 +35,7 @@
#include <unistd.h>
#include <glib/gi18n.h>
#include <glib/gstdio.h>
-#include <gdk/gdkkeysyms.h>
+#include <e-util/e-binding.h>
#include <widgets/misc/e-gui-utils.h>
#include <table/e-cell-checkbox.h>
#include <table/e-cell-toggle.h>
@@ -43,110 +43,108 @@
#include <table/e-cell-combo.h>
#include <table/e-cell-date.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"
#include "dialogs/delete-error.h"
#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"
-enum TargetType{
- TARGET_TYPE_VCALENDAR
-};
+#define E_MEMO_TABLE_GET_PRIVATE(obj) \
+ (G_TYPE_INSTANCE_GET_PRIVATE \
+ ((obj), E_TYPE_MEMO_TABLE, EMemoTablePrivate))
-static GtkTargetEntry target_types[] = {
- { (gchar *) "text/x-calendar", 0, TARGET_TYPE_VCALENDAR },
- { (gchar *) "text/calendar", 0, TARGET_TYPE_VCALENDAR }
+struct _EMemoTablePrivate {
+ gpointer shell_view; /* weak pointer */
+ ECalModel *model;
};
-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);
+enum {
+ PROP_0,
+ PROP_MODEL,
+ PROP_SHELL_VIEW
+};
-/* 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[] = {
+ { (gchar *) "text/calendar", 0, TARGET_TYPE_VCALENDAR },
+ { (gchar *) "text/x-calendar", 0, TARGET_TYPE_VCALENDAR }
+};
+
+static struct tm e_memo_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_MEMO_MODEL_NUM_ICONS 2
-static const gchar * icon_names[E_MEMO_MODEL_NUM_ICONS] = {
- "stock_notes", "stock_insert-note"
+#define NUM_ICONS 2
+static const gchar *icon_names[NUM_ICONS] = {
+ "stock_notes",
+ "stock_insert-note"
};
-static GdkPixbuf* icon_pixbufs[E_MEMO_MODEL_NUM_ICONS] = { NULL };
+static GdkPixbuf *icon_pixbufs[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);
+}
+
+static void
+memo_table_emit_user_created (EMemoTable *memo_table)
+{
+ guint signal_id = signals[USER_CREATED];
- /* clipboard atom */
- if (!clipboard_atom)
- clipboard_atom = gdk_atom_intern ("CLIPBOARD", FALSE);
+ 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;
@@ -174,87 +172,443 @@ 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)
{
- g_signal_emit (memo_table, signals[USER_CREATED], 0);
+ 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)
+{
+ 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;
+ gboolean use_24_hour_format;
+ 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 ("");
+ use_24_hour_format = e_cal_model_get_use_24_hour_format (model);
+
+ 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, use_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, use_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_object_add_weak_pointer (
+ G_OBJECT (shell_view),
+ &memo_table->priv->shell_view);
+}
- g_return_val_if_fail (E_IS_MEMO_TABLE (user_data), FALSE);
+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);
- return ec_query_tooltip (widget, x, y, keyboard_mode, tooltip, GTK_WIDGET (e_memo_table_get_table (memo_table)), memo_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_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);
+
+ e_mutual_binding_new (
+ G_OBJECT (model), "timezone",
+ G_OBJECT (cell), "timezone");
+
+ e_mutual_binding_new (
+ G_OBJECT (model), "use-24-hour-format",
+ G_OBJECT (cell), "use-24-hour-format");
popup_cell = e_cell_date_edit_new ();
e_cell_popup_set_child (E_CELL_POPUP (popup_cell), cell);
g_object_unref (cell);
+
+ e_mutual_binding_new (
+ G_OBJECT (model), "use-24-hour-format",
+ G_OBJECT (popup_cell), "use-24-hour-format");
+
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 */
if (!icon_pixbufs[0])
- for (i = 0; i < E_MEMO_MODEL_NUM_ICONS; i++) {
+ for (i = 0; i < NUM_ICONS; i++) {
icon_pixbufs[i] = e_icon_factory_get_icon (icon_names[i], GTK_ICON_SIZE_MENU);
}
- 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]);
+ cell = e_cell_toggle_new (0, NUM_ICONS, icon_pixbufs);
+ e_table_extras_add_cell (extras, "icon", cell);
+ e_table_extras_add_pixbuf (extras, "icon", icon_pixbufs[0]);
+
+ /* set proper format component for a default 'date' cell renderer */
+ cell = e_table_extras_get_cell (extras, "date");
+ e_cell_date_set_format_component (E_CELL_DATE (cell), "calendar");
/* set proper format component for a default 'date' cell renderer */
cell = e_table_extras_get_cell (extras, "date");
@@ -262,51 +616,166 @@ e_memo_table_init (EMemoTable *memo_table)
/* 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);
+}
- 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);
+static void
+memo_table_init (EMemoTable *memo_table)
+{
+ memo_table->priv = E_MEMO_TABLE_GET_PRIVATE (memo_table);
+}
- a11y = gtk_widget_get_accessible (GTK_WIDGET(e_table));
- if (a11y)
- atk_object_set_name (a11y, _("Memos"));
+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);
+ }
+
+ 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 memo_table;
+ return g_object_new (
+ E_TYPE_MEMO_TABLE,
+ "model", model, "shell-view", shell_view, NULL);
}
/**
@@ -323,22 +792,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;
}
/**
@@ -353,20 +807,21 @@ e_memo_table_destroy (GtkObject *object)
ETable *
e_memo_table_get_table (EMemoTable *memo_table)
{
- g_return_val_if_fail (memo_table != NULL, NULL);
+ ETableScrolled *table_scrolled;
+
g_return_val_if_fail (E_IS_MEMO_TABLE (memo_table), NULL);
- return e_table_scrolled_get_table (E_TABLE_SCROLLED (memo_table->etable));
+ table_scrolled = E_TABLE_SCROLLED (memo_table->etable);
+
+ return e_table_scrolled_get_table (table_scrolled);
}
-void
-e_memo_table_open_selected (EMemoTable *memo_table)
+EShellView *
+e_memo_table_get_shell_view (EMemoTable *memo_table)
{
- ECalModelComponent *comp_data;
+ g_return_val_if_fail (E_IS_MEMO_TABLE (memo_table), NULL);
- comp_data = get_selected_comp (memo_table);
- if (comp_data != NULL)
- open_memo (memo_table, comp_data);
+ return memo_table->priv->shell_view;
}
/* Used from e_table_selected_row_foreach(); puts the selected row number in an
@@ -388,10 +843,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;
@@ -401,7 +858,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 {
@@ -415,38 +872,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;
@@ -458,27 +904,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.
*
@@ -495,7 +926,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)
@@ -523,6 +954,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.
*
@@ -537,12 +992,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;
@@ -550,7 +1026,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;
@@ -568,26 +1045,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.
@@ -606,16 +1063,18 @@ 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);
- if (!gtk_clipboard_set_with_data(clipboard, target_types, n_target_types,
- clipboard_get_calendar_cb,
- NULL, comp_str)) {
+ if (!gtk_clipboard_set_with_data (
+ clipboard, target_types, G_N_ELEMENTS (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);
+ gtk_clipboard_set_can_store (
+ clipboard, target_types + 1,
+ G_N_ELEMENTS (target_types) - 1);
}
/* free memory */
@@ -631,7 +1090,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));
@@ -645,13 +1106,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;
@@ -663,7 +1128,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 ();
@@ -694,7 +1161,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
@@ -703,7 +1170,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;
@@ -738,332 +1205,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, FALSE);
-
- 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);
-}
+ g_return_if_fail (E_IS_MEMO_TABLE (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);
+ clipboard = gtk_widget_get_clipboard (
+ GTK_WIDGET (memo_table), clipboard_atom);
- return e_memo_table_show_popup_menu (table, NULL,
- E_MEMO_TABLE(data));
-}
-
-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;
- }
-
- 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.
@@ -1072,12 +1250,15 @@ e_memo_table_save_state (EMemoTable *memo_table,
static struct tm
e_memo_table_get_current_time (ECellDateEdit *ecde, gpointer data)
{
+ EMemoTable *memo_table = data;
+ ECalModel *model;
icaltimezone *zone;
struct tm tmp_tm = { 0 };
struct icaltimetype tt;
/* Get the current timezone. */
- zone = calendar_config_get_icaltimezone ();
+ model = e_memo_table_get_model (memo_table);
+ zone = e_cal_model_get_timezone (model);
tt = icaltime_from_timet_with_zone (time (NULL), FALSE, zone);
@@ -1092,44 +1273,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..d7f1857374 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,51 @@ 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);
+icaltimezone * e_memo_table_get_timezone (EMemoTable *memo_table);
+void e_memo_table_set_timezone (EMemoTable *memo_table,
+ icaltimezone *timezone);
+gboolean e_memo_table_get_use_24_hour_format
+ (EMemoTable *memo_table);
+void e_memo_table_set_use_24_hour_format
+ (EMemoTable *memo_table,
+ gboolean use_24_hour_format);
+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
deleted file mode 100644
index 82f6d91c33..0000000000
--- a/calendar/gui/e-memos.c
+++ /dev/null
@@ -1,1229 +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 <glib/gi18n.h>
-#include <libedataserver/e-time-utils.h>
-#include <table/e-table-scrolled.h>
-#include <widgets/menus/gal-view-instance.h>
-#include <widgets/menus/gal-view-factory-etable.h>
-#include <widgets/menus/gal-view-etable.h>
-
-#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>
-#include "widgets/menus/gal-view-menus.h"
-#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"
-
-/* Private part of the GnomeCalendar structure */
-struct _EMemosPrivate {
- /* The memo lists for display */
- GHashTable *clients;
- GList *clients_list;
- ECal *default_client;
-
- ECalView *query;
-
- /* The EMemoTable showing the memos. */
- GtkWidget *memos_view;
- EMemoTableConfig *memos_view_config;
-
- /* Calendar search bar for memos */
- GtkWidget *search_bar;
-
- /* Paned widget */
- GtkWidget *paned;
-
- /* The preview */
- GtkWidget *preview;
-
- gchar *current_uid;
- gchar *sexp;
-
- /* View instance and the view menus handler */
- GalViewInstance *view_instance;
- GalViewMenus *view_menus;
-
- GList *notifications;
-};
-
-static void setup_widgets (EMemos *memos);
-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 {
- SELECTION_CHANGED,
- SOURCE_ADDED,
- SOURCE_REMOVED,
- 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)
-{
- EMemos *memos;
- EMemosPrivate *priv;
-
- memos = E_MEMOS (data);
- priv = memos->priv;
-
- if (priv->sexp)
- g_free (priv->sexp);
-
- priv->sexp = g_strdup (sexp);
-
- update_view (memos);
-}
-
-/* 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)
-{
- EMemos *memos;
- EMemosPrivate *priv;
- ECalModel *model;
-
- memos = E_MEMOS (data);
- priv = memos->priv;
-
- model = e_memo_table_get_model (E_MEMO_TABLE (priv->memos_view));
- 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)
-{
- EMemosPrivate *priv;
- icaltimezone *zone;
- GList *l;
-
- priv = memos->priv;
-
- zone = calendar_config_get_icaltimezone ();
- for (l = priv->clients_list; 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, 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);
-}
-
-static void
-timezone_changed_cb (GConfClient *client, guint id, GConfEntry *entry, gpointer data)
-{
- EMemos *memos = data;
-
- set_timezone (memos);
-}
-
-static void
-update_view (EMemos *memos)
-{
- EMemosPrivate *priv;
- ECalModel *model;
-
- priv = memos->priv;
-
- model = e_memo_table_get_model (E_MEMO_TABLE (priv->memos_view));
-
- e_cal_model_set_search_query (model, priv->sexp);
-
- e_cal_component_memo_preview_clear (E_CAL_COMPONENT_MEMO_PREVIEW (priv->preview));
-}
-
-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;
- guint not;
-
- priv = memos->priv;
-
- /* Timezone */
- set_timezone (memos);
-
- not = calendar_config_add_notification_timezone (timezone_changed_cb, 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)
-{
- EMemosPrivate *priv;
- ETable *etable;
- ECalModel *model;
-
- priv = memos->priv;
-
- priv->search_bar = cal_search_bar_new (CAL_SEARCH_MEMOS_DEFAULT);
- g_signal_connect (priv->search_bar, "sexp_changed",
- G_CALLBACK (search_bar_sexp_changed_cb), memos);
- g_signal_connect (priv->search_bar, "category_changed",
- G_CALLBACK (search_bar_category_changed_cb), memos);
-
- categories_changed_cb (NULL, memos);
-
- gtk_table_attach (GTK_TABLE (memos), priv->search_bar, 0, 1, 0, 1,
- 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 */
-static void
-e_memos_class_init (EMemosClass *klass)
-{
- GtkObjectClass *object_class;
-
- object_class = (GtkObjectClass *) klass;
-
- e_memos_signals[SELECTION_CHANGED] =
- g_signal_new ("selection_changed",
- G_TYPE_FROM_CLASS (object_class),
- G_SIGNAL_RUN_LAST,
- G_STRUCT_OFFSET (EMemosClass, selection_changed),
- NULL, NULL,
- g_cclosure_marshal_VOID__INT,
- G_TYPE_NONE, 1,
- G_TYPE_INT);
-
- e_memos_signals[SOURCE_ADDED] =
- g_signal_new ("source_added",
- G_TYPE_FROM_CLASS (object_class),
- G_SIGNAL_RUN_FIRST,
- G_STRUCT_OFFSET (EMemosClass, source_added),
- NULL, NULL,
- g_cclosure_marshal_VOID__OBJECT,
- G_TYPE_NONE,
- 1,
- G_TYPE_OBJECT);
-
- e_memos_signals[SOURCE_REMOVED] =
- g_signal_new ("source_removed",
- G_TYPE_FROM_CLASS (object_class),
- G_SIGNAL_RUN_FIRST,
- G_STRUCT_OFFSET (EMemosClass, source_removed),
- NULL, NULL,
- g_cclosure_marshal_VOID__OBJECT,
- G_TYPE_NONE,
- 1,
- G_TYPE_OBJECT);
-
- object_class->destroy = e_memos_destroy;
-
- klass->selection_changed = NULL;
- klass->source_added = NULL;
- klass->source_removed = NULL;
-}
-
-static void
-categories_changed_cb (gpointer object, gpointer user_data)
-{
- GList *cat_list;
- GPtrArray *cat_array;
- EMemosPrivate *priv;
- EMemos *memos = user_data;
-
- priv = memos->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 (CAL_SEARCH_BAR(priv->search_bar), cat_array);
-
- g_ptr_array_free (cat_array, TRUE);
-}
-
-/* Object initialization function for the gnome calendar */
-static void
-e_memos_init (EMemos *memos)
-{
- EMemosPrivate *priv;
-
- priv = g_new0 (EMemosPrivate, 1);
- memos->priv = priv;
-
- setup_config (memos);
- setup_widgets (memos);
-
- e_categories_register_change_listener (G_CALLBACK (categories_changed_cb), memos);
-
- 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;
- 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)
-{
- EMemos *memos;
- EMemosPrivate *priv;
-
- g_return_if_fail (object != NULL);
- g_return_if_fail (E_IS_MEMOS (object));
-
- memos = E_MEMOS (object);
- priv = memos->priv;
-
- if (priv) {
- GList *l;
-
- e_categories_unregister_change_listener (G_CALLBACK (categories_changed_cb), memos);
-
- /* 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,
- 0, 0, NULL, NULL, memos);
- }
-
- 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;
- }
-
- if (priv->sexp) {
- g_free (priv->sexp);
- priv->sexp = NULL;
- }
-
- if (priv->memos_view_config) {
- g_object_unref (priv->memos_view_config);
- priv->memos_view_config = NULL;
- }
-
- for (l = priv->notifications; l; l = l->next)
- calendar_config_remove_notification (GPOINTER_TO_UINT (l->data));
- priv->notifications = NULL;
-
- g_free (priv);
- memos->priv = NULL;
- }
-
- if (GTK_OBJECT_CLASS (e_memos_parent_class)->destroy)
- (* 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)
-{
- 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_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
deleted file mode 100644
index a03541c6d6..0000000000
--- a/calendar/gui/e-memos.h
+++ /dev/null
@@ -1,85 +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_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>
-#include "e-memo-table.h"
-
-#define E_TYPE_MEMOS (e_memos_get_type ())
-#define E_MEMOS(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), E_TYPE_MEMOS, EMemos))
-#define E_MEMOS_CLASS(klass) (G_TYPE_CHECK_INSTANCE_CAST_CLASS ((klass), E_TYPE_MEMOS, \
- EMemosClass))
-#define E_IS_MEMOS(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), E_TYPE_MEMOS))
-#define E_IS_MEMOS_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), E_TYPE_MEMOS))
-
-typedef struct _EMemos EMemos;
-typedef struct _EMemosClass EMemosClass;
-typedef struct _EMemosPrivate EMemosPrivate;
-
-struct _EMemos {
- GtkTable table;
-
- /* Private data */
- EMemosPrivate *priv;
-};
-
-struct _EMemosClass {
- GtkTableClass parent_class;
-
- /* Notification signals */
- void (* selection_changed) (EMemos *memos, gint n_selected);
- void (* source_added) (EMemos *memos, ESource *source);
- void (* source_removed) (EMemos *memos, ESource *source);
-};
-
-GType e_memos_get_type (void);
-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);
-ECal *e_memos_get_default_client (EMemos *memos);
-
-void e_memos_open_memo (EMemos *memos);
-void e_memos_new_memo (EMemos *memos);
-void e_memos_complete_selected (EMemos *memos);
-void e_memos_delete_selected (EMemos *memos);
-
-void e_memos_setup_view_menus (EMemos *memos, BonoboUIComponent *uic);
-void e_memos_discard_view_menus (EMemos *memos);
-
-EMemoTable *e_memos_get_calendar_table (EMemos *memos);
-GtkWidget *e_memos_get_preview (EMemos *memos);
-
-#endif /* _E_MEMOS_H_ */
diff --git a/calendar/gui/e-mini-calendar-config.c b/calendar/gui/e-mini-calendar-config.c
deleted file mode 100644
index d9b2192ad2..0000000000
--- a/calendar/gui/e-mini-calendar-config.c
+++ /dev/null
@@ -1,235 +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:
- * JP Rosevear <jpr@ximian.com>
- *
- * Copyright (C) 1999-2008 Novell, Inc. (www.novell.com)
- *
- */
-
-#include "calendar-config.h"
-#include "e-mini-calendar-config.h"
-
-struct _EMiniCalendarConfigPrivate {
- ECalendar *mini_cal;
-
- GList *notifications;
-};
-
-/* Property IDs */
-enum props {
- PROP_0,
- PROP_CALENDAR
-};
-
-G_DEFINE_TYPE (EMiniCalendarConfig, e_mini_calendar_config, G_TYPE_OBJECT)
-
-static void
-e_mini_calendar_config_set_property (GObject *object, guint property_id, const GValue *value, GParamSpec *pspec)
-{
- EMiniCalendarConfig *mini_config;
-
- mini_config = E_MINI_CALENDAR_CONFIG (object);
-
- switch (property_id) {
- case PROP_CALENDAR:
- e_mini_calendar_config_set_calendar (mini_config, g_value_get_object (value));
- break;
- default:
- G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
- break;
- }
-}
-
-static void
-e_mini_calendar_config_get_property (GObject *object, guint property_id, GValue *value, GParamSpec *pspec)
-{
- EMiniCalendarConfig *mini_config;
-
- mini_config = E_MINI_CALENDAR_CONFIG (object);
-
- switch (property_id) {
- case PROP_CALENDAR:
- g_value_set_object (value, e_mini_calendar_config_get_calendar (mini_config));
- break;
- default:
- G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
- break;
- }
-}
-
-static void
-e_mini_calendar_config_dispose (GObject *object)
-{
- EMiniCalendarConfig *mini_config = E_MINI_CALENDAR_CONFIG (object);
-
- e_mini_calendar_config_set_calendar (mini_config, NULL);
-
- if (G_OBJECT_CLASS (e_mini_calendar_config_parent_class)->dispose)
- G_OBJECT_CLASS (e_mini_calendar_config_parent_class)->dispose (object);
-}
-
-static void
-e_mini_calendar_config_finalize (GObject *object)
-{
- EMiniCalendarConfig *mini_config = E_MINI_CALENDAR_CONFIG (object);
- EMiniCalendarConfigPrivate *priv;
-
- priv = mini_config->priv;
-
- g_free (priv);
-
- if (G_OBJECT_CLASS (e_mini_calendar_config_parent_class)->finalize)
- G_OBJECT_CLASS (e_mini_calendar_config_parent_class)->finalize (object);
-}
-
-static void
-e_mini_calendar_config_class_init (EMiniCalendarConfigClass *klass)
-{
- GObjectClass *gobject_class = G_OBJECT_CLASS (klass);
- GParamSpec *spec;
-
- /* Method override */
- gobject_class->set_property = e_mini_calendar_config_set_property;
- gobject_class->get_property = e_mini_calendar_config_get_property;
- gobject_class->dispose = e_mini_calendar_config_dispose;
- gobject_class->finalize = e_mini_calendar_config_finalize;
-
- spec = g_param_spec_object ("calendar", NULL, NULL, e_calendar_get_type (),
- G_PARAM_READABLE | G_PARAM_WRITABLE | G_PARAM_CONSTRUCT);
- g_object_class_install_property (gobject_class, PROP_CALENDAR, spec);
-}
-
-static void
-e_mini_calendar_config_init (EMiniCalendarConfig *mini_config)
-{
- mini_config->priv = g_new0 (EMiniCalendarConfigPrivate, 1);
-
-}
-
-EMiniCalendarConfig *
-e_mini_calendar_config_new (ECalendar *mini_cal)
-{
- EMiniCalendarConfig *mini_config;
-
- mini_config = g_object_new (e_mini_calendar_config_get_type (), "calendar", mini_cal, NULL);
-
- return mini_config;
-}
-
-ECalendar *
-e_mini_calendar_config_get_calendar (EMiniCalendarConfig *mini_config)
-{
- EMiniCalendarConfigPrivate *priv;
-
- g_return_val_if_fail (mini_config != NULL, NULL);
- g_return_val_if_fail (E_IS_MINI_CALENDAR_CONFIG (mini_config), NULL);
-
- priv = mini_config->priv;
-
- return priv->mini_cal;
-}
-
-static void
-set_week_start (ECalendar *mini_cal)
-{
- gint week_start_day;
-
- week_start_day = calendar_config_get_week_start_day ();
-
- /* Convert it to 0 (Mon) to 6 (Sun), which is what we use. */
- week_start_day = (week_start_day + 6) % 7;
-
- gnome_canvas_item_set (GNOME_CANVAS_ITEM (mini_cal->calitem),
- "week_start_day", week_start_day,
- NULL);
-}
-
-static void
-week_start_changed_cb (GConfClient *client, guint id, GConfEntry *entry, gpointer data)
-{
- EMiniCalendarConfig *mini_config = data;
- EMiniCalendarConfigPrivate *priv;
-
- priv = mini_config->priv;
-
- set_week_start (priv->mini_cal);
-}
-
-static void
-set_dnav_show_week_no (ECalendar *mini_cal)
-{
- gboolean show_week_no;
-
- show_week_no = calendar_config_get_dnav_show_week_no ();
-
- gnome_canvas_item_set (GNOME_CANVAS_ITEM (mini_cal->calitem),
- "show_week_numbers", show_week_no,
- NULL);
-}
-
-static void
-dnav_show_week_no_changed_cb (GConfClient *client, guint id, GConfEntry *entry, gpointer data)
-{
- EMiniCalendarConfig *mini_config = data;
- EMiniCalendarConfigPrivate *priv;
-
- priv = mini_config->priv;
-
- set_dnav_show_week_no (priv->mini_cal);
-}
-
-void
-e_mini_calendar_config_set_calendar (EMiniCalendarConfig *mini_config, ECalendar *mini_cal)
-{
- EMiniCalendarConfigPrivate *priv;
- guint not;
- GList *l;
-
- g_return_if_fail (mini_config != NULL);
- g_return_if_fail (E_IS_MINI_CALENDAR_CONFIG (mini_config));
-
- priv = mini_config->priv;
-
- if (priv->mini_cal) {
- g_object_unref (priv->mini_cal);
- priv->mini_cal = 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;
-
- /* If the new view is NULL, return right now */
- if (!mini_cal)
- return;
-
- priv->mini_cal = g_object_ref (mini_cal);
-
- /* Week start */
- set_week_start (mini_cal);
-
- not = calendar_config_add_notification_week_start_day (week_start_changed_cb, mini_config);
- priv->notifications = g_list_prepend (priv->notifications, GUINT_TO_POINTER (not));
-
- /* Show week numbers */
- set_dnav_show_week_no (mini_cal);
-
- not = calendar_config_add_notification_dnav_show_week_no (dnav_show_week_no_changed_cb, mini_config);
- priv->notifications = g_list_prepend (priv->notifications, GUINT_TO_POINTER (not));
-}
diff --git a/calendar/gui/e-mini-calendar-config.h b/calendar/gui/e-mini-calendar-config.h
deleted file mode 100644
index 60c88a1b9c..0000000000
--- a/calendar/gui/e-mini-calendar-config.h
+++ /dev/null
@@ -1,55 +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:
- * JP Rosevear <jpr@ximian.com>
- *
- * Copyright (C) 1999-2008 Novell, Inc. (www.novell.com)
- *
- */
-
-#ifndef _E_MINI_CALENDAR_CONFIG_H_
-#define _E_MINI_CALENDAR_CONFIG_H_
-
-#include <misc/e-calendar.h>
-
-G_BEGIN_DECLS
-
-#define E_MINI_CALENDAR_CONFIG(obj) G_TYPE_CHECK_INSTANCE_CAST (obj, e_mini_calendar_config_get_type (), EMiniCalendarConfig)
-#define E_MINI_CALENDAR_CONFIG_CLASS(klass) G_TYPE_CHECK_CLASS_CAST (klass, e_mini_calendar_config_get_type (), EMiniCalendarConfigClass)
-#define E_IS_MINI_CALENDAR_CONFIG(obj) G_TYPE_CHECK_INSTANCE_TYPE (obj, e_mini_calendar_config_get_type ())
-
-typedef struct _EMiniCalendarConfig EMiniCalendarConfig;
-typedef struct _EMiniCalendarConfigClass EMiniCalendarConfigClass;
-typedef struct _EMiniCalendarConfigPrivate EMiniCalendarConfigPrivate;
-
-struct _EMiniCalendarConfig {
- GObject parent;
-
- EMiniCalendarConfigPrivate *priv;
-};
-
-struct _EMiniCalendarConfigClass {
- GObjectClass parent_class;
-};
-
-GType e_mini_calendar_config_get_type (void);
-EMiniCalendarConfig *e_mini_calendar_config_new (ECalendar *mini_cal);
-ECalendar *e_mini_calendar_config_get_calendar (EMiniCalendarConfig *mini_config);
-void e_mini_calendar_config_set_calendar (EMiniCalendarConfig *mini_config, ECalendar *mini_cal);
-
-G_END_DECLS
-
-#endif
diff --git a/calendar/gui/e-month-view.c b/calendar/gui/e-month-view.c
new file mode 100644
index 0000000000..238492c92c
--- /dev/null
+++ b/calendar/gui/e-month-view.c
@@ -0,0 +1,213 @@
+/*
+ * 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"
+
+#include <libecal/e-cal-time-util.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;
+}
+
+ECalendarView *
+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..0ff91a963f
--- /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);
+ECalendarView * 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
deleted file mode 100644
index bf400590a8..0000000000
--- a/calendar/gui/e-tasks.c
+++ /dev/null
@@ -1,1569 +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>
- *
- * Copyright (C) 1999-2008 Novell, Inc. (www.novell.com)
- *
- */
-
-#ifdef HAVE_CONFIG_H
-#include <config.h>
-#endif
-
-#include <glib/gi18n.h>
-#include <libedataserver/e-time-utils.h>
-#include <table/e-table-scrolled.h>
-#include <widgets/menus/gal-view-instance.h>
-#include <widgets/menus/gal-view-factory-etable.h>
-#include <widgets/menus/gal-view-etable.h>
-
-#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 <libedataserver/e-url.h>
-#include <libedataserver/e-categories.h>
-#include <libecal/e-cal-time-util.h>
-#include "widgets/menus/gal-view-menus.h"
-#include "dialogs/delete-error.h"
-#include "dialogs/task-editor.h"
-#include "cal-search-bar.h"
-#include "calendar-config.h"
-#include "calendar-component.h"
-#include "comp-util.h"
-#include "e-calendar-table-config.h"
-#include "misc.h"
-#include "tasks-component.h"
-#include "e-cal-component-preview.h"
-#include "e-tasks.h"
-#include "common/authentication.h"
-#include "e-cal-menu.h"
-#include "e-cal-model-tasks.h"
-
-/* Private part of the GnomeCalendar structure */
-struct _ETasksPrivate {
- /* The task lists for display */
- GHashTable *clients;
- GList *clients_list;
- ECal *default_client;
-
- ECalView *query;
-
- /* The ECalendarTable showing the tasks. */
- GtkWidget *tasks_view;
- ECalendarTableConfig *tasks_view_config;
-
- /* Calendar search bar for tasks */
- GtkWidget *search_bar;
-
- /* Tasks menu */
- ECalMenu *tasks_menu;
-
- /* Paned widget */
- GtkWidget *paned;
-
- /* The preview */
- GtkWidget *preview;
-
- gchar *current_uid;
- 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 */
-enum {
- SELECTION_CHANGED,
- SOURCE_ADDED,
- SOURCE_REMOVED,
- 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)
-{
- ETasks *tasks;
- ETasksPrivate *priv;
- ECalModel *model;
-
- tasks = E_TASKS (data);
- priv = tasks->priv;
-
- model = e_calendar_table_get_model (E_CALENDAR_TABLE (priv->tasks_view));
- 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.
- * 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
- * @param user_data User data, will be passed to func.
- **/
-static void
-do_for_selected_components (ECalendarTable *cal_table, GFunc func, gpointer user_data)
-{
- 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, 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,
- ETasks *tasks)
-{
- ETasksPrivate *priv;
-
- priv = tasks->priv;
-
- if (info == TARGET_VCALENDAR) {
- /* we will pass an icalcalendar component for both types */
- GSList *components = NULL;
-
- do_for_selected_components (E_CALENDAR_TABLE (priv->tasks_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_begin (ETable *table,
- gint row,
- gint col,
- GdkDragContext *context,
- ETasks *tasks)
-{
-
-}
-
-static void
-table_drag_end (ETable *table,
- gint row,
- gint col,
- GdkDragContext *context,
- ETasks *tasks)
-{
-
-}
-*/
-
-static void
-table_drag_data_delete (ETable *table,
- gint row,
- gint col,
- GdkDragContext *context,
- ETasks *tasks)
-{
- /* 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_TASKS_TABLE_DEFAULT_STATE \
- "<?xml version=\"1.0\"?>" \
- "<ETableState>" \
- "<column source=\"13\"/>" \
- "<column source=\"14\"/>" \
- "<column source=\"9\"/>" \
- "<column source=\"5\"/>" \
- "<grouping/>" \
- "</ETableState>"
-
-static void
-pane_realized (GtkWidget *widget, ETasks *tasks)
-{
- gtk_paned_set_position ((GtkPaned *)widget, calendar_config_get_task_vpane_pos ());
-}
-
-static void
-setup_widgets (ETasks *tasks)
-{
- ETasksPrivate *priv;
- ETable *etable;
- ECalModel *model;
- gboolean state;
-
- priv = tasks->priv;
-
- priv->search_bar = cal_search_bar_new (CAL_SEARCH_TASKS_DEFAULT);
- g_signal_connect (priv->search_bar, "sexp_changed",
- 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);
- gtk_widget_show (priv->search_bar);
-
- /* add the paned widget for the task list and task detail areas */
- 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);
-
- /* create the task list */
- priv->tasks_view = e_calendar_table_new ();
- g_object_set_data (G_OBJECT (priv->tasks_view), "tasks", tasks);
- priv->tasks_view_config = e_calendar_table_config_new (E_CALENDAR_TABLE (priv->tasks_view));
-
- g_signal_connect (priv->tasks_view, "user_created", G_CALLBACK (user_created_cb), tasks);
-
- etable = e_table_scrolled_get_table (
- E_TABLE_SCROLLED (E_CALENDAR_TABLE (priv->tasks_view)->etable));
- e_table_set_state (etable, E_TASKS_TABLE_DEFAULT_STATE);
- gtk_paned_add1 (GTK_PANED (priv->paned), priv->tasks_view);
- gtk_widget_show (priv->tasks_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), tasks);
- g_signal_connect (etable, "table_drag_data_delete",
- G_CALLBACK(table_drag_data_delete), tasks);
-
- /*
- e_table_drag_dest_set (e_table_scrolled_get_table (E_TABLE_SCROLLED (editor->table)),
- 0, list_drag_types, num_list_drag_types, GDK_ACTION_LINK);
-
- g_signal_connect (e_table_scrolled_get_table (E_TABLE_SCROLLED (editor->table)),
- "table_drag_motion", G_CALLBACK(table_drag_motion_cb), editor);
- g_signal_connect (e_table_scrolled_get_table (E_TABLE_SCROLLED (editor->table)),
- "table_drag_drop", G_CALLBACK (table_drag_drop_cb), editor);
- g_signal_connect (e_table_scrolled_get_table (E_TABLE_SCROLLED (editor->table)),
- "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 ());
- gtk_paned_add2 (GTK_PANED (priv->paned), priv->preview);
- state = calendar_config_get_preview_state ();
-
- 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 */
-static void
-e_tasks_class_init (ETasksClass *class)
-{
- GtkObjectClass *object_class;
-
- object_class = (GtkObjectClass *) class;
-
- e_tasks_signals[SELECTION_CHANGED] =
- g_signal_new ("selection_changed",
- G_TYPE_FROM_CLASS (object_class),
- G_SIGNAL_RUN_LAST,
- G_STRUCT_OFFSET (ETasksClass, selection_changed),
- NULL, NULL,
- g_cclosure_marshal_VOID__INT,
- G_TYPE_NONE, 1,
- G_TYPE_INT);
-
- e_tasks_signals[SOURCE_ADDED] =
- g_signal_new ("source_added",
- G_TYPE_FROM_CLASS (object_class),
- G_SIGNAL_RUN_FIRST,
- G_STRUCT_OFFSET (ETasksClass, source_added),
- NULL, NULL,
- g_cclosure_marshal_VOID__OBJECT,
- G_TYPE_NONE,
- 1,
- G_TYPE_OBJECT);
-
- e_tasks_signals[SOURCE_REMOVED] =
- g_signal_new ("source_removed",
- G_TYPE_FROM_CLASS (object_class),
- G_SIGNAL_RUN_FIRST,
- G_STRUCT_OFFSET (ETasksClass, source_removed),
- NULL, NULL,
- g_cclosure_marshal_VOID__OBJECT,
- G_TYPE_NONE,
- 1,
- G_TYPE_OBJECT);
-
- object_class->destroy = e_tasks_destroy;
-
- class->selection_changed = NULL;
- class->source_added = NULL;
- 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)
-{
- ETasksPrivate *priv;
-
- 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 *
-e_tasks_new (void)
-{
- ETasks *tasks;
-
- tasks = g_object_new (e_tasks_get_type (), NULL);
-
- 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)
-{
- ETasks *tasks;
- ETasksPrivate *priv;
-
- g_return_if_fail (object != NULL);
- g_return_if_fail (E_IS_TASKS (object));
-
- tasks = E_TASKS (object);
- priv = tasks->priv;
-
- 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,
- 0, 0, NULL, NULL, tasks);
- }
-
- 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;
- }
-
- if (priv->sexp) {
- g_free (priv->sexp);
- 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;
- }
-
- for (l = priv->notifications; l; l = l->next)
- calendar_config_remove_notification (GPOINTER_TO_UINT (l->data));
- priv->notifications = NULL;
-
- g_free (priv);
- tasks->priv = NULL;
- }
-
- if (GTK_OBJECT_CLASS (e_tasks_parent_class)->destroy)
- (* GTK_OBJECT_CLASS (e_tasks_parent_class)->destroy) (object);
-}
-
-static void
-set_status_message (ETasks *tasks, const gchar *message, ...)
-{
- ETasksPrivate *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 = tasks->priv;
-
- 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
-open_ecal (ETasks *tasks, ECal *cal, gboolean only_if_exists, open_func of)
-{
- ETasksPrivate *priv;
- icaltimezone *zone;
-
- priv = tasks->priv;
-
- zone = calendar_config_get_icaltimezone ();
- e_cal_set_default_timezone (cal, zone, NULL);
-
- set_status_message (tasks, _("Opening tasks at %s"), e_cal_get_uri (cal));
-
- g_signal_connect (G_OBJECT (cal), "cal_opened", G_CALLBACK (of), tasks);
- e_cal_open_async (cal, only_if_exists);
-
- return TRUE;
-}
-
-void
-e_tasks_open_task (ETasks *tasks)
-{
- ECalendarTable *cal_table;
-
- cal_table = e_tasks_get_calendar_table (tasks);
- e_calendar_table_open_selected (cal_table);
-}
-
-void
-e_tasks_new_task (ETasks *tasks)
-{
- ETasksPrivate *priv;
- CompEditor *editor;
- ECalComponent *comp;
- const gchar *category;
- ECal *ecal;
- guint32 flags = 0;
-
- g_return_if_fail (E_IS_TASKS (tasks));
-
- priv = tasks->priv;
-
- /* FIXME What to do about no default client */
- ecal = e_tasks_get_default_client (tasks);
- if (!ecal)
- return;
-
- flags |= COMP_EDITOR_NEW_ITEM | COMP_EDITOR_USER_ORG;
-
- comp = cal_comp_task_new_with_defaults (ecal);
-
- category = cal_search_bar_get_category (CAL_SEARCH_BAR (priv->search_bar));
- e_cal_component_set_categories (comp, category);
-
- editor = task_editor_new (ecal, flags);
- comp_editor_edit_comp (editor, comp);
- g_object_unref (comp);
-
- 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)
-{
- ETasksPrivate *priv;
- ECal *client;
- ECalModel *model;
- 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)
- 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, tasks);
-
- model = e_calendar_table_get_model (E_CALENDAR_TABLE (priv->tasks_view));
- e_cal_model_remove_client (model, client);
-
- g_hash_table_remove (priv->clients, uid);
-
- g_signal_emit (tasks, e_tasks_signals[SOURCE_REMOVED], 0, source);
-
- return TRUE;
-}
-
-gboolean
-e_tasks_set_default_source (ETasks *tasks, ESource *source)
-{
- ETasksPrivate *priv;
- ECal *ecal;
-
- 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;
-
- 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_TODO);
- if (!priv->default_client)
- return FALSE;
- }
-
- open_ecal (tasks, priv->default_client, FALSE, default_client_cal_opened_cb);
-
- 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
- *
- * Removes all tasks marked as completed
- **/
-void
-e_tasks_delete_completed (ETasks *tasks)
-{
- ETasksPrivate *priv;
- gchar *sexp;
- GList *l;
-
- g_return_if_fail (tasks != NULL);
- g_return_if_fail (E_IS_TASKS (tasks));
-
- priv = tasks->priv;
-
- sexp = g_strdup ("(is-completed?)");
-
- set_status_message (tasks, _("Expunging"));
-
- for (l = priv->clients_list; l != NULL; l = l->next) {
- ECal *client = l->data;
- GList *objects, *m;
- gboolean read_only = TRUE;
-
- e_cal_is_read_only (client, &read_only, NULL);
- if (read_only)
- continue;
-
- if (!e_cal_get_object_list (client, sexp, &objects, NULL)) {
- g_warning (G_STRLOC ": Could not get the objects");
-
- continue;
- }
-
- for (m = objects; m; m = m->next) {
- /* FIXME Better error handling */
- e_cal_remove_object (client, icalcomponent_get_uid (m->data), NULL);
- }
-
- g_list_foreach (objects, (GFunc) icalcomponent_free, NULL);
- g_list_free (objects);
- }
-
- set_status_message (tasks, NULL);
-
- 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,
- const gchar *comp_uid,
- const gchar *comp_rid)
-{
- ECal *client = NULL;
- GList *l;
- icalcomponent* icalcomp = NULL;
- icalproperty *attendee_prop = NULL;
-
- if (!src_uid || !comp_uid)
- return;
-
- for (l = tasks->priv->clients_list; l != NULL; l = l->next) {
- ESource *client_src;
-
- client = l->data;
- client_src = e_cal_get_source (client);
-
- if (!strcmp (src_uid, e_source_peek_uid (client_src)))
- break;
- }
-
- if (!client)
- return;
-
- e_cal_get_object (client, comp_uid, comp_rid, &icalcomp, NULL);
-
- if (!icalcomp)
- return;
-
- attendee_prop = icalcomponent_get_first_property (icalcomp, ICAL_ATTENDEE_PROPERTY);
- e_calendar_table_open_task (E_CALENDAR_TABLE (tasks->priv->tasks_view), client, icalcomp, attendee_prop != NULL);
- icalcomponent_free (icalcomp);
-
- 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
deleted file mode 100644
index f9eacb7819..0000000000
--- a/calendar/gui/e-tasks.h
+++ /dev/null
@@ -1,91 +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>
- *
- * Copyright (C) 1999-2008 Novell, Inc. (www.novell.com)
- *
- */
-
-#ifndef _E_TASKS_H_
-#define _E_TASKS_H_
-
-#include <bonobo/bonobo-ui-component.h>
-#include <gtk/gtk.h>
-#include <libedataserver/e-source.h>
-#include <libecal/e-cal.h>
-#include "e-calendar-table.h"
-
-#define E_TYPE_TASKS (e_tasks_get_type ())
-#define E_TASKS(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), E_TYPE_TASKS, ETasks))
-#define E_TASKS_CLASS(klass) (G_TYPE_CHECK_INSTANCE_CAST_CLASS ((klass), E_TYPE_TASKS, \
- ETasksClass))
-#define E_IS_TASKS(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), E_TYPE_TASKS))
-#define E_IS_TASKS_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), E_TYPE_TASKS))
-
-typedef struct _ETasks ETasks;
-typedef struct _ETasksClass ETasksClass;
-typedef struct _ETasksPrivate ETasksPrivate;
-
-struct _ETasks {
- GtkTable table;
-
- /* Private data */
- ETasksPrivate *priv;
-};
-
-struct _ETasksClass {
- GtkTableClass parent_class;
-
- /* Notification signals */
- void (* selection_changed) (ETasks *tasks, gint n_selected);
- void (* source_added) (ETasks *tasks, ESource *source);
- void (* source_removed) (ETasks *tasks, ESource *source);
-};
-
-GType e_tasks_get_type (void);
-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-timezone-entry.c b/calendar/gui/e-timezone-entry.c
index f3e239aa63..53a8a4498b 100644
--- a/calendar/gui/e-timezone-entry.c
+++ b/calendar/gui/e-timezone-entry.c
@@ -33,12 +33,16 @@
#include <glib/gi18n.h>
#include "e-timezone-entry.h"
+#define E_TIMEZONE_ENTRY_GET_PRIVATE(obj) \
+ (G_TYPE_INSTANCE_GET_PRIVATE \
+ ((obj), E_TYPE_TIMEZONE_ENTRY, ETimezoneEntryPrivate))
+
struct _ETimezoneEntryPrivate {
/* The current timezone, set in e_timezone_entry_set_timezone()
or from the timezone dialog. Note that we don't copy it or
use a ref count - we assume it is never destroyed for the
lifetime of this widget. */
- icaltimezone *zone;
+ icaltimezone *timezone;
/* This can be set to the default timezone. If the current timezone
setting in the ETimezoneEntry matches this, then the entry field
@@ -50,314 +54,320 @@ struct _ETimezoneEntryPrivate {
};
enum {
- CHANGED,
- LAST_SIGNAL
+ PROP_0,
+ PROP_TIMEZONE
};
-static void e_timezone_entry_destroy (GtkObject *object);
-
-static gboolean e_timezone_entry_mnemonic_activate (GtkWidget *widget,
- gboolean group_cycling);
-static gboolean e_timezone_entry_focus (GtkWidget *widget,
- GtkDirectionType direction);
-static void on_entry_changed (GtkEntry *entry,
- ETimezoneEntry *tentry);
-static void on_button_clicked (GtkWidget *widget,
- ETimezoneEntry *tentry);
-static void add_relation (ETimezoneEntry *tentry,
- GtkWidget *widget);
-
-static void e_timezone_entry_set_entry (ETimezoneEntry *tentry);
+enum {
+ CHANGED,
+ LAST_SIGNAL
+};
-static guint timezone_entry_signals[LAST_SIGNAL] = { 0 };
+static guint signals[LAST_SIGNAL];
G_DEFINE_TYPE (ETimezoneEntry, e_timezone_entry, GTK_TYPE_HBOX)
static void
-e_timezone_entry_class_init (ETimezoneEntryClass *class)
+timezone_entry_emit_changed (ETimezoneEntry *timezone_entry)
{
- GtkObjectClass *object_class = (GtkObjectClass *) class;
- GtkWidgetClass *widget_class = GTK_WIDGET_CLASS (class);
-
- object_class = (GtkObjectClass*) class;
-
- widget_class->mnemonic_activate = e_timezone_entry_mnemonic_activate;
- widget_class->focus = e_timezone_entry_focus;
- timezone_entry_signals[CHANGED] =
- g_signal_new ("changed",
- G_TYPE_FROM_CLASS (object_class),
- G_SIGNAL_RUN_LAST,
- G_STRUCT_OFFSET (ETimezoneEntryClass, changed),
- NULL, NULL,
- g_cclosure_marshal_VOID__VOID,
- G_TYPE_NONE, 0);
-
- object_class->destroy = e_timezone_entry_destroy;
-
- class->changed = NULL;
+ g_signal_emit (timezone_entry, signals[CHANGED], 0);
}
static void
-e_timezone_entry_init (ETimezoneEntry *tentry)
+timezone_entry_update_entry (ETimezoneEntry *timezone_entry)
{
- ETimezoneEntryPrivate *priv;
- AtkObject *a11y;
-
- tentry->priv = priv = g_new0 (ETimezoneEntryPrivate, 1);
+ const gchar *display_name;
+ gchar *name_buffer;
+ icaltimezone *timezone;
- priv->zone = NULL;
- priv->default_zone = NULL;
+ timezone = e_timezone_entry_get_timezone (timezone_entry);
- priv->entry = gtk_entry_new ();
- gtk_editable_set_editable (GTK_EDITABLE (priv->entry), FALSE);
- /*gtk_widget_set_usize (priv->date_entry, 90, 0);*/
- gtk_box_pack_start (GTK_BOX (tentry), priv->entry, TRUE, TRUE, 0);
- gtk_widget_show (priv->entry);
- g_signal_connect (priv->entry, "changed", G_CALLBACK (on_entry_changed), tentry);
+ if (timezone != NULL) {
+ display_name = icaltimezone_get_display_name (timezone);
- priv->button = gtk_button_new_with_label (_("Select..."));
- g_signal_connect (priv->button, "clicked", G_CALLBACK (on_button_clicked), tentry);
- gtk_box_pack_start (GTK_BOX (tentry), priv->button, FALSE, FALSE, 6);
- gtk_widget_show (priv->button);
- a11y = gtk_widget_get_accessible (priv->button);
- if (a11y != NULL) {
- atk_object_set_name (a11y, _("Select Timezone"));
- }
-}
+ /* We check if it is one of our builtin timezone
+ names, in which case we call gettext to translate
+ it. If it isn't a builtin timezone name, we don't. */
+ if (icaltimezone_get_builtin_timezone (display_name))
+ display_name = _(display_name);
+ } else
+ display_name = "";
-/**
- * e_timezone_entry_new:
- *
- * Description: Creates a new #ETimezoneEntry widget which can be used
- * to provide an easy to use way for entering dates and times.
- *
- * Returns: a new #ETimezoneEntry widget.
- */
-GtkWidget *
-e_timezone_entry_new (void)
-{
- ETimezoneEntry *tentry;
+ name_buffer = g_strdup (display_name);
- tentry = g_object_new (e_timezone_entry_get_type (), NULL);
+ gtk_entry_set_text (GTK_ENTRY (timezone_entry->priv->entry), name_buffer);
- GTK_WIDGET_SET_FLAGS (GTK_WIDGET(tentry), GTK_CAN_FOCUS);
+ /* XXX Do we need to hide the timezone entry at all? I know
+ * this overrules the previous case of hiding the timezone
+ * entry field when we select the default timezone. */
+ gtk_widget_show (timezone_entry->priv->entry);
- return GTK_WIDGET (tentry);
+ g_free (name_buffer);
}
-
static void
-e_timezone_entry_destroy (GtkObject *object)
+timezone_entry_add_relation (ETimezoneEntry *timezone_entry)
{
- ETimezoneEntry *tentry;
+ AtkObject *a11y_timezone_entry;
+ AtkObject *a11y_widget;
+ AtkRelationSet *set;
+ AtkRelation *relation;
+ GtkWidget *widget;
+ GPtrArray *target;
+ gpointer target_object;
- g_return_if_fail (E_IS_TIMEZONE_ENTRY (object));
+ /* add a labelled_by relation for widget for accessibility */
- tentry = E_TIMEZONE_ENTRY (object);
+ widget = GTK_WIDGET (timezone_entry);
+ a11y_timezone_entry = gtk_widget_get_accessible (widget);
- g_free (tentry->priv);
- tentry->priv = NULL;
+ widget = timezone_entry->priv->entry;
+ a11y_widget = gtk_widget_get_accessible (widget);
- if (GTK_OBJECT_CLASS (e_timezone_entry_parent_class)->destroy)
- (* GTK_OBJECT_CLASS (e_timezone_entry_parent_class)->destroy) (object);
+ set = atk_object_ref_relation_set (a11y_widget);
+ if (set != NULL) {
+ relation = atk_relation_set_get_relation_by_type (
+ set, ATK_RELATION_LABELLED_BY);
+ /* check whether has a labelled_by relation already */
+ if (relation != NULL)
+ return;
+ }
+
+ set = atk_object_ref_relation_set (a11y_timezone_entry);
+ if (!set)
+ return;
+
+ relation = atk_relation_set_get_relation_by_type (
+ set, ATK_RELATION_LABELLED_BY);
+ if (relation != NULL) {
+ target = atk_relation_get_target (relation);
+ target_object = g_ptr_array_index (target, 0);
+ if (ATK_IS_OBJECT (target_object)) {
+ atk_object_add_relationship (
+ a11y_widget,
+ ATK_RELATION_LABELLED_BY,
+ ATK_OBJECT (target_object));
+ }
+ }
}
/* The arrow button beside the date field has been clicked, so we show the
popup with the ECalendar in. */
static void
-on_button_clicked (GtkWidget *widget,
- ETimezoneEntry *tentry)
+timezone_entry_button_clicked_cb (ETimezoneEntry *timezone_entry)
{
- ETimezoneEntryPrivate *priv;
ETimezoneDialog *timezone_dialog;
GtkWidget *dialog;
-
- priv = tentry->priv;
+ icaltimezone *timezone;
timezone_dialog = e_timezone_dialog_new ();
- e_timezone_dialog_set_timezone (timezone_dialog, priv->zone);
+ timezone = e_timezone_entry_get_timezone (timezone_entry);
+ e_timezone_dialog_set_timezone (timezone_dialog, timezone);
dialog = e_timezone_dialog_get_toplevel (timezone_dialog);
- if (gtk_dialog_run (GTK_DIALOG (dialog)) == GTK_RESPONSE_ACCEPT) {
- priv->zone = e_timezone_dialog_get_timezone (timezone_dialog);
- e_timezone_entry_set_entry (tentry);
- }
+ if (gtk_dialog_run (GTK_DIALOG (dialog)) != GTK_RESPONSE_ACCEPT)
+ goto exit;
+ timezone = e_timezone_dialog_get_timezone (timezone_dialog);
+ e_timezone_entry_set_timezone (timezone_entry, timezone);
+ timezone_entry_update_entry (timezone_entry);
+
+exit:
g_object_unref (timezone_dialog);
}
static void
-on_entry_changed (GtkEntry *entry,
- ETimezoneEntry *tentry)
+timezone_entry_set_property (GObject *object,
+ guint property_id,
+ const GValue *value,
+ GParamSpec *pspec)
{
- g_signal_emit (GTK_OBJECT (tentry), timezone_entry_signals[CHANGED], 0);
-}
-
-icaltimezone*
-e_timezone_entry_get_timezone (ETimezoneEntry *tentry)
-{
- ETimezoneEntryPrivate *priv;
-
- g_return_val_if_fail (E_IS_TIMEZONE_ENTRY (tentry), NULL);
-
- priv = tentry->priv;
+ switch (property_id) {
+ case PROP_TIMEZONE:
+ e_timezone_entry_set_timezone (
+ E_TIMEZONE_ENTRY (object),
+ g_value_get_pointer (value));
+ return;
+ }
- return priv->zone;
+ G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
}
static void
-add_relation (ETimezoneEntry *tentry,
- GtkWidget *widget)
+timezone_entry_get_property (GObject *object,
+ guint property_id,
+ GValue *value,
+ GParamSpec *pspec)
{
- AtkObject *a11ytentry, *a11yWidget;
- AtkRelationSet *set;
- AtkRelation *relation;
- GPtrArray *target;
- gpointer target_object;
-
- /* add a labelled_by relation for widget for accessibility */
-
- a11ytentry = gtk_widget_get_accessible (GTK_WIDGET (tentry));
- a11yWidget = gtk_widget_get_accessible (widget);
-
- set = atk_object_ref_relation_set (a11yWidget);
- if (set != NULL) {
- relation = atk_relation_set_get_relation_by_type (set,
- ATK_RELATION_LABELLED_BY);
- /* check whether has a labelled_by relation already */
- if (relation != NULL)
+ switch (property_id) {
+ case PROP_TIMEZONE:
+ g_value_set_pointer (
+ value, e_timezone_entry_get_timezone (
+ E_TIMEZONE_ENTRY (object)));
return;
}
- set = atk_object_ref_relation_set (a11ytentry);
- if (!set)
- return;
-
- relation = atk_relation_set_get_relation_by_type (set,
- ATK_RELATION_LABELLED_BY);
- if (relation != NULL) {
- target = atk_relation_get_target (relation);
- target_object = g_ptr_array_index (target, 0);
- if (ATK_IS_OBJECT (target_object)) {
- atk_object_add_relationship (a11yWidget,
- ATK_RELATION_LABELLED_BY,
- ATK_OBJECT (target_object));
- }
- }
+ G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
}
-void
-e_timezone_entry_set_timezone (ETimezoneEntry *tentry,
- icaltimezone *zone)
+static gboolean
+timezone_entry_mnemonic_activate (GtkWidget *widget,
+ gboolean group_cycling)
{
ETimezoneEntryPrivate *priv;
- g_return_if_fail (E_IS_TIMEZONE_ENTRY (tentry));
+ priv = E_TIMEZONE_ENTRY_GET_PRIVATE (widget);
- priv = tentry->priv;
-
- priv->zone = zone;
-
- e_timezone_entry_set_entry (tentry);
+ if (GTK_WIDGET_CAN_FOCUS (widget)) {
+ if (priv->button != NULL)
+ gtk_widget_grab_focus (priv->button);
+ }
- add_relation (tentry, priv->entry);
+ return TRUE;
}
-/* Sets the default timezone. If the current timezone matches this, then the
- entry field is hidden. This is useful since most people do not use timezones
- so it makes the user interface simpler. */
-void
-e_timezone_entry_set_default_timezone (ETimezoneEntry *tentry,
- icaltimezone *zone)
+static gboolean
+timezone_entry_focus (GtkWidget *widget,
+ GtkDirectionType direction)
{
ETimezoneEntryPrivate *priv;
- g_return_if_fail (E_IS_TIMEZONE_ENTRY (tentry));
+ priv = E_TIMEZONE_ENTRY_GET_PRIVATE (widget);
- priv = tentry->priv;
+ if (direction == GTK_DIR_TAB_FORWARD) {
+ if (GTK_WIDGET_HAS_FOCUS (priv->entry))
+ gtk_widget_grab_focus (priv->button);
+ else if (GTK_WIDGET_HAS_FOCUS (priv->button))
+ return FALSE;
+ else if (GTK_WIDGET_VISIBLE (priv->entry))
+ gtk_widget_grab_focus (priv->entry);
+ else
+ gtk_widget_grab_focus (priv->button);
- priv->default_zone = zone;
+ } else if (direction == GTK_DIR_TAB_BACKWARD) {
+ if (GTK_WIDGET_HAS_FOCUS (priv->entry))
+ return FALSE;
+ else if (GTK_WIDGET_HAS_FOCUS (priv->button)) {
+ if (GTK_WIDGET_VISIBLE (priv->entry))
+ gtk_widget_grab_focus (priv->entry);
+ else
+ return FALSE;
+ } else
+ gtk_widget_grab_focus (priv->button);
+ } else
+ return FALSE;
- e_timezone_entry_set_entry (tentry);
+ return TRUE;
}
static void
-e_timezone_entry_set_entry (ETimezoneEntry *tentry)
+e_timezone_entry_class_init (ETimezoneEntryClass *class)
{
- ETimezoneEntryPrivate *priv;
- const gchar *display_name;
- gchar *name_buffer;
+ GObjectClass *object_class;
+ GtkWidgetClass *widget_class;
+
+ g_type_class_add_private (class, sizeof (ETimezoneEntryPrivate));
+
+ object_class = G_OBJECT_CLASS (class);
+ object_class->set_property = timezone_entry_set_property;
+ object_class->get_property = timezone_entry_get_property;
+
+ widget_class = GTK_WIDGET_CLASS (class);
+ widget_class->mnemonic_activate = timezone_entry_mnemonic_activate;
+ widget_class->focus = timezone_entry_focus;
+
+ g_object_class_install_property (
+ object_class,
+ PROP_TIMEZONE,
+ g_param_spec_pointer (
+ "timezone",
+ "Timezone",
+ NULL,
+ G_PARAM_READWRITE));
+
+ signals[CHANGED] = g_signal_new (
+ "changed",
+ G_TYPE_FROM_CLASS (object_class),
+ G_SIGNAL_RUN_LAST,
+ G_STRUCT_OFFSET (ETimezoneEntryClass, changed),
+ NULL, NULL,
+ g_cclosure_marshal_VOID__VOID,
+ G_TYPE_NONE, 0);
+}
- priv = tentry->priv;
+static void
+e_timezone_entry_init (ETimezoneEntry *timezone_entry)
+{
+ AtkObject *a11y;
+ GtkWidget *widget;
- if (priv->zone) {
- display_name = icaltimezone_get_display_name (priv->zone);
+ timezone_entry->priv = E_TIMEZONE_ENTRY_GET_PRIVATE (timezone_entry);
- /* We check if it is one of our builtin timezone
- names, in which case we call gettext to translate
- it. If it isn't a builtin timezone name, we
- don't. */
- if (icaltimezone_get_builtin_timezone (display_name))
- display_name = _(display_name);
- } else
- display_name = "";
+ GTK_WIDGET_SET_FLAGS (GTK_WIDGET (timezone_entry), GTK_CAN_FOCUS);
- name_buffer = g_strdup (display_name);
+ widget = gtk_entry_new ();
+ gtk_editable_set_editable (GTK_EDITABLE (widget), FALSE);
+ gtk_box_pack_start (GTK_BOX (timezone_entry), widget, TRUE, TRUE, 0);
+ timezone_entry->priv->entry = widget;
+ gtk_widget_show (widget);
- gtk_entry_set_text (GTK_ENTRY (priv->entry), name_buffer);
+ g_signal_connect_swapped (
+ widget, "changed",
+ G_CALLBACK (timezone_entry_emit_changed), timezone_entry);
- /* do we need to hide the timezone entry at all? i know this overrules the previous case of hiding the timezone
- * entry field when we select the default timezone
- */
- gtk_widget_show (priv->entry);
+ widget = gtk_button_new_with_label (_("Select..."));
+ gtk_box_pack_start (GTK_BOX (timezone_entry), widget, FALSE, FALSE, 6);
+ timezone_entry->priv->button = widget;
+ gtk_widget_show (widget);
- g_free (name_buffer);
+ g_signal_connect_swapped (
+ widget, "clicked",
+ G_CALLBACK (timezone_entry_button_clicked_cb), timezone_entry);
+
+ a11y = gtk_widget_get_accessible (timezone_entry->priv->button);
+ if (a11y != NULL)
+ atk_object_set_name (a11y, _("Select Timezone"));
}
-static gboolean
-e_timezone_entry_mnemonic_activate (GtkWidget *widget,
- gboolean group_cycling)
+GtkWidget *
+e_timezone_entry_new (void)
{
- GtkButton *button = NULL;
+ return g_object_new (E_TYPE_TIMEZONE_ENTRY, NULL);
+}
- if (GTK_WIDGET_CAN_FOCUS (widget)) {
- button = GTK_BUTTON (((ETimezoneEntryPrivate *) ((ETimezoneEntry *) widget)->priv)->button);
- if (button != NULL)
- gtk_widget_grab_focus (GTK_WIDGET (button));
- }
+icaltimezone *
+e_timezone_entry_get_timezone (ETimezoneEntry *timezone_entry)
+{
+ g_return_val_if_fail (E_IS_TIMEZONE_ENTRY (timezone_entry), NULL);
- return TRUE;
+ return timezone_entry->priv->timezone;
}
-static gboolean
-e_timezone_entry_focus (GtkWidget *widget, GtkDirectionType direction)
+void
+e_timezone_entry_set_timezone (ETimezoneEntry *timezone_entry,
+ icaltimezone *timezone)
{
- ETimezoneEntry *tentry;
+ g_return_if_fail (E_IS_TIMEZONE_ENTRY (timezone_entry));
- tentry = E_TIMEZONE_ENTRY (widget);
+ timezone_entry->priv->timezone = timezone;
- if (direction == GTK_DIR_TAB_FORWARD) {
- if (GTK_WIDGET_HAS_FOCUS (tentry->priv->entry))
- gtk_widget_grab_focus (tentry->priv->button);
- else if (GTK_WIDGET_HAS_FOCUS (tentry->priv->button))
- return FALSE;
- else if (GTK_WIDGET_VISIBLE (tentry->priv->entry))
- gtk_widget_grab_focus (tentry->priv->entry);
- else
- gtk_widget_grab_focus (tentry->priv->button);
- } else if (direction == GTK_DIR_TAB_BACKWARD) {
- if (GTK_WIDGET_HAS_FOCUS (tentry->priv->entry))
- return FALSE;
- else if (GTK_WIDGET_HAS_FOCUS (tentry->priv->button)) {
- if (GTK_WIDGET_VISIBLE (tentry->priv->entry))
- gtk_widget_grab_focus (tentry->priv->entry);
- else
- return FALSE;
- } else
- gtk_widget_grab_focus (tentry->priv->button);
- } else
- return FALSE;
- return TRUE;
+ timezone_entry_update_entry (timezone_entry);
+ timezone_entry_add_relation (timezone_entry);
+
+ g_object_notify (G_OBJECT (timezone_entry), "timezone");
}
+/* Sets the default timezone. If the current timezone matches this,
+ * then the entry field is hidden. This is useful since most people
+ * do not use timezones so it makes the user interface simpler. */
+void
+e_timezone_entry_set_default_timezone (ETimezoneEntry *timezone_entry,
+ icaltimezone *timezone)
+{
+ g_return_if_fail (E_IS_TIMEZONE_ENTRY (timezone_entry));
+
+ timezone_entry->priv->default_zone = timezone;
+
+ timezone_entry_update_entry (timezone_entry);
+}
diff --git a/calendar/gui/e-timezone-entry.h b/calendar/gui/e-timezone-entry.h
index c1bf482aef..6c0cd1dc6b 100644
--- a/calendar/gui/e-timezone-entry.h
+++ b/calendar/gui/e-timezone-entry.h
@@ -29,50 +29,61 @@
* timezone.
*/
-#ifndef __E_TIMEZONE_ENTRY_H_
-#define __E_TIMEZONE_ENTRY_H_
+#ifndef E_TIMEZONE_ENTRY_H
+#define E_TIMEZONE_ENTRY_H
#include <gtk/gtk.h>
#include <libecal/e-cal.h>
-G_BEGIN_DECLS
+/* Standard GObject macros */
+#define E_TYPE_TIMEZONE_ENTRY \
+ (e_timezone_entry_get_type ())
+#define E_TIMEZONE_ENTRY(obj) \
+ (G_TYPE_CHECK_INSTANCE_CAST \
+ ((obj), E_TYPE_TIMEZONE_ENTRY, ETimezoneEntry))
+#define E_TIMEZONE_ENTRY_CLASS(cls) \
+ (G_TYPE_CHECK_CLASS_CAST \
+ ((cls), E_TYPE_TIMEZONE_ENTRY, ETimezoneEntryClass))
+#define E_IS_TIMEZONE_ENTRY(obj) \
+ (G_TYPE_CHECK_INSTANCE_TYPE \
+ ((obj), E_TYPE_TIMEZONE_ENTRY))
+#define E_IS_TIMEZONE_ENTRY_CLASS(cls) \
+ (G_TYPE_CHECK_CLASS_TYPE \
+ ((cls), E_TYPE_TIMEZONE_ENTRY))
+#define E_IS_TIMEZONE_ENTRY_GET_CLASS(obj) \
+ (G_TYPE_INSTANCE_GET_CLASS \
+ ((obj), E_TYPE_TIMEZONE_ENTRY, ETimezoneEntryClass))
-#define E_TYPE_TIMEZONE_ENTRY (e_timezone_entry_get_type ())
-#define E_TIMEZONE_ENTRY(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), E_TYPE_TIMEZONE_ENTRY, ETimezoneEntry))
-#define E_TIMEZONE_ENTRY_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), E_TYPE_TIMEZONE_ENTRY, ETimezoneEntryClass))
-#define E_IS_TIMEZONE_ENTRY(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), E_TYPE_TIMEZONE_ENTRY))
-#define E_IS_TIMEZONE_ENTRY_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), E_TYPE_TIMEZONE_ENTRY))
+G_BEGIN_DECLS
-typedef struct _ETimezoneEntry ETimezoneEntry;
+typedef struct _ETimezoneEntry ETimezoneEntry;
+typedef struct _ETimezoneEntryClass ETimezoneEntryClass;
typedef struct _ETimezoneEntryPrivate ETimezoneEntryPrivate;
-typedef struct _ETimezoneEntryClass ETimezoneEntryClass;
struct _ETimezoneEntry {
- GtkHBox hbox;
-
- /*< private >*/
+ GtkHBox parent;
ETimezoneEntryPrivate *priv;
};
struct _ETimezoneEntryClass {
GtkHBoxClass parent_class;
- void (* changed) (ETimezoneEntry *tentry);
+ void (*changed) (ETimezoneEntry *timezone_entry);
};
-GType e_timezone_entry_get_type (void);
-GtkWidget* e_timezone_entry_new (void);
-
-icaltimezone* e_timezone_entry_get_timezone (ETimezoneEntry *tentry);
-void e_timezone_entry_set_timezone (ETimezoneEntry *tentry,
- icaltimezone *zone);
+GType e_timezone_entry_get_type (void);
+GtkWidget * e_timezone_entry_new (void);
+icaltimezone * e_timezone_entry_get_timezone (ETimezoneEntry *timezone_entry);
+void e_timezone_entry_set_timezone (ETimezoneEntry *timezone_entry,
+ icaltimezone *timezone);
-/* Sets the default timezone. If the current timezone matches this, then the
- entry field is hidden. This is useful since most people do not use timezones
- so it makes the user interface simpler. */
-void e_timezone_entry_set_default_timezone(ETimezoneEntry *tentry,
- icaltimezone *zone);
+/* Sets the default timezone. If the current timezone matches this,
+ * then the entry field is hidden. This is useful since most people
+ * do not use timezones so it makes the user interface simpler. */
+void e_timezone_entry_set_default_timezone
+ (ETimezoneEntry *timezone_entry,
+ icaltimezone *timezone);
G_END_DECLS
-#endif /* __E_TIMEZONE_ENTRY_H_ */
+#endif /* E_TIMEZONE_ENTRY_H */
diff --git a/calendar/gui/e-week-view-config.c b/calendar/gui/e-week-view-config.c
deleted file mode 100644
index 423a12a2d9..0000000000
--- a/calendar/gui/e-week-view-config.c
+++ /dev/null
@@ -1,286 +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 "calendar-config.h"
-#include "e-week-view-config.h"
-
-struct _EWeekViewConfigPrivate {
- EWeekView *view;
-
- GList *notifications;
-};
-
-/* Property IDs */
-enum props {
- PROP_0,
- PROP_VIEW,
-};
-
-G_DEFINE_TYPE (EWeekViewConfig, e_week_view_config, G_TYPE_OBJECT)
-
-static void
-e_week_view_config_set_property (GObject *object, guint property_id, const GValue *value, GParamSpec *pspec)
-{
- EWeekViewConfig *view_config;
-
- view_config = E_WEEK_VIEW_CONFIG (object);
-
- switch (property_id) {
- case PROP_VIEW:
- e_week_view_config_set_view (view_config, g_value_get_object (value));
- break;
- default:
- G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
- break;
- }
-}
-
-static void
-e_week_view_config_get_property (GObject *object, guint property_id, GValue *value, GParamSpec *pspec)
-{
- EWeekViewConfig *view_config;
-
- view_config = E_WEEK_VIEW_CONFIG (object);
-
- switch (property_id) {
- case PROP_VIEW:
- g_value_set_object (value, e_week_view_config_get_view (view_config));
- break;
- default:
- G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
- break;
- }
-}
-
-static void
-e_week_view_config_dispose (GObject *object)
-{
- EWeekViewConfig *view_config = E_WEEK_VIEW_CONFIG (object);
-
- e_week_view_config_set_view (view_config, NULL);
-
- if (G_OBJECT_CLASS (e_week_view_config_parent_class)->dispose)
- G_OBJECT_CLASS (e_week_view_config_parent_class)->dispose (object);
-}
-
-static void
-e_week_view_config_finalize (GObject *object)
-{
- EWeekViewConfig *view_config = E_WEEK_VIEW_CONFIG (object);
- EWeekViewConfigPrivate *priv;
-
- priv = view_config->priv;
-
- g_free (priv);
-
- if (G_OBJECT_CLASS (e_week_view_config_parent_class)->finalize)
- G_OBJECT_CLASS (e_week_view_config_parent_class)->finalize (object);
-}
-
-static void
-e_week_view_config_class_init (EWeekViewConfigClass *klass)
-{
- GObjectClass *gobject_class = G_OBJECT_CLASS (klass);
- GParamSpec *spec;
-
- /* Method override */
- gobject_class->set_property = e_week_view_config_set_property;
- gobject_class->get_property = e_week_view_config_get_property;
- 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 (),
- G_PARAM_READABLE | G_PARAM_WRITABLE | G_PARAM_CONSTRUCT);
- g_object_class_install_property (gobject_class, PROP_VIEW, spec);
-}
-
-static void
-e_week_view_config_init (EWeekViewConfig *view_config)
-{
- view_config->priv = g_new0 (EWeekViewConfigPrivate, 1);
-
-}
-
-EWeekViewConfig *
-e_week_view_config_new (EWeekView *week_view)
-{
- EWeekViewConfig *view_config;
-
- view_config = g_object_new (e_week_view_config_get_type (), "view", week_view, NULL);
-
- return view_config;
-}
-
-EWeekView *
-e_week_view_config_get_view (EWeekViewConfig *view_config)
-{
- EWeekViewConfigPrivate *priv;
-
- g_return_val_if_fail (view_config != NULL, NULL);
- g_return_val_if_fail (E_IS_WEEK_VIEW_CONFIG (view_config), NULL);
-
- priv = view_config->priv;
-
- return priv->view;
-}
-
-static void
-set_week_start (EWeekView *week_view)
-{
- gint week_start_week;
-
- week_start_week = calendar_config_get_week_start_day ();
-
- /* Convert it to 0 (Mon) to 6 (Sun), which is what we use. */
- week_start_week = (week_start_week + 6) % 7;
-
- e_week_view_set_week_start_day (week_view, week_start_week);
-}
-
-static void
-week_start_changed_cb (GConfClient *client, guint id, GConfEntry *entry, gpointer data)
-{
- EWeekViewConfig *view_config = data;
- EWeekViewConfigPrivate *priv;
-
- priv = view_config->priv;
-
- set_week_start (priv->view);
-}
-
-static void
-set_twentyfour_hour (EWeekView *week_view)
-{
- gboolean use_24_hour;
-
- use_24_hour = calendar_config_get_24_hour_format ();
-
- e_calendar_view_set_use_24_hour_format (E_CALENDAR_VIEW (week_view), use_24_hour);
-}
-
-static void
-twentyfour_hour_changed_cb (GConfClient *client, guint id, GConfEntry *entry, gpointer data)
-{
- EWeekViewConfig *view_config = data;
- EWeekViewConfigPrivate *priv;
-
- priv = view_config->priv;
-
- set_twentyfour_hour (priv->view);
-}
-
-static void
-set_show_event_end (EWeekView *week_view)
-{
- gboolean show_event_end;
-
- show_event_end = calendar_config_get_show_event_end ();
-
- e_week_view_set_show_event_end_times (week_view, show_event_end);
-}
-
-static void
-show_event_end_changed_cb (GConfClient *client, guint id, GConfEntry *entry, gpointer data)
-{
- EWeekViewConfig *view_config = data;
- EWeekViewConfigPrivate *priv;
-
- priv = view_config->priv;
-
- set_show_event_end (priv->view);
-}
-
-static void
-set_compress_weekend (EWeekView *week_view)
-{
- gboolean compress_weekend;
-
- compress_weekend = calendar_config_get_compress_weekend ();
-
- e_week_view_set_compress_weekend (week_view, compress_weekend);
-}
-
-static void
-compress_weekend_changed_cb (GConfClient *client, guint id, GConfEntry *entry, gpointer data)
-{
- EWeekViewConfig *view_config = data;
- EWeekViewConfigPrivate *priv;
-
- priv = view_config->priv;
-
- set_compress_weekend (priv->view);
-}
-
-void
-e_week_view_config_set_view (EWeekViewConfig *view_config, EWeekView *week_view)
-{
- EWeekViewConfigPrivate *priv;
- guint not;
- GList *l;
-
- g_return_if_fail (view_config != NULL);
- g_return_if_fail (E_IS_WEEK_VIEW_CONFIG (view_config));
-
- priv = view_config->priv;
-
- if (priv->view) {
- g_object_unref (priv->view);
- priv->view = 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;
-
- /* If the new view is NULL, return right now */
- if (!week_view)
- return;
-
- priv->view = g_object_ref (week_view);
-
- /* Week start */
- set_week_start (week_view);
-
- not = calendar_config_add_notification_week_start_day (week_start_changed_cb, view_config);
- priv->notifications = g_list_prepend (priv->notifications, GUINT_TO_POINTER (not));
-
- /* 24 Hour format */
- set_twentyfour_hour (week_view);
-
- not = calendar_config_add_notification_24_hour_format (twentyfour_hour_changed_cb, view_config);
- priv->notifications = g_list_prepend (priv->notifications, GUINT_TO_POINTER (not));
-
- /* Show event end */
- set_show_event_end (week_view);
-
- not = calendar_config_add_notification_show_event_end (show_event_end_changed_cb, view_config);
- priv->notifications = g_list_prepend (priv->notifications, GUINT_TO_POINTER (not));
-
- /* Compress weekend */
- set_compress_weekend (week_view);
-
- not = calendar_config_add_notification_compress_weekend (compress_weekend_changed_cb, view_config);
- priv->notifications = g_list_prepend (priv->notifications, GUINT_TO_POINTER (not));
-}
-
diff --git a/calendar/gui/e-week-view-config.h b/calendar/gui/e-week-view-config.h
deleted file mode 100644
index e86e0fa968..0000000000
--- a/calendar/gui/e-week-view-config.h
+++ /dev/null
@@ -1,55 +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:
- * JP Rosevear <jpr@ximian.com>
- *
- * Copyright (C) 1999-2008 Novell, Inc. (www.novell.com)
- *
- */
-
-#ifndef _E_WEEK_VIEW_CONFIG_H_
-#define _E_WEEK_VIEW_CONFIG_H_
-
-#include "e-week-view.h"
-
-G_BEGIN_DECLS
-
-#define E_WEEK_VIEW_CONFIG(obj) G_TYPE_CHECK_INSTANCE_CAST (obj, e_week_view_config_get_type (), EWeekViewConfig)
-#define E_WEEK_VIEW_CONFIG_CLASS(klass) G_TYPE_CHECK_CLASS_CAST (klass, e_week_view_config_get_type (), EWeekViewConfigClass)
-#define E_IS_WEEK_VIEW_CONFIG(obj) G_TYPE_CHECK_INSTANCE_TYPE (obj, e_week_view_config_get_type ())
-
-typedef struct _EWeekViewConfig EWeekViewConfig;
-typedef struct _EWeekViewConfigClass EWeekViewConfigClass;
-typedef struct _EWeekViewConfigPrivate EWeekViewConfigPrivate;
-
-struct _EWeekViewConfig {
- GObject parent;
-
- EWeekViewConfigPrivate *priv;
-};
-
-struct _EWeekViewConfigClass {
- GObjectClass parent_class;
-};
-
-GType e_week_view_config_get_type (void);
-EWeekViewConfig *e_week_view_config_new (EWeekView *week_view);
-EWeekView *e_week_view_config_get_view (EWeekViewConfig *view_config);
-void e_week_view_config_set_view (EWeekViewConfig *view_config, EWeekView *week_view);
-
-G_END_DECLS
-
-#endif
diff --git a/calendar/gui/e-week-view-event-item.c b/calendar/gui/e-week-view-event-item.c
index ed939feb10..dc31e20696 100644
--- a/calendar/gui/e-week-view-event-item.c
+++ b/calendar/gui/e-week-view-event-item.c
@@ -629,6 +629,7 @@ e_week_view_draw_time (EWeekView *week_view,
gint hour,
gint minute)
{
+ ECalModel *model;
GtkStyle *style;
GdkGC *gc;
gint hour_to_display, suffix_width;
@@ -638,6 +639,8 @@ e_week_view_draw_time (EWeekView *week_view,
PangoLayout *layout;
PangoFontDescription *small_font_desc;
+ model = e_calendar_view_get_model (E_CALENDAR_VIEW (week_view));
+
style = gtk_widget_get_style (GTK_WIDGET (week_view));
small_font_desc = week_view->small_font_desc;
gc = week_view->main_gc;
@@ -687,7 +690,7 @@ e_week_view_draw_time (EWeekView *week_view,
time_x += week_view->small_digit_width * 2;
/* Draw the 'am'/'pm' suffix, if 12-hour format. */
- if (!e_calendar_view_get_use_24_hour_format (E_CALENDAR_VIEW (week_view))) {
+ if (!e_cal_model_get_use_24_hour_format (model)) {
pango_layout_set_text (layout, suffix, -1);
gdk_draw_layout (drawable, gc,
diff --git a/calendar/gui/e-week-view.c b/calendar/gui/e-week-view.c
index 4d21eae9d0..d4043ff4fe 100644
--- a/calendar/gui/e-week-view.c
+++ b/calendar/gui/e-week-view.c
@@ -39,7 +39,8 @@
#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-binding.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 +52,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 +169,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,42 +194,409 @@ static gboolean e_week_view_layout_timeout_cb (gpointer data);
G_DEFINE_TYPE (EWeekView, e_week_view, E_TYPE_CALENDAR_VIEW)
+enum {
+ PROP_0,
+ PROP_COMPRESS_WEEKEND,
+ PROP_SHOW_EVENT_END_TIMES
+};
+
+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_class_init (EWeekViewClass *class)
+timezone_changed_cb (ECalendarView *cal_view,
+ icaltimezone *old_zone,
+ icaltimezone *new_zone,
+ gpointer user_data)
{
- GtkObjectClass *object_class;
- GtkWidgetClass *widget_class;
- ECalendarViewClass *view_class;
+ struct icaltimetype tt = icaltime_null_time ();
+ time_t lower;
+ EWeekView *week_view = (EWeekView *) cal_view;
+
+ g_return_if_fail (E_IS_WEEK_VIEW (week_view));
+
+ if (!cal_view->in_focus)
+ return;
+
+ /* If we don't have a valid date set yet, just return. */
+ if (!g_date_valid (&week_view->first_day_shown))
+ return;
+
+ /* Recalculate the new start of the first week. We just use exactly
+ the same time, but with the new timezone. */
+ tt.year = g_date_get_year (&week_view->first_day_shown);
+ tt.month = g_date_get_month (&week_view->first_day_shown);
+ tt.day = g_date_get_day (&week_view->first_day_shown);
+
+ lower = icaltime_as_timet_with_zone (tt, new_zone);
+
+ e_week_view_recalc_day_starts (week_view, lower);
+ e_week_view_update_query (week_view);
+}
+
+static void
+week_view_notify_week_start_day_cb (EWeekView *week_view)
+{
+ GDate *first_day_shown;
+
+ first_day_shown = &week_view->first_day_shown;
+
+ e_week_view_recalc_display_start_day (week_view);
+
+ /* Recalculate the days shown and reload if necessary. */
+ if (g_date_valid (first_day_shown))
+ e_week_view_set_first_day_shown (week_view, first_day_shown);
+
+ gtk_widget_queue_draw (week_view->titles_canvas);
+ gtk_widget_queue_draw (week_view->main_canvas);
+}
+
+static void
+week_view_set_property (GObject *object,
+ guint property_id,
+ const GValue *value,
+ GParamSpec *pspec)
+{
+ switch (property_id) {
+ case PROP_COMPRESS_WEEKEND:
+ e_week_view_set_compress_weekend (
+ E_WEEK_VIEW (object),
+ g_value_get_boolean (value));
+ return;
+
+ case PROP_SHOW_EVENT_END_TIMES:
+ e_week_view_set_show_event_end_times (
+ E_WEEK_VIEW (object),
+ g_value_get_boolean (value));
+ return;
+ }
+
+ G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
+}
+
+static void
+week_view_get_property (GObject *object,
+ guint property_id,
+ GValue *value,
+ GParamSpec *pspec)
+{
+ switch (property_id) {
+ case PROP_COMPRESS_WEEKEND:
+ g_value_set_boolean (
+ value,
+ e_week_view_get_compress_weekend (
+ E_WEEK_VIEW (object)));
+ return;
+
+ case PROP_SHOW_EVENT_END_TIMES:
+ g_value_set_boolean (
+ value,
+ e_week_view_get_show_event_end_times (
+ E_WEEK_VIEW (object)));
+ return;
+ }
+
+ G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
+}
+
+static void
+week_view_constructed (GObject *object)
+{
+ ECalModel *model;
+ EWeekView *week_view;
+ EShellSettings *shell_settings;
+
+ week_view = E_WEEK_VIEW (object);
+ model = e_calendar_view_get_model (E_CALENDAR_VIEW (week_view));
+ shell_settings = e_cal_model_get_shell_settings (model);
+
+ e_binding_new (
+ G_OBJECT (shell_settings), "cal-compress-weekend",
+ G_OBJECT (week_view), "compress-weekend");
+
+ e_binding_new (
+ G_OBJECT (shell_settings), "cal-show-event-end-times",
+ G_OBJECT (week_view), "show-event-end-times");
+
+ g_signal_connect_swapped (
+ model, "notify::week-start-day",
+ G_CALLBACK (week_view_notify_week_start_day_cb), week_view);
+}
+
+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;
+ }
- object_class = (GtkObjectClass *) class;
- widget_class = (GtkWidgetClass *) class;
- view_class = (ECalendarViewClass *) class;
+ 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);
+}
- /* Method override */
- object_class->destroy = e_week_view_destroy;
+static void
+week_view_cursor_key_left (EWeekView *week_view)
+{
+ if (week_view->selection_start_day == -1)
+ return;
- widget_class->realize = e_week_view_realize;
- widget_class->unrealize = e_week_view_unrealize;
- widget_class->style_set = e_week_view_style_set;
- widget_class->size_allocate = e_week_view_size_allocate;
- widget_class->focus_in_event = e_week_view_focus_in;
- widget_class->focus_out_event = e_week_view_focus_out;
- widget_class->key_press_event = e_week_view_key_press;
- widget_class->popup_menu = e_week_view_popup_menu;
- widget_class->expose_event = e_week_view_expose_event;
- widget_class->focus = e_week_view_focus;
+ 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)
+{
+ GObjectClass *object_class;
+ GtkObjectClass *gtk_object_class;
+ GtkWidgetClass *widget_class;
+ ECalendarViewClass *view_class;
+
+ object_class = G_OBJECT_CLASS (class);
+ object_class->set_property = week_view_set_property;
+ object_class->get_property = week_view_get_property;
+ object_class->constructed = week_view_constructed;
+
+ gtk_object_class = GTK_OBJECT_CLASS (class);
+ gtk_object_class->destroy = e_week_view_destroy;
+
+ widget_class = GTK_WIDGET_CLASS (class);
+ widget_class->realize = e_week_view_realize;
+ widget_class->unrealize = e_week_view_unrealize;
+ widget_class->style_set = e_week_view_style_set;
+ widget_class->size_allocate = e_week_view_size_allocate;
+ widget_class->focus_in_event = e_week_view_focus_in;
+ widget_class->focus_out_event = e_week_view_focus_out;
+ widget_class->key_press_event = e_week_view_key_press;
+ widget_class->popup_menu = e_week_view_popup_menu;
+ widget_class->expose_event = e_week_view_expose_event;
+ widget_class->focus = e_week_view_focus;
+
+ view_class = E_CALENDAR_VIEW_CLASS (class);
view_class->get_selected_events = e_week_view_get_selected_events;
view_class->get_selected_time_range = e_week_view_get_selected_time_range;
view_class->set_selected_time_range = e_week_view_set_selected_time_range;
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;
+
+ /* XXX This property really belongs in EMonthView,
+ * but too much drawing code is tied to it. */
+ g_object_class_install_property (
+ object_class,
+ PROP_COMPRESS_WEEKEND,
+ g_param_spec_boolean (
+ "compress-weekend",
+ "Compress Weekend",
+ NULL,
+ TRUE,
+ G_PARAM_READWRITE));
+
+ g_object_class_install_property (
+ object_class,
+ PROP_SHOW_EVENT_END_TIMES,
+ g_param_spec_boolean (
+ "show-event-end-times",
+ "Show Event End Times",
+ NULL,
+ TRUE,
+ G_PARAM_READWRITE));
+
/* init the accessibility support for e_week_view */
e_week_view_a11y_init ();
}
static void
+e_week_view_init (EWeekView *week_view)
+{
+ GnomeCanvasGroup *canvas_group;
+ GtkObject *adjustment;
+ GdkPixbuf *pixbuf;
+ gint i;
+
+ GTK_WIDGET_SET_FLAGS (week_view, GTK_CAN_FOCUS);
+
+ week_view->query = NULL;
+ week_view->event_destroyed = FALSE;
+ week_view->events = g_array_new (FALSE, FALSE,
+ sizeof (EWeekViewEvent));
+ week_view->events_sorted = TRUE;
+ week_view->events_need_layout = FALSE;
+ week_view->events_need_reshape = FALSE;
+
+ week_view->layout_timeout_id = 0;
+
+ week_view->spans = NULL;
+
+ week_view->multi_week_view = FALSE;
+ week_view->month_scroll_by_week = FALSE;
+ week_view->scroll_by_week_notif_id = 0;
+ week_view->update_base_date = TRUE;
+ week_view->weeks_shown = 6;
+ week_view->rows = 6;
+ week_view->columns = 2;
+ week_view->compress_weekend = TRUE;
+ week_view->show_event_end_times = TRUE;
+ week_view->display_start_day = 0; /* Monday. */
+
+ g_date_clear (&week_view->base_date, 1);
+ g_date_clear (&week_view->first_day_shown, 1);
+
+ week_view->row_height = 10;
+ week_view->rows_per_cell = 1;
+
+ week_view->selection_start_day = -1;
+ week_view->selection_drag_pos = E_WEEK_VIEW_DRAG_NONE;
+
+ week_view->pressed_event_num = -1;
+ week_view->editing_event_num = -1;
+
+ week_view->last_edited_comp_string = NULL;
+
+ week_view->main_gc = NULL;
+
+ /* Create the small font. */
+ week_view->use_small_font = TRUE;
+
+ week_view->small_font_desc =
+ pango_font_description_copy (gtk_widget_get_style (GTK_WIDGET (week_view))->font_desc);
+ pango_font_description_set_size (week_view->small_font_desc,
+ E_WEEK_VIEW_SMALL_FONT_PTSIZE * PANGO_SCALE);
+
+ /* String to use in 12-hour time format for times in the morning. */
+ week_view->am_string = _("am");
+
+ /* String to use in 12-hour time format for times in the afternoon. */
+ week_view->pm_string = _("pm");
+
+ week_view->bc_event_time = 0;
+ week_view->before_click_dtstart = 0;
+ week_view->before_click_dtend = 0;
+
+ /*
+ * Titles Canvas. Note that we don't show it is only shown in the
+ * Month view.
+ */
+ week_view->titles_canvas = e_canvas_new ();
+ gtk_table_attach (GTK_TABLE (week_view), week_view->titles_canvas,
+ 1, 2, 0, 1, GTK_EXPAND | GTK_FILL, GTK_FILL, 0, 0);
+
+ canvas_group = GNOME_CANVAS_GROUP (GNOME_CANVAS (week_view->titles_canvas)->root);
+
+ week_view->titles_canvas_item =
+ gnome_canvas_item_new (canvas_group,
+ e_week_view_titles_item_get_type (),
+ "EWeekViewTitlesItem::week_view", week_view,
+ NULL);
+
+ /*
+ * Main Canvas
+ */
+ week_view->main_canvas = e_canvas_new ();
+ gtk_table_attach (GTK_TABLE (week_view), week_view->main_canvas,
+ 1, 2, 1, 2,
+ GTK_EXPAND | GTK_FILL, GTK_EXPAND | GTK_FILL, 1, 1);
+ gtk_widget_show (week_view->main_canvas);
+
+ canvas_group = GNOME_CANVAS_GROUP (GNOME_CANVAS (week_view->main_canvas)->root);
+
+ week_view->main_canvas_item =
+ gnome_canvas_item_new (canvas_group,
+ e_week_view_main_item_get_type (),
+ "EWeekViewMainItem::week_view", week_view,
+ NULL);
+
+ g_signal_connect_after (week_view->main_canvas, "button_press_event",
+ G_CALLBACK (e_week_view_on_button_press), week_view);
+ g_signal_connect (week_view->main_canvas, "button_release_event",
+ G_CALLBACK (e_week_view_on_button_release), week_view);
+ g_signal_connect (week_view->main_canvas, "scroll_event",
+ G_CALLBACK (e_week_view_on_scroll), week_view);
+ g_signal_connect (week_view->main_canvas, "motion_notify_event",
+ G_CALLBACK (e_week_view_on_motion), week_view);
+
+ /* Create the buttons to jump to each days. */
+ pixbuf = gdk_pixbuf_new_from_xpm_data ((const gchar **) jump_xpm);
+
+ for (i = 0; i < E_WEEK_VIEW_MAX_WEEKS * 7; i++) {
+ week_view->jump_buttons[i] = gnome_canvas_item_new
+ (canvas_group,
+ gnome_canvas_pixbuf_get_type (),
+ "GnomeCanvasPixbuf::pixbuf", pixbuf,
+ NULL);
+
+ g_signal_connect (week_view->jump_buttons[i], "event",
+ G_CALLBACK (e_week_view_on_jump_button_event), week_view);
+ }
+ week_view->focused_jump_button = E_WEEK_VIEW_JUMP_BUTTON_NO_FOCUS;
+
+ g_object_unref (pixbuf);
+
+ /*
+ * Scrollbar.
+ */
+ adjustment = gtk_adjustment_new (0, -52, 52, 1, 1, 1);
+
+ week_view->vscrollbar = gtk_vscrollbar_new (GTK_ADJUSTMENT (adjustment));
+ gtk_table_attach (GTK_TABLE (week_view), week_view->vscrollbar,
+ 2, 3, 1, 2, 0, GTK_EXPAND | GTK_FILL, 0, 0);
+ gtk_widget_show (week_view->vscrollbar);
+
+ /* Create the cursors. */
+ week_view->normal_cursor = gdk_cursor_new (GDK_LEFT_PTR);
+ week_view->move_cursor = gdk_cursor_new (GDK_FLEUR);
+ week_view->resize_width_cursor = gdk_cursor_new (GDK_SB_H_DOUBLE_ARROW);
+ week_view->last_cursor_set = NULL;
+
+ /* connect to ECalendarView's signals */
+ g_signal_connect (G_OBJECT (week_view), "timezone_changed",
+ G_CALLBACK (timezone_changed_cb), NULL);
+}
+
+static void
time_range_changed_cb (ECalModel *model, time_t start_time, time_t end_time, gpointer user_data)
{
EWeekView *week_view = E_WEEK_VIEW (user_data);
@@ -451,183 +817,6 @@ model_comps_deleted_cb (ETableModel *etm, gpointer data, gpointer user_data)
}
static void
-timezone_changed_cb (ECalendarView *cal_view, icaltimezone *old_zone,
- icaltimezone *new_zone, gpointer user_data)
-{
- struct icaltimetype tt = icaltime_null_time ();
- time_t lower;
- EWeekView *week_view = (EWeekView *) cal_view;
-
- g_return_if_fail (E_IS_WEEK_VIEW (week_view));
-
- if (!cal_view->in_focus)
- return;
-
- /* If we don't have a valid date set yet, just return. */
- if (!g_date_valid (&week_view->first_day_shown))
- return;
-
- /* Recalculate the new start of the first week. We just use exactly
- the same time, but with the new timezone. */
- tt.year = g_date_get_year (&week_view->first_day_shown);
- tt.month = g_date_get_month (&week_view->first_day_shown);
- tt.day = g_date_get_day (&week_view->first_day_shown);
-
- lower = icaltime_as_timet_with_zone (tt, new_zone);
-
- e_week_view_recalc_day_starts (week_view, lower);
- e_week_view_update_query (week_view);
-}
-
-static void
-e_week_view_init (EWeekView *week_view)
-{
- GnomeCanvasGroup *canvas_group;
- GtkObject *adjustment;
- GdkPixbuf *pixbuf;
- gint i;
-
- GTK_WIDGET_SET_FLAGS (week_view, GTK_CAN_FOCUS);
-
- week_view->query = NULL;
- week_view->event_destroyed = FALSE;
- week_view->events = g_array_new (FALSE, FALSE,
- sizeof (EWeekViewEvent));
- week_view->events_sorted = TRUE;
- week_view->events_need_layout = FALSE;
- week_view->events_need_reshape = FALSE;
-
- week_view->layout_timeout_id = 0;
-
- week_view->spans = NULL;
-
- week_view->multi_week_view = FALSE;
- week_view->month_scroll_by_week = FALSE;
- week_view->scroll_by_week_notif_id = 0;
- week_view->update_base_date = TRUE;
- week_view->weeks_shown = 6;
- week_view->rows = 6;
- week_view->columns = 2;
- week_view->compress_weekend = TRUE;
- week_view->show_event_end_times = TRUE;
- week_view->week_start_day = 0; /* Monday. */
- week_view->display_start_day = 0; /* Monday. */
-
- g_date_clear (&week_view->base_date, 1);
- g_date_clear (&week_view->first_day_shown, 1);
-
- week_view->row_height = 10;
- week_view->rows_per_cell = 1;
-
- week_view->selection_start_day = -1;
- week_view->selection_drag_pos = E_WEEK_VIEW_DRAG_NONE;
-
- week_view->pressed_event_num = -1;
- week_view->editing_event_num = -1;
-
- week_view->last_edited_comp_string = NULL;
-
- week_view->main_gc = NULL;
-
- /* Create the small font. */
- week_view->use_small_font = TRUE;
-
- week_view->small_font_desc =
- pango_font_description_copy (gtk_widget_get_style (GTK_WIDGET (week_view))->font_desc);
- pango_font_description_set_size (week_view->small_font_desc,
- E_WEEK_VIEW_SMALL_FONT_PTSIZE * PANGO_SCALE);
-
- /* String to use in 12-hour time format for times in the morning. */
- week_view->am_string = _("am");
-
- /* String to use in 12-hour time format for times in the afternoon. */
- week_view->pm_string = _("pm");
-
- week_view->bc_event_time = 0;
- week_view->before_click_dtstart = 0;
- week_view->before_click_dtend = 0;
-
- /*
- * Titles Canvas. Note that we don't show it is only shown in the
- * Month view.
- */
- week_view->titles_canvas = e_canvas_new ();
- gtk_table_attach (GTK_TABLE (week_view), week_view->titles_canvas,
- 1, 2, 0, 1, GTK_EXPAND | GTK_FILL, GTK_FILL, 0, 0);
-
- canvas_group = GNOME_CANVAS_GROUP (GNOME_CANVAS (week_view->titles_canvas)->root);
-
- week_view->titles_canvas_item =
- gnome_canvas_item_new (canvas_group,
- e_week_view_titles_item_get_type (),
- "EWeekViewTitlesItem::week_view", week_view,
- NULL);
-
- /*
- * Main Canvas
- */
- week_view->main_canvas = e_canvas_new ();
- gtk_table_attach (GTK_TABLE (week_view), week_view->main_canvas,
- 1, 2, 1, 2,
- GTK_EXPAND | GTK_FILL, GTK_EXPAND | GTK_FILL, 1, 1);
- gtk_widget_show (week_view->main_canvas);
-
- canvas_group = GNOME_CANVAS_GROUP (GNOME_CANVAS (week_view->main_canvas)->root);
-
- week_view->main_canvas_item =
- gnome_canvas_item_new (canvas_group,
- e_week_view_main_item_get_type (),
- "EWeekViewMainItem::week_view", week_view,
- NULL);
-
- g_signal_connect_after (week_view->main_canvas, "button_press_event",
- G_CALLBACK (e_week_view_on_button_press), week_view);
- g_signal_connect (week_view->main_canvas, "button_release_event",
- G_CALLBACK (e_week_view_on_button_release), week_view);
- g_signal_connect (week_view->main_canvas, "scroll_event",
- G_CALLBACK (e_week_view_on_scroll), week_view);
- g_signal_connect (week_view->main_canvas, "motion_notify_event",
- G_CALLBACK (e_week_view_on_motion), week_view);
-
- /* Create the buttons to jump to each days. */
- pixbuf = gdk_pixbuf_new_from_xpm_data ((const gchar **) jump_xpm);
-
- for (i = 0; i < E_WEEK_VIEW_MAX_WEEKS * 7; i++) {
- week_view->jump_buttons[i] = gnome_canvas_item_new
- (canvas_group,
- gnome_canvas_pixbuf_get_type (),
- "GnomeCanvasPixbuf::pixbuf", pixbuf,
- NULL);
-
- g_signal_connect (week_view->jump_buttons[i], "event",
- G_CALLBACK (e_week_view_on_jump_button_event), week_view);
- }
- week_view->focused_jump_button = E_WEEK_VIEW_JUMP_BUTTON_NO_FOCUS;
-
- g_object_unref (pixbuf);
-
- /*
- * Scrollbar.
- */
- adjustment = gtk_adjustment_new (0, -52, 52, 1, 1, 1);
-
- week_view->vscrollbar = gtk_vscrollbar_new (GTK_ADJUSTMENT (adjustment));
- gtk_table_attach (GTK_TABLE (week_view), week_view->vscrollbar,
- 2, 3, 1, 2, 0, GTK_EXPAND | GTK_FILL, 0, 0);
- gtk_widget_show (week_view->vscrollbar);
-
- /* Create the cursors. */
- week_view->normal_cursor = gdk_cursor_new (GDK_LEFT_PTR);
- week_view->move_cursor = gdk_cursor_new (GDK_FLEUR);
- week_view->resize_width_cursor = gdk_cursor_new (GDK_SB_H_DOUBLE_ARROW);
- week_view->last_cursor_set = NULL;
-
- /* connect to ECalendarView's signals */
- g_signal_connect (G_OBJECT (week_view), "timezone_changed",
- G_CALLBACK (timezone_changed_cb), NULL);
-}
-
-static void
init_model (EWeekView *week_view, ECalModel *model)
{
/* connect to ECalModel's signals */
@@ -650,14 +839,15 @@ init_model (EWeekView *week_view, ECalModel *model)
*
* Creates a new #EWeekView.
**/
-GtkWidget *
+ECalendarView *
e_week_view_new (ECalModel *model)
{
- GtkWidget *week_view;
+ ECalendarView *week_view;
- week_view = GTK_WIDGET (g_object_new (e_week_view_get_type (), NULL));
- e_calendar_view_set_model ((ECalendarView *) week_view, model);
- init_model ((EWeekView *) week_view, model);
+ g_return_val_if_fail (E_IS_CAL_MODEL (model), NULL);
+
+ week_view = g_object_new (E_TYPE_WEEK_VIEW, "model", model, NULL);
+ init_model (E_WEEK_VIEW (week_view), model);
return week_view;
}
@@ -1796,7 +1986,7 @@ e_week_view_set_weeks_shown (EWeekView *week_view,
}
gboolean
-e_week_view_get_compress_weekend (EWeekView *week_view)
+e_week_view_get_compress_weekend (EWeekView *week_view)
{
g_return_val_if_fail (E_IS_WEEK_VIEW (week_view), FALSE);
@@ -1804,17 +1994,17 @@ e_week_view_get_compress_weekend (EWeekView *week_view)
}
void
-e_week_view_set_compress_weekend (EWeekView *week_view,
- gboolean compress)
+e_week_view_set_compress_weekend (EWeekView *week_view,
+ gboolean compress_weekend)
{
gboolean need_reload = FALSE;
g_return_if_fail (E_IS_WEEK_VIEW (week_view));
- if (week_view->compress_weekend == compress)
+ if (week_view->compress_weekend == compress_weekend)
return;
- week_view->compress_weekend = compress;
+ week_view->compress_weekend = compress_weekend;
/* The option only affects the month view. */
if (!week_view->multi_week_view)
@@ -1838,11 +2028,13 @@ e_week_view_set_compress_weekend (EWeekView *week_view,
gtk_widget_queue_draw (week_view->titles_canvas);
gtk_widget_queue_draw (week_view->main_canvas);
+
+ g_object_notify (G_OBJECT (week_view), "compress-weekend");
}
/* Whether we display event end times. */
gboolean
-e_week_view_get_show_event_end_times (EWeekView *week_view)
+e_week_view_get_show_event_end_times (EWeekView *week_view)
{
g_return_val_if_fail (E_IS_WEEK_VIEW (week_view), TRUE);
@@ -1850,61 +2042,36 @@ 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)
+e_week_view_set_show_event_end_times (EWeekView *week_view,
+ gboolean show_event_end_times)
{
g_return_if_fail (E_IS_WEEK_VIEW (week_view));
- if (week_view->show_event_end_times != show) {
- week_view->show_event_end_times = show;
- e_week_view_recalc_cell_sizes (week_view);
- week_view->events_need_reshape = TRUE;
- e_week_view_check_layout (week_view);
- }
-}
-
-/* The first day of the week, 0 (Monday) to 6 (Sunday). */
-gint
-e_week_view_get_week_start_day (EWeekView *week_view)
-{
- g_return_val_if_fail (E_IS_WEEK_VIEW (week_view), 0);
-
- return week_view->week_start_day;
-}
-
-void
-e_week_view_set_week_start_day (EWeekView *week_view,
- gint week_start_day)
-{
- g_return_if_fail (E_IS_WEEK_VIEW (week_view));
- g_return_if_fail (week_start_day >= 0);
- g_return_if_fail (week_start_day < 7);
-
- if (week_view->week_start_day == week_start_day)
+ if (week_view->show_event_end_times != show_event_end_times)
return;
- week_view->week_start_day = week_start_day;
-
- e_week_view_recalc_display_start_day (week_view);
-
- /* Recalculate the days shown and reload if necessary. */
- if (g_date_valid (&week_view->first_day_shown))
- e_week_view_set_first_day_shown (week_view,
- &week_view->first_day_shown);
+ week_view->show_event_end_times = show_event_end_times;
+ e_week_view_recalc_cell_sizes (week_view);
+ week_view->events_need_reshape = TRUE;
+ e_week_view_check_layout (week_view);
- gtk_widget_queue_draw (week_view->titles_canvas);
- gtk_widget_queue_draw (week_view->main_canvas);
+ g_object_notify (G_OBJECT (week_view), "show-event-end-times");
}
static gboolean
e_week_view_recalc_display_start_day (EWeekView *week_view)
{
+ ECalModel *model;
+ gint week_start_day;
gint display_start_day;
+ model = e_calendar_view_get_model (E_CALENDAR_VIEW (week_view));
+ week_start_day = e_cal_model_get_week_start_day (model);
+
/* The display start day defaults to week_start_day, but we have
to use Saturday if the weekend is compressed and week_start_day
is Sunday. */
- display_start_day = week_view->week_start_day;
+ display_start_day = week_start_day;
if (display_start_day == 6
&& (!week_view->multi_week_view || week_view->compress_weekend))
@@ -1940,6 +2107,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.
@@ -3426,7 +3596,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;
@@ -3627,7 +3797,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);
@@ -3817,227 +3988,48 @@ 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)
+e_week_view_cursor_key_up (EWeekView *week_view)
{
- if (week_view->selection_start_day == -1)
- return;
-
- week_view->selection_start_day--;
+ EWeekViewClass *week_view_class;
- 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_class = E_WEEK_VIEW_GET_CLASS (week_view);
+ g_return_if_fail (week_view_class->cursor_key_up != NULL);
- 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_week_view_do_cursor_key_down (EWeekView *week_view)
+e_week_view_cursor_key_down (EWeekView *week_view)
{
- if (week_view->selection_start_day == -1)
- return;
-
- week_view->selection_start_day++;
+ EWeekViewClass *week_view_class;
- 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_class = E_WEEK_VIEW_GET_CLASS (week_view);
+ g_return_if_fail (week_view_class->cursor_key_down != NULL);
- 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_down (week_view);
}
static void
-e_week_view_do_cursor_key_left (EWeekView *week_view)
+e_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);
-}
+ EWeekViewClass *week_view_class;
-static void
-e_week_view_do_cursor_key_right (EWeekView *week_view)
-{
- 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);
- 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);
+ week_view_class->cursor_key_left (week_view);
}
static void
-e_month_view_do_cursor_key_up (EWeekView *week_view)
+e_week_view_cursor_key_right (EWeekView *week_view)
{
- if (week_view->selection_start_day == -1)
- return;
+ EWeekViewClass *week_view_class;
- 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;
- }
+ week_view_class = E_WEEK_VIEW_GET_CLASS (week_view);
+ g_return_if_fail (week_view_class->cursor_key_right != NULL);
- 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);
-}
-
-static void
-e_month_view_do_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, 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;
- }
-
- 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_right (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 * 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);
-}
-
-static void
-e_week_view_cursor_key_up (EWeekView *week_view, GnomeCalendarViewType view_type)
-{
- 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 ();
- }
-}
-
-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 ();
- }
-}
-
-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
@@ -4138,7 +4130,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);
@@ -4158,7 +4149,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)) {
@@ -4177,16 +4167,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;
@@ -4275,26 +4265,14 @@ e_week_view_key_press (GtkWidget *widget, GdkEventKey *event)
return handled;
}
-static void
-popup_destroyed_cb (gpointer data, GObject *where_object_was)
-{
- EWeekView *week_view = data;
-
- week_view->popup_event_num = -1;
-}
-
void
e_week_view_show_popup_menu (EWeekView *week_view,
GdkEventButton *bevent,
gint event_num)
{
- GtkMenu *popup;
-
week_view->popup_event_num = event_num;
- 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());
+ e_calendar_view_popup_event (E_CALENDAR_VIEW (week_view), bevent);
}
static gboolean
@@ -4391,10 +4369,14 @@ e_week_view_convert_time_to_display (EWeekView *week_view,
const gchar **suffix,
gint *suffix_width)
{
+ ECalModel *model;
+
+ model = e_calendar_view_get_model (E_CALENDAR_VIEW (week_view));
+
/* Calculate the actual hour number to display. For 12-hour
format we convert 0-23 to 12-11am/12-11pm. */
*display_hour = hour;
- if (e_calendar_view_get_use_24_hour_format (E_CALENDAR_VIEW (week_view))) {
+ if (e_cal_model_get_use_24_hour_format (model)) {
*suffix = "";
*suffix_width = 0;
} else {
@@ -4416,8 +4398,11 @@ e_week_view_convert_time_to_display (EWeekView *week_view,
gint
e_week_view_get_time_string_width (EWeekView *week_view)
{
+ ECalModel *model;
gint time_width;
+ model = e_calendar_view_get_model (E_CALENDAR_VIEW (week_view));
+
if (week_view->use_small_font && week_view->small_font_desc)
time_width = week_view->digit_width * 2
+ week_view->small_digit_width * 2;
@@ -4425,7 +4410,7 @@ e_week_view_get_time_string_width (EWeekView *week_view)
time_width = week_view->digit_width * 4
+ week_view->colon_width;
- if (!e_calendar_view_get_use_24_hour_format (E_CALENDAR_VIEW (week_view)))
+ if (!e_cal_model_get_use_24_hour_format (model))
time_width += MAX (week_view->am_string_width,
week_view->pm_string_width);
diff --git a/calendar/gui/e-week-view.h b/calendar/gui/e-week-view.h
index b536e5d5a3..0712e1ac6f 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,16 +166,11 @@ 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
-{
- ECalendarView cal_view;
+struct _EWeekView {
+ ECalendarView parent;
/* The top canvas where the dates are shown. */
GtkWidget *titles_canvas;
@@ -342,110 +356,120 @@ 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);
+ECalendarView * 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_weekend);
/* 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_event_end_times);
-/* 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);
-
-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..bca4710260
--- /dev/null
+++ b/calendar/gui/ea-cal-view.c
@@ -0,0 +1,427 @@
+/*
+ * 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;
+#if 0 /* FIXME Have to go through GnomeCalendar */
+ 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;
+#endif
+ 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..58ecad70fd
--- /dev/null
+++ b/calendar/gui/ea-gnome-calendar.c
@@ -0,0 +1,324 @@
+/*
+ *
+ * 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)
+{
+ GnomeCalendarViewType view_type;
+ ECalendarView *calendar_view;
+ ECalModel *model;
+ 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;
+
+ model = gnome_calendar_get_model (gcal);
+ zone = e_cal_model_get_timezone (model);
+
+ view_type = gnome_calendar_get_view (gcal);
+ calendar_view = gnome_calendar_get_calendar_view (gcal, view_type);
+
+ e_calendar_view_get_visible_time_range (
+ calendar_view, &start_time, &end_time);
+
+ 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;
+ ECalendar *date_navigator;
+ 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 */
+ date_navigator = gnome_calendar_get_date_navigator (calendarWidget);
+ childWidget = GTK_WIDGET (date_navigator);
+ 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 576dfc81d2..defda15875 100644
--- a/calendar/gui/gnome-cal.c
+++ b/calendar/gui/gnome-cal.c
@@ -36,42 +36,30 @@
#include <glib.h>
#include <gdk/gdkkeysyms.h>
#include <glib/gi18n.h>
-#include <bonobo/bonobo-exception.h>
#include <libedataserver/e-categories.h>
#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-binding.h"
#include "e-util/e-util.h"
#include "e-util/e-error.h"
#include "e-util/e-util-private.h"
+#include "shell/e-shell.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"
-#include "e-day-view-config.h"
#include "e-day-view-time-item.h"
+#include "e-month-view.h"
#include "e-week-view.h"
-#include "e-week-view-config.h"
#include "e-cal-list-view.h"
-#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"
@@ -79,14 +67,6 @@
#include "misc.h"
#include "ea-calendar.h"
#include "common/authentication.h"
-#include "e-cal-popup.h"
-#include "e-cal-menu.h"
-#include "e-cal-model-tasks.h"
-
-/* FIXME glib 2.4 and above has this */
-#ifndef G_MAXINT32
-#define G_MAXINT32 ((gint32) 0x7fffffff)
-#endif
#define d(x)
@@ -95,11 +75,14 @@ static GHashTable *non_intrusive_error_table = NULL;
/* Private part of the GnomeCalendar structure */
struct _GnomeCalendarPrivate {
- /* The clients for display */
+ EShellSettings *shell_settings;
- GHashTable *clients[E_CAL_SOURCE_TYPE_LAST];
- GList *clients_list[E_CAL_SOURCE_TYPE_LAST];
- ECal *default_client[E_CAL_SOURCE_TYPE_LAST];
+ ECalModel *model;
+
+ /* The clients for display */
+ GHashTable *clients;
+ GList *clients_list;
+ ECal *default_client;
/*
* Fields for the calendar view
@@ -110,33 +93,9 @@ 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;
- GtkWidget *week_view;
- 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 */
@@ -150,7 +109,6 @@ struct _GnomeCalendarPrivate {
positions of the panes. range_selected is TRUE if a range of dates
was selected in the date navigator to show the view. */
ECalendarView *views[GNOME_CAL_LAST_VIEW];
- GObject *configs[GNOME_CAL_LAST_VIEW];
GnomeCalendarViewType current_view_type;
GList *notifications;
@@ -161,22 +119,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;
-
- /* Our current timezone. */
- icaltimezone *zone;
-
/* The dates currently shown. If they are -1 then we have no dates
shown. We only use these to check if we need to emit a
'dates-shown-changed' signal.*/
@@ -188,24 +134,20 @@ struct _GnomeCalendarPrivate {
it uses the date range set in search bar */
gboolean lview_select_daten_range;
- /* 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;
-
/* used in update_todo_view, to prevent interleaving when called in separate thread */
GMutex *todo_update_lock;
};
-/* Signal IDs */
+enum {
+ PROP_0,
+ PROP_DATE_NAVIGATOR,
+ PROP_SHELL_SETTINGS,
+ PROP_VIEW
+};
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,41 +155,15 @@ 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];
-
-
+static guint signals[LAST_SIGNAL];
static void gnome_calendar_destroy (GtkObject *object);
static void gnome_calendar_goto_date (GnomeCalendar *gcal,
GnomeCalendarGotoDateType goto_date);
-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);
-static void gnome_calendar_on_date_navigator_selection_changed (ECalendarItem *calitem,
- GnomeCalendar *gcal);
-static void gnome_calendar_notify_dates_shown_changed (GnomeCalendar *gcal);
-
-static void update_query (GnomeCalendar *gcal);
static void update_todo_view (GnomeCalendar *gcal);
static void update_memo_view (GnomeCalendar *gcal);
@@ -289,16 +205,340 @@ message_push (Message *msg)
G_DEFINE_TYPE (GnomeCalendar, gnome_calendar, GTK_TYPE_VBOX)
+static void
+update_adjustment (GnomeCalendar *gcal,
+ GtkAdjustment *adjustment,
+ EWeekView *week_view)
+{
+ GDate date;
+ ECalModel *model;
+ gint week_offset;
+ struct icaltimetype start_tt = icaltime_null_time ();
+ time_t lower;
+ guint32 old_first_day_julian, new_first_day_julian;
+ icaltimezone *timezone;
+
+ /* If we don't have a valid date set yet, just return. */
+ if (!g_date_valid (&week_view->first_day_shown))
+ return;
+
+ /* Determine the first date shown. */
+ date = week_view->base_date;
+ week_offset = floor (adjustment->value + 0.5);
+ g_date_add_days (&date, week_offset * 7);
+
+ /* Convert the old & new first days shown to julian values. */
+ old_first_day_julian = g_date_get_julian (&week_view->first_day_shown);
+ new_first_day_julian = g_date_get_julian (&date);
+
+ /* If we are already showing the date, just return. */
+ if (old_first_day_julian == new_first_day_julian)
+ return;
+
+ /* Convert it to a time_t. */
+ start_tt.year = g_date_get_year (&date);
+ start_tt.month = g_date_get_month (&date);
+ start_tt.day = g_date_get_day (&date);
+
+ model = gnome_calendar_get_model (gcal);
+ timezone = e_cal_model_get_timezone (model);
+ lower = icaltime_as_timet_with_zone (start_tt, timezone);
+
+ e_week_view_set_update_base_date (week_view, FALSE);
+ gnome_calendar_set_selected_time_range (gcal, lower);
+ e_week_view_set_update_base_date (week_view, TRUE);
+}
+
+static void
+week_view_adjustment_changed_cb (GtkAdjustment *adjustment,
+ GnomeCalendar *gcal)
+{
+ ECalendarView *view;
+
+ view = gnome_calendar_get_calendar_view (gcal, GNOME_CAL_WEEK_VIEW);
+ update_adjustment (gcal, adjustment, E_WEEK_VIEW (view));
+}
+
+static void
+month_view_adjustment_changed_cb (GtkAdjustment *adjustment,
+ GnomeCalendar *gcal)
+{
+ ECalendarView *view;
+
+ view = gnome_calendar_get_calendar_view (gcal, GNOME_CAL_MONTH_VIEW);
+ update_adjustment (gcal, adjustment, E_WEEK_VIEW (view));
+}
+
+static void
+view_selection_changed_cb (GnomeCalendar *gcal)
+{
+ g_signal_emit (gcal, signals[CALENDAR_SELECTION_CHANGED], 0);
+}
+
+static void
+view_progress_cb (ECalModel *model,
+ const gchar *message,
+ gint percent,
+ ECalSourceType type,
+ GnomeCalendar *gcal)
+{
+#if 0 /* KILL-BONOBO */
+ ECalendarView *view;
+
+ view = gnome_calendar_get_calendar_view (gcal, GNOME_CAL_WEEK_VIEW);
+ e_calendar_view_set_status_message (view, message, percent);
+#endif
+}
+
+static void
+view_done_cb (ECalModel *model,
+ ECalendarStatus status,
+ ECalSourceType type,
+ GnomeCalendar *gcal)
+{
+#if 0 /* KILL-BONOBO */
+ ECalendarView *view;
+
+ view = gnome_calendar_get_calendar_view (gcal, GNOME_CAL_WEEK_VIEW);
+ e_calendar_view_set_status_message (view, NULL, -1);
+#endif
+}
+
+static void
+gnome_calendar_notify_week_start_day_cb (GnomeCalendar *gcal)
+{
+ time_t start_time;
+
+ start_time = gcal->priv->base_view_time;
+ gnome_calendar_set_selected_time_range (gcal, start_time);
+}
+
+static void
+gnome_calendar_update_time_range (GnomeCalendar *gcal)
+{
+ time_t start_time;
+
+ start_time = gcal->priv->base_view_time;
+ gnome_calendar_set_selected_time_range (gcal, start_time);
+}
+
+static void
+gnome_calendar_set_shell_settings (GnomeCalendar *gcal,
+ EShellSettings *shell_settings)
+{
+ g_return_if_fail (E_IS_SHELL_SETTINGS (shell_settings));
+ g_return_if_fail (gcal->priv->shell_settings == NULL);
+
+ gcal->priv->shell_settings = g_object_ref (shell_settings);
+}
+
+static void
+gnome_calendar_set_property (GObject *object,
+ guint property_id,
+ const GValue *value,
+ GParamSpec *pspec)
+{
+ switch (property_id) {
+ case PROP_DATE_NAVIGATOR:
+ gnome_calendar_set_date_navigator (
+ GNOME_CALENDAR (object),
+ g_value_get_object (value));
+ return;
+
+ case PROP_SHELL_SETTINGS:
+ gnome_calendar_set_shell_settings (
+ GNOME_CALENDAR (object),
+ g_value_get_object (value));
+ return;
+
+ case PROP_VIEW:
+ gnome_calendar_set_view (
+ GNOME_CALENDAR (object),
+ g_value_get_int (value));
+ return;
+ }
+
+ G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
+}
+
+static void
+gnome_calendar_get_property (GObject *object,
+ guint property_id,
+ GValue *value,
+ GParamSpec *pspec)
+{
+ switch (property_id) {
+ case PROP_DATE_NAVIGATOR:
+ g_value_set_object (
+ value, gnome_calendar_get_date_navigator (
+ GNOME_CALENDAR (object)));
+ return;
+
+ case PROP_SHELL_SETTINGS:
+ g_value_set_object (
+ value, gnome_calendar_get_shell_settings (
+ GNOME_CALENDAR (object)));
+ return;
+
+ case PROP_VIEW:
+ g_value_set_int (
+ value, gnome_calendar_get_view (
+ GNOME_CALENDAR (object)));
+ return;
+ }
+
+ G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
+}
+
+static void
+gnome_calendar_constructed (GObject *object)
+{
+ GnomeCalendar *gcal = GNOME_CALENDAR (object);
+ EShellSettings *shell_settings;
+ ECalendarView *calendar_view;
+ ECalModel *model;
+ GtkAdjustment *adjustment;
+
+ shell_settings = gnome_calendar_get_shell_settings (gcal);
+
+ /* Create the model for the views. */
+ model = e_cal_model_calendar_new (shell_settings);
+ e_cal_model_set_flags (model, E_CAL_MODEL_FLAGS_EXPAND_RECURRENCES);
+ gcal->priv->model = model;
+
+ g_signal_connect (
+ model, "cal-view-progress",
+ G_CALLBACK (view_progress_cb), gcal);
+
+ g_signal_connect (
+ model, "cal-view-done",
+ G_CALLBACK (view_done_cb), gcal);
+
+ /* Day View */
+ calendar_view = e_day_view_new (model);
+ e_calendar_view_set_calendar (calendar_view, gcal);
+ gcal->priv->views[GNOME_CAL_DAY_VIEW] = calendar_view;
+
+ g_signal_connect_swapped (
+ calendar_view, "selection-changed",
+ G_CALLBACK (view_selection_changed_cb), gcal);
+
+ /* Work Week View */
+ calendar_view = e_day_view_new (model);
+ e_day_view_set_work_week_view (E_DAY_VIEW (calendar_view), TRUE);
+ e_day_view_set_days_shown (E_DAY_VIEW (calendar_view), 5);
+ e_calendar_view_set_calendar (calendar_view, gcal);
+ gcal->priv->views[GNOME_CAL_WORK_WEEK_VIEW] = calendar_view;
+
+ g_signal_connect_swapped (
+ calendar_view, "notify::working-days",
+ G_CALLBACK (gnome_calendar_update_time_range), gcal);
+
+ /* Week View */
+ calendar_view = e_week_view_new (model);
+ e_calendar_view_set_calendar (calendar_view, gcal);
+ gcal->priv->views[GNOME_CAL_WEEK_VIEW] = calendar_view;
+
+ g_signal_connect_swapped (
+ calendar_view, "selection-changed",
+ G_CALLBACK (view_selection_changed_cb), gcal);
+
+ adjustment = gtk_range_get_adjustment (
+ GTK_RANGE (E_WEEK_VIEW (calendar_view)->vscrollbar));
+ g_signal_connect (
+ adjustment, "value-changed",
+ G_CALLBACK (week_view_adjustment_changed_cb), gcal);
+
+ /* Month View */
+ calendar_view = e_month_view_new (model);
+ e_week_view_set_multi_week_view (E_WEEK_VIEW (calendar_view), TRUE);
+ e_week_view_set_weeks_shown (E_WEEK_VIEW (calendar_view), 6);
+ e_calendar_view_set_calendar (calendar_view, gcal);
+ gcal->priv->views[GNOME_CAL_MONTH_VIEW] = calendar_view;
+
+ g_signal_connect_swapped (
+ calendar_view, "selection-changed",
+ G_CALLBACK (view_selection_changed_cb), gcal);
+
+ adjustment = gtk_range_get_adjustment (
+ GTK_RANGE (E_WEEK_VIEW (calendar_view)->vscrollbar));
+ g_signal_connect (
+ adjustment, "value-changed",
+ G_CALLBACK (month_view_adjustment_changed_cb), gcal);
+
+ /* List View */
+ calendar_view = e_cal_list_view_new (model);
+ e_calendar_view_set_calendar (calendar_view, gcal);
+ gcal->priv->views[GNOME_CAL_LIST_VIEW] = calendar_view;
+
+ g_signal_connect_swapped (
+ calendar_view, "selection-changed",
+ G_CALLBACK (view_selection_changed_cb), gcal);
+
+ g_signal_connect_swapped (
+ model, "notify::week-start-day",
+ G_CALLBACK (gnome_calendar_notify_week_start_day_cb), gcal);
+
+ gnome_calendar_update_time_range (gcal);
+}
+
/* Class initialization function for the gnome calendar */
static void
gnome_calendar_class_init (GnomeCalendarClass *class)
{
- GtkObjectClass *object_class;
+ GObjectClass *object_class;
+ GtkObjectClass *gtk_object_class;
GtkBindingSet *binding_set;
- object_class = (GtkObjectClass *) class;
+ object_class = G_OBJECT_CLASS (class);
+ object_class->set_property = gnome_calendar_set_property;
+ object_class->get_property = gnome_calendar_get_property;
+ object_class->constructed = gnome_calendar_constructed;
- gnome_calendar_signals[DATES_SHOWN_CHANGED] =
+ gtk_object_class = GTK_OBJECT_CLASS (class);
+ gtk_object_class->destroy = gnome_calendar_destroy;
+
+ class->dates_shown_changed = NULL;
+ class->calendar_selection_changed = NULL;
+ class->source_added = NULL;
+ class->source_removed = NULL;
+ class->goto_date = gnome_calendar_goto_date;
+ class->change_view = gnome_calendar_set_view;
+
+ g_object_class_install_property (
+ object_class,
+ PROP_DATE_NAVIGATOR,
+ g_param_spec_object (
+ "date-navigator",
+ "Date Navigator",
+ NULL,
+ E_TYPE_CALENDAR,
+ G_PARAM_READWRITE));
+
+ g_object_class_install_property (
+ object_class,
+ PROP_SHELL_SETTINGS,
+ g_param_spec_object (
+ "shell-settings",
+ _("Shell Settings"),
+ _("Application-wide settings"),
+ E_TYPE_SHELL_SETTINGS,
+ G_PARAM_READWRITE |
+ G_PARAM_CONSTRUCT_ONLY));
+
+ g_object_class_install_property (
+ object_class,
+ PROP_VIEW,
+ g_param_spec_int (
+ "view",
+ "View",
+ NULL,
+ GNOME_CAL_DAY_VIEW,
+ GNOME_CAL_LIST_VIEW,
+ 0,
+ G_PARAM_READWRITE));
+
+ signals[DATES_SHOWN_CHANGED] =
g_signal_new ("dates_shown_changed",
G_TYPE_FROM_CLASS (object_class),
G_SIGNAL_RUN_LAST,
@@ -307,7 +547,7 @@ gnome_calendar_class_init (GnomeCalendarClass *class)
g_cclosure_marshal_VOID__VOID,
G_TYPE_NONE, 0);
- gnome_calendar_signals[CALENDAR_SELECTION_CHANGED] =
+ signals[CALENDAR_SELECTION_CHANGED] =
g_signal_new ("calendar_selection_changed",
G_TYPE_FROM_CLASS (object_class),
G_SIGNAL_RUN_LAST,
@@ -316,55 +556,7 @@ 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] =
+ signals[SOURCE_ADDED] =
g_signal_new ("source_added",
G_TYPE_FROM_CLASS (object_class),
G_SIGNAL_RUN_FIRST,
@@ -375,7 +567,7 @@ gnome_calendar_class_init (GnomeCalendarClass *class)
2,
G_TYPE_INT, G_TYPE_OBJECT);
- gnome_calendar_signals[SOURCE_REMOVED] =
+ signals[SOURCE_REMOVED] =
g_signal_new ("source_removed",
G_TYPE_FROM_CLASS (object_class),
G_SIGNAL_RUN_FIRST,
@@ -386,7 +578,7 @@ gnome_calendar_class_init (GnomeCalendarClass *class)
2,
G_TYPE_INT, G_TYPE_OBJECT);
- gnome_calendar_signals[GOTO_DATE] =
+ signals[GOTO_DATE] =
g_signal_new ("goto_date",
G_TYPE_FROM_CLASS (object_class),
G_SIGNAL_RUN_FIRST | G_SIGNAL_ACTION,
@@ -397,7 +589,7 @@ gnome_calendar_class_init (GnomeCalendarClass *class)
1,
G_TYPE_INT);
- gnome_calendar_signals[CHANGE_VIEW] =
+ signals[CHANGE_VIEW] =
g_signal_new ("change_view",
G_TYPE_FROM_CLASS (object_class),
G_SIGNAL_RUN_FIRST | G_SIGNAL_ACTION,
@@ -408,20 +600,6 @@ gnome_calendar_class_init (GnomeCalendarClass *class)
1,
G_TYPE_INT);
- object_class->destroy = gnome_calendar_destroy;
-
- 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;
- class->change_view = gnome_calendar_change_view;
-
/*
* Key bindings
*/
@@ -527,26 +705,31 @@ gnome_calendar_class_init (GnomeCalendarClass *class)
}
-/* We do this check since the calendar items are downloaded from the server in the open_method,
- since the default timezone might not be set there */
+/* We do this check since the calendar items are downloaded from the server
+ * in the open_method, since the default timezone might not be set there. */
static void
-ensure_dates_are_in_default_zone (icalcomponent *icalcomp)
+ensure_dates_are_in_default_zone (GnomeCalendar *gcal,
+ icalcomponent *icalcomp)
{
+ ECalModel *model;
+ icaltimezone *timezone;
icaltimetype dt;
- icaltimezone *zone = calendar_config_get_icaltimezone ();
- if (!zone)
+ model = gnome_calendar_get_model (gcal);
+ timezone = e_cal_model_get_timezone (model);
+
+ if (timezone == NULL)
return;
dt = icalcomponent_get_dtstart (icalcomp);
if (dt.is_utc) {
- dt = icaltime_convert_to_zone (dt, zone);
+ dt = icaltime_convert_to_zone (dt, timezone);
icalcomponent_set_dtstart (icalcomp, dt);
}
dt = icalcomponent_get_dtend (icalcomp);
if (dt.is_utc) {
- dt = icaltime_convert_to_zone (dt, zone);
+ dt = icaltime_convert_to_zone (dt, timezone);
icalcomponent_set_dtend (icalcomp, dt);
}
}
@@ -565,7 +748,7 @@ dn_e_cal_view_objects_added_cb (ECalView *query, GList *objects, gpointer data)
for (l = objects; l; l = l->next) {
ECalComponent *comp = NULL;
- ensure_dates_are_in_default_zone (l->data);
+ ensure_dates_are_in_default_zone (gcal, l->data);
comp = e_cal_component_new ();
if (!e_cal_component_set_icalcomponent (comp, icalcomponent_new_clone (l->data))) {
g_object_unref (comp);
@@ -590,7 +773,7 @@ dn_e_cal_view_objects_modified_cb (ECalView *query, GList *objects, gpointer dat
* and the tag_calendar_by_comp() below would not know how to
* untag the old dates.
*/
- update_query (gcal);
+ gnome_calendar_update_query (gcal);
}
/* Callback used when the calendar query reports of a removed object */
@@ -602,7 +785,7 @@ dn_e_cal_view_objects_removed_cb (ECalView *query, GList *ids, gpointer data)
gcal = GNOME_CALENDAR (data);
/* Just retag the whole thing */
- update_query (gcal);
+ gnome_calendar_update_query (gcal);
}
/* Callback used when the calendar query is done */
@@ -614,39 +797,48 @@ 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 < GNOME_CAL_LAST_VIEW, NULL);
- return GTK_WIDGET (priv->views[priv->current_view_type]);
+ return gcal->priv->views[view_type];
}
static void
get_times_for_views (GnomeCalendar *gcal, GnomeCalendarViewType view_type, time_t *start_time, time_t *end_time, time_t *select_time)
{
GnomeCalendarPrivate *priv;
+ ECalModel *model;
gint shown, display_start;
GDate date;
+ gint week_start_day;
gint weekday, first_day, last_day, days_shown, i;
gboolean has_working_days = FALSE;
guint offset;
struct icaltimetype tt = icaltime_null_time ();
+ icaltimezone *timezone;
+ gboolean range_selected;
+
+ model = gnome_calendar_get_model (gcal);
+ range_selected = gnome_calendar_get_range_selected (gcal);
+
+ timezone = e_cal_model_get_timezone (model);
+ week_start_day = e_cal_model_get_week_start_day (model);
priv = gcal->priv;
switch (view_type) {
case GNOME_CAL_DAY_VIEW:
shown = e_day_view_get_days_shown (E_DAY_VIEW (priv->views[view_type]));
- *start_time = time_day_begin_with_zone (*start_time, priv->zone);
- *end_time = time_add_day_with_zone (*start_time, shown, priv->zone);
+ *start_time = time_day_begin_with_zone (*start_time, timezone);
+ *end_time = time_add_day_with_zone (*start_time, shown, timezone);
break;
case GNOME_CAL_WORK_WEEK_VIEW:
/* FIXME Kind of gross, but it works */
- time_to_gdate_with_zone (&date, *start_time, priv->zone);
+ time_to_gdate_with_zone (&date, *start_time, timezone);
/* The start of the work-week is the first working day after the
week start day. */
@@ -655,7 +847,7 @@ get_times_for_views (GnomeCalendar *gcal, GnomeCalendarViewType view_type, time_
weekday = g_date_get_weekday (&date) % 7;
/* Find the first working day in the week, 0 (Sun) to 6 (Sat). */
- first_day = (E_DAY_VIEW (priv->views[view_type])->week_start_day + 1) % 7;
+ first_day = (week_start_day + 1) % 7;
for (i = 0; i < 7; i++) {
if (E_DAY_VIEW (priv->views[view_type])->working_days & (1 << first_day)) {
has_working_days = TRUE;
@@ -666,7 +858,7 @@ get_times_for_views (GnomeCalendar *gcal, GnomeCalendarViewType view_type, time_
if (has_working_days) {
/* Now find the last working day of the week, backwards. */
- last_day = E_DAY_VIEW (priv->views[view_type])->week_start_day % 7;
+ last_day = week_start_day % 7;
for (i = 0; i < 7; i++) {
if (E_DAY_VIEW (priv->views[view_type])->working_days & (1 << last_day))
break;
@@ -693,8 +885,8 @@ get_times_for_views (GnomeCalendar *gcal, GnomeCalendarViewType view_type, time_
tt.month = g_date_get_month (&date);
tt.day = g_date_get_day (&date);
- *start_time = icaltime_as_timet_with_zone (tt, priv->zone);
- *end_time = time_add_day_with_zone (*start_time, days_shown, priv->zone);
+ *start_time = icaltime_as_timet_with_zone (tt, timezone);
+ *end_time = time_add_day_with_zone (*start_time, days_shown, timezone);
if (select_time && E_DAY_VIEW (priv->views[view_type])->selection_start_day == -1)
time (select_time);
@@ -703,8 +895,8 @@ get_times_for_views (GnomeCalendar *gcal, GnomeCalendarViewType view_type, time_
/* FIXME We should be using the same day of the week enum every where */
display_start = (E_WEEK_VIEW (priv->views[view_type])->display_start_day + 1) % 7;
- *start_time = time_week_begin_with_zone (*start_time, display_start, priv->zone);
- *end_time = time_add_week_with_zone (*start_time, 1, priv->zone);
+ *start_time = time_week_begin_with_zone (*start_time, display_start, timezone);
+ *end_time = time_add_week_with_zone (*start_time, 1, timezone);
if (select_time && E_WEEK_VIEW (priv->views[view_type])->selection_start_day == -1)
time (select_time);
@@ -714,108 +906,45 @@ get_times_for_views (GnomeCalendar *gcal, GnomeCalendarViewType view_type, time_
/* FIXME We should be using the same day of the week enum every where */
display_start = (E_WEEK_VIEW (priv->views[view_type])->display_start_day + 1) % 7;
- if (!priv->range_selected && (!E_WEEK_VIEW (priv->views[view_type])->multi_week_view || !E_WEEK_VIEW (priv->views[view_type])->month_scroll_by_week))
- *start_time = time_month_begin_with_zone (*start_time, priv->zone);
- *start_time = time_week_begin_with_zone (*start_time, display_start, priv->zone);
- *end_time = time_add_week_with_zone (*start_time, shown, priv->zone);
+ if (!range_selected && (!E_WEEK_VIEW (priv->views[view_type])->multi_week_view || !E_WEEK_VIEW (priv->views[view_type])->month_scroll_by_week))
+ *start_time = time_month_begin_with_zone (*start_time, timezone);
+ *start_time = time_week_begin_with_zone (*start_time, display_start, timezone);
+ *end_time = time_add_week_with_zone (*start_time, shown, timezone);
if (select_time && E_WEEK_VIEW (priv->views[view_type])->selection_start_day == -1)
time (select_time);
break;
case GNOME_CAL_LIST_VIEW:
/* FIXME What to do here? */
- *start_time = time_month_begin_with_zone (*start_time, priv->zone);
- *end_time = time_add_month_with_zone (*start_time, 1, priv->zone);
+ *start_time = time_month_begin_with_zone (*start_time, timezone);
+ *end_time = time_add_month_with_zone (*start_time, 1, timezone);
break;
default:
g_return_if_reached ();
}
}
-/* 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
- || GTK_WIDGET_HAS_FOCUS (dv))
- 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
- || GTK_WIDGET_HAS_FOCUS (wv))
- 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))
- || GTK_WIDGET_HAS_FOCUS (lv))
- 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)
{
- GnomeCalendarPrivate *priv;
+ ECalModel *model;
gint start_year, start_month, start_day;
gint end_year, end_month, end_day;
struct icaltimetype start_tt;
struct icaltimetype end_tt;
+ icaltimezone *timezone;
- priv = gcal->priv;
+ model = gnome_calendar_get_model (gcal);
+ timezone = e_cal_model_get_timezone (model);
start_tt = icaltime_null_time ();
end_tt = icaltime_null_time ();
- if (!e_calendar_item_get_date_range (priv->date_navigator->calitem,
- &start_year, &start_month, &start_day,
- &end_year, &end_month, &end_day)) {
+ if (!e_calendar_item_get_date_range (
+ gcal->priv->date_navigator->calitem,
+ &start_year, &start_month, &start_day,
+ &end_year, &end_month, &end_day)) {
*start_time = -1;
*end_time = -1;
return;
@@ -831,8 +960,8 @@ get_date_navigator_range (GnomeCalendar *gcal, time_t *start_time, time_t *end_t
icaltime_adjust (&end_tt, 1, 0, 0, 0);
- *start_time = icaltime_as_timet_with_zone (start_tt, priv->zone);
- *end_time = icaltime_as_timet_with_zone (end_tt, priv->zone);
+ *start_time = icaltime_as_timet_with_zone (start_tt, timezone);
+ *end_time = icaltime_as_timet_with_zone (end_tt, timezone);
}
/* Adjusts a given query sexp with the time range of the date navigator */
@@ -901,7 +1030,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;
@@ -951,11 +1080,13 @@ try_again:
}
/* Restarts a query for the date navigator in the calendar */
-static void
-update_query (GnomeCalendar *gcal)
+void
+gnome_calendar_update_query (GnomeCalendar *gcal)
{
struct _date_query_msg *msg;
+ g_return_if_fail (GNOME_IS_CALENDAR (gcal));
+
e_calendar_item_clear_marks (gcal->priv->date_navigator->calitem);
msg = g_slice_new0 (struct _date_query_msg);
@@ -965,353 +1096,79 @@ 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;
+ ECalModel *model;
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);
priv = gcal->priv;
- /* Set the query on the date navigator */
+ model = gnome_calendar_get_model (gcal);
- if (priv->sexp)
- g_free (priv->sexp);
+ /* Set the query on the date navigator */
+ 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);
+ gnome_calendar_update_query (gcal);
i = priv->current_view_type;
/* 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);
+ e_cal_model_set_search_query_with_time_range (
+ model, sexp, start, end);
} else {
start = priv->base_view_time;
get_times_for_views (gcal, GNOME_CAL_LIST_VIEW, &start, &end, NULL);
- e_cal_model_set_search_query_with_time_range (e_calendar_view_get_model (priv->views [i]), sexp, start, end);
+ e_cal_model_set_search_query_with_time_range (
+ model, sexp, start, end);
if (priv->current_view_type == GNOME_CAL_LIST_VIEW)
gnome_calendar_update_date_navigator (gcal);
}
} else
- e_cal_model_set_search_query (e_calendar_view_get_model (priv->views[i]), sexp);
+ e_cal_model_set_search_query (model, sexp);
/* Set the query on the task pad */
update_todo_view (gcal);
}
-/* Returns the current time, for the ECalendarItem. */
-static struct tm
-get_current_time (ECalendarItem *calitem, gpointer data)
-{
- GnomeCalendar *cal = data;
- struct tm tmp_tm = { 0 };
- struct icaltimetype tt;
-
- g_return_val_if_fail (cal != NULL, tmp_tm);
- g_return_val_if_fail (GNOME_IS_CALENDAR (cal), tmp_tm);
-
- tt = icaltime_from_timet_with_zone (time (NULL), FALSE,
- cal->priv->zone);
-
- /* Now copy it to the struct tm and return it. */
- tmp_tm = icaltimetype_to_tm (&tt);
-
- 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)
+set_timezone (GnomeCalendar *gcal)
{
- 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)
-{
- GnomeCalendarPrivate *priv;
-
- priv = calendar->priv;
-
- priv->week_start = calendar_config_get_week_start_day ();
-
- /* Only do this if views exist */
- if (priv->day_view && priv->work_week_view && priv->week_view && priv->month_view && priv->list_view) {
- update_view_times (calendar, priv->base_view_time);
- gnome_calendar_update_date_navigator (calendar);
- gnome_calendar_notify_dates_shown_changed (calendar);
- }
-}
-
-static void
-week_start_changed_cb (GConfClient *client, guint id, GConfEntry *entry, gpointer data)
-{
- GnomeCalendar *calendar = data;
-
- set_week_start (calendar);
-}
-
-static void
-set_working_days (GnomeCalendar *calendar)
-{
- GnomeCalendarPrivate *priv;
-
- priv = calendar->priv;
-
- /* Only do this if views exist */
- if (priv->day_view && priv->work_week_view && priv->week_view && priv->month_view && priv->list_view) {
- update_view_times (calendar, priv->base_view_time);
- gnome_calendar_update_date_navigator (calendar);
- gnome_calendar_notify_dates_shown_changed (calendar);
- }
-}
-
-static void
-working_days_changed_cb (GConfClient *client, guint id, GConfEntry *entry, gpointer data)
-{
- GnomeCalendar *calendar = data;
-
- set_working_days (calendar);
-}
-
-static void
-set_timezone (GnomeCalendar *calendar)
-{
- GnomeCalendarPrivate *priv;
- gint i;
-
- priv = calendar->priv;
-
- priv->zone = calendar_config_get_icaltimezone ();
-
- for (i = 0; i < E_CAL_SOURCE_TYPE_LAST; i++) {
- GList *l;
+ icaltimezone *timezone;
+ GList *l;
- for (l = priv->clients_list[i]; l != NULL; l = l->next) {
- ECal *client = l->data;
+ model = gnome_calendar_get_model (gcal);
+ timezone = e_cal_model_get_timezone (model);
- 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 = gcal->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, timezone, NULL);
}
-
- if (priv->views [priv->current_view_type])
- e_calendar_view_set_timezone (priv->views [priv->current_view_type], priv->zone);
-}
-
-static void
-timezone_changed_cb (GConfClient *client, guint id, GConfEntry *entry, gpointer data)
-{
- GnomeCalendar *calendar = data;
-
- set_timezone (calendar);
}
struct _mupdate_todo_msg {
@@ -1319,6 +1176,7 @@ struct _mupdate_todo_msg {
GnomeCalendar *gcal;
};
+#if 0 /* KILL-BONOBO */
static void
update_todo_view_async (struct _mupdate_todo_msg *msg)
{
@@ -1357,10 +1215,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);
@@ -1368,11 +1228,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;
@@ -1382,7 +1244,7 @@ update_memo_view (GnomeCalendar *gcal)
/* Set the query on the memo pad*/
model = e_memo_table_get_model (E_MEMO_TABLE (priv->memo));
- view_model = e_calendar_view_get_model(priv->views[priv->current_view_type]);
+ view_model = gnome_calendar_get_model (gcal);
e_cal_model_get_time_range (view_model, &start, &end);
if (start != -1 && end != -1) {
@@ -1404,21 +1266,24 @@ 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);
g_return_if_fail (GNOME_IS_CALENDAR(gcal));
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)
{
@@ -1431,26 +1296,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_marcus_bains_update (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);
@@ -1466,175 +1334,6 @@ update_marcus_bains_line_cb (GnomeCalendar *gcal)
}
static void
-config_hide_completed_tasks_changed_cb (GConfClient *client, guint id, GConfEntry *entry, gpointer data)
-{
- process_completed_tasks (data, TRUE);
-}
-
-static void
-setup_config (GnomeCalendar *calendar)
-{
- GnomeCalendarPrivate *priv;
- guint not;
-
- priv = calendar->priv;
-
- /* Week Start */
- set_week_start (calendar);
- not = calendar_config_add_notification_week_start_day (week_start_changed_cb, calendar);
- priv->notifications = g_list_prepend (priv->notifications, GUINT_TO_POINTER (not));
-
- /* Working Days */
- set_working_days (calendar);
- not = calendar_config_add_notification_working_days (working_days_changed_cb, calendar);
- priv->notifications = g_list_prepend (priv->notifications, GUINT_TO_POINTER (not));
-
- /* Timezone */
- set_timezone (calendar);
- not = calendar_config_add_notification_timezone (timezone_changed_cb, calendar);
- priv->notifications = g_list_prepend (priv->notifications, GUINT_TO_POINTER (not));
-
- /* Hide completed tasks */
- not = calendar_config_add_notification_hide_completed_tasks (config_hide_completed_tasks_changed_cb,
- calendar);
- 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,
- calendar);
- 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,
- calendar);
- priv->notifications = g_list_prepend (priv->notifications, GUINT_TO_POINTER (not));
-
- /* 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
-update_adjustment (GnomeCalendar *gcal, GtkAdjustment *adjustment, EWeekView *week_view)
-{
- GDate date;
- gint week_offset;
- struct icaltimetype start_tt = icaltime_null_time ();
- time_t lower;
- guint32 old_first_day_julian, new_first_day_julian;
-
- /* If we don't have a valid date set yet, just return. */
- if (!g_date_valid (&week_view->first_day_shown))
- return;
-
- /* Determine the first date shown. */
- date = week_view->base_date;
- week_offset = floor (adjustment->value + 0.5);
- g_date_add_days (&date, week_offset * 7);
-
- /* Convert the old & new first days shown to julian values. */
- old_first_day_julian = g_date_get_julian (&week_view->first_day_shown);
- new_first_day_julian = g_date_get_julian (&date);
-
- /* If we are already showing the date, just return. */
- if (old_first_day_julian == new_first_day_julian)
- return;
-
- /* Convert it to a time_t. */
- start_tt.year = g_date_get_year (&date);
- start_tt.month = g_date_get_month (&date);
- start_tt.day = g_date_get_day (&date);
-
- lower = icaltime_as_timet_with_zone (start_tt, gcal->priv->zone);
-
- e_week_view_set_update_base_date (week_view, FALSE);
- update_view_times (gcal, lower);
- gnome_calendar_update_date_navigator (gcal);
- gnome_calendar_notify_dates_shown_changed (gcal);
- e_week_view_set_update_base_date (week_view, TRUE);
-}
-
-static void
-week_view_adjustment_changed_cb (GtkAdjustment *adjustment, GnomeCalendar *gcal)
-{
- update_adjustment (gcal, adjustment, E_WEEK_VIEW (gcal->priv->week_view));
-}
-
-static void
-month_view_adjustment_changed_cb (GtkAdjustment *adjustment, GnomeCalendar *gcal)
-{
- update_adjustment (gcal, adjustment, E_WEEK_VIEW (gcal->priv->month_view));
-}
-
-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) {
- e_calendar_view_set_status_message (E_CALENDAR_VIEW (gcal->priv->week_view), message, percent);
- } else if (type == E_CAL_SOURCE_TYPE_TODO) {
- e_calendar_table_set_status_message (E_CALENDAR_TABLE (gcal->priv->todo), message, percent);
- } else if (type == E_CAL_SOURCE_TYPE_JOURNAL) {
- e_memo_table_set_status_message (E_MEMO_TABLE (gcal->priv->memo), message);
- }
-}
-
-static void
-view_done_cb (ECalModel *model, ECalendarStatus status, ECalSourceType type, GnomeCalendar *gcal)
-{
- if (type == E_CAL_SOURCE_TYPE_EVENT) {
- e_calendar_view_set_status_message (E_CALENDAR_VIEW (gcal->priv->week_view), NULL, -1);
- } else if (type == E_CAL_SOURCE_TYPE_TODO) {
- e_calendar_table_set_status_message (E_CALENDAR_TABLE (gcal->priv->todo), NULL, -1);
- } else if (type == E_CAL_SOURCE_TYPE_JOURNAL) {
- e_memo_table_set_status_message (E_MEMO_TABLE (gcal->priv->memo), NULL);
- }
-
-}
-
-GtkWidget *
-gnome_calendar_get_tag (GnomeCalendar *gcal)
-{
- return GTK_WIDGET (gcal->priv->date_navigator);
-}
-
-static time_t
-gc_get_default_time (ECalModel *model, gpointer user_data)
-{
- GnomeCalendar *gcal = user_data;
- time_t res = 0, end;
-
- g_return_val_if_fail (model != NULL, 0);
- g_return_val_if_fail (GNOME_IS_CALENDAR (user_data), 0);
-
- gnome_calendar_get_current_time_range (gcal, &res, &end);
-
- return res;
-}
-
-static void
setup_widgets (GnomeCalendar *gcal)
{
GnomeCalendarPrivate *priv;
@@ -1642,7 +1341,6 @@ setup_widgets (GnomeCalendar *gcal)
gchar *filename;
ETable *etable;
GtkAdjustment *adjustment;
- ECalModel *w_model;
GtkWidget *vbox;
GtkWidget *label;
ECalModel *cal_model;
@@ -1651,234 +1349,17 @@ 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 ();
- g_signal_connect_after(priv->hpane, "realize",
- G_CALLBACK(gnome_calendar_hpane_realized), gcal);
- g_signal_connect (priv->hpane, "button_release_event",
- G_CALLBACK (gnome_calendar_hpane_resized), 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);
- priv->date_navigator_config = e_mini_calendar_config_new (priv->date_navigator);
- e_calendar_item_set_days_start_week_sel (priv->date_navigator->calitem, 9);
- e_calendar_item_set_max_days_sel (priv->date_navigator->calitem, 42);
- gtk_widget_show (w);
- e_calendar_item_set_get_time_callback (priv->date_navigator->calitem,
- (ECalendarItemGetTimeCallback) get_current_time,
- gcal, NULL);
-
- g_signal_connect (priv->date_navigator->calitem, "selection_changed",
- G_CALLBACK (gnome_calendar_on_date_navigator_selection_changed), gcal);
- g_signal_connect (priv->date_navigator->calitem, "date_range_changed",
- G_CALLBACK (gnome_calendar_on_date_navigator_date_range_changed), 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 ();
- gtk_box_pack_start ((GtkBox *)vbox, sep, FALSE, TRUE, 0);
-
- label = gtk_label_new (NULL);
- tmp = g_strdup_printf ("<b> %s </b>", _("Tasks"));
- gtk_label_set_markup ((GtkLabel *)label, tmp);
- 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);
-
- /* Create the model for the views */
- cal_model = (ECalModel *) e_cal_model_calendar_new ();
- e_cal_model_set_flags (cal_model, E_CAL_MODEL_FLAGS_EXPAND_RECURRENCES);
-
- /* The Day View. */
- priv->day_view = e_day_view_new (cal_model);
- e_calendar_view_set_calendar (E_CALENDAR_VIEW (priv->day_view), 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);
- e_day_view_set_work_week_view (E_DAY_VIEW (priv->work_week_view),
- TRUE);
- 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));
+#endif
/* 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);
- /* The Week View. */
- priv->week_view = e_week_view_new (cal_model);
- e_calendar_view_set_calendar (E_CALENDAR_VIEW (priv->week_view), gcal);
- e_calendar_view_set_timezone (E_CALENDAR_VIEW (priv->week_view), priv->zone);
- 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),
- gcal);
- w_model = e_calendar_view_get_model ((ECalendarView *)priv->week_view);
- g_signal_connect (w_model, "cal_view_progress",
- G_CALLBACK (view_progress_cb), gcal);
- g_signal_connect (w_model, "cal_view_done",
- G_CALLBACK (view_done_cb), gcal);
-
- /* The Month View. */
- priv->month_view = e_week_view_new (cal_model);
- e_calendar_view_set_calendar (E_CALENDAR_VIEW (priv->month_view), gcal);
- e_calendar_view_set_timezone (E_CALENDAR_VIEW (priv->month_view), priv->zone);
- e_week_view_set_multi_week_view (E_WEEK_VIEW (priv->month_view), TRUE);
- e_week_view_set_weeks_shown (E_WEEK_VIEW (priv->month_view), 6);
- 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),
- gcal);
-
- /* The List View. */
- priv->list_view = e_cal_list_view_new (cal_model);
-
- e_calendar_view_set_calendar (E_CALENDAR_VIEW (priv->list_view), gcal);
- e_calendar_view_set_timezone (E_CALENDAR_VIEW (priv->list_view), priv->zone);
- 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);
- priv->configs[GNOME_CAL_WORK_WEEK_VIEW] = G_OBJECT (e_day_view_config_new (E_DAY_VIEW (priv->views[GNOME_CAL_WORK_WEEK_VIEW])));
- priv->views[GNOME_CAL_WEEK_VIEW] = E_CALENDAR_VIEW (priv->week_view);
- priv->configs[GNOME_CAL_WEEK_VIEW] = G_OBJECT (e_week_view_config_new (E_WEEK_VIEW (priv->views[GNOME_CAL_WEEK_VIEW])));
- priv->views[GNOME_CAL_MONTH_VIEW] = E_CALENDAR_VIEW (priv->month_view);
- priv->configs[GNOME_CAL_MONTH_VIEW] = G_OBJECT (e_week_view_config_new (E_WEEK_VIEW (priv->views[GNOME_CAL_MONTH_VIEW])));
- 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);
- tmp = g_strdup_printf ("<b> %s </b>", _("Memos"));
- gtk_label_set_markup ((GtkLabel *)label, tmp);
- g_free (tmp);
- gtk_box_pack_start ((GtkBox *)vbox, label, FALSE, TRUE, 0);
- priv->memo = e_memo_table_new ();
- priv->memo_config = e_memo_table_config_new (E_MEMO_TABLE (priv->memo));
- gtk_paned_pack2 (GTK_PANED (priv->vpane), vbox, TRUE, FALSE);
- gtk_box_pack_end ((GtkBox *)vbox, priv->memo, TRUE, TRUE, 0);
-
- gtk_widget_show (priv->memo);
- gtk_widget_show (label);
- gtk_widget_show (vbox);
-
- filename = g_build_filename (memos_component_peek_config_directory (memos_component_peek ()),
- "MemoPad", NULL);
- e_memo_table_load_state (E_MEMO_TABLE (priv->memo), filename);
-
- e_cal_model_set_default_time_func (e_memo_table_get_model (E_MEMO_TABLE (priv->memo)), gc_get_default_time, gcal);
-
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 */
@@ -1886,18 +1367,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 ();
@@ -1905,21 +1385,13 @@ gnome_calendar_init (GnomeCalendar *gcal)
priv->range_selected = FALSE;
priv->lview_select_daten_range = TRUE;
- setup_config (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;
@@ -1931,7 +1403,6 @@ gnome_calendar_destroy (GtkObject *object)
GnomeCalendar *gcal;
GnomeCalendarPrivate *priv;
gchar *filename;
- ECalModel *cal_model;
g_return_if_fail (object != NULL);
g_return_if_fail (GNOME_IS_CALENDAR (object));
@@ -1943,67 +1414,45 @@ 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;
+ if (priv->shell_settings != NULL) {
+ g_object_unref (priv->shell_settings);
+ priv->shell_settings = NULL;
+ }
- if (priv->default_client[i]) {
- ESource *source = e_cal_get_source (priv->default_client[i]);
+ if (priv->model != NULL) {
+ g_signal_handlers_disconnect_by_func (
+ priv->model, view_progress_cb, gcal);
+ g_signal_handlers_disconnect_by_func (
+ priv->model, view_done_cb, gcal);
+ g_object_unref (priv->model);
+ priv->model = NULL;
+ }
- g_signal_handlers_disconnect_matched (priv->default_client[i],
- G_SIGNAL_MATCH_DATA,
- 0, 0, NULL, NULL, gcal);
+ /* Clean up the clients */
+ 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 (source)
- g_signal_handlers_disconnect_matched (source, G_SIGNAL_MATCH_DATA, 0, 0, NULL, NULL, gcal);
+ g_hash_table_destroy (priv->clients);
+ g_list_free (priv->clients_list);
- g_object_unref (priv->default_client[i]);
- }
- priv->default_client[i] = NULL;
- }
+ priv->clients = NULL;
+ priv->clients_list = NULL;
- for (i = 0; i < GNOME_CAL_LAST_VIEW; i++) {
- if (priv->configs[i])
- g_object_unref (priv->configs[i]);
- priv->configs[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);
}
- g_object_unref (priv->date_navigator_config);
- g_object_unref (priv->todo_config);
- g_object_unref (priv->memo_config);
+ priv->default_client = 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;
- /* 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,
@@ -2025,69 +1474,16 @@ 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,
- G_CALLBACK (view_progress_cb), gcal);
- 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);
@@ -2114,14 +1510,17 @@ static void
gnome_calendar_goto_date (GnomeCalendar *gcal,
GnomeCalendarGotoDateType goto_date)
{
- GnomeCalendarPrivate *priv;
+ ECalModel *model;
time_t new_time = 0;
+ gint week_start_day;
gboolean need_updating = FALSE;
+ icaltimezone *timezone;
- g_return_if_fail (gcal != NULL);
g_return_if_fail (GNOME_IS_CALENDAR(gcal));
- priv = gcal->priv;
+ model = gnome_calendar_get_model (gcal);
+ week_start_day = e_cal_model_get_week_start_day (model);
+ timezone = e_cal_model_get_timezone (model);
switch (goto_date) {
/* GNOME_CAL_GOTO_TODAY and GNOME_CAL_GOTO_DATE are
@@ -2132,39 +1531,45 @@ gnome_calendar_goto_date (GnomeCalendar *gcal,
case GNOME_CAL_GOTO_DATE:
break;
case GNOME_CAL_GOTO_FIRST_DAY_OF_MONTH:
- new_time = time_month_begin_with_zone (priv->base_view_time, priv->zone);
+ new_time = time_month_begin_with_zone (
+ gcal->priv->base_view_time, timezone);
need_updating = TRUE;
break;
case GNOME_CAL_GOTO_LAST_DAY_OF_MONTH:
- new_time = time_add_month_with_zone (priv->base_view_time, 1, priv->zone);
- new_time = time_month_begin_with_zone (new_time, priv->zone);
- new_time = time_add_day_with_zone (new_time, -1, priv->zone);
+ new_time = time_add_month_with_zone (
+ gcal->priv->base_view_time, 1, timezone);
+ new_time = time_month_begin_with_zone (new_time, timezone);
+ new_time = time_add_day_with_zone (new_time, -1, timezone);
need_updating = TRUE;
break;
case GNOME_CAL_GOTO_FIRST_DAY_OF_WEEK:
- new_time = time_week_begin_with_zone (priv->base_view_time, priv->week_start, priv->zone);
+ new_time = time_week_begin_with_zone (
+ gcal->priv->base_view_time, week_start_day, timezone);
need_updating = TRUE;
break;
case GNOME_CAL_GOTO_LAST_DAY_OF_WEEK:
- new_time = time_week_begin_with_zone (priv->base_view_time, priv->week_start, priv->zone);
- if (priv->current_view_type == GNOME_CAL_DAY_VIEW ||
- priv->current_view_type == GNOME_CAL_WORK_WEEK_VIEW) {
+ new_time = time_week_begin_with_zone (
+ gcal->priv->base_view_time, week_start_day, timezone);
+ if (gcal->priv->current_view_type == GNOME_CAL_DAY_VIEW ||
+ gcal->priv->current_view_type == GNOME_CAL_WORK_WEEK_VIEW) {
/* FIXME Shouldn't hard code work week end */
/* goto Friday of this week */
- new_time = time_add_day_with_zone (new_time, 4, priv->zone);
+ new_time = time_add_day_with_zone (new_time, 4, timezone);
} else {
/* goto Sunday of this week */
/* FIXME Shouldn't hard code week end */
- new_time = time_add_day_with_zone (new_time, 6, priv->zone);
+ new_time = time_add_day_with_zone (new_time, 6, timezone);
}
need_updating = TRUE;
break;
case GNOME_CAL_GOTO_SAME_DAY_OF_PREVIOUS_WEEK:
- new_time = time_add_week_with_zone (priv->base_view_time, -1, priv->zone);
+ new_time = time_add_week_with_zone (
+ gcal->priv->base_view_time, -1, timezone);
need_updating = TRUE;
break;
case GNOME_CAL_GOTO_SAME_DAY_OF_NEXT_WEEK:
- new_time = time_add_week_with_zone (priv->base_view_time, 1, priv->zone);
+ new_time = time_add_week_with_zone (
+ gcal->priv->base_view_time, 1, timezone);
need_updating = TRUE;
break;
default:
@@ -2172,9 +1577,7 @@ gnome_calendar_goto_date (GnomeCalendar *gcal,
}
if (need_updating) {
- update_view_times (gcal, new_time);
- gnome_calendar_update_date_navigator (gcal);
- gnome_calendar_notify_dates_shown_changed (gcal);
+ gnome_calendar_set_selected_time_range (gcal, new_time);
notify_selected_time_changed (gcal);
}
}
@@ -2185,15 +1588,12 @@ gnome_calendar_goto (GnomeCalendar *gcal, time_t new_time)
GnomeCalendarPrivate *priv;
gint i;
- g_return_if_fail (gcal != NULL);
g_return_if_fail (GNOME_IS_CALENDAR (gcal));
g_return_if_fail (new_time != -1);
priv = gcal->priv;
- update_view_times (gcal, new_time);
- gnome_calendar_update_date_navigator (gcal);
- gnome_calendar_notify_dates_shown_changed (gcal);
+ gnome_calendar_set_selected_time_range (gcal, new_time);
for (i = 0; i < GNOME_CAL_LAST_VIEW; i++) {
if (E_CALENDAR_VIEW_CLASS (G_OBJECT_GET_CLASS (priv->views[i]))->set_selected_time_range)
@@ -2201,19 +1601,23 @@ gnome_calendar_goto (GnomeCalendar *gcal, time_t new_time)
}
}
-static void
-update_view_times (GnomeCalendar *gcal, time_t start_time)
+void
+gnome_calendar_update_view_times (GnomeCalendar *gcal,
+ time_t start_time)
{
GnomeCalendarPrivate *priv;
ECalModel *model;
time_t real_start_time = start_time;
time_t end_time, select_time = 0;
+ g_return_if_fail (GNOME_IS_CALENDAR (gcal));
+
priv = gcal->priv;
priv->base_view_time = start_time;
- model = e_calendar_view_get_model (priv->views [priv->current_view_type]);
+ model = gnome_calendar_get_model (gcal);
+
get_times_for_views (gcal, priv->current_view_type, &real_start_time, &end_time, &select_time);
if (priv->current_view_type == GNOME_CAL_LIST_VIEW && !priv->lview_select_daten_range)
@@ -2222,42 +1626,44 @@ update_view_times (GnomeCalendar *gcal, time_t start_time)
e_cal_model_set_time_range (model, real_start_time, end_time);
if (select_time != 0 && select_time >= real_start_time && select_time <= end_time)
- e_calendar_view_set_selected_time_range (priv->views [priv->current_view_type], select_time, select_time);
+ e_calendar_view_set_selected_time_range (priv->views[priv->current_view_type], select_time, select_time);
}
static void
gnome_calendar_direction (GnomeCalendar *gcal, gint direction)
{
- GnomeCalendarPrivate *priv;
+ ECalModel *model;
+ icaltimezone *timezone;
- priv = gcal->priv;
+ model = gnome_calendar_get_model (gcal);
+ timezone = e_cal_model_get_timezone (model);
- switch (priv->current_view_type) {
+ switch (gnome_calendar_get_view (gcal)) {
case GNOME_CAL_DAY_VIEW:
- priv->base_view_time = time_add_day_with_zone (priv->base_view_time, direction, priv->zone);
+ gcal->priv->base_view_time = time_add_day_with_zone (
+ gcal->priv->base_view_time, direction, timezone);
break;
case GNOME_CAL_WORK_WEEK_VIEW:
case GNOME_CAL_WEEK_VIEW:
- priv->base_view_time = time_add_week_with_zone (priv->base_view_time, direction, priv->zone);
+ gcal->priv->base_view_time = time_add_week_with_zone (
+ gcal->priv->base_view_time, direction, timezone);
break;
- case GNOME_CAL_LIST_VIEW:
- g_warning ("Using month view time interval for list view.");
case GNOME_CAL_MONTH_VIEW:
- priv->base_view_time = time_add_month_with_zone (priv->base_view_time, direction, priv->zone);
+ case GNOME_CAL_LIST_VIEW:
+ gcal->priv->base_view_time = time_add_month_with_zone (
+ gcal->priv->base_view_time, direction, timezone);
break;
default:
g_return_if_reached ();
}
- update_view_times (gcal, priv->base_view_time);
- gnome_calendar_update_date_navigator (gcal);
- gnome_calendar_notify_dates_shown_changed (gcal);
+ gnome_calendar_set_selected_time_range (
+ gcal, gcal->priv->base_view_time);
}
void
gnome_calendar_next (GnomeCalendar *gcal)
{
- g_return_if_fail (gcal != NULL);
g_return_if_fail (GNOME_IS_CALENDAR (gcal));
gnome_calendar_direction (gcal, 1);
@@ -2266,7 +1672,6 @@ gnome_calendar_next (GnomeCalendar *gcal)
void
gnome_calendar_previous (GnomeCalendar *gcal)
{
- g_return_if_fail (gcal != NULL);
g_return_if_fail (GNOME_IS_CALENDAR (gcal));
gnome_calendar_direction (gcal, -1);
@@ -2275,33 +1680,34 @@ gnome_calendar_previous (GnomeCalendar *gcal)
void
gnome_calendar_dayjump (GnomeCalendar *gcal, time_t time)
{
- GnomeCalendarPrivate *priv;
+ ECalModel *model;
+ icaltimezone *timezone;
- g_return_if_fail (gcal != NULL);
g_return_if_fail (GNOME_IS_CALENDAR (gcal));
- priv = gcal->priv;
+ model = gnome_calendar_get_model (gcal);
+ timezone = e_cal_model_get_timezone (model);
- priv->base_view_time = time_day_begin_with_zone (time, priv->zone);
+ gcal->priv->base_view_time =
+ time_day_begin_with_zone (time, timezone);
- update_view_times (gcal, priv->base_view_time);
+ gnome_calendar_update_view_times (gcal, gcal->priv->base_view_time);
gnome_calendar_set_view (gcal, GNOME_CAL_DAY_VIEW);
}
-static void
-focus_current_view (GnomeCalendar *gcal)
-{
- gtk_widget_grab_focus (gnome_calendar_get_current_view_widget (gcal));
-}
-
void
gnome_calendar_goto_today (GnomeCalendar *gcal)
{
- g_return_if_fail (gcal != NULL);
+ GnomeCalendarViewType view_type;
+ ECalendarView *view;
+
g_return_if_fail (GNOME_IS_CALENDAR (gcal));
+ view_type = gnome_calendar_get_view (gcal);
+ view = gnome_calendar_get_calendar_view (gcal, view_type);
+
gnome_calendar_goto (gcal, time (NULL));
- focus_current_view (gcal);
+ gtk_widget_grab_focus (GTK_WIDGET (view));
}
/**
@@ -2315,56 +1721,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;
-}
-
-static void
-set_view (GnomeCalendar *gcal, GnomeCalendarViewType view_type, gboolean range_selected)
-{
- GnomeCalendarPrivate *priv;
- const gchar *view_id;
-
- g_return_if_fail (gcal != NULL);
- g_return_if_fail (GNOME_IS_CALENDAR (gcal));
-
- priv = gcal->priv;
-
- switch (view_type) {
- case GNOME_CAL_DAY_VIEW:
- view_id = "Day_View";
- break;
-
- case GNOME_CAL_WORK_WEEK_VIEW:
- view_id = "Work_Week_View";
- break;
-
- case GNOME_CAL_WEEK_VIEW:
- view_id = "Week_View";
- break;
-
- case GNOME_CAL_MONTH_VIEW:
- view_id = "Month_View";
- break;
-
- case GNOME_CAL_LIST_VIEW:
- view_id = "List_View";
- break;
-
- default:
- g_return_if_reached ();
- }
-
- 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);
+ return gcal->priv->current_view_type;
}
/**
@@ -2377,34 +1736,46 @@ set_view (GnomeCalendar *gcal, GnomeCalendarViewType view_type, gboolean range_s
* the view; otherwise the last configuration will be kept.
**/
void
-gnome_calendar_set_view (GnomeCalendar *gcal, GnomeCalendarViewType view_type)
+gnome_calendar_set_view (GnomeCalendar *gcal,
+ GnomeCalendarViewType view_type)
{
- g_return_if_fail (gcal != NULL);
+ ECalendarView *calendar_view;
+
g_return_if_fail (GNOME_IS_CALENDAR (gcal));
- set_view (gcal, view_type, FALSE);
+ gcal->priv->current_view_type = view_type;
+ gnome_calendar_set_range_selected (gcal, FALSE);
+
+ calendar_view = gnome_calendar_get_calendar_view (gcal, view_type);
+ gtk_widget_grab_focus (GTK_WIDGET (calendar_view));
+
+ g_object_notify (G_OBJECT (gcal), "view");
}
-/* Sets the view without changing the selection or updating the date
- * navigator. If a range of dates isn't selected it will also reset the number
- * of days/weeks shown to the default (i.e. 1 day for the day view or 5 weeks
- * for the month view).
- */
-static void
-display_view (GnomeCalendar *gcal, GnomeCalendarViewType view_type, gboolean grab_focus)
+void
+gnome_calendar_display_view (GnomeCalendar *gcal,
+ GnomeCalendarViewType view_type)
{
- GnomeCalendarPrivate *priv;
+ CalendarView *cal_view;
+ ECalendarView *view;
gboolean preserve_day;
- gint i;
+ gboolean range_selected;
+ time_t start_time;
+ gint ii;
- priv = gcal->priv;
+ view = gnome_calendar_get_calendar_view (gcal, view_type);
+
+ /* Set the view without changing the selection or updating the date
+ * navigator. If a range of dates isn't selected, also reset the
+ * number of days/weeks shown to the default (i.e. 1 day for the
+ * day view or 6 weeks for the month view). */
preserve_day = FALSE;
switch (view_type) {
case GNOME_CAL_DAY_VIEW:
- if (!priv->range_selected)
- e_day_view_set_days_shown (E_DAY_VIEW (priv->day_view), 1);
+ if (!gnome_calendar_get_range_selected (gcal))
+ e_day_view_set_days_shown (E_DAY_VIEW (view), 1);
gtk_widget_show (GTK_WIDGET (gcal->priv->date_navigator));
break;
@@ -2420,15 +1791,15 @@ display_view (GnomeCalendar *gcal, GnomeCalendarViewType view_type, gboolean gra
break;
case GNOME_CAL_MONTH_VIEW:
- if (!priv->range_selected)
- e_week_view_set_weeks_shown (E_WEEK_VIEW (priv->month_view), 6);
+ if (!gnome_calendar_get_range_selected (gcal))
+ e_week_view_set_weeks_shown (E_WEEK_VIEW (view), 6);
preserve_day = TRUE;
gtk_widget_show (GTK_WIDGET (gcal->priv->date_navigator));
break;
case GNOME_CAL_LIST_VIEW:
- if (!priv->lview_select_daten_range)
+ if (!gcal->priv->lview_select_daten_range)
gtk_widget_hide (GTK_WIDGET (gcal->priv->date_navigator));
else
gtk_widget_show (GTK_WIDGET (gcal->priv->date_navigator));
@@ -2438,345 +1809,32 @@ display_view (GnomeCalendar *gcal, GnomeCalendarViewType view_type, gboolean gra
g_return_if_reached ();
}
- priv->current_view_type = view_type;
- E_CALENDAR_VIEW (priv->views [view_type])->in_focus = TRUE;
+ range_selected = gnome_calendar_get_range_selected (gcal);
+ gnome_calendar_set_view (gcal, view_type);
+ gnome_calendar_set_range_selected (gcal, range_selected);
- gtk_notebook_set_current_page (
- GTK_NOTEBOOK (priv->notebook), (gint) view_type);
-
- for (i = 0; i < GNOME_CAL_LAST_VIEW; i++) {
- if (i == view_type)
+ /* XXX Move this to set_view()? */
+ E_CALENDAR_VIEW (gcal->priv->views[view_type])->in_focus = TRUE;
+ for (ii = 0; ii < GNOME_CAL_LAST_VIEW; ii++) {
+ if (ii == view_type)
continue;
- E_CALENDAR_VIEW (priv->views [i])->in_focus = FALSE;
+ E_CALENDAR_VIEW (gcal->priv->views[ii])->in_focus = FALSE;
}
- 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. */
- g_object_set (G_OBJECT (priv->date_navigator->calitem),
- "preserve_day_when_moving", preserve_day,
- NULL);
-}
-
-static void gnome_calendar_change_view (GnomeCalendar *gcal, GnomeCalendarViewType view_type)
-{
- if (gnome_calendar_get_view(gcal) == view_type)
- return;
-
- gnome_calendar_set_view(gcal, view_type);
-}
-
-/* Callback used when the view collection asks us to display a particular view */
-static void
-display_view_cb (GalViewInstance *view_instance, GalView *view, gpointer data)
-{
- GnomeCalendar *gcal;
- GnomeCalendarPrivate *priv;
- CalendarView *cal_view;
- GnomeCalendarViewType view_type;
-
- gcal = GNOME_CALENDAR (data);
- priv = gcal->priv;
+ g_object_set (
+ gcal->priv->date_navigator->calitem,
+ "preserve_day_when_moving", preserve_day, NULL);
- if (GAL_IS_VIEW_ETABLE(view)) {
- ETable *table;
-
- view_type = GNOME_CAL_LIST_VIEW;
-
- table = e_table_scrolled_get_table (E_CAL_LIST_VIEW (priv->list_view)->table_scrolled);
- gal_view_etable_attach_table (GAL_VIEW_ETABLE (view), table);
- } else if (IS_CALENDAR_VIEW (view)) {
- cal_view = CALENDAR_VIEW (view);
-
- view_type = calendar_view_get_view_type (cal_view);
- } else {
- g_error (G_STRLOC ": Unknown type of view for GnomeCalendar");
- return;
- }
-
- display_view (gcal, view_type, TRUE);
-
- if (!priv->base_view_time)
- update_view_times (gcal, time (NULL));
+ if (!gcal->priv->base_view_time)
+ start_time = time (NULL);
else
- update_view_times (gcal, priv->base_view_time);
-
- gnome_calendar_update_date_navigator (gcal);
- 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);
+ start_time = gcal->priv->base_view_time;
- 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);
- }
+ gnome_calendar_set_selected_time_range (gcal, start_time);
- 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);
- }
}
struct _mclient_msg {
@@ -2818,7 +1876,6 @@ static void
client_cal_opened_cb (ECal *ecal, ECalendarStatus status, GnomeCalendar *gcal)
{
GnomeCalendarPrivate *priv;
- ECalSourceType source_type;
ESource *source;
ECalModel *model;
ECalLoadState state;
@@ -2828,23 +1885,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);
@@ -2865,7 +1908,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);
@@ -2876,32 +1919,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, signals[SOURCE_REMOVED], 0, source);
g_object_unref (source);
g_warning ("Unable to load the calendar %s \n", e_cal_get_error_message (status));
@@ -2911,74 +1949,36 @@ 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 = gnome_calendar_get_model (gcal);
+ add_mclient (model, ecal);
- e_cal_model_add_client (e_calendar_table_get_model (E_CALENDAR_TABLE (priv->todo)), ecal);
+ /* update date navigator query */
+ gnome_calendar_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;
+ ECalModel *model;
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;
@@ -2999,15 +1999,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, signals[SOURCE_REMOVED], 0, source);
g_object_unref (source);
g_warning ("Unable to load the calendar %s \n", e_cal_get_error_message (status));
@@ -3017,22 +2017,8 @@ 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;
- }
+ model = gnome_calendar_get_model (gcal);
+ e_cal_model_set_default_client (model, ecal);
}
typedef void (*open_func) (ECal *, ECalendarStatus, GnomeCalendar *);
@@ -3050,20 +2036,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);
@@ -3094,7 +2067,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);
@@ -3108,7 +2081,6 @@ backend_died_cb (ECal *ecal, gpointer data)
{
GnomeCalendar *gcal;
GnomeCalendarPrivate *priv;
- ECalSourceType source_type;
ESource *source;
const gchar *id;
GtkWidget *w = NULL;
@@ -3119,39 +2091,16 @@ backend_died_cb (ECal *ecal, gpointer data)
/* FIXME What about default sources? */
/* Make sure the source doesn't go away on us since we use it below */
- source_type = e_cal_get_source_type (ecal);
source = g_object_ref (e_cal_get_source (ecal));
- priv->clients_list[source_type] = g_list_remove (priv->clients_list[source_type], ecal);
- g_hash_table_remove (priv->clients[source_type], e_source_peek_uid (source));
-
- switch (source_type) {
- case E_CAL_SOURCE_TYPE_EVENT:
- id = g_strdup ("calendar:calendar-crashed");
-
- e_calendar_view_set_status_message (E_CALENDAR_VIEW (priv->week_view), NULL, -1);
-
- g_signal_emit (gcal, gnome_calendar_signals[SOURCE_REMOVED], 0, source_type, source);
- break;
-
- case E_CAL_SOURCE_TYPE_TODO:
- id = g_strdup ("calendar:calendar-crashed");
-
- 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;
+ priv->clients_list = g_list_remove (priv->clients_list, ecal);
+ g_hash_table_remove (priv->clients, e_source_peek_uid (source));
- case E_CAL_SOURCE_TYPE_JOURNAL:
- id = g_strdup ("calendar:calendar-crashed");
+ id = g_strdup ("calendar:calendar-crashed");
- e_memo_table_set_status_message (E_MEMO_TABLE (priv->memo), NULL);
+ /* e_calendar_view_set_status_message (E_CALENDAR_VIEW (priv->week_view), NULL, -1); KILL-BONOBO */
- g_signal_emit (gcal, gnome_calendar_signals[SOURCE_REMOVED], 0, source_type, source);
- break;
- default:
- g_return_if_reached ();
- }
+ g_signal_emit (gcal, signals[SOURCE_REMOVED], 0, source);
g_object_unref (source);
@@ -3162,71 +2111,58 @@ 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);
}
GtkWidget *
-gnome_calendar_construct (GnomeCalendar *gcal)
+gnome_calendar_new (EShellSettings *shell_settings)
{
- GnomeCalendarPrivate *priv;
-
- g_return_val_if_fail (gcal != NULL, NULL);
- g_return_val_if_fail (GNOME_IS_CALENDAR (gcal), NULL);
-
- priv = gcal->priv;
+ g_return_val_if_fail (E_IS_SHELL_SETTINGS (shell_settings), NULL);
- return GTK_WIDGET (gcal);
+ return g_object_new (
+ GNOME_TYPE_CALENDAR,
+ "shell-settings", shell_settings, NULL);
}
-GtkWidget *
-gnome_calendar_new (void)
+EShellSettings *
+gnome_calendar_get_shell_settings (GnomeCalendar *gcal)
{
- GnomeCalendar *gcal;
-
- gcal = g_object_new (gnome_calendar_get_type (), NULL);
-
- if (!gnome_calendar_construct (gcal)) {
- g_message (G_STRLOC ": Could not construct the calendar GUI");
- g_object_unref (gcal);
- return NULL;
- }
+ g_return_val_if_fail (GNOME_IS_CALENDAR (gcal), NULL);
- return GTK_WIDGET (gcal);
+ return gcal->priv->shell_settings;
}
-void
-gnome_calendar_set_activity_handler (GnomeCalendar *cal, EActivityHandler *activity_handler)
+ECalendar *
+gnome_calendar_get_date_navigator (GnomeCalendar *gcal)
{
- 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);
+ g_return_val_if_fail (GNOME_IS_CALENDAR (gcal), NULL);
- e_calendar_table_set_activity_handler (E_CALENDAR_TABLE (priv->todo), activity_handler);
+ return gcal->priv->date_navigator;
}
void
-gnome_calendar_set_ui_component (GnomeCalendar *gcal,
- BonoboUIComponent *ui_component)
+gnome_calendar_set_date_navigator (GnomeCalendar *gcal,
+ ECalendar *date_navigator)
{
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);
+ if (date_navigator != NULL) {
+ g_return_if_fail (E_IS_CALENDAR (date_navigator));
+ g_object_ref (date_navigator);
+ }
+
+ if (gcal->priv->date_navigator != NULL)
+ g_object_unref (gcal->priv->date_navigator);
+
+ gcal->priv->date_navigator = date_navigator;
+
+ g_object_notify (G_OBJECT (gcal), "date-navigator");
}
/**
- * gnome_calendar_get_calendar_model:
+ * gnome_calendar_get_model:
* @gcal: A calendar view.
*
* Queries the calendar model object that a calendar view is using.
@@ -3234,92 +2170,11 @@ gnome_calendar_set_ui_component (GnomeCalendar *gcal,
* Return value: A calendar client interface object.
**/
ECalModel *
-gnome_calendar_get_calendar_model (GnomeCalendar *gcal)
+gnome_calendar_get_model (GnomeCalendar *gcal)
{
- GnomeCalendarPrivate *priv;
-
- g_return_val_if_fail (gcal != NULL, NULL);
g_return_val_if_fail (GNOME_IS_CALENDAR (gcal), NULL);
- priv = gcal->priv;
-
- return e_calendar_view_get_model (priv->views[priv->current_view_type]);
-}
-
-/**
- * gnome_calendar_get_default_client
- */
-ECal *
-gnome_calendar_get_default_client (GnomeCalendar *gcal)
-{
- GnomeCalendarPrivate *priv;
-
- g_return_val_if_fail (gcal != NULL, NULL);
- g_return_val_if_fail (GNOME_IS_CALENDAR (gcal), NULL);
-
- priv = gcal->priv;
-
- return e_cal_model_get_default_client (e_calendar_view_get_model (gcal->priv->views[priv->current_view_type]));
-}
-
-/**
- * gnome_calendar_add_source:
- * @gcal: A GnomeCalendar.
- * @source: #ESource to add to the calendar views.
- *
- * Adds the given calendar source to the calendar views.
- *
- * Returns: TRUE if successful, FALSE if error.
- */
-gboolean
-gnome_calendar_add_source (GnomeCalendar *gcal, ECalSourceType source_type, ESource *source)
-{
- GnomeCalendarPrivate *priv;
- ECal *client;
-
- g_return_val_if_fail (gcal != NULL, FALSE);
- g_return_val_if_fail (GNOME_IS_CALENDAR (gcal), FALSE);
- g_return_val_if_fail (E_IS_SOURCE (source), FALSE);
-
- priv = gcal->priv;
-
- client = g_hash_table_lookup (priv->clients[source_type], e_source_peek_uid (source));
- if (client) {
- /* We already have it */
-
- return TRUE;
- } else {
- ESource *default_source;
-
- if (priv->default_client[source_type]) {
- default_source = e_cal_get_source (priv->default_client[source_type]);
-
- 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]);
- }
-
- /* Create a new one */
- if (!client) {
- client = auth_new_cal_from_source (source, source_type);
- if (!client)
- return FALSE;
- }
- }
-
- g_signal_connect (G_OBJECT (client), "backend_error", G_CALLBACK (backend_error_cb), gcal);
- 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_signal_emit (gcal, gnome_calendar_signals[SOURCE_ADDED], 0, source_type, source);
-
- open_ecal (gcal, client, FALSE, client_cal_opened_cb);
-
- return TRUE;
+ return gcal->priv->model;
}
/**
@@ -3333,80 +2188,61 @@ 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;
- g_return_val_if_fail (gcal != NULL, FALSE);
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, 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;
ECalModel *model;
GList *l;
- g_return_val_if_fail (gcal != NULL, FALSE);
g_return_val_if_fail (GNOME_IS_CALENDAR (gcal), FALSE);
g_return_val_if_fail (uid != NULL, FALSE);
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 = gnome_calendar_get_model (gcal);
+ e_cal_model_remove_client (model, client);
- default:
- g_return_val_if_reached (TRUE);
- }
+ /* update date navigator query */
+ gnome_calendar_update_query (gcal);
- g_hash_table_remove (priv->clients[source_type], uid);
+ g_hash_table_remove (priv->clients, uid);
return TRUE;
}
@@ -3424,68 +2260,58 @@ 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;
- g_return_val_if_fail (gcal != NULL, FALSE);
g_return_val_if_fail (GNOME_IS_CALENDAR (gcal), FALSE);
g_return_val_if_fail (E_IS_SOURCE (source), FALSE);
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;
}
-void
-gnome_calendar_set_selected_time_range (GnomeCalendar *gcal,
- time_t start_time,
- time_t end_time)
+gboolean
+gnome_calendar_get_range_selected (GnomeCalendar *gcal)
{
- update_view_times (gcal, start_time);
- gnome_calendar_update_date_navigator (gcal);
- gnome_calendar_notify_dates_shown_changed (gcal);
+ g_return_val_if_fail (GNOME_IS_CALENDAR (gcal), FALSE);
+
+ return gcal->priv->range_selected;
}
-/**
- * gnome_calendar_get_selected_time_range:
- * @gcal: A calendar view.
- * @start_time: Return value for the start of the time selection.
- * @end_time: Return value for the end of the time selection.
- *
- * Queries the time selection range on the calendar view.
- **/
void
-gnome_calendar_get_selected_time_range (GnomeCalendar *gcal,
- time_t *start_time,
- time_t *end_time)
+gnome_calendar_set_range_selected (GnomeCalendar *gcal,
+ gboolean range_selected)
{
- GnomeCalendarPrivate *priv;
- ECalModel *model;
-
- g_return_if_fail (gcal != NULL);
g_return_if_fail (GNOME_IS_CALENDAR (gcal));
- priv = gcal->priv;
+ gcal->priv->range_selected = range_selected;
+}
- model = e_calendar_view_get_model (priv->views[priv->current_view_type]);
- e_cal_model_get_time_range (model, start_time, end_time);
+void
+gnome_calendar_set_selected_time_range (GnomeCalendar *gcal,
+ time_t start_time)
+{
+ gnome_calendar_update_view_times (gcal, start_time);
+ gnome_calendar_update_date_navigator (gcal);
+ gnome_calendar_notify_dates_shown_changed (gcal);
}
/**
@@ -3496,6 +2322,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)
{
@@ -3510,7 +2337,6 @@ gnome_calendar_new_task (GnomeCalendar *gcal, time_t *dtstart, time_t *dtend)
ECalComponentDateTime dt;
struct icaltimetype itt;
- g_return_if_fail (gcal != NULL);
g_return_if_fail (GNOME_IS_CALENDAR (gcal));
priv = gcal->priv;
@@ -3526,9 +2352,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));
@@ -3550,6 +2373,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
@@ -3559,25 +2383,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);
-}
-
-/* Gets the visible time range for the current view. Returns FALSE if no
- time range has been set yet. */
-gboolean
-gnome_calendar_get_visible_time_range (GnomeCalendar *gcal,
- time_t *start_time,
- time_t *end_time)
-{
- gboolean retval = FALSE;
-
- g_return_val_if_fail (GNOME_IS_CALENDAR (gcal), FALSE);
+ GnomeCalendarViewType view_type;
+ ECalendarView *view;
- 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;
+ e_calendar_view_get_selected_time_range (view, start_time, end_time);
}
/* This updates the month shown and the days selected in the calendar, if
@@ -3588,10 +2400,16 @@ gnome_calendar_update_date_navigator (GnomeCalendar *gcal)
GnomeCalendarPrivate *priv;
ECalModel *model;
time_t start, end;
+ gint week_start_day;
GDate start_date, end_date;
+ icaltimezone *timezone;
priv = gcal->priv;
+ /* If the ECalendar is not yet set, we just return. */
+ if (priv->date_navigator == NULL)
+ return;
+
/* If the ECalendar isn't visible, we just return. */
if (!GTK_WIDGET_VISIBLE (priv->date_navigator))
return;
@@ -3599,163 +2417,39 @@ gnome_calendar_update_date_navigator (GnomeCalendar *gcal)
if (priv->current_view_type == GNOME_CAL_LIST_VIEW && !priv->lview_select_daten_range)
return;
- model = e_calendar_view_get_model (priv->views[priv->current_view_type]);
+ model = gnome_calendar_get_model (gcal);
+ timezone = e_cal_model_get_timezone (model);
+ week_start_day = e_cal_model_get_week_start_day (model);
e_cal_model_get_time_range (model, &start, &end);
- time_to_gdate_with_zone (&start_date, start, priv->zone);
+ time_to_gdate_with_zone (&start_date, start, timezone);
if (priv->current_view_type == GNOME_CAL_MONTH_VIEW) {
EWeekView *week_view = E_WEEK_VIEW (priv->views[priv->current_view_type]);
- if (priv->week_start == 0
+ if (week_start_day == 0
&& (!week_view->multi_week_view || week_view->compress_weekend))
g_date_add_days (&start_date, 1);
}
- time_to_gdate_with_zone (&end_date, end, priv->zone);
+ time_to_gdate_with_zone (&end_date, end, timezone);
g_date_subtract_days (&end_date, 1);
e_calendar_item_set_selection (priv->date_navigator->calitem,
&start_date, &end_date);
}
-static void
-gnome_calendar_on_date_navigator_selection_changed (ECalendarItem *calitem, GnomeCalendar *gcal)
-{
- GnomeCalendarPrivate *priv;
- GnomeCalendarViewType view_type;
- ECalModel *model;
- GDate start_date, end_date, new_start_date, new_end_date;
- gint new_days_shown;
- gboolean starts_on_week_start_day;
- time_t new_time, start, end;
- struct icaltimetype tt;
-
- priv = gcal->priv;
-
- starts_on_week_start_day = FALSE;
-
- model = e_calendar_view_get_model (priv->views[priv->current_view_type]);
- e_cal_model_get_time_range (model, &start, &end);
-
- time_to_gdate_with_zone (&start_date, start, priv->zone);
- if (priv->current_view_type == GNOME_CAL_MONTH_VIEW) {
- EWeekView *week_view = E_WEEK_VIEW (priv->views[priv->current_view_type]);
-
- if (priv->week_start == 0 && (!week_view->multi_week_view || week_view->compress_weekend))
- g_date_add_days (&start_date, 1);
- }
- time_to_gdate_with_zone (&end_date, end, priv->zone);
- g_date_subtract_days (&end_date, 1);
-
- e_calendar_item_get_selection (calitem, &new_start_date, &new_end_date);
-
- /* If the selection hasn't changed just return. */
- if (!g_date_compare (&start_date, &new_start_date)
- && !g_date_compare (&end_date, &new_end_date)) {
- return;
- }
-
- new_days_shown = g_date_get_julian (&new_end_date) - g_date_get_julian (&new_start_date) + 1;
-
- /* If a complete week is selected we show the Week view.
- Note that if weekends are compressed and the week start day is set
- to Sunday we don't actually show complete weeks in the Week view,
- so this may need tweaking. */
- if (g_date_get_weekday (&new_start_date) % 7 == priv->week_start)
- starts_on_week_start_day = TRUE;
-
- /* Update selection to be in the new time range */
- tt = icaltime_null_time ();
- tt.year = g_date_get_year (&new_start_date);
- tt.month = g_date_get_month (&new_start_date);
- tt.day = g_date_get_day (&new_start_date);
- new_time = icaltime_as_timet_with_zone (tt, priv->zone);
-
- /* Switch views as appropriate, and change the number of days or weeks
- shown. */
- if (new_days_shown > 9) {
- /* FIXME Gross hack so that the view times are updated properly */
- priv->range_selected = TRUE;
-
- if (priv->current_view_type != GNOME_CAL_LIST_VIEW) {
- e_week_view_set_weeks_shown (E_WEEK_VIEW (priv->month_view),
- (new_days_shown + 6) / 7);
- view_type = GNOME_CAL_MONTH_VIEW;
- } else
- view_type = GNOME_CAL_LIST_VIEW;
- } else if (new_days_shown == 7 && starts_on_week_start_day) {
- view_type = GNOME_CAL_WEEK_VIEW;
- } else {
- e_day_view_set_days_shown (E_DAY_VIEW (priv->day_view), new_days_shown);
-
- if (new_days_shown == 5 && starts_on_week_start_day
- && priv->current_view_type == GNOME_CAL_WORK_WEEK_VIEW)
- view_type = GNOME_CAL_WORK_WEEK_VIEW;
- else
- view_type = GNOME_CAL_DAY_VIEW;
- }
-
- /* Make the views display things properly */
- update_view_times (gcal, new_time);
- set_view (gcal, view_type, TRUE);
-
- gnome_calendar_notify_dates_shown_changed (gcal);
-}
-
-static void
-gnome_calendar_on_date_navigator_date_range_changed (ECalendarItem *calitem, GnomeCalendar *gcal)
-{
- update_query (gcal);
-}
-
-static void
-gnome_calendar_hpane_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->hpane), priv->hpane_pos_month_view);
- } else {
- gtk_paned_set_position (GTK_PANED (priv->hpane), priv->hpane_pos);
- }
-}
-
-static void
-gnome_calendar_date_navigator_scrolled (GtkWidget *widget, GdkEventScroll *event, gpointer user_data)
-{
- GnomeCalendar *gcal = user_data;
- ECalendarItem *calitem = gcal->priv->date_navigator->calitem;
- GDate start_date, end_date;
-
- if (e_calendar_item_get_selection (calitem, &start_date, &end_date)) {
- switch (event->direction) {
- case GDK_SCROLL_UP:
- g_date_subtract_months (&start_date, 1);
- g_date_subtract_months (&end_date, 1);
- break;
- case GDK_SCROLL_DOWN:
- g_date_add_months (&start_date, 1);
- g_date_add_months (&end_date, 1);
- break;
- default:
- break;
-
- }
- e_calendar_item_set_selection (calitem, &start_date, &end_date);
- gnome_calendar_on_date_navigator_selection_changed (calitem, gcal);
- }
-}
-
static gboolean
gnome_calendar_hpane_resized (GtkWidget *w, GdkEventButton *e, GnomeCalendar *gcal)
{
GnomeCalendarPrivate *priv;
+ ECalendarView *view;
+ gboolean range_selected;
gint times_width;
priv = gcal->priv;
- if (priv->current_view_type == GNOME_CAL_MONTH_VIEW && !priv->range_selected) {
+ range_selected = gnome_calendar_get_range_selected (gcal);
+
+ if (priv->current_view_type == GNOME_CAL_MONTH_VIEW && !range_selected) {
priv->hpane_pos_month_view = gtk_paned_get_position (GTK_PANED (priv->hpane));
calendar_config_set_month_hpane_pos (priv->hpane_pos_month_view);
} else {
@@ -3764,124 +2458,37 @@ gnome_calendar_hpane_resized (GtkWidget *w, GdkEventButton *e, GnomeCalendar *gc
}
/* adjust the size of the EDayView's time column */
+ view = gnome_calendar_get_calendar_view (gcal, GNOME_CAL_DAY_VIEW);
times_width = e_day_view_time_item_get_column_width (
- E_DAY_VIEW_TIME_ITEM (E_DAY_VIEW (priv->day_view)->time_canvas_item));
+ E_DAY_VIEW_TIME_ITEM (E_DAY_VIEW (view)->time_canvas_item));
if (times_width < priv->hpane_pos - 20)
- gtk_widget_set_size_request (E_DAY_VIEW (priv->day_view)->time_canvas, times_width, -1);
+ gtk_widget_set_size_request (E_DAY_VIEW (view)->time_canvas, times_width, -1);
else
- gtk_widget_set_size_request (E_DAY_VIEW (priv->day_view)->time_canvas, priv->hpane_pos - 20, -1);
-
- 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);
- }
+ gtk_widget_set_size_request (E_DAY_VIEW (view)->time_canvas, priv->hpane_pos - 20, -1);
return FALSE;
}
void
-gnome_calendar_cut_clipboard (GnomeCalendar *gcal)
-{
- GnomeCalendarPrivate *priv;
- FocusLocation location;
-
- priv = gcal->priv;
-
- location = get_focus_location (gcal);
-
- if (location == FOCUS_CALENDAR) {
- e_calendar_view_cut_clipboard (E_CALENDAR_VIEW (gnome_calendar_get_current_view_widget (gcal)));
- } else if (location == FOCUS_TASKPAD)
- e_calendar_table_cut_clipboard (E_CALENDAR_TABLE (priv->todo));
- else if (location == FOCUS_MEMOPAD)
- e_memo_table_cut_clipboard (E_MEMO_TABLE (priv->memo));
-}
-
-void
-gnome_calendar_copy_clipboard (GnomeCalendar *gcal)
-{
- GnomeCalendarPrivate *priv;
- FocusLocation location;
-
- priv = gcal->priv;
-
- location = get_focus_location (gcal);
-
- if (location == FOCUS_CALENDAR) {
- e_calendar_view_copy_clipboard (E_CALENDAR_VIEW (gnome_calendar_get_current_view_widget (gcal)));
- } else if (location == FOCUS_TASKPAD)
- e_calendar_table_copy_clipboard (E_CALENDAR_TABLE (priv->todo));
- else if (location == FOCUS_MEMOPAD)
- e_memo_table_copy_clipboard (E_MEMO_TABLE (priv->memo));
-}
-
-void
-gnome_calendar_paste_clipboard (GnomeCalendar *gcal)
-{
- GnomeCalendarPrivate *priv;
- FocusLocation location;
-
- priv = gcal->priv;
-
- location = get_focus_location (gcal);
-
- if (location == FOCUS_CALENDAR) {
- e_calendar_view_paste_clipboard (E_CALENDAR_VIEW (gnome_calendar_get_current_view_widget (gcal)));
- } else if (location == FOCUS_TASKPAD)
- e_calendar_table_paste_clipboard (E_CALENDAR_TABLE (priv->todo));
- else if (location == FOCUS_MEMOPAD)
- e_memo_table_paste_clipboard (E_MEMO_TABLE (priv->memo));
-}
-
-/* Get the current timezone. */
-icaltimezone*
-gnome_calendar_get_timezone (GnomeCalendar *gcal)
-{
- g_return_val_if_fail (gcal != NULL, NULL);
- g_return_val_if_fail (GNOME_IS_CALENDAR (gcal), NULL);
-
- return gcal->priv->zone;
-}
-
-static void
gnome_calendar_notify_dates_shown_changed (GnomeCalendar *gcal)
{
+ GnomeCalendarViewType view_type;
+ ECalendarView *calendar_view;
GnomeCalendarPrivate *priv;
time_t start_time, end_time;
+ gboolean has_time_range;
g_return_if_fail (GNOME_IS_CALENDAR (gcal));
priv = gcal->priv;
+ view_type = gnome_calendar_get_view (gcal);
+ calendar_view = gnome_calendar_get_calendar_view (gcal, view_type);
+
/* If no time range is set yet, just return. */
- if (!gnome_calendar_get_visible_time_range (gcal, &start_time,
- &end_time))
+ has_time_range = e_calendar_view_get_visible_time_range (
+ calendar_view, &start_time, &end_time);
+ if (!has_time_range)
return;
/* We check if the visible date range has changed, and only emit the
@@ -3892,7 +2499,7 @@ gnome_calendar_notify_dates_shown_changed (GnomeCalendar *gcal)
priv->visible_start = start_time;
priv->visible_end = end_time;
- g_signal_emit (gcal, gnome_calendar_signals[DATES_SHOWN_CHANGED], 0);
+ g_signal_emit (gcal, signals[DATES_SHOWN_CHANGED], 0);
}
update_memo_view (gcal);
}
@@ -3901,12 +2508,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
@@ -3915,70 +2525,6 @@ 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)
-{
- GnomeCalendarPrivate *priv;
- FocusLocation location;
- GtkWidget *view;
-
- g_return_if_fail (GNOME_IS_CALENDAR (gcal));
-
- priv = gcal->priv;
-
- location = get_focus_location (gcal);
-
- if (location == FOCUS_CALENDAR) {
- view = gnome_calendar_get_current_view_widget (gcal);
-
- e_calendar_view_delete_selected_events (E_CALENDAR_VIEW (view));
- } else if (location == FOCUS_TASKPAD)
- e_calendar_table_delete_selected (E_CALENDAR_TABLE (priv->todo));
- else if (location == FOCUS_MEMOPAD)
- e_memo_table_delete_selected (E_MEMO_TABLE (priv->memo));
-}
-
-void
-gnome_calendar_delete_selected_occurrence (GnomeCalendar *gcal)
-{
- FocusLocation location;
- GtkWidget *view;
-
- g_return_if_fail (GNOME_IS_CALENDAR (gcal));
-
- location = get_focus_location (gcal);
-
- if (location == FOCUS_CALENDAR) {
-
- view = gnome_calendar_get_current_view_widget (gcal);
- e_calendar_view_delete_selected_occurrence (E_CALENDAR_VIEW (view));
- }
-}
-
static gboolean
check_instance_cb (ECalComponent *comp,
time_t instance_start,
@@ -4009,10 +2555,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;
@@ -4067,101 +2613,10 @@ 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);
g_free (end);
}
-
-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)
-{
- g_return_val_if_fail (GNOME_IS_CALENDAR (gcal), NULL);
-
- 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);
-
- 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,
- const gchar * comp_uid,
- const gchar * comp_rid)
-{
- ECal *client = NULL;
- GList *l;
- icalcomponent* icalcomp = NULL;
- icalproperty *attendee_prop = NULL;
-
- if (!src_uid || !comp_uid)
- return;
-
- for (l = gcal->priv->clients_list[E_CAL_SOURCE_TYPE_EVENT]; l != NULL; l = l->next) {
- ESource *client_src;
-
- client = l->data;
- client_src = e_cal_get_source (client);
-
- if (!strcmp (src_uid, e_source_peek_uid (client_src)))
- break;
- }
-
- if (!client)
- return;
-
- e_cal_get_object (client, comp_uid, comp_rid, &icalcomp, NULL);
-
- if (!icalcomp)
- return;
-
- attendee_prop = icalcomponent_get_first_property (icalcomp, ICAL_ATTENDEE_PROPERTY);
- e_calendar_view_edit_appointment (gcal->priv->views[gcal->priv->current_view_type],
- client, icalcomp, attendee_prop ? TRUE:FALSE);
- icalcomponent_free (icalcomp);
-}
diff --git a/calendar/gui/gnome-cal.h b/calendar/gui/gnome-cal.h
index 2a5e2f847d..0cc528fe3c 100644
--- a/calendar/gui/gnome-cal.h
+++ b/calendar/gui/gnome-cal.h
@@ -24,29 +24,40 @@
*
*/
-#ifndef GNOME_CALENDAR_APP_H
-#define GNOME_CALENDAR_APP_H
+#ifndef GNOME_CALENDAR_H
+#define GNOME_CALENDAR_H
#include <time.h>
#include <gtk/gtk.h>
-#include <bonobo/bonobo-ui-component.h>
#include <misc/e-calendar.h>
#include <libecal/e-cal.h>
-#include <e-util/e-popup.h>
+#include <shell/e-shell-settings.h>
-#include "e-cal-menu.h"
#include "e-calendar-table.h"
-G_BEGIN_DECLS
+/* Standard GObject macros */
+#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(cls) \
+ (G_TYPE_CHECK_INSTANCE_CAST_CLASS \
+ ((cls), GNOME_TYPE_CALENDAR, GnomeCalendarClass))
+#define GNOME_IS_CALENDAR(obj) \
+ (G_TYPE_CHECK_INSTANCE_TYPE \
+ ((obj), GNOME_TYPE_CALENDAR))
+#define GNOME_IS_CALENDAR_CLASS(cls) \
+ (G_TYPE_CHECK_CLASS_TYPE \
+ ((cls), GNOME_TYPE_CALENDAR))
+#define GNOME_CALENDAR_GET_CLASS(obj) \
+ (G_TYPE_INSTANCE_GET_CLASS \
+ ((obj), GNOME_TYPE_CALENDAR, GnomeCalendarClass))
-
+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, \
- GnomeCalendarClass))
-#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))
+/* Avoid circular inclusion. */
+struct _ECalendarView;
typedef struct _GnomeCalendar GnomeCalendar;
typedef struct _GnomeCalendarClass GnomeCalendarClass;
@@ -75,8 +86,6 @@ typedef enum {
struct _GnomeCalendar {
GtkVBox vbox;
-
- /* Private data */
GnomeCalendarPrivate *priv;
};
@@ -87,118 +96,94 @@ 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);
};
-GType gnome_calendar_get_type (void);
-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);
-
-void gnome_calendar_next (GnomeCalendar *gcal);
-void gnome_calendar_previous (GnomeCalendar *gcal);
-void gnome_calendar_goto (GnomeCalendar *gcal,
+GType gnome_calendar_get_type (void);
+GtkWidget * gnome_calendar_new (EShellSettings *shell_settings);
+EShellSettings *gnome_calendar_get_shell_settings
+ (GnomeCalendar *gcal);
+ECalendar * gnome_calendar_get_date_navigator
+ (GnomeCalendar *gcal);
+void gnome_calendar_set_date_navigator
+ (GnomeCalendar *gcal,
+ ECalendar *date_navigator);
+ECalModel * gnome_calendar_get_model (GnomeCalendar *gcal);
+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_update_query (GnomeCalendar *gcal);
+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);
+void gnome_calendar_goto (GnomeCalendar *gcal,
time_t new_time);
-void gnome_calendar_dayjump (GnomeCalendar *gcal,
+void gnome_calendar_update_view_times(GnomeCalendar *gcal,
+ time_t start_time);
+void gnome_calendar_dayjump (GnomeCalendar *gcal,
time_t time);
-/* Jumps to the current day */
-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);
-
-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,
- time_t end_time);
-void gnome_calendar_get_selected_time_range (GnomeCalendar *gcal,
- time_t *start_time,
- time_t *end_time);
-
-void gnome_calendar_new_task (GnomeCalendar *gcal, time_t *dtstart, time_t *dtend);
+void gnome_calendar_goto_today (GnomeCalendar *gcal);
+
+GnomeCalendarViewType
+ gnome_calendar_get_view (GnomeCalendar *gcal);
+void gnome_calendar_set_view (GnomeCalendar *gcal,
+ GnomeCalendarViewType view_type);
+void gnome_calendar_display_view (GnomeCalendar *gcal,
+ GnomeCalendarViewType view_type);
+
+struct _ECalendarView *
+ gnome_calendar_get_calendar_view(GnomeCalendar *gcal,
+ GnomeCalendarViewType view_type);
+
+gboolean gnome_calendar_get_range_selected
+ (GnomeCalendar *gcal);
+void gnome_calendar_set_range_selected
+ (GnomeCalendar *gcal,
+ gboolean range_selected);
+void gnome_calendar_set_selected_time_range
+ (GnomeCalendar *gcal,
+ time_t start_time);
+void gnome_calendar_new_task (GnomeCalendar *gcal,
+ time_t *dtstart,
+ time_t *dtend);
/* 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
this or choose a more appropriate time. */
-void gnome_calendar_get_current_time_range (GnomeCalendar *gcal,
- time_t *start_time,
- time_t *end_time);
+void gnome_calendar_get_current_time_range
+ (GnomeCalendar *gcal,
+ time_t *start_time,
+ time_t *end_time);
-/* Gets the visible time range for the current view. Returns FALSE if no
- time range has been set yet. */
-gboolean gnome_calendar_get_visible_time_range (GnomeCalendar *gcal,
- time_t *start_time,
- time_t *end_time);
+void gnome_calendar_notify_dates_shown_changed
+ (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);
+gint gnome_calendar_get_num_events_selected
+ (GnomeCalendar *gcal);
-/* Get the current timezone. */
-icaltimezone *gnome_calendar_get_timezone (GnomeCalendar *gcal);
-
-/* Clipboard operations */
-void gnome_calendar_cut_clipboard (GnomeCalendar *gcal);
-void gnome_calendar_copy_clipboard (GnomeCalendar *gcal);
-void gnome_calendar_paste_clipboard (GnomeCalendar *gcal);
-
-void gnome_calendar_delete_selection (GnomeCalendar *gcal);
-void gnome_calendar_delete_selected_occurrence (GnomeCalendar *gcal);
-void gnome_calendar_purge (GnomeCalendar *gcal,
+void gnome_calendar_purge (GnomeCalendar *gcal,
time_t older_than);
-
-
-/* Direct calendar component operations */
-void gnome_calendar_edit_appointment (GnomeCalendar *gcal,
- const gchar * src_uid,
- 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..6e68ec71ee 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"
@@ -77,9 +76,11 @@ static void
ecal_date_range_changed (ECalendarItem *calitem, gpointer user_data)
{
GoToDialog *dlg = user_data;
+ ECalModel *model;
ECal *client;
- client = gnome_calendar_get_default_client (dlg->gcal);
+ model = gnome_calendar_get_model (dlg->gcal);
+ client = e_cal_model_get_default_client (model);
if (client)
tag_calendar_by_client (dlg->ecal, client);
}
@@ -92,16 +93,20 @@ ecal_event (ECalendarItem *calitem, gpointer user_data)
{
GoToDialog *dlg = user_data;
GDate start_date, end_date;
+ ECalModel *model;
struct icaltimetype tt = icaltime_null_time ();
+ icaltimezone *timezone;
time_t et;
+ model = gnome_calendar_get_model (dlg->gcal);
e_calendar_item_get_selection (calitem, &start_date, &end_date);
+ timezone = e_cal_model_get_timezone (model);
tt.year = g_date_get_year (&start_date);
tt.month = g_date_get_month (&start_date);
tt.day = g_date_get_day (&start_date);
- et = icaltime_as_timet_with_zone (tt, gnome_calendar_get_timezone (dlg->gcal));
+ et = icaltime_as_timet_with_zone (tt, timezone);
gnome_calendar_goto (dlg->gcal, et);
@@ -201,8 +206,10 @@ goto_dialog_init_widgets (GoToDialog *dlg)
void
goto_dialog (GnomeCalendar *gcal)
{
+ ECalModel *model;
time_t start_time;
struct icaltimetype tt;
+ icaltimezone *timezone;
gint b;
gchar *gladefile;
@@ -231,8 +238,10 @@ goto_dialog (GnomeCalendar *gcal)
}
dlg->gcal = gcal;
- gnome_calendar_get_selected_time_range (dlg->gcal, &start_time, NULL);
- tt = icaltime_from_timet_with_zone (start_time, FALSE, gnome_calendar_get_timezone (gcal));
+ model = gnome_calendar_get_model (gcal);
+ timezone = e_cal_model_get_timezone (model);
+ e_cal_model_get_time_range (model, &start_time, NULL);
+ tt = icaltime_from_timet_with_zone (start_time, FALSE, timezone);
dlg->year_val = tt.year;
dlg->month_val = tt.month - 1;
dlg->day_val = tt.day;
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 10751a3629..38fcb46bb7 100644
--- a/calendar/gui/itip-utils.c
+++ b/calendar/gui/itip-utils.c
@@ -38,7 +38,6 @@
#include "dialogs/comp-editor-util.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[] = {
@@ -1260,7 +1259,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);
@@ -1368,7 +1366,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
deleted file mode 100644
index f4e3200e8c..0000000000
--- a/calendar/gui/memos-component.c
+++ /dev/null
@@ -1,1222 +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>
- * Nathan Owens <pianocomp81@yahoo.com>
- *
- * Copyright (C) 1999-2008 Novell, Inc. (www.novell.com)
- *
- */
-
-#ifdef HAVE_CONFIG_H
-#include <config.h>
-#endif
-
-#include <errno.h>
-#include <string.h>
-#include <glib/gi18n-lib.h>
-#include <bonobo/bonobo-control.h>
-#include <bonobo/bonobo-exception.h>
-#include <gconf/gconf-client.h>
-#include <libecal/e-cal.h>
-#include <libedataserver/e-data-server-util.h>
-#include <libedataserverui/e-source-selector.h>
-#include <shell/e-user-creatable-items-handler.h>
-#include <shell/e-component-view.h>
-#include "e-cal-model.h"
-#include "e-memos.h"
-#include "memos-component.h"
-#include "memos-control.h"
-#include "e-comp-editor-registry.h"
-#include "migration.h"
-#include "comp-util.h"
-#include "calendar-config.h"
-#include "e-cal-popup.h"
-#include "common/authentication.h"
-#include "dialogs/calendar-setup.h"
-#include "dialogs/comp-editor.h"
-#include "dialogs/copy-source-dialog.h"
-#include "dialogs/memo-editor.h"
-#include "widgets/misc/e-info-label.h"
-#include "e-util/e-error.h"
-#include "calendar-component.h"
-
-#define CREATE_MEMO_ID "memo"
-#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;
-
- GSList *source_selection;
-
- EMemos *memos;
- 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;
-};
-
-#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
-is_in_selection (GSList *selection, ESource *source)
-{
- GSList *l;
-
- for (l = selection; l; l = l->next) {
- ESource *selected_source = l->data;
-
- if (!strcmp (e_source_peek_uid (selected_source), e_source_peek_uid (source)))
- return TRUE;
- }
-
- return FALSE;
-}
-
-static gboolean
-is_in_uids (GSList *uids, ESource *source)
-{
- GSList *l;
-
- for (l = uids; l; l = l->next) {
- const gchar *uid = l->data;
-
- if (!strcmp (uid, e_source_peek_uid (source)))
- return TRUE;
- }
-
- return FALSE;
-}
-
-static void
-update_uris_for_selection (MemosComponentView *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))
- e_memos_remove_memo_source (component_view->memos, old_selected_source);
- }
-
- for (l = selection; l; l = l->next) {
- ESource *selected_source = l->data;
-
- e_memos_add_memo_source (component_view->memos, 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_memos_selected (uids_selected);
- 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,
- ESource *destination,
- GdkDragAction action,
- guint info,
- MemosComponent *component)
-{
- gboolean success = FALSE;
- icalcomponent *icalcomp = NULL;
- ECal *client = NULL;
- GSList *components, *p;
-
- client = auth_new_cal_from_source (
- destination, E_CAL_SOURCE_TYPE_JOURNAL);
-
- if (!client || !e_cal_open (client, TRUE, NULL))
- goto finish;
-
- components = cal_comp_selection_get_string_list (data);
- success = components != NULL;
- for (p = components; p && success; p = p->next) {
- gchar *comp_str; /* do not free this! */
-
- /* p->data is "source_uid\ncomponent_string" */
- comp_str = strchr (p->data, '\n');
- if (!comp_str)
- continue;
-
- comp_str [0] = 0;
- comp_str++;
- icalcomp = icalparser_parse_string (comp_str);
-
- if (!icalcomp)
- continue;
-
- success = cal_comp_process_source_list_drop (client, icalcomp, action, p->data, component->priv->source_list);
- icalcomponent_free (icalcomp);
- }
-
- g_slist_foreach (components, (GFunc)g_free, NULL);
- g_slist_free (components);
-
- finish:
- if (client)
- g_object_unref (client);
-
- return success;
-}
-
-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;
- MemosComponentPrivate *priv;
-
- priv = component->priv;
-
- g_object_unref (priv->create_ecal);
- priv->create_ecal = NULL;
-
- priv->notifications = g_list_remove (priv->notifications, GUINT_TO_POINTER (id));
-}
-
-static ECal *
-setup_create_ecal (MemosComponent *component, MemosComponentView *component_view)
-{
- MemosComponentPrivate *priv;
- ESource *source = NULL;
- gchar *uid;
- guint not;
-
- priv = component->priv;
-
- if (component_view) {
- ECal *default_ecal;
-
- default_ecal = e_memos_get_default_client (component_view->memos);
- if (default_ecal)
- return default_ecal;
- }
-
- if (priv->create_ecal)
- return priv->create_ecal;
-
- /* Get the current primary calendar, or try to set one if it doesn't already exist */
- uid = calendar_config_get_primary_memos ();
- if (uid) {
- source = e_source_list_peek_source_by_uid (priv->source_list, uid);
- g_free (uid);
-
- priv->create_ecal = auth_new_cal_from_source (source, E_CAL_SOURCE_TYPE_JOURNAL);
- }
-
- if (!priv->create_ecal) {
- /* Try to create a default if there isn't one */
- source = e_source_list_peek_source_any (priv->source_list);
- if (source)
- priv->create_ecal = auth_new_cal_from_source (source, E_CAL_SOURCE_TYPE_JOURNAL);
- }
-
- if (priv->create_ecal) {
-
- if (!e_cal_open (priv->create_ecal, FALSE, NULL)) {
- GtkWidget *dialog;
-
- dialog = gtk_message_dialog_new (NULL, GTK_DIALOG_MODAL,
- GTK_MESSAGE_WARNING, GTK_BUTTONS_OK,
- _("Unable to open the memo list '%s' for creating events and meetings"),
- e_source_peek_name (source));
- gtk_dialog_run (GTK_DIALOG (dialog));
- gtk_widget_destroy (dialog);
-
- return NULL;
- }
-
- } else {
- GtkWidget *dialog;
-
- dialog = gtk_message_dialog_new (NULL, GTK_DIALOG_MODAL,
- GTK_MESSAGE_WARNING, GTK_BUTTONS_OK,
- "%s", _("There is no calendar available for creating memos"));
- gtk_dialog_run (GTK_DIALOG (dialog));
- gtk_widget_destroy (dialog);
-
- return NULL;
- }
-
- /* Handle the fact it may change on us */
- not = calendar_config_add_notification_primary_memos (config_create_ecal_changed_cb,
- component);
- priv->notifications = g_list_prepend (priv->notifications, GUINT_TO_POINTER (not));
-
- /* Save the primary source for use elsewhere */
- calendar_config_set_primary_memos (e_source_peek_uid (source));
-
- return priv->create_ecal;
-}
-
-/* Ensures the calendar is selected */
-static void
-object_created_cb (CompEditor *ce, EMemoTable *memo_table)
-{
- g_return_if_fail (memo_table != NULL);
-
- memo_table->user_created_cal = comp_editor_get_client (ce);
- g_signal_emit_by_name (memo_table, "user_created");
- memo_table->user_created_cal = NULL;
-}
-
-static gboolean
-create_new_memo (MemosComponent *memo_component, gboolean is_assigned, MemosComponentView *component_view)
-{
- ECal *ecal;
- ECalComponent *comp;
- CompEditor *editor;
- CompEditorFlags flags = 0;
-
- ecal = setup_create_ecal (memo_component, component_view);
- if (!ecal)
- return FALSE;
-
- flags |= COMP_EDITOR_NEW_ITEM;
- if (is_assigned) {
- flags |= COMP_EDITOR_IS_SHARED;
- flags |= COMP_EDITOR_USER_ORG;
- }
-
- editor = memo_editor_new (ecal, flags);
- comp = cal_comp_memo_new_with_defaults (ecal);
-
- if (component_view)
- g_signal_connect (editor, "object_created", G_CALLBACK (object_created_cb), e_memos_get_calendar_table (component_view->memos));
-
- comp_editor_edit_comp (editor, comp);
- 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)
-{
- 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;
- }
-
- 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;
-}
-
-static void
-destroy_component_view (MemosComponentView *component_view)
-{
- GList *l;
-
- if (component_view->source_list)
- g_object_unref (component_view->source_list);
-
- if (component_view->source_selection)
- e_source_selector_free_selection (component_view->source_selection);
-
- for (l = component_view->notifications; l; l = l->next)
- 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
-impl_dispose (GObject *object)
-{
- MemosComponent *memos_component = MEMOS_COMPONENT (object);
- MemosComponentPrivate *priv = memos_component->priv;
- GList *l;
-
- if (priv->source_list != NULL) {
- g_object_unref (priv->source_list);
- priv->source_list = NULL;
- }
- if (priv->source_selection != NULL) {
- e_source_selector_free_selection (priv->source_selection);
- priv->source_selection = NULL;
- }
-
- if (priv->create_ecal) {
- g_object_unref (priv->create_ecal);
- 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);
- priv->notifications = NULL;
-
- (* 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
deleted file mode 100644
index 54f522ba9c..0000000000
--- a/calendar/gui/memos-component.h
+++ /dev/null
@@ -1,61 +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>
- * Nathan Owens <pianocomp81@yahoo.com>
- *
- * Copyright (C) 1999-2008 Novell, Inc. (www.novell.com)
- *
- */
-
-#ifndef _MEMOS_COMPONENT_H_
-#define _MEMOS_COMPONENT_H_
-
-#include <bonobo/bonobo-object.h>
-#include <libedataserver/e-source-list.h>
-#include <widgets/misc/e-activity-handler.h>
-#include "Evolution.h"
-
-#define MEMOS_TYPE_COMPONENT (memos_component_get_type ())
-#define MEMOS_COMPONENT(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), MEMOS_TYPE_COMPONENT, MemosComponent))
-#define MEMOS_COMPONENT_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), MEMOS_TYPE_COMPONENT, MemosComponentClass))
-#define MEMOS_IS_COMPONENT(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), MEMOS_TYPE_COMPONENT))
-#define MEMOS_IS_COMPONENT_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((obj), MEMOS_TYPE_COMPONENT))
-
-typedef struct _MemosComponent MemosComponent;
-typedef struct _MemosComponentPrivate MemosComponentPrivate;
-typedef struct _MemosComponentClass MemosComponentClass;
-
-struct _MemosComponent {
- BonoboObject parent;
-
- MemosComponentPrivate *priv;
-};
-
-struct _MemosComponentClass {
- BonoboObjectClass parent_class;
-
- POA_GNOME_Evolution_Component__epv epv;
-};
-
-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..e6563cd846 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"
@@ -677,7 +676,7 @@ print_month_small (GtkPrintContext *context, GnomeCalendar *gcal, time_t month,
sprintf (buf, "%d", day);
/* this is a slow messy way to do this ... but easy ... */
- e_cal_model_generate_instances (gnome_calendar_get_calendar_model (gcal), now,
+ e_cal_model_generate_instances (gnome_calendar_get_model (gcal), now,
time_day_end_with_zone (now, zone),
instance_cb, &found);
@@ -1248,7 +1247,7 @@ print_day_details (GtkPrintContext *context, GnomeCalendar *gcal, time_t whence,
double font_size, max_font_size;
cairo_t *cr;
- ECalModel *model = gnome_calendar_get_calendar_model (gcal);
+ ECalModel *model = gnome_calendar_get_model (gcal);
start = time_day_begin_with_zone (whence, zone);
end = time_day_end_with_zone (start, zone);
@@ -1734,7 +1733,7 @@ print_week_summary (GtkPrintContext *context, GnomeCalendar *gcal,
GArray *spans;
PangoFontDescription *font;
double cell_width, cell_height;
- ECalModel *model = gnome_calendar_get_calendar_model (gcal);
+ ECalModel *model = gnome_calendar_get_model (gcal);
psi.days_shown = weeks_shown * 7;
psi.events = g_array_new (FALSE, FALSE, sizeof (EWeekViewEvent));
@@ -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
@@ -2389,7 +2390,8 @@ print_calendar_draw_page (GtkPrintOperation *operation,
}
void
-print_calendar (GnomeCalendar *gcal, GtkPrintOperationAction action,
+print_calendar (GnomeCalendar *gcal,
+ GtkPrintOperationAction action,
time_t start)
{
GtkPrintOperation *operation;
@@ -2398,6 +2400,34 @@ print_calendar (GnomeCalendar *gcal, GtkPrintOperationAction action,
g_return_if_fail (gcal != NULL);
g_return_if_fail (GNOME_IS_CALENDAR (gcal));
+ if (gnome_calendar_get_view (gcal) == GNOME_CAL_MONTH_VIEW) {
+ GnomeCalendarViewType view_type;
+ ECalendarView *calendar_view;
+ EWeekView *week_view;
+
+ view_type = gnome_calendar_get_view (gcal);
+ calendar_view = gnome_calendar_get_calendar_view (gcal, view_type);
+ week_view = E_WEEK_VIEW (calendar_view);
+
+ if (week_view && week_view->multi_week_view &&
+ week_view->weeks_shown >= 4 &&
+ g_date_valid (&week_view->first_day_shown)) {
+
+ GDate date = week_view->first_day_shown;
+ struct icaltimetype start_tt;
+
+ g_date_add_days (&date, 7);
+
+ start_tt = icaltime_null_time ();
+ start_tt.is_date = TRUE;
+ start_tt.year = g_date_get_year (&date);
+ start_tt.month = g_date_get_month (&date);
+ start_tt.day = g_date_get_day (&date);
+
+ start = icaltime_as_timet (start_tt);
+ }
+ }
+
pcali.gcal = (GnomeCalendar *)gcal;
pcali.start = start;
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
deleted file mode 100644
index f7934742d2..0000000000
--- a/calendar/gui/tasks-component.c
+++ /dev/null
@@ -1,1293 +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)
- *
- */
-
-#ifdef HAVE_CONFIG_H
-#include <config.h>
-#endif
-
-#include <errno.h>
-#include <string.h>
-#include <glib/gi18n-lib.h>
-#include <bonobo/bonobo-control.h>
-#include <bonobo/bonobo-exception.h>
-#include <gconf/gconf-client.h>
-#include <libecal/e-cal.h>
-#include <libedataserver/e-data-server-util.h>
-#include <libedataserver/e-url.h>
-#include <libedataserverui/e-source-selector.h>
-#include <shell/e-user-creatable-items-handler.h>
-#include <shell/e-component-view.h>
-#include "e-cal-model.h"
-#include "e-tasks.h"
-#include "tasks-component.h"
-#include "tasks-control.h"
-#include "e-comp-editor-registry.h"
-#include "migration.h"
-#include "comp-util.h"
-#include "calendar-config.h"
-#include "e-cal-popup.h"
-#include "common/authentication.h"
-#include "dialogs/calendar-setup.h"
-#include "dialogs/comp-editor.h"
-#include "dialogs/copy-source-dialog.h"
-#include "dialogs/task-editor.h"
-#include "misc/e-info-label.h"
-#include "e-util/e-error.h"
-
-#define CREATE_TASK_ID "task"
-#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;
-
- GSList *source_selection;
-
- ETasks *tasks;
- 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;
-
- GList *views;
-
- ECal *create_ecal;
-
- 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
-is_in_selection (GSList *selection, ESource *source)
-{
- GSList *l;
-
- for (l = selection; l; l = l->next) {
- ESource *selected_source = l->data;
-
- if (!strcmp (e_source_peek_uid (selected_source), e_source_peek_uid (source)))
- return TRUE;
- }
-
- return FALSE;
-}
-
-static gboolean
-is_in_uids (GSList *uids, ESource *source)
-{
- GSList *l;
-
- for (l = uids; l; l = l->next) {
- const gchar *uid = l->data;
-
- if (!strcmp (uid, e_source_peek_uid (source)))
- return TRUE;
- }
-
- return FALSE;
-}
-
-static void
-update_uris_for_selection (TasksComponentView *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))
- e_tasks_remove_todo_source (component_view->tasks, old_selected_source);
- }
-
- for (l = selection; l; l = l->next) {
- ESource *selected_source = l->data;
-
- e_tasks_add_todo_source (component_view->tasks, 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_tasks_selected (uids_selected);
- g_slist_free (uids_selected);
-}
-
-static void
-update_uri_for_primary_selection (TasksComponentView *component_view)
-{
- ESource *source;
- ECalendarTable *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_tasks_set_default_source (component_view->tasks, source);
-
- cal_table = e_tasks_get_calendar_table (component_view->tasks);
- etable = e_calendar_table_get_table (cal_table);
-
- tasks_control_sensitize_commands (component_view->view_control, component_view->tasks, e_table_selected_count (etable));
-
- /* Save the selection for next time we start up */
- 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)
-{
- TasksComponentView *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_TODO);
-}
-
-static void
-delete_task_list_cb (EPopup *ep, EPopupItem *pitem, gpointer data)
-{
- TasksComponentView *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-task-list", e_source_peek_name(selected_source), NULL) != GTK_RESPONSE_YES)
- return;
-
- /* first, ask the backend to remove the task list */
- uri = e_source_get_uri (selected_source);
- cal = e_cal_model_get_client_for_uri (
- e_calendar_table_get_model (E_CALENDAR_TABLE (e_tasks_get_calendar_table (component_view->tasks))),
- uri);
- if (!cal)
- cal = e_cal_new_from_uri (uri, E_CAL_SOURCE_TYPE_TODO);
- 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_tasks_remove_todo_source (component_view->tasks, 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_task_list_cb (EPopup *ep, EPopupItem *pitem, gpointer data)
-{
- calendar_setup_new_task_list (GTK_WINDOW (gtk_widget_get_toplevel(ep->target->widget)));
-}
-
-static void
-rename_task_list_cb (EPopup *ep, EPopupItem *pitem, gpointer data)
-{
- TasksComponentView *component_view = data;
- ESourceSelector *selector;
-
- selector = E_SOURCE_SELECTOR (component_view->source_selector);
- e_source_selector_edit_primary_selection (selector);
-}
-
-static void
-edit_task_list_cb (EPopup *ep, EPopupItem *pitem, gpointer data)
-{
- TasksComponentView *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_task_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)
-{
- TasksComponentView *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 etc_source_popups[] = {
- { E_POPUP_ITEM, (gchar *) "10.new", (gchar *) N_("_New Task List"), new_task_list_cb, NULL, (gchar *) "stock_todo", 0, 0 },
- { E_POPUP_ITEM, (gchar *) "15.copy", (gchar *) N_("_Copy..."), copy_task_list_cb, NULL, (gchar *) "edit-copy", 0, E_CAL_POPUP_SOURCE_PRIMARY },
- { E_POPUP_ITEM, (gchar *) "18.rename", (gchar *) N_("_Rename..."), rename_task_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_task_list_cb, NULL, (gchar *) "edit-delete", 0, E_CAL_POPUP_SOURCE_USER|E_CAL_POPUP_SOURCE_PRIMARY },
- { E_POPUP_ITEM, (gchar *) "30.mark_tasks_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_tasks_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_task_list_cb, NULL, (gchar *) "document-properties", 0, E_CAL_POPUP_SOURCE_PRIMARY },
-};
-
-static void
-etc_source_popup_free(EPopup *ep, GSList *list, gpointer data)
-{
- g_slist_free(list);
-}
-
-static gboolean
-popup_event_cb(ESourceSelector *selector, ESource *insource, GdkEventButton *event, TasksComponentView *component_view)
-{
- ECalPopup *ep;
- ECalPopupTargetSource *t;
- GSList *menus = NULL;
- gint i;
- GtkMenu *menu;
-
- /** @HookPoint-ECalPopup: Tasks Source Selector Context Menu
- * @Id: org.gnome.evolution.tasks.source.popup
- * @Class: org.gnome.evolution.calendar.popup:1.0
- * @Target: ECalPopupTargetSource
- *
- * The context menu on the source selector in the tasks window.
- */
- ep = e_cal_popup_new("org.gnome.evolution.tasks.source.popup");
- t = e_cal_popup_target_new_source(ep, selector);
- t->target.widget = (GtkWidget *)component_view->tasks;
-
- for (i=0;i<sizeof(etc_source_popups)/sizeof(etc_source_popups[0]);i++)
- menus = g_slist_prepend(menus, &etc_source_popups[i]);
-
- e_popup_add_items((EPopup *)ep, menus, NULL,etc_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, TasksComponentView *component_view)
-{
- update_uris_for_selection (component_view);
-}
-
-static void
-primary_source_selection_changed_cb (ESourceSelector *selector, TasksComponentView *component_view)
-{
- update_uri_for_primary_selection (component_view);
-}
-
-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,
- ESource *destination,
- GdkDragAction action,
- guint info,
- TasksComponent *component)
-{
- gboolean success = FALSE;
- icalcomponent *icalcomp = NULL;
- ECal *client = NULL;
- GSList *components, *p;
-
- client = auth_new_cal_from_source (
- destination, E_CAL_SOURCE_TYPE_TODO);
-
- if (!client || !e_cal_open (client, TRUE, NULL))
- goto finish;
-
- components = cal_comp_selection_get_string_list (data);
- success = components != NULL;
- for (p = components; p && success; p = p->next) {
- gchar *comp_str; /* do not free this! */
-
- /* p->data is "source_uid\ncomponent_string" */
- comp_str = strchr (p->data, '\n');
- if (!comp_str)
- continue;
-
- comp_str [0] = 0;
- comp_str++;
- icalcomp = icalparser_parse_string (comp_str);
-
- if (!icalcomp)
- continue;
-
- success = cal_comp_process_source_list_drop (client, icalcomp, action, p->data, component->priv->source_list);
- icalcomponent_free (icalcomp);
- }
- g_slist_foreach (components, (GFunc)g_free, NULL);
- g_slist_free (components);
-
- finish:
- if (client)
- g_object_unref (client);
-
- return success;
-}
-
-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;
- TasksComponentPrivate *priv;
-
- priv = component->priv;
-
- g_object_unref (priv->create_ecal);
- priv->create_ecal = NULL;
-
- priv->notifications = g_list_remove (priv->notifications, GUINT_TO_POINTER (id));
-}
-
-static ECal *
-setup_create_ecal (TasksComponent *component, TasksComponentView *component_view)
-{
- TasksComponentPrivate *priv;
- ESource *source = NULL;
- gchar *uid;
- guint not;
-
- priv = component->priv;
-
- if (component_view) {
- ECal *default_ecal;
-
- default_ecal = e_tasks_get_default_client (component_view->tasks);
- if (default_ecal)
- return default_ecal;
- }
-
- if (priv->create_ecal)
- return priv->create_ecal;
-
- /* Get the current primary calendar, or try to set one if it doesn't already exist */
- uid = calendar_config_get_primary_tasks ();
- if (uid) {
- source = e_source_list_peek_source_by_uid (priv->source_list, uid);
- g_free (uid);
-
- priv->create_ecal = auth_new_cal_from_source (source, E_CAL_SOURCE_TYPE_TODO);
- }
-
- if (!priv->create_ecal) {
- /* Try to create a default if there isn't one */
- source = e_source_list_peek_source_any (priv->source_list);
- if (source)
- priv->create_ecal = auth_new_cal_from_source (source, E_CAL_SOURCE_TYPE_TODO);
- }
-
- if (priv->create_ecal) {
- icaltimezone *zone;
-
- zone = calendar_config_get_icaltimezone ();
- e_cal_set_default_timezone (priv->create_ecal, zone, NULL);
-
- if (!e_cal_open (priv->create_ecal, FALSE, NULL)) {
- GtkWidget *dialog;
-
- dialog = gtk_message_dialog_new (NULL, GTK_DIALOG_MODAL,
- GTK_MESSAGE_WARNING, GTK_BUTTONS_OK,
- _("Unable to open the task list '%s' for creating events and meetings"),
- e_source_peek_name (source));
- gtk_dialog_run (GTK_DIALOG (dialog));
- gtk_widget_destroy (dialog);
-
- return NULL;
- }
-
- } else {
- GtkWidget *dialog;
-
- dialog = gtk_message_dialog_new (NULL, GTK_DIALOG_MODAL,
- GTK_MESSAGE_WARNING, GTK_BUTTONS_OK,
- "%s", _("There is no calendar available for creating tasks"));
- gtk_dialog_run (GTK_DIALOG (dialog));
- gtk_widget_destroy (dialog);
-
- return NULL;
- }
-
- /* Handle the fact it may change on us */
- not = calendar_config_add_notification_primary_tasks (config_create_ecal_changed_cb,
- component);
- priv->notifications = g_list_prepend (priv->notifications, GUINT_TO_POINTER (not));
-
- /* Save the primary source for use elsewhere */
- calendar_config_set_primary_tasks (e_source_peek_uid (source));
-
- return priv->create_ecal;
-}
-
-/* Ensures the calendar is selected */
-static void
-object_created_cb (CompEditor *ce, ECalendarTable *cal_table)
-{
- g_return_if_fail (cal_table != NULL);
-
- cal_table->user_created_cal = comp_editor_get_client (ce);
- g_signal_emit_by_name (cal_table, "user_created");
- cal_table->user_created_cal = NULL;
-}
-
-static gboolean
-create_new_todo (TasksComponent *task_component, gboolean is_assigned, TasksComponentView *component_view)
-{
- ECal *ecal;
- ECalComponent *comp;
- CompEditor *editor;
- guint32 flags = 0;
-
- ecal = setup_create_ecal (task_component, component_view);
- if (!ecal)
- return FALSE;
-
- if (is_assigned)
- flags |= COMP_EDITOR_IS_ASSIGNED;
-
- flags |= COMP_EDITOR_NEW_ITEM | COMP_EDITOR_USER_ORG;
-
- editor = task_editor_new (ecal, flags);
- comp = cal_comp_task_new_with_defaults (ecal);
-
- if (component_view)
- g_signal_connect (editor, "object_created", G_CALLBACK (object_created_cb), e_tasks_get_calendar_table (component_view->tasks));
-
- comp_editor_edit_comp (editor, comp);
- if (is_assigned)
- task_editor_show_assignment (TASK_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)
-{
- 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;
-
- /* Create the calendar component view */
- component_view = g_new0 (TasksComponentView, 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 (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;
- }
-
- 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",
- 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 ("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;
-}
-
-static void
-destroy_component_view (TasksComponentView *component_view)
-{
- GList *l;
-
- g_signal_handlers_disconnect_matched (component_view->model, G_SIGNAL_MATCH_DATA, 0, 0, 0, 0, component_view);
-
- if (component_view->source_list)
- g_object_unref (component_view->source_list);
-
- if (component_view->source_selection)
- e_source_selector_free_selection (component_view->source_selection);
-
- for (l = component_view->notifications; l; l = l->next)
- 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)
-{
- TasksComponent *tasks_component = data;
- TasksComponentPrivate *priv;
- GList *l;
-
- priv = tasks_component->priv;
-
- for (l = priv->views; l; l = l->next) {
- TasksComponentView *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)
-{
- 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)
-{
- TasksComponent *tasks_component = TASKS_COMPONENT (bonobo_object_from_servant (servant));
- TasksComponentPrivate *priv;
- GList *l;
- TasksComponentView *view = NULL;
-
- gchar *src_uid = NULL;
- gchar *uid = NULL;
- gchar *rid = NULL;
-
- priv = tasks_component->priv;
-
- l = g_list_last (priv->views);
- if (!l)
- return;
-
- view = l->data;
-
- if (!strncmp (uri, "task:", 5)) {
- EUri *euri = e_uri_new (uri);
- const gchar *p;
- gchar *header, *content;
- gsize len, clen;
-
- p = euri->query;
- if (p) {
- while (*p) {
- len = strcspn (p, "=&");
-
- /* If it's malformed, give up. */
- if (p[len] != '=')
- break;
-
- header = (gchar *) p;
- header[len] = '\0';
- p += len + 1;
-
- clen = strcspn (p, "&");
-
- content = g_strndup (p, clen);
- if (!g_ascii_strcasecmp (header, "source-uid")) {
- src_uid = g_strdup (content);
- } else if (!g_ascii_strcasecmp (header, "comp-uid")) {
- uid = g_strdup (content);
- } else if (!g_ascii_strcasecmp (header, "comp-rid")) {
- rid = g_strdup (content);
- }
- g_free (content);
-
- p += clen;
- if (*p == '&') {
- p++;
- if (!strcmp (p, "amp;"))
- p += 4;
- }
- }
-
- if (uid && src_uid) {
- e_tasks_open_task_id (view->tasks, src_uid, uid, rid);
- }
-
- g_free (src_uid);
- g_free (uid);
- g_free (rid);
- }
- e_uri_free (euri);
- }
-
- 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,
- CORBA_Environment *ev)
-{
- TasksComponent *tasks_component = TASKS_COMPONENT (bonobo_object_from_servant (servant));
-
- if (strcmp (item_type_name, CREATE_TASK_ID) == 0) {
- if (!create_new_todo (tasks_component, FALSE, NULL))
- bonobo_exception_set (ev, ex_GNOME_Evolution_Component_Failed);
- } else if (strcmp (item_type_name, CREATE_TASK_ASSIGNED_ID) == 0) {
- if (!create_new_todo (tasks_component, TRUE, NULL))
- bonobo_exception_set (ev, ex_GNOME_Evolution_Component_Failed);
- } else if (strcmp (item_type_name, CREATE_TASK_LIST_ID) == 0) {
- /* FIXME Should we use the last opened window? */
- calendar_setup_new_task_list (NULL);
- } else {
- bonobo_exception_set (ev, ex_GNOME_Evolution_Component_UnknownType);
- }
-}
-
-/* GObject methods. */
-
-static void
-impl_dispose (GObject *object)
-{
- TasksComponent *tasks_component = TASKS_COMPONENT (object);
- TasksComponentPrivate *priv = tasks_component->priv;
- GList *l;
-
- if (priv->source_list != NULL) {
- g_object_unref (priv->source_list);
- priv->source_list = NULL;
- }
- if (priv->source_selection != NULL) {
- e_source_selector_free_selection (priv->source_selection);
- priv->source_selection = NULL;
- }
-
- if (priv->create_ecal) {
- g_object_unref (priv->create_ecal);
- priv->create_ecal = NULL;
- }
-
- for (l = priv->views; l; l = l->next) {
- TasksComponentView *component_view = l->data;
-
- g_object_weak_unref (G_OBJECT (component_view->view_control), view_destroyed_cb, tasks_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);
- priv->notifications = NULL;
-
- (* G_OBJECT_CLASS (parent_class)->dispose) (object);
-}
-
-static void
-impl_finalize (GObject *object)
-{
- TasksComponentPrivate *priv = TASKS_COMPONENT (object)->priv;
- GList *l;
-
- for (l = priv->views; l; l = l->next) {
- TasksComponentView *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
-tasks_component_class_init (TasksComponentClass *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;
- epv->handleURI = impl_handleURI;
-
- object_class->dispose = impl_dispose;
- object_class->finalize = impl_finalize;
-}
-
-static void
-tasks_component_init (TasksComponent *component, TasksComponentClass *klass)
-{
- TasksComponentPrivate *priv;
-
- 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
deleted file mode 100644
index 9824797640..0000000000
--- a/calendar/gui/tasks-component.h
+++ /dev/null
@@ -1,60 +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 _TASKS_COMPONENT_H_
-#define _TASKS_COMPONENT_H_
-
-#include <bonobo/bonobo-object.h>
-#include <libedataserver/e-source-list.h>
-#include <misc/e-activity-handler.h>
-#include "Evolution.h"
-
-#define TASKS_TYPE_COMPONENT (tasks_component_get_type ())
-#define TASKS_COMPONENT(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), TASKS_TYPE_COMPONENT, TasksComponent))
-#define TASKS_COMPONENT_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), TASKS_TYPE_COMPONENT, TasksComponentClass))
-#define TASKS_IS_COMPONENT(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), TASKS_TYPE_COMPONENT))
-#define TASKS_IS_COMPONENT_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((obj), TASKS_TYPE_COMPONENT))
-
-typedef struct _TasksComponent TasksComponent;
-typedef struct _TasksComponentPrivate TasksComponentPrivate;
-typedef struct _TasksComponentClass TasksComponentClass;
-
-struct _TasksComponent {
- BonoboObject parent;
-
- TasksComponentPrivate *priv;
-};
-
-struct _TasksComponentClass {
- BonoboObjectClass parent_class;
-
- POA_GNOME_Evolution_Component__epv epv;
-};
-
-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
deleted file mode 100644
index 41de092681..0000000000
--- a/calendar/gui/tasks-control.c
+++ /dev/null
@@ -1,593 +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 <ettore@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-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 "dialogs/cal-prefs-dialog.h"
-#include "calendar-config.h"
-#include "calendar-commands.h"
-#include "e-tasks.h"
-#include "e-calendar-table.h"
-#include "print.h"
-#include "tasks-control.h"
-#include "evolution-shell-component-utils.h"
-#include "e-util/e-menu.h"
-#include "e-cal-menu.h"
-#include "e-cal-component-preview.h"
-#include "e-util/e-menu.h"
-#include "itip-utils.h"
-
-#define FIXED_MARGIN .05
-
-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);
-
-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;
-};
-
-static void
-sensitize_items(BonoboUIComponent *uic, struct _tasks_sensitize_item *items, guint32 mask)
-{
- while (items->command) {
- gchar command[32];
-
- if (strlen(items->command)>=21) {
- g_warning ("Size more than 21: %s\n", items->command);
- continue;
- }
-
- sprintf(command, "/commands/%s", items->command);
-
- bonobo_ui_component_set_prop (uic, command, "sensitive",
- (items->enable & mask) == 0 ? "1" : "0",
- NULL);
- items++;
- }
-}
-
-#define E_CAL_TASKS_PREVIEW_ACTIVE (1<<31)
-
-static struct _tasks_sensitize_item tasks_sensitize_table[] = {
- { "TasksOpenTask", E_CAL_MENU_SELECT_ONE },
- { "TasksCut", E_CAL_MENU_SELECT_ANY | E_CAL_MENU_SELECT_EDITABLE | E_CAL_TASKS_PREVIEW_ACTIVE },
- { "TasksCopy", E_CAL_MENU_SELECT_ANY },
- { "TasksPaste", E_CAL_MENU_SELECT_EDITABLE | E_CAL_TASKS_PREVIEW_ACTIVE },
- { "TasksDelete", E_CAL_MENU_SELECT_ANY | E_CAL_MENU_SELECT_EDITABLE },
- { "TasksMarkComplete", E_CAL_MENU_SELECT_ANY | E_CAL_MENU_SELECT_EDITABLE | E_CAL_MENU_SELECT_NOTCOMPLETE},
- { "TasksPurge", E_CAL_MENU_SELECT_EDITABLE },
- { "TasksAssign", E_CAL_MENU_SELECT_ONE | E_CAL_MENU_SELECT_EDITABLE | E_CAL_MENU_SELECT_ASSIGNABLE },
- { "TasksForward", E_CAL_MENU_SELECT_ONE },
- { NULL }
-};
-
-/* Sensitizes the UI Component menu/toolbar commands based on the number of
- * selected tasks.
- */
-void
-tasks_control_sensitize_commands (BonoboControl *control, ETasks *tasks, gint n_selected)
-{
- BonoboUIComponent *uic;
- gboolean read_only = TRUE;
- ECal *ecal;
- ECalModel *model;
- ECalMenu *menu;
- ECalMenuTargetSelect *t;
- GPtrArray *events;
- GSList *selected = NULL, *l = NULL;
- ECalendarTable *cal_table;
- 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;
-
- menu = e_tasks_get_tasks_menu (tasks);
- cal_table = e_tasks_get_calendar_table (tasks);
- model = e_calendar_table_get_model (cal_table);
- events = g_ptr_array_new ();
- selected = e_calendar_table_get_selected (cal_table);
-
- for (l = selected;l;l = g_slist_next (l)) {
- g_ptr_array_add (events, e_cal_model_copy_component_data ((ECalModelComponent *)l->data));
- }
-
- g_slist_free (selected);
-
- t = e_cal_menu_target_new_select (menu, model, events);
-
- ecal = e_cal_model_get_default_client (model);
-
- if (ecal)
- e_cal_is_read_only (ecal, &read_only, NULL);
-
- 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))
- t->target.mask = t->target.mask | E_CAL_TASKS_PREVIEW_ACTIVE;
- else
- t->target.mask = t->target.mask & (~E_CAL_TASKS_PREVIEW_ACTIVE);
-
- sensitize_items (uic, tasks_sensitize_table, t->target.mask);
- e_menu_update_target ((EMenu *)menu, (EMenuTarget *)t);
-}
-
-/* Callback used when the selection in the table changes */
-static void
-selection_changed_cb (ETasks *tasks, gint n_selected, gpointer data)
-{
- BonoboControl *control;
-
- control = BONOBO_CONTROL (data);
-
- tasks_control_sensitize_commands (control, tasks, n_selected);
-}
-
-static gboolean
-tasks_control_focus_changed (GtkWidget *widget, GdkEventFocus *event, struct focus_changed_data *fc_data)
-{
- g_return_val_if_fail (fc_data != NULL, FALSE);
-
- tasks_control_sensitize_commands (fc_data->control, fc_data->tasks, -1);
-
- return FALSE;
-}
-
-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)
-{
- Bonobo_UIContainer remote_uih;
- BonoboUIComponent *uic;
- gint n_selected;
- ECalendarTable *cal_table;
- ETable *etable;
- gboolean state;
- 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_tasks_set_ui_component (tasks, uic);
-
- bonobo_ui_component_add_verb_list_with_data (uic, verbs, tasks);
-
- bonobo_ui_component_freeze (uic, NULL);
-
- xmlfile = g_build_filename (EVOLUTION_UIDIR,
- "evolution-tasks.xml",
- NULL);
- bonobo_ui_util_set_ui (uic, PREFIX,
- xmlfile,
- "evolution-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 */
-
- g_signal_connect (tasks, "selection_changed", G_CALLBACK (selection_changed_cb), control);
-
- e_menu_activate ((EMenu *)e_tasks_get_tasks_menu (tasks), uic, 1);
- cal_table = e_tasks_get_calendar_table (tasks);
- etable = e_calendar_table_get_table (cal_table);
- n_selected = e_table_selected_count (etable);
-
- tasks_control_sensitize_commands (control, tasks, n_selected);
-
- state = calendar_config_get_preview_state();
-
- bonobo_ui_component_thaw (uic, NULL);
-
- bonobo_ui_component_add_listener(uic, "ViewPreview", tasks_control_view_preview, tasks);
- bonobo_ui_component_set_prop(uic, "/commands/ViewPreview", "state", state?"1":"0", NULL);
-}
-
-void
-tasks_control_deactivate (BonoboControl *control, ETasks *tasks)
-{
- BonoboUIComponent *uic = bonobo_control_get_ui_component (control);
-
- g_return_if_fail (uic != NULL);
-
- e_menu_activate ((EMenu *)e_tasks_get_tasks_menu (tasks), uic, 0);
- e_tasks_set_ui_component (tasks, NULL);
-
- e_tasks_discard_view_menus (tasks);
-
- /* Stop monitoring the "selection_changed" signal */
- g_signal_handlers_disconnect_matched (tasks, G_SIGNAL_MATCH_DATA, 0, 0, NULL, NULL, control);
-
- bonobo_ui_component_rm (uic, "/", NULL);
- 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,
- const gchar *path)
-{
- ETasks *tasks;
-
- tasks = E_TASKS (data);
- e_tasks_new_task (tasks);
-}
-
-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)
-{
- ETasks *tasks;
-
- bonobo_ui_component_set_prop (uic, "/commands/TasksMarkComplete", "sensitive",
- "0",
- NULL);
- tasks = E_TASKS (data);
- e_tasks_complete_selected (tasks);
-}
-
-static gboolean
-confirm_purge (ETasks *tasks)
-{
- GtkWidget *dialog, *checkbox, *parent;
- gint button;
-
- if (!calendar_config_get_confirm_purge ())
- return TRUE;
-
- parent = gtk_widget_get_toplevel (GTK_WIDGET (tasks));
- dialog = gtk_message_dialog_new (
- (GtkWindow *)parent,
- GTK_DIALOG_DESTROY_WITH_PARENT,
- GTK_MESSAGE_WARNING,
- GTK_BUTTONS_YES_NO,
- "%s",
- _("This operation will permanently erase all tasks marked as completed. If you continue, you will not be able to recover these tasks.\n\nReally erase these tasks?"));
- gtk_dialog_set_default_response (GTK_DIALOG (dialog), GTK_RESPONSE_NO);
-
- checkbox = gtk_check_button_new_with_label (_("Do not ask me again."));
- gtk_widget_show (checkbox);
- gtk_box_pack_start (GTK_BOX (GTK_DIALOG (dialog)->vbox), checkbox, TRUE, TRUE, 6);
-
- button = gtk_dialog_run (GTK_DIALOG (dialog));
- if (button == GTK_RESPONSE_YES && gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (checkbox)))
- calendar_config_set_confirm_purge (FALSE);
- gtk_widget_destroy (dialog);
-
- return button == GTK_RESPONSE_YES ? TRUE : FALSE;
-}
-
-static void
-tasks_control_purge_cmd (BonoboUIComponent *uic,
- gpointer data,
- const gchar *path)
-{
- ETasks *tasks;
-
- tasks = E_TASKS (data);
- 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, FALSE);
- 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');
-}
diff --git a/calendar/gui/tasks-control.h b/calendar/gui/tasks-control.h
deleted file mode 100644
index de98914e40..0000000000
--- a/calendar/gui/tasks-control.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:
- * Federico Mena Quintero <federico@ximian.com>
- * Damon Chaplin <damon@ximian.com>
- *
- * Copyright (C) 1999-2008 Novell, Inc. (www.novell.com)
- *
- */
-
-#ifndef _TASKS_CONTROL_H_
-#define _TASKS_CONTROL_H_
-
-#include "e-tasks.h"
-
-BonoboControl *tasks_control_new (void);
-void tasks_control_activate (BonoboControl *control, ETasks *tasks);
-void tasks_control_deactivate (BonoboControl *control, ETasks *tasks);
-void tasks_control_sensitize_commands (BonoboControl *control, ETasks *tasks, gint n_selected);
-
-#endif /* _TASKS_CONTROL_H_ */